[Persistence] Use identifierService from persistence

User identifierService from the persistence capability, for
consistent interpretation of spaces associated with domain
object identifiers.
This commit is contained in:
Victor Woeltjen
2015-11-10 12:21:53 -08:00
parent a2db98d275
commit 689f80bb23

View File

@ -44,12 +44,16 @@ define(
* @constructor * @constructor
* @implements {Capability} * @implements {Capability}
*/ */
function PersistenceCapability(persistenceService, space, domainObject) { function PersistenceCapability(
persistenceService,
identifierService,
domainObject
) {
// Cache modified timestamp // Cache modified timestamp
this.modified = domainObject.getModel().modified; this.modified = domainObject.getModel().modified;
this.domainObject = domainObject; this.domainObject = domainObject;
this.space = space; this.identifierService = identifierService;
this.persistenceService = persistenceService; this.persistenceService = persistenceService;
} }
@ -135,11 +139,8 @@ define(
* be used to persist this object * be used to persist this object
*/ */
PersistenceCapability.prototype.getSpace = function () { PersistenceCapability.prototype.getSpace = function () {
if (this.domainObject.getId().indexOf(":") !== -1) { var id = this.domainObject.getId();
return this.domainObject.getId().split(":")[0]; return this.identifierService.parse(id).getSpace();
}
return this.space;
}; };
return PersistenceCapability; return PersistenceCapability;