diff --git a/platform/commonUI/browse/src/creation/CreationPolicy.js b/platform/commonUI/browse/src/creation/CreationPolicy.js index 0ccf82d907..28749e711f 100644 --- a/platform/commonUI/browse/src/creation/CreationPolicy.js +++ b/platform/commonUI/browse/src/creation/CreationPolicy.js @@ -27,23 +27,19 @@ define( "use strict"; /** - * A policy for determining whether objects of a certain type can be + * A policy for determining whether objects of a given type can be * created. - * @returns {{allow: Function}} * @constructor + * @implements {Policy} + * @memberof platform/commonUI/browse */ function CreationPolicy() { - return { - /** - * Only allow creation of object types that have the - * Creation capability - */ - allow: function (type) { - return type.hasFeature("creation"); - } - }; } + CreationPolicy.prototype.allow = function (type) { + return type.hasFeature("creation"); + }; + return CreationPolicy; } ); \ No newline at end of file diff --git a/platform/entanglement/src/services/CopyTask.js b/platform/entanglement/src/services/CopyTask.js index a12bdf2f11..770b21f27a 100644 --- a/platform/entanglement/src/services/CopyTask.js +++ b/platform/entanglement/src/services/CopyTask.js @@ -23,8 +23,8 @@ /*global define */ define( - ["uuid"], - function (uuid) { + [], + function () { "use strict"; /** @@ -53,8 +53,8 @@ define( parent.getModel().composition.push(child.getId()); - //Check if the object being composed is a link - if (!child.getCapability("location").isLink()) { + //If a location is not specified, set it. + if (!child.getModel().location) { child.getModel().location = parent.getId(); } } @@ -99,7 +99,7 @@ define( */ function addClonesToParent(self) { return self.firstClone.getCapability("persistence").persist() - .then(function(){self.parent.getCapability("composition").add(self.firstClone.getId())}) + .then(function(){self.parent.getCapability("composition").add(self.firstClone.getId());}) .then(function(){return self.parent.getCapability("persistence").persist();}) .then(function(){return self.firstClone;}); } @@ -132,11 +132,8 @@ define( * cloning objects, and composing them with their child clones * as it goes * @private - * @param originalObject - * @param originalParent - * @returns {*} */ - CopyTask.prototype.copy = function(originalObject, originalParent) { + CopyTask.prototype.copy = function(originalObject) { var self = this, clone; @@ -148,7 +145,7 @@ define( // creation capability of the targetParent to create the // new clone. This will ensure that the correct persistence // space is used. - clone = this.parent.hasCapability("instantiation") && this.parent.useCapability("instantiation", cloneObjectModel(originalObject.getModel())); + clone = this.parent.useCapability("instantiation", cloneObjectModel(originalObject.getModel())); //Iterate through child tree return this.$q.when(originalObject.useCapability('composition')).then(function(composees){ @@ -203,10 +200,6 @@ define( CopyTask.prototype.perform = function(){ this.deferred = this.$q.defer(); - if (!this.parent.hasCapability('composition')){ - return this.$q.reject(); - } - this.buildCopyPlan() .then(persistObjects) .then(addClonesToParent) diff --git a/platform/entanglement/test/services/CopyServiceSpec.js b/platform/entanglement/test/services/CopyServiceSpec.js index d4de5aa2aa..3d4ebf147e 100644 --- a/platform/entanglement/test/services/CopyServiceSpec.js +++ b/platform/entanglement/test/services/CopyServiceSpec.js @@ -174,7 +174,6 @@ define( ['notify', 'resolve', 'reject'] ); mockDeferred.notify.andCallFake(function(notification){}); - mockDeferred.reject.andCallFake(function(){}); mockDeferred.resolve.andCallFake(function(value){resolvedValue = value;}); mockDeferred.promise = { then: function(callback){ @@ -413,15 +412,23 @@ define( object = domainObjectFactory({ name: 'object', capabilities: { - type: { type: 'object' } + type: { type: 'object' }, + location: locationCapability, + persistence: persistenceCapability } }); + newParent = domainObjectFactory({ name: 'parentCandidate', capabilities: { - type: { type: 'parentCandidate' } + type: { type: 'parentCandidate' }, + instantiation: instantiationCapability, + composition: compositionCapability, + persistence: persistenceCapability } }); + + instantiationCapability.invoke.andReturn(object); }); it("throws an error", function () {