mirror of
https://github.com/nasa/openmct.git
synced 2025-03-10 22:43:55 +00:00
[Persistence] Use identifier service to get key
Retrieve key from identifier service for all persist operations. Fixes https://github.com/nasa/openmct/issues/1013
This commit is contained in:
parent
3480809129
commit
2d5824c4ab
@ -60,11 +60,6 @@ define(
|
||||
this.$q = $q;
|
||||
}
|
||||
|
||||
function getKey(id) {
|
||||
var parts = id.split(":");
|
||||
return parts.length > 1 ? parts.slice(1).join(":") : id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the value returned is falsey, and if so returns a
|
||||
* rejected promise
|
||||
@ -131,7 +126,7 @@ define(
|
||||
// ...and persist
|
||||
return persistenceFn.apply(persistenceService, [
|
||||
this.getSpace(),
|
||||
getKey(domainObject.getId()),
|
||||
this.getKey(),
|
||||
domainObject.getModel()
|
||||
]).then(function (result) {
|
||||
return rejectIfFalsey(result, self.$q);
|
||||
@ -159,7 +154,7 @@ define(
|
||||
|
||||
return this.persistenceService.readObject(
|
||||
this.getSpace(),
|
||||
this.domainObject.getId()
|
||||
this.getKey()
|
||||
).then(updateModel);
|
||||
};
|
||||
|
||||
@ -178,6 +173,17 @@ define(
|
||||
return this.identifierService.parse(id).getSpace();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the key for this domain object in the given space.
|
||||
*
|
||||
* @returns {string} the key of the object in it's space.
|
||||
*/
|
||||
PersistenceCapability.prototype.getKey = function () {
|
||||
var id = this.domainObject.getId();
|
||||
return this.identifierService.parse(id).getKey();
|
||||
};
|
||||
|
||||
return PersistenceCapability;
|
||||
}
|
||||
);
|
||||
|
@ -101,6 +101,7 @@ define(
|
||||
});
|
||||
mockIdentifierService.parse.andReturn(mockIdentifier);
|
||||
mockIdentifier.getSpace.andReturn(SPACE);
|
||||
mockIdentifier.getKey.andReturn(id);
|
||||
persistence = new PersistenceCapability(
|
||||
mockCacheService,
|
||||
mockPersistenceService,
|
||||
|
Loading…
x
Reference in New Issue
Block a user