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:
Shefali Joshi
2020-10-19 10:17:18 -07:00
committed by GitHub
parent d27f73579b
commit e53399495b
6 changed files with 26 additions and 36 deletions

View File

@ -129,13 +129,6 @@ define([
ObjectServiceProvider.prototype.get = function (key) {
let keyString = utils.makeKeyString(key);
const space = this.getSpace(keyString);
let identifier = utils.parseKeyString(keyString);
// We assign to the space for legacy persistence providers since they register themselves using a defaultSpace.
// This is the way to make everyone happy.
identifier.namespace = space;
keyString = utils.makeKeyString(identifier);
return this.objectService.getObjects([keyString])
.then(function (results) {

View File

@ -86,7 +86,10 @@ export default class CouchObjectProvider {
this.objectQueue[key] = new CouchObjectQueue(undefined, response[REV]);
}
this.objectQueue[key].updateRevision(response[REV]);
//Sometimes CouchDB returns the old rev which fetching the object if there is a document update in progress
if (!this.objectQueue[key].pending) {
this.objectQueue[key].updateRevision(response[REV]);
}
return object;
} else {

View File

@ -22,7 +22,7 @@
import CouchObjectProvider from './CouchObjectProvider';
const NAMESPACE = '';
const PERSISTENCE_SPACE = '';
const PERSISTENCE_SPACE = 'mct';
export default function CouchPlugin(url) {
return function install(openmct) {

View File

@ -31,19 +31,18 @@ describe('the plugin', () => {
let element;
let child;
let provider;
let testSpace = 'testSpace';
let testPath = '/test/db';
let mockDomainObject;
beforeEach((done) => {
mockDomainObject = {
identifier: {
namespace: '',
namespace: 'mct',
key: 'some-value'
}
};
openmct = createOpenMct(false);
openmct.install(new CouchPlugin(testSpace, testPath));
openmct.install(new CouchPlugin(testPath));
element = document.createElement('div');
child = document.createElement('div');