mirror of
https://github.com/nasa/openmct.git
synced 2025-06-13 12:48:14 +00:00
Legacy and new object providers work together (#3461)
* Strip mct namespace from ids when getting models from cache * Revert PersistenceCapability to use legacy code Enforce empty namespace for LegacyPersistenceAdapter for new object providers * Reverts change to caching provider * CouchObject provider is registered with the mct space. When saving objects via the persistence capability use the mct space to find the couchdb object provider
This commit is contained in:
@ -114,7 +114,12 @@ define(["objectUtils"],
|
||||
var self = this,
|
||||
domainObject = this.domainObject;
|
||||
|
||||
let newStyleObject = objectUtils.toNewFormat(domainObject.getModel(), domainObject.getId());
|
||||
const identifier = {
|
||||
namespace: this.getSpace(),
|
||||
key: this.getKey()
|
||||
};
|
||||
|
||||
let newStyleObject = objectUtils.toNewFormat(domainObject.getModel(), identifier);
|
||||
|
||||
return this.openmct.objects
|
||||
.save(newStyleObject)
|
||||
@ -146,6 +151,7 @@ define(["objectUtils"],
|
||||
return domainObject.useCapability("mutation", function () {
|
||||
return model;
|
||||
}, modified);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,11 +159,10 @@ define(["objectUtils"],
|
||||
return this.$q.when(true);
|
||||
}
|
||||
|
||||
return this.openmct.objects.get(domainObject.getId()).then((newStyleObject) => {
|
||||
let oldStyleObject = this.openmct.legacyObject(newStyleObject);
|
||||
|
||||
return updateModel(oldStyleObject.getModel());
|
||||
});
|
||||
return this.persistenceService.readObject(
|
||||
this.getSpace(),
|
||||
this.getKey()
|
||||
).then(updateModel);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,6 @@ define(
|
||||
key = "persistence key",
|
||||
id = "object identifier",
|
||||
model,
|
||||
refreshModel,
|
||||
SPACE = "some space",
|
||||
persistence,
|
||||
mockOpenMCT,
|
||||
@ -61,7 +60,6 @@ define(
|
||||
someKey: "some value",
|
||||
name: "domain object"
|
||||
};
|
||||
refreshModel = {someOtherKey: "some other value"};
|
||||
|
||||
mockPersistenceService = jasmine.createSpyObj(
|
||||
"persistenceService",
|
||||
@ -101,8 +99,8 @@ define(
|
||||
|
||||
mockNewStyleDomainObject = Object.assign({}, model);
|
||||
mockNewStyleDomainObject.identifier = {
|
||||
namespace: "",
|
||||
key: id
|
||||
namespace: SPACE,
|
||||
key: key
|
||||
};
|
||||
|
||||
// Simulate mutation capability
|
||||
@ -112,16 +110,8 @@ define(
|
||||
}
|
||||
});
|
||||
|
||||
mockOpenMCT = {
|
||||
legacyObject: function (object) {
|
||||
return {
|
||||
getModel: function () {
|
||||
return object;
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
mockOpenMCT.objects = jasmine.createSpyObj('Object API', ['save', 'get']);
|
||||
mockOpenMCT = {};
|
||||
mockOpenMCT.objects = jasmine.createSpyObj('Object API', ['save']);
|
||||
|
||||
mockIdentifierService.parse.and.returnValue(mockIdentifier);
|
||||
mockIdentifier.getSpace.and.returnValue(SPACE);
|
||||
@ -141,7 +131,6 @@ define(
|
||||
describe("successful persistence", function () {
|
||||
beforeEach(function () {
|
||||
mockOpenMCT.objects.save.and.returnValue(Promise.resolve(true));
|
||||
mockOpenMCT.objects.get.and.returnValue(Promise.resolve(refreshModel));
|
||||
});
|
||||
it("creates unpersisted objects with the persistence service", function () {
|
||||
// Verify precondition; no call made during constructor
|
||||
@ -157,10 +146,11 @@ define(
|
||||
});
|
||||
|
||||
it("refreshes the domain object model from persistence", function () {
|
||||
var refreshModel = {someOtherKey: "some other value"};
|
||||
model.persisted = 1;
|
||||
persistence.refresh().then(() => {
|
||||
expect(model).toEqual(refreshModel);
|
||||
});
|
||||
mockPersistenceService.readObject.and.returnValue(asPromise(refreshModel));
|
||||
persistence.refresh();
|
||||
expect(model).toEqual(refreshModel);
|
||||
});
|
||||
|
||||
it("does not trigger error notification on successful"
|
||||
|
Reference in New Issue
Block a user