mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 07:08:12 +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:
@ -72,7 +72,12 @@ define(
|
|||||||
*/
|
*/
|
||||||
PersistenceCapability.prototype.persist = function () {
|
PersistenceCapability.prototype.persist = function () {
|
||||||
var domainObject = this.domainObject,
|
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...
|
// Update persistence timestamp...
|
||||||
domainObject.useCapability("mutation", function (model) {
|
domainObject.useCapability("mutation", function (model) {
|
||||||
@ -80,11 +85,11 @@ define(
|
|||||||
}, modified);
|
}, modified);
|
||||||
|
|
||||||
// ...and persist
|
// ...and persist
|
||||||
return this.persistenceService.updateObject(
|
return persistenceFn.apply(persistenceService, [
|
||||||
this.getSpace(),
|
this.getSpace(),
|
||||||
domainObject.getId(),
|
domainObject.getId(),
|
||||||
domainObject.getModel()
|
domainObject.getModel()
|
||||||
);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user