[Creation] Simplify creationService

Add the newly-created domain object directly, instead of via
its id.
This commit is contained in:
Victor Woeltjen 2015-11-05 15:36:33 -08:00
parent 3f26be885e
commit 62b9eb5180

View File

@ -75,10 +75,10 @@ define(
// Add the newly-created object's id to the parent's
// composition, so that it will subsequently appear
// as a child contained by that parent.
function addToComposition(id, parent, parentPersistence) {
function addToComposition() {
var compositionCapability = parent.getCapability('composition'),
addResult = compositionCapability &&
compositionCapability.add(id);
compositionCapability.add(newObject);
return self.$q.when(addResult).then(function (result) {
if (!result) {
@ -86,7 +86,7 @@ define(
return undefined;
}
return parentPersistence.persist().then(function () {
return persistence.persist().then(function () {
return result;
});
});
@ -100,10 +100,7 @@ define(
}
// Persist the new object, then add it to composition.
return newObjectPersistence.persist().then(function () {
var id = newObject.getId();
return addToComposition(id, parent, persistence);
});
return newObjectPersistence.persist().then(addToComposition);
};