Merge branch 'open338' into rems_data

This commit is contained in:
Henry 2015-12-03 18:41:50 -08:00
commit 1fef6b30b7
3 changed files with 24 additions and 28 deletions

View File

@ -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;
}
);

View File

@ -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)

View File

@ -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 () {