[Create] Add filter to copyService

Add an optional parameter to method signature of
copyService, used to determine if a domain object should
or should not be cloned.

This will be used to support usages of copyService
where links should remain links;
https://github.com/nasa/openmctweb/pull/666/files#r52525612
This commit is contained in:
Victor Woeltjen
2016-02-10 13:29:56 -08:00
parent b37b82133e
commit f602aa9247

View File

@@ -54,16 +54,33 @@ define(
);
};
/**
* A function used to check if a domain object should be cloned
* or not.
* @callback platform/entanglement.CopyService~filter
* @param {DomainObject} domainObject the object to be cloned
* @returns {boolean} true if the object should be cloned; false
* if it should be linked
*/
/**
* Creates a duplicate of the object tree starting at domainObject to
* the new parent specified.
* @param domainObject
* @param parent
* @param progress
*
* Any domain objects which cannot be created will not be cloned;
* instead, these will appear as links. If a filtering function
* is provided, any objects which fail that check will also be
* linked instead of cloned
*
* @param {DomainObject} domainObject the object to duplicate
* @param {DomainObject} parent the destination for the clone
* @param {platform/entanglement.CopyService~filter} [filter]
* an optional function used to filter out objects from
* the cloning process
* @returns a promise that will be completed with the clone of
* domainObject when the duplication is successful.
*/
CopyService.prototype.perform = function (domainObject, parent) {
CopyService.prototype.perform = function (domainObject, parent, filter) {
var $q = this.$q,
copyTask = new CopyTask(domainObject, parent, this.policyService, this.$q);
if (this.validate(domainObject, parent)) {