mirror of
https://github.com/nasa/openmct.git
synced 2024-12-29 17:38:53 +00:00
omm-cherry-pick(#6602) : [ExportAsJson] Multiple Aliases in Export and Conditional Styles Fixes (#6602) Fixes issues that prevent import and export from being completed successfully. Specifically: * if multiple aliases are detected, the first is created as a new object and and added to it's parent's composition, any subsequent aliases of the same object will not be recreated, but the originally created one will be added to the current parent's composition, creating an alias. * Also, there are cases were conditionSetIdentifiers are stored in an object keyed by an item id in the configuration.objectstyles object, this fix will handle these as well. * Replaces an errant `return` statement with a `continue` statement to prevent early exit from a recursive function. --------- Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
parent
23310f85ae
commit
faf71f1e67
@ -20,8 +20,6 @@
|
|||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
import JSONExporter from '/src/exporters/JSONExporter.js';
|
import JSONExporter from '/src/exporters/JSONExporter.js';
|
||||||
|
|
||||||
import _ from 'lodash';
|
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
|
|
||||||
export default class ExportAsJSONAction {
|
export default class ExportAsJSONAction {
|
||||||
@ -35,10 +33,9 @@ export default class ExportAsJSONAction {
|
|||||||
this.group = "json";
|
this.group = "json";
|
||||||
this.priority = 1;
|
this.priority = 1;
|
||||||
|
|
||||||
this.externalIdentifiers = [];
|
this.tree = null;
|
||||||
this.tree = {};
|
this.calls = null;
|
||||||
this.calls = 0;
|
this.idMap = null;
|
||||||
this.idMap = {};
|
|
||||||
|
|
||||||
this.JSONExportService = new JSONExporter();
|
this.JSONExportService = new JSONExporter();
|
||||||
}
|
}
|
||||||
@ -60,21 +57,164 @@ export default class ExportAsJSONAction {
|
|||||||
*/
|
*/
|
||||||
invoke(objectpath) {
|
invoke(objectpath) {
|
||||||
this.tree = {};
|
this.tree = {};
|
||||||
|
this.calls = 0;
|
||||||
|
this.idMap = {};
|
||||||
|
|
||||||
const root = objectpath[0];
|
const root = objectpath[0];
|
||||||
this.root = JSON.parse(JSON.stringify(root));
|
this.root = this._copy(root);
|
||||||
const rootId = this._getId(this.root);
|
|
||||||
|
const rootId = this._getKeystring(this.root);
|
||||||
this.tree[rootId] = this.root;
|
this.tree[rootId] = this.root;
|
||||||
|
|
||||||
this._write(this.root);
|
this._write(this.root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @param {object} parent
|
||||||
|
*/
|
||||||
|
async _write(parent) {
|
||||||
|
this.calls++;
|
||||||
|
|
||||||
|
//conditional object styles are not saved on the composition, so we need to check for them
|
||||||
|
const conditionSetIdentifier = this._getConditionSetIdentifier(parent);
|
||||||
|
const hasItemConditionSetIdentifiers = this._hasItemConditionSetIdentifiers(parent);
|
||||||
|
const composition = this.openmct.composition.get(parent);
|
||||||
|
|
||||||
|
if (composition) {
|
||||||
|
const children = await composition.load();
|
||||||
|
|
||||||
|
children.forEach((child) => {
|
||||||
|
this._exportObject(child, parent);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!conditionSetIdentifier && !hasItemConditionSetIdentifiers) {
|
||||||
|
this._decrementCallsAndSave();
|
||||||
|
} else {
|
||||||
|
const conditionSetObjects = [];
|
||||||
|
|
||||||
|
// conditionSetIdentifiers directly in objectStyles object
|
||||||
|
if (conditionSetIdentifier) {
|
||||||
|
conditionSetObjects.push(await this.openmct.objects.get(conditionSetIdentifier));
|
||||||
|
}
|
||||||
|
|
||||||
|
// conditionSetIdentifiers stored on item ids in the objectStyles object
|
||||||
|
if (hasItemConditionSetIdentifiers) {
|
||||||
|
const itemConditionSetIdentifiers = this._getItemConditionSetIdentifiers(parent);
|
||||||
|
|
||||||
|
for (const itemConditionSetIdentifier of itemConditionSetIdentifiers) {
|
||||||
|
conditionSetObjects.push(await this.openmct.objects.get(itemConditionSetIdentifier));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const conditionSetObject of conditionSetObjects) {
|
||||||
|
this._exportObject(conditionSetObject, parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._decrementCallsAndSave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_exportObject(child, parent) {
|
||||||
|
const originalKeyString = this._getKeystring(child);
|
||||||
|
const createable = this._isCreatableAndPersistable(child);
|
||||||
|
const isNotInfinite = !Object.prototype.hasOwnProperty.call(this.tree, originalKeyString);
|
||||||
|
|
||||||
|
if (createable && isNotInfinite) {
|
||||||
|
// for external or linked objects we generate new keys, if they don't exist already
|
||||||
|
if (this._isLinkedObject(child, parent)) {
|
||||||
|
child = this._rewriteLink(child, parent);
|
||||||
|
} else {
|
||||||
|
this.tree[originalKeyString] = child;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._write(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @param {object} child
|
||||||
|
* @param {object} parent
|
||||||
|
* @returns {object}
|
||||||
|
*/
|
||||||
|
_rewriteLink(child, parent) {
|
||||||
|
const originalKeyString = this._getKeystring(child);
|
||||||
|
const parentKeyString = this._getKeystring(parent);
|
||||||
|
const conditionSetIdentifier = this._getConditionSetIdentifier(parent);
|
||||||
|
const hasItemConditionSetIdentifiers = this._hasItemConditionSetIdentifiers(parent);
|
||||||
|
const existingMappedKeyString = this.idMap[originalKeyString];
|
||||||
|
let copy;
|
||||||
|
|
||||||
|
if (!existingMappedKeyString) {
|
||||||
|
copy = this._copy(child);
|
||||||
|
copy.identifier.key = uuid();
|
||||||
|
|
||||||
|
if (!conditionSetIdentifier && !hasItemConditionSetIdentifiers) {
|
||||||
|
copy.location = parentKeyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
let newKeyString = this._getKeystring(copy);
|
||||||
|
this.idMap[originalKeyString] = newKeyString;
|
||||||
|
this.tree[newKeyString] = copy;
|
||||||
|
} else {
|
||||||
|
copy = this.tree[existingMappedKeyString];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (conditionSetIdentifier || hasItemConditionSetIdentifiers) {
|
||||||
|
|
||||||
|
// update objectStyle object
|
||||||
|
if (conditionSetIdentifier) {
|
||||||
|
const directObjectStylesIdentifier = this.openmct.objects.areIdsEqual(
|
||||||
|
parent.configuration.objectStyles.conditionSetIdentifier,
|
||||||
|
child.identifier
|
||||||
|
);
|
||||||
|
|
||||||
|
if (directObjectStylesIdentifier) {
|
||||||
|
parent.configuration.objectStyles.conditionSetIdentifier = copy.identifier;
|
||||||
|
this.tree[parentKeyString].configuration.objectStyles.conditionSetIdentifier = copy.identifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update per item id on objectStyle object
|
||||||
|
if (hasItemConditionSetIdentifiers) {
|
||||||
|
for (const itemId in parent.configuration.objectStyles) {
|
||||||
|
if (parent.configuration.objectStyles[itemId]) {
|
||||||
|
const itemConditionSetIdentifier = parent.configuration.objectStyles[itemId].conditionSetIdentifier;
|
||||||
|
|
||||||
|
if (
|
||||||
|
itemConditionSetIdentifier
|
||||||
|
&& this.openmct.objects.areIdsEqual(itemConditionSetIdentifier, child.identifier)
|
||||||
|
) {
|
||||||
|
parent.configuration.objectStyles[itemId].conditionSetIdentifier = copy.identifier;
|
||||||
|
this.tree[parentKeyString].configuration.objectStyles[itemId].conditionSetIdentifier = copy.identifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// just update parent
|
||||||
|
const index = parent.composition.findIndex(identifier => {
|
||||||
|
return this.openmct.objects.areIdsEqual(child.identifier, identifier);
|
||||||
|
});
|
||||||
|
|
||||||
|
parent.composition[index] = copy.identifier;
|
||||||
|
this.tree[parentKeyString].composition[index] = copy.identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {object} domainObject
|
* @param {object} domainObject
|
||||||
* @returns {string} A string representation of the given identifier, including namespace and key
|
* @returns {string} A string representation of the given identifier, including namespace and key
|
||||||
*/
|
*/
|
||||||
_getId(domainObject) {
|
_getKeystring(domainObject) {
|
||||||
return this.openmct.objects.makeKeyString(domainObject.identifier);
|
return this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {object} domainObject
|
* @param {object} domainObject
|
||||||
@ -86,6 +226,7 @@ export default class ExportAsJSONAction {
|
|||||||
|
|
||||||
return type && type.definition.creatable && isPersistable;
|
return type && type.definition.creatable && isPersistable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {object} child
|
* @param {object} child
|
||||||
@ -93,65 +234,47 @@ export default class ExportAsJSONAction {
|
|||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
_isLinkedObject(child, parent) {
|
_isLinkedObject(child, parent) {
|
||||||
if (child.location !== this._getId(parent)
|
const rootKeyString = this._getKeystring(this.root);
|
||||||
&& !Object.keys(this.tree).includes(child.location)
|
const childKeyString = this._getKeystring(child);
|
||||||
&& this._getId(child) !== this._getId(this.root)
|
const parentKeyString = this._getKeystring(parent);
|
||||||
|| this.externalIdentifiers.includes(this._getId(child))) {
|
|
||||||
|
|
||||||
return true;
|
return (child.location !== parentKeyString
|
||||||
|
&& !Object.keys(this.tree).includes(child.location)
|
||||||
|
&& childKeyString !== rootKeyString)
|
||||||
|
|| this.idMap[childKeyString] !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
_getConditionSetIdentifier(object) {
|
||||||
|
return object.configuration?.objectStyles?.conditionSetIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hasItemConditionSetIdentifiers(parent) {
|
||||||
|
const objectStyles = parent.configuration?.objectStyles;
|
||||||
|
|
||||||
|
for (const itemId in objectStyles) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(objectStyles[itemId], 'conditionSetIdentifier')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @param {object} child
|
|
||||||
* @param {object} parent
|
|
||||||
* @returns {object}
|
|
||||||
*/
|
|
||||||
_rewriteLink(child, parent) {
|
|
||||||
this.externalIdentifiers.push(this._getId(child));
|
|
||||||
const index = parent.composition.findIndex(id => {
|
|
||||||
return _.isEqual(child.identifier, id);
|
|
||||||
});
|
|
||||||
const copyOfChild = JSON.parse(JSON.stringify(child));
|
|
||||||
|
|
||||||
copyOfChild.identifier.key = uuid();
|
_getItemConditionSetIdentifiers(parent) {
|
||||||
const newIdString = this._getId(copyOfChild);
|
const objectStyles = parent.configuration?.objectStyles;
|
||||||
const parentId = this._getId(parent);
|
let identifiers = new Set();
|
||||||
|
|
||||||
this.idMap[this._getId(child)] = newIdString;
|
if (objectStyles) {
|
||||||
copyOfChild.location = parentId;
|
Object.keys(objectStyles).forEach(itemId => {
|
||||||
parent.composition[index] = copyOfChild.identifier;
|
if (objectStyles[itemId].conditionSetIdentifier) {
|
||||||
this.tree[newIdString] = copyOfChild;
|
identifiers.add(objectStyles[itemId].conditionSetIdentifier);
|
||||||
this.tree[parentId].composition[index] = copyOfChild.identifier;
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return copyOfChild;
|
return Array.from(identifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @param {object} child
|
|
||||||
* @param {object} parent
|
|
||||||
* @returns {object}
|
|
||||||
*/
|
|
||||||
_rewriteLinkForReference(child, parent) {
|
|
||||||
const childId = this._getId(child);
|
|
||||||
this.externalIdentifiers.push(childId);
|
|
||||||
const copyOfChild = JSON.parse(JSON.stringify(child));
|
|
||||||
|
|
||||||
copyOfChild.identifier.key = uuid();
|
|
||||||
const newIdString = this._getId(copyOfChild);
|
|
||||||
const parentId = this._getId(parent);
|
|
||||||
|
|
||||||
this.idMap[childId] = newIdString;
|
|
||||||
copyOfChild.location = null;
|
|
||||||
parent.configuration.objectStyles.conditionSetIdentifier = copyOfChild.identifier;
|
|
||||||
this.tree[newIdString] = copyOfChild;
|
|
||||||
this.tree[parentId].configuration.objectStyles.conditionSetIdentifier = copyOfChild.identifier;
|
|
||||||
|
|
||||||
return copyOfChild;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@ -204,72 +327,10 @@ export default class ExportAsJSONAction {
|
|||||||
_wrapTree() {
|
_wrapTree() {
|
||||||
return {
|
return {
|
||||||
"openmct": this.tree,
|
"openmct": this.tree,
|
||||||
"rootId": this._getId(this.root)
|
"rootId": this._getKeystring(this.root)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @param {object} parent
|
|
||||||
*/
|
|
||||||
_write(parent) {
|
|
||||||
this.calls++;
|
|
||||||
//conditional object styles are not saved on the composition, so we need to check for them
|
|
||||||
let childObjectReferenceId = parent.configuration?.objectStyles?.conditionSetIdentifier;
|
|
||||||
|
|
||||||
const composition = this.openmct.composition.get(parent);
|
|
||||||
if (composition !== undefined) {
|
|
||||||
composition.load()
|
|
||||||
.then((children) => {
|
|
||||||
children.forEach((child, index) => {
|
|
||||||
// Only export if object is creatable
|
|
||||||
if (this._isCreatableAndPersistable(child)) {
|
|
||||||
// Prevents infinite export of self-contained objs
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(this.tree, this._getId(child))) {
|
|
||||||
// If object is a link to something absent from
|
|
||||||
// tree, generate new id and treat as new object
|
|
||||||
if (this._isLinkedObject(child, parent)) {
|
|
||||||
child = this._rewriteLink(child, parent);
|
|
||||||
} else {
|
|
||||||
this.tree[this._getId(child)] = child;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._write(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!childObjectReferenceId) {
|
|
||||||
this._decrementCallsAndSave();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (!childObjectReferenceId) {
|
|
||||||
this._decrementCallsAndSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (childObjectReferenceId) {
|
|
||||||
this.openmct.objects.get(childObjectReferenceId)
|
|
||||||
.then((child) => {
|
|
||||||
// Only export if object is creatable
|
|
||||||
if (this._isCreatableAndPersistable(child)) {
|
|
||||||
// Prevents infinite export of self-contained objs
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(this.tree, this._getId(child))) {
|
|
||||||
// If object is a link to something absent from
|
|
||||||
// tree, generate new id and treat as new object
|
|
||||||
if (this._isLinkedObject(child, parent)) {
|
|
||||||
child = this._rewriteLinkForReference(child, parent);
|
|
||||||
} else {
|
|
||||||
this.tree[this._getId(child)] = child;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._write(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this._decrementCallsAndSave();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_decrementCallsAndSave() {
|
_decrementCallsAndSave() {
|
||||||
this.calls--;
|
this.calls--;
|
||||||
if (this.calls === 0) {
|
if (this.calls === 0) {
|
||||||
@ -277,4 +338,8 @@ export default class ExportAsJSONAction {
|
|||||||
this._saveAs(this._wrapTree());
|
this._saveAs(this._wrapTree());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_copy(object) {
|
||||||
|
return JSON.parse(JSON.stringify(object));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ export default class ImportAsJSONAction {
|
|||||||
this.cssClass = "icon-import";
|
this.cssClass = "icon-import";
|
||||||
this.group = "json";
|
this.group = "json";
|
||||||
this.priority = 2;
|
this.priority = 2;
|
||||||
|
this.newObjects = [];
|
||||||
|
|
||||||
this.openmct = openmct;
|
this.openmct = openmct;
|
||||||
}
|
}
|
||||||
@ -85,22 +86,25 @@ export default class ImportAsJSONAction {
|
|||||||
let objectIdentifiers = this._getObjectReferenceIds(parent);
|
let objectIdentifiers = this._getObjectReferenceIds(parent);
|
||||||
|
|
||||||
if (objectIdentifiers.length) {
|
if (objectIdentifiers.length) {
|
||||||
let newObj;
|
const parentId = this.openmct.objects.makeKeyString(parent.identifier);
|
||||||
|
seen.push(parentId);
|
||||||
|
|
||||||
seen.push(parent.id);
|
for (const childId of objectIdentifiers) {
|
||||||
|
|
||||||
objectIdentifiers.forEach(async (childId) => {
|
|
||||||
const keystring = this.openmct.objects.makeKeyString(childId);
|
const keystring = this.openmct.objects.makeKeyString(childId);
|
||||||
if (!tree[keystring] || seen.includes(keystring)) {
|
if (!tree[keystring] || seen.includes(keystring)) {
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newModel = tree[keystring];
|
const newModel = tree[keystring];
|
||||||
delete newModel.persisted;
|
delete newModel.persisted;
|
||||||
|
|
||||||
newObj = await this._instantiate(newModel);
|
this.newObjects.push(newModel);
|
||||||
this._deepInstantiate(newObj, tree, seen);
|
|
||||||
}, this);
|
// make sure there weren't any errors saving
|
||||||
|
if (newModel) {
|
||||||
|
this._deepInstantiate(newModel, tree, seen);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -110,19 +114,32 @@ export default class ImportAsJSONAction {
|
|||||||
*/
|
*/
|
||||||
_getObjectReferenceIds(parent) {
|
_getObjectReferenceIds(parent) {
|
||||||
let objectIdentifiers = [];
|
let objectIdentifiers = [];
|
||||||
|
let itemObjectReferences = [];
|
||||||
|
const objectStyles = parent?.configuration?.objectStyles;
|
||||||
|
const parentComposition = this.openmct.composition.get(parent);
|
||||||
|
|
||||||
let parentComposition = this.openmct.composition.get(parent);
|
|
||||||
if (parentComposition) {
|
if (parentComposition) {
|
||||||
objectIdentifiers = Array.from(parentComposition.domainObject.composition);
|
objectIdentifiers = Array.from(parent.composition);
|
||||||
}
|
}
|
||||||
|
|
||||||
//conditional object styles are not saved on the composition, so we need to check for them
|
//conditional object styles are not saved on the composition, so we need to check for them
|
||||||
let parentObjectReference = parent.configuration?.objectStyles?.conditionSetIdentifier;
|
if (objectStyles) {
|
||||||
if (parentObjectReference) {
|
const parentObjectReference = objectStyles.conditionSetIdentifier;
|
||||||
objectIdentifiers.push(parentObjectReference);
|
|
||||||
|
if (parentObjectReference) {
|
||||||
|
objectIdentifiers.push(parentObjectReference);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasConditionSetIdentifier(item) {
|
||||||
|
return Boolean(item.conditionSetIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
itemObjectReferences = Object.values(objectStyles)
|
||||||
|
.filter(hasConditionSetIdentifier)
|
||||||
|
.map(item => item.conditionSetIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
return objectIdentifiers;
|
return Array.from(new Set([...objectIdentifiers, ...itemObjectReferences]));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@ -155,13 +172,21 @@ export default class ImportAsJSONAction {
|
|||||||
const tree = this._generateNewIdentifiers(objTree, namespace);
|
const tree = this._generateNewIdentifiers(objTree, namespace);
|
||||||
const rootId = tree.rootId;
|
const rootId = tree.rootId;
|
||||||
|
|
||||||
const rootModel = tree.openmct[rootId];
|
const rootObj = tree.openmct[rootId];
|
||||||
delete rootModel.persisted;
|
delete rootObj.persisted;
|
||||||
|
this.newObjects.push(rootObj);
|
||||||
|
|
||||||
const rootObj = await this._instantiate(rootModel);
|
|
||||||
if (this.openmct.composition.checkPolicy(domainObject, rootObj)) {
|
if (this.openmct.composition.checkPolicy(domainObject, rootObj)) {
|
||||||
this._deepInstantiate(rootObj, tree.openmct, []);
|
this._deepInstantiate(rootObj, tree.openmct, []);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await Promise.all(this.newObjects.map(this._instantiate, this));
|
||||||
|
} catch (error) {
|
||||||
|
this.openmct.notifications.error('Error saving objects');
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
const compositionCollection = this.openmct.composition.get(domainObject);
|
const compositionCollection = this.openmct.composition.get(domainObject);
|
||||||
let domainObjectKeyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
let domainObjectKeyString = this.openmct.objects.makeKeyString(domainObject.identifier);
|
||||||
this.openmct.objects.mutate(rootObj, 'location', domainObjectKeyString);
|
this.openmct.objects.mutate(rootObj, 'location', domainObjectKeyString);
|
||||||
@ -184,16 +209,11 @@ export default class ImportAsJSONAction {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {object} rootModel
|
* @param {object} model
|
||||||
* @returns {object}
|
* @returns {object}
|
||||||
*/
|
*/
|
||||||
async _instantiate(rootModel) {
|
_instantiate(model) {
|
||||||
const success = await this.openmct.objects.save(rootModel);
|
return this.openmct.objects.save(model);
|
||||||
if (success) {
|
|
||||||
return rootModel;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.openmct.notifications.error('Error saving objects');
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
Loading…
Reference in New Issue
Block a user