mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 09:26:45 +00:00
Refactored some CopyService functions out to CopyTask
This commit is contained in:
parent
aa2a835cb1
commit
e1c6c76612
@ -23,8 +23,11 @@
|
||||
/*global define */
|
||||
|
||||
define(
|
||||
["uuid"],
|
||||
function (uuid) {
|
||||
[
|
||||
"uuid",
|
||||
"./CopyTask"
|
||||
],
|
||||
function (uuid, CopyTask) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
|
@ -50,7 +50,7 @@ define(
|
||||
clone.model.persisted = self.now();
|
||||
return self.persistenceService.createObject(clone.persistenceSpace, clone.id, clone.model)
|
||||
.then(function(){
|
||||
return self.deferred.notify({phase: "copying", totalObjects: objectClones.length, processed: ++persisted});
|
||||
return self.deferred.notify({phase: "copying", totalObjects: objectClones.length, processed: ++self.persisted});
|
||||
});
|
||||
})).then(function(){
|
||||
return objectClones;
|
||||
@ -66,7 +66,7 @@ define(
|
||||
self = this;
|
||||
|
||||
if (!this.parent.hasCapability('composition')){
|
||||
return this.deferred.reject();
|
||||
return this.$q.reject();
|
||||
}
|
||||
|
||||
return this.persistenceService
|
||||
@ -145,7 +145,7 @@ define(
|
||||
}
|
||||
|
||||
return copy(self.domainObject, self.parent).then(function(domainObjectClone){
|
||||
domainObjectClone.model.location = parent.getId();
|
||||
domainObjectClone.model.location = self.parent.getId();
|
||||
return clones;
|
||||
});
|
||||
};
|
||||
@ -156,11 +156,12 @@ define(
|
||||
|
||||
this.deferred = this.$q.defer();
|
||||
|
||||
return this.buildCopyPlan()
|
||||
this.buildCopyPlan()
|
||||
.then(persistObjects)
|
||||
.then(addClonesToParent)
|
||||
.then(this.deferred.resolve)
|
||||
.catch(this.deferred.reject);
|
||||
.then(this.deferred.resolve, this.deferred.reject);
|
||||
|
||||
return this.deferred.promise;
|
||||
}
|
||||
|
||||
return CopyTask;
|
||||
|
@ -342,17 +342,7 @@ define(
|
||||
expect(copyFinished.mostRecentCall.args[0].model.modified).toBeUndefined();
|
||||
expect(copyFinished.mostRecentCall.args[0].model.persisted).toBe(mockNow.now());
|
||||
});
|
||||
|
||||
/**
|
||||
Preserves links
|
||||
*/
|
||||
it ("preserves links", function() {
|
||||
expect(copyFinished.mostRecentCall.args[0].model.location).toBe("testLocation");
|
||||
});
|
||||
|
||||
/**
|
||||
Preserves links
|
||||
*/
|
||||
|
||||
it ("correctly locates cloned objects", function() {
|
||||
expect(mockPersistenceService.createObject.calls[0].args[2].location).toEqual(mockPersistenceService.createObject.calls[1].args[1]);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user