mirror of
https://github.com/nasa/openmct.git
synced 2025-06-22 17:08:57 +00:00
[Build] Remove apparent strict violations
...from persistence providers.
This commit is contained in:
@ -69,24 +69,24 @@ define(
|
|||||||
// Check the response to a create/update/delete request;
|
// Check the response to a create/update/delete request;
|
||||||
// track the rev if it's valid, otherwise return false to
|
// track the rev if it's valid, otherwise return false to
|
||||||
// indicate that the request failed.
|
// indicate that the request failed.
|
||||||
function checkResponse(response) {
|
CouchPersistenceProvider.prototype.checkResponse = function (response) {
|
||||||
if (response && response.ok) {
|
if (response && response.ok) {
|
||||||
this.revs[response.id] = response.rev;
|
this.revs[response.id] = response.rev;
|
||||||
return response.ok;
|
return response.ok;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Get a domain object model out of CouchDB's response
|
// Get a domain object model out of CouchDB's response
|
||||||
function getModel(response) {
|
CouchPersistenceProvider.prototype.getModel = function (response) {
|
||||||
if (response && response.model) {
|
if (response && response.model) {
|
||||||
this.revs[response[ID]] = response[REV];
|
this.revs[response[ID]] = response[REV];
|
||||||
return response.model;
|
return response.model;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Issue a request using $http; get back the plain JS object
|
// Issue a request using $http; get back the plain JS object
|
||||||
// from the expected JSON response
|
// from the expected JSON response
|
||||||
@ -122,24 +122,24 @@ define(
|
|||||||
|
|
||||||
CouchPersistenceProvider.prototype.createObject = function (space, key, value) {
|
CouchPersistenceProvider.prototype.createObject = function (space, key, value) {
|
||||||
return this.put(key, new CouchDocument(key, value))
|
return this.put(key, new CouchDocument(key, value))
|
||||||
.then(bind(checkResponse, this));
|
.then(bind(this.checkResponse, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
CouchPersistenceProvider.prototype.readObject = function (space, key) {
|
CouchPersistenceProvider.prototype.readObject = function (space, key) {
|
||||||
return this.get(key).then(bind(getModel, this));
|
return this.get(key).then(bind(this.getModel, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
CouchPersistenceProvider.prototype.updateObject = function (space, key, value) {
|
CouchPersistenceProvider.prototype.updateObject = function (space, key, value) {
|
||||||
var rev = this.revs[key];
|
var rev = this.revs[key];
|
||||||
return this.put(key, new CouchDocument(key, value, rev))
|
return this.put(key, new CouchDocument(key, value, rev))
|
||||||
.then(bind(checkResponse, this));
|
.then(bind(this.checkResponse, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
CouchPersistenceProvider.prototype.deleteObject = function (space, key, value) {
|
CouchPersistenceProvider.prototype.deleteObject = function (space, key, value) {
|
||||||
var rev = this.revs[key];
|
var rev = this.revs[key];
|
||||||
return this.put(key, new CouchDocument(key, value, rev, true))
|
return this.put(key, new CouchDocument(key, value, rev, true))
|
||||||
.then(bind(checkResponse, this));
|
.then(bind(this.checkResponse, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
return CouchPersistenceProvider;
|
return CouchPersistenceProvider;
|
||||||
|
@ -108,14 +108,14 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Get a domain object model out of ElasticSearch's response
|
// Get a domain object model out of ElasticSearch's response
|
||||||
function getModel(response) {
|
ElasticPersistenceProvider.prototype.getModel = function (response) {
|
||||||
if (response && response[SRC]) {
|
if (response && response[SRC]) {
|
||||||
this.revs[response[ID]] = response[REV];
|
this.revs[response[ID]] = response[REV];
|
||||||
return response[SRC];
|
return response[SRC];
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// Check the response to a create/update/delete request;
|
// Check the response to a create/update/delete request;
|
||||||
// track the rev if it's valid, otherwise return false to
|
// track the rev if it's valid, otherwise return false to
|
||||||
@ -145,15 +145,16 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
ElasticPersistenceProvider.prototype.readObject = function (space, key) {
|
ElasticPersistenceProvider.prototype.readObject = function (space, key) {
|
||||||
return this.get(key).then(bind(getModel, this));
|
return this.get(key).then(bind(this.getModel, this));
|
||||||
};
|
};
|
||||||
|
|
||||||
ElasticPersistenceProvider.prototype.updateObject = function (space, key, value) {
|
ElasticPersistenceProvider.prototype.updateObject = function (space, key, value) {
|
||||||
|
var self = this;
|
||||||
function checkUpdate(response) {
|
function checkUpdate(response) {
|
||||||
return this.checkResponse(response, key);
|
return self.checkResponse(response, key);
|
||||||
}
|
}
|
||||||
return this.put(key, value, { version: this.revs[key] })
|
return this.put(key, value, { version: this.revs[key] })
|
||||||
.then(bind(checkUpdate, this));
|
.then(checkUpdate);
|
||||||
};
|
};
|
||||||
|
|
||||||
ElasticPersistenceProvider.prototype.deleteObject = function (space, key, value) {
|
ElasticPersistenceProvider.prototype.deleteObject = function (space, key, value) {
|
||||||
|
Reference in New Issue
Block a user