mirror of
https://github.com/nasa/openmct.git
synced 2025-04-22 01:51:49 +00:00
[Persistence] Use create from persistence capability
...when an object hasn't been previously persisted. This allows for compatibility with persistence services which disallow updates for nonexistent objects (which is not abnomal behavior.) nasa/openmctweb#92
This commit is contained in:
parent
5230bdfc6b
commit
620c0415cf
@ -72,7 +72,12 @@ define(
|
||||
*/
|
||||
PersistenceCapability.prototype.persist = function () {
|
||||
var domainObject = this.domainObject,
|
||||
modified = domainObject.getModel().modified;
|
||||
model = domainObject.getModel(),
|
||||
modified = model.modified,
|
||||
persistenceService = this.persistenceService,
|
||||
persistenceFn = model.persisted !== undefined ?
|
||||
this.persistenceService.updateObject :
|
||||
this.persistenceService.createObject;
|
||||
|
||||
// Update persistence timestamp...
|
||||
domainObject.useCapability("mutation", function (model) {
|
||||
@ -80,11 +85,11 @@ define(
|
||||
}, modified);
|
||||
|
||||
// ...and persist
|
||||
return this.persistenceService.updateObject(
|
||||
return persistenceFn.apply(persistenceService, [
|
||||
this.getSpace(),
|
||||
domainObject.getId(),
|
||||
domainObject.getModel()
|
||||
);
|
||||
]);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user