[Entanglement] Throw errors if validation is skipped
...per feedback from nasa/openmctweb#98
This commit is contained in:
@@ -64,6 +64,12 @@ define(
|
|||||||
return self.perform(domainObject, parent);
|
return self.perform(domainObject, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.validate(domainObject, parent)) {
|
||||||
|
throw new Error(
|
||||||
|
"Tried to copy objects without validating first."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (domainObject.hasCapability('composition')) {
|
if (domainObject.hasCapability('composition')) {
|
||||||
model.composition = [];
|
model.composition = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,15 +53,18 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
LinkService.prototype.perform = function (object, parentObject) {
|
LinkService.prototype.perform = function (object, parentObject) {
|
||||||
// It is assumed here that validate has been called, and therefore
|
if (!this.validate(object, parentObject)) {
|
||||||
// that parentObject.hasCapability('composition').
|
throw new Error(
|
||||||
var composition = parentObject.getCapability('composition');
|
"Tried to link objects without validating first."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return composition.add(object).then(function (objectInNewContext) {
|
return parentObject.getCapability('composition').add(object)
|
||||||
return parentObject.getCapability('persistence')
|
.then(function (objectInNewContext) {
|
||||||
.persist()
|
return parentObject.getCapability('persistence')
|
||||||
.then(function () { return objectInNewContext; });
|
.persist()
|
||||||
});
|
.then(function () { return objectInNewContext; });
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return LinkService;
|
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
|
return this.linkService
|
||||||
.perform(object, parentObject)
|
.perform(object, parentObject)
|
||||||
.then(relocate)
|
.then(relocate)
|
||||||
|
|||||||
Reference in New Issue
Block a user