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