mirror of
https://github.com/nasa/openmct.git
synced 2025-04-16 15:29:20 +00:00
[Entanglement] Throw errors if validation is skipped
...per feedback from nasa/openmctweb#98
This commit is contained in:
parent
ff24f06475
commit
119403e71c
@ -64,6 +64,12 @@ define(
|
||||
return self.perform(domainObject, parent);
|
||||
}
|
||||
|
||||
if (!this.validate(domainObject, parent)) {
|
||||
throw new Error(
|
||||
"Tried to copy objects without validating first."
|
||||
);
|
||||
}
|
||||
|
||||
if (domainObject.hasCapability('composition')) {
|
||||
model.composition = [];
|
||||
}
|
||||
|
@ -53,15 +53,18 @@ define(
|
||||
};
|
||||
|
||||
LinkService.prototype.perform = function (object, parentObject) {
|
||||
// It is assumed here that validate has been called, and therefore
|
||||
// that parentObject.hasCapability('composition').
|
||||
var composition = parentObject.getCapability('composition');
|
||||
if (!this.validate(object, parentObject)) {
|
||||
throw new Error(
|
||||
"Tried to link objects without validating first."
|
||||
);
|
||||
}
|
||||
|
||||
return composition.add(object).then(function (objectInNewContext) {
|
||||
return parentObject.getCapability('persistence')
|
||||
.persist()
|
||||
.then(function () { return objectInNewContext; });
|
||||
});
|
||||
return parentObject.getCapability('composition').add(object)
|
||||
.then(function (objectInNewContext) {
|
||||
return parentObject.getCapability('persistence')
|
||||
.persist()
|
||||
.then(function () { return objectInNewContext; });
|
||||
});
|
||||
};
|
||||
|
||||
return LinkService;
|
||||
|
@ -82,6 +82,12 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.validate(object, parentObject)) {
|
||||
throw new Error(
|
||||
"Tried to move objects without validating first."
|
||||
);
|
||||
}
|
||||
|
||||
return this.linkService
|
||||
.perform(object, parentObject)
|
||||
.then(relocate)
|
||||
|
Loading…
x
Reference in New Issue
Block a user