mirror of
https://github.com/nasa/openmct.git
synced 2025-06-02 15:40:49 +00:00
[Creation] Use identifierService
...from CreationCapability.
This commit is contained in:
parent
d8f3f0f430
commit
06436bb876
@ -34,8 +34,9 @@ define(
|
|||||||
* @memberof platform/core
|
* @memberof platform/core
|
||||||
* @param $injector Angular's `$injector`
|
* @param $injector Angular's `$injector`
|
||||||
*/
|
*/
|
||||||
function CreationCapability($injector, domainObject) {
|
function CreationCapability($injector, identifierService, domainObject) {
|
||||||
this.$injector = $injector;
|
this.$injector = $injector;
|
||||||
|
this.identifierService = identifierService;
|
||||||
this.domainObject = domainObject;
|
this.domainObject = domainObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,14 +64,12 @@ define(
|
|||||||
* @returns {DomainObject} the new domain object
|
* @returns {DomainObject} the new domain object
|
||||||
*/
|
*/
|
||||||
CreationCapability.prototype.create = function (model) {
|
CreationCapability.prototype.create = function (model) {
|
||||||
var id = uuid(),
|
var parsedId =
|
||||||
|
this.identifierService.parse(this.domainObject.getId()),
|
||||||
|
space = parsedId.getDefinedSpace(),
|
||||||
|
id = this.identifierService.generate(space),
|
||||||
capabilities = this.getCapabilities(model);
|
capabilities = this.getCapabilities(model);
|
||||||
|
|
||||||
// Retain any space-prefixing from the parent
|
|
||||||
if (this.domainObject.getId().indexOf(":") !== -1) {
|
|
||||||
id = this.domainObject.getId().split(":")[0] + ":" + id;
|
|
||||||
}
|
|
||||||
|
|
||||||
return new DomainObjectImpl(id, model, capabilities);
|
return new DomainObjectImpl(id, model, capabilities);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ define(
|
|||||||
if (separatorIndex > -1) {
|
if (separatorIndex > -1) {
|
||||||
this.key = id.substring(separatorIndex + 1);
|
this.key = id.substring(separatorIndex + 1);
|
||||||
this.space = id.substring(0, separatorIndex);
|
this.space = id.substring(0, separatorIndex);
|
||||||
this.spaceDefined = true;
|
this.definedSpace = this.pace;
|
||||||
} else {
|
} else {
|
||||||
this.key = id;
|
this.key = id;
|
||||||
this.space = defaultSpace;
|
this.space = defaultSpace;
|
||||||
this.spaceDefined = false;
|
this.definedSpace = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ define(
|
|||||||
return this.space;
|
return this.space;
|
||||||
};
|
};
|
||||||
|
|
||||||
Identifier.prototype.hasDefinedSpace = function () {
|
Identifier.prototype.getDefinedSpace = function () {
|
||||||
return this.spaceDefined;
|
return this.definedSpace;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Identifier;
|
return Identifier;
|
||||||
|
@ -35,7 +35,7 @@ define(
|
|||||||
|
|
||||||
IdentifierProvider.prototype.generate = function (space) {
|
IdentifierProvider.prototype.generate = function (space) {
|
||||||
var id = uuid();
|
var id = uuid();
|
||||||
if (arguments.length > 0) {
|
if (space !== undefined) {
|
||||||
id = space + ":" + id;
|
id = space + ":" + id;
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user