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