Commit 191ed5ef authored by Aurélien Vermylen's avatar Aurélien Vermylen

Some fixes to Automatic API Storage to be used easily with MappingStorage

and push to ERP5.
parent a2b984ad
...@@ -14535,13 +14535,13 @@ return new Parser; ...@@ -14535,13 +14535,13 @@ return new Parser;
var path, temp; var path, temp;
path = URI(dat.url).path(); path = URI(dat.url).path();
temp = { temp = {
'path': path, 'automatic_path': path,
'reference': '/' + user_id + path, 'reference': '/' + user_id + path,
'id': '/' + user_id + path, 'id': '/' + user_id + path,
'type': type, 'type': type,
'started_at': dat.started_at || null, 'started_at': dat.started_at || null,
'ended_at': dat.ended_at || null, 'ended_at': dat.ended_at || null,
'user': user_id 'automatic_user': user_id
}; };
result.push(temp); result.push(temp);
return jio._cache.put('/' + user_id + path, temp).push(function () { return jio._cache.put('/' + user_id + path, temp).push(function () {
...@@ -14692,16 +14692,26 @@ return new Parser; ...@@ -14692,16 +14692,26 @@ return new Parser;
}); });
}; };
AutomaticAPIStorage.prototype.put = function () { AutomaticAPIStorage.prototype.put = function (id, doc) {
return; var self = this;
return new RSVP.Queue().push(function () {
return self._cache.get(id);
}).push(function () {
return self._cache.put(id, doc);
});
}; };
AutomaticAPIStorage.prototype.post = function () { AutomaticAPIStorage.prototype.post = function () {
return; return;
}; };
AutomaticAPIStorage.prototype.remove = function () { AutomaticAPIStorage.prototype.remove = function (id) {
return; var self = this;
return new RSVP.Queue().push(function () {
return self._cache.get(id);
}).push(function () {
return self._cache.remove(id);
});
}; };
AutomaticAPIStorage.prototype.getAttachment = function (id, name, options) { AutomaticAPIStorage.prototype.getAttachment = function (id, name, options) {
...@@ -14734,8 +14744,13 @@ return new Parser; ...@@ -14734,8 +14744,13 @@ return new Parser;
}); });
}; };
AutomaticAPIStorage.prototype.putAttachment = function () { AutomaticAPIStorage.prototype.putAttachment = function (id, name, blob) {
return; var self = this;
return new RSVP.Queue().push(function () {
return self._cache.get(id);
}).push(function () {
return self._cache.putAttachment(id, name, blob);
});
}; };
AutomaticAPIStorage.prototype.removeAttachment = function () { AutomaticAPIStorage.prototype.removeAttachment = function () {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -93,13 +93,13 @@ ...@@ -93,13 +93,13 @@
var path, temp; var path, temp;
path = URI(dat.url).path(); path = URI(dat.url).path();
temp = { temp = {
'path': path, 'automatic_path': path,
'reference': '/' + user_id + path, 'reference': '/' + user_id + path,
'id': '/' + user_id + path, 'id': '/' + user_id + path,
'type': type, 'type': type,
'started_at': dat.started_at || null, 'started_at': dat.started_at || null,
'ended_at': dat.ended_at || null, 'ended_at': dat.ended_at || null,
'user': user_id 'automatic_user': user_id
}; };
result.push(temp); result.push(temp);
return jio._cache.put('/' + user_id + path, temp).push(function () { return jio._cache.put('/' + user_id + path, temp).push(function () {
...@@ -250,16 +250,26 @@ ...@@ -250,16 +250,26 @@
}); });
}; };
AutomaticAPIStorage.prototype.put = function () { AutomaticAPIStorage.prototype.put = function (id, doc) {
return; var self = this;
return new RSVP.Queue().push(function () {
return self._cache.get(id);
}).push(function () {
return self._cache.put(id, doc);
});
}; };
AutomaticAPIStorage.prototype.post = function () { AutomaticAPIStorage.prototype.post = function () {
return; return;
}; };
AutomaticAPIStorage.prototype.remove = function () { AutomaticAPIStorage.prototype.remove = function (id) {
return; var self = this;
return new RSVP.Queue().push(function () {
return self._cache.get(id);
}).push(function () {
return self._cache.remove(id);
});
}; };
AutomaticAPIStorage.prototype.getAttachment = function (id, name, options) { AutomaticAPIStorage.prototype.getAttachment = function (id, name, options) {
...@@ -292,8 +302,13 @@ ...@@ -292,8 +302,13 @@
}); });
}; };
AutomaticAPIStorage.prototype.putAttachment = function () { AutomaticAPIStorage.prototype.putAttachment = function (id, name, blob) {
return; var self = this;
return new RSVP.Queue().push(function () {
return self._cache.get(id);
}).push(function () {
return self._cache.putAttachment(id, name, blob);
});
}; };
AutomaticAPIStorage.prototype.removeAttachment = function () { AutomaticAPIStorage.prototype.removeAttachment = function () {
......
...@@ -211,13 +211,13 @@ ...@@ -211,13 +211,13 @@
this.jio.get("/usertest/trip/T_randomtrip/") this.jio.get("/usertest/trip/T_randomtrip/")
.then(function (result) { .then(function (result) {
deepEqual(result, { deepEqual(result, {
'path': '/trip/T_randomtrip/', 'automatic_path': '/trip/T_randomtrip/',
'reference': '/usertest/trip/T_randomtrip/', 'reference': '/usertest/trip/T_randomtrip/',
'id': '/usertest/trip/T_randomtrip/', 'id': '/usertest/trip/T_randomtrip/',
'type': 'trip', 'type': 'trip',
'started_at': null, 'started_at': null,
'ended_at': null, 'ended_at': null,
'user': 'usertest' 'automatic_user': 'usertest'
}, "Check single element type"); }, "Check single element type");
}) })
.fail(function (error) { .fail(function (error) {
...@@ -513,13 +513,13 @@ ...@@ -513,13 +513,13 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, [{ deepEqual(result, [{
'path': '/trip/T_example/', 'automatic_path': '/trip/T_example/',
'reference': '/0/trip/T_example/', 'reference': '/0/trip/T_example/',
'id': '/0/trip/T_example/', 'id': '/0/trip/T_example/',
'type': 'trip', 'type': 'trip',
'started_at': "2017-06-17T16:45:41Z", 'started_at': "2017-06-17T16:45:41Z",
'ended_at': "2017-06-17T16:46:38Z", 'ended_at': "2017-06-17T16:46:38Z",
'user': '0' 'automatic_user': '0'
}], "Check trip is returned in result"); }], "Check trip is returned in result");
}) })
.fail(function (error) { .fail(function (error) {
...@@ -551,13 +551,13 @@ ...@@ -551,13 +551,13 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, [{ deepEqual(result, [{
'path': '/trip/T_example/', 'automatic_path': '/trip/T_example/',
'reference': '/0/trip/T_example/', 'reference': '/0/trip/T_example/',
'id': '/0/trip/T_example/', 'id': '/0/trip/T_example/',
'type': 'trip', 'type': 'trip',
'started_at': "2017-06-17T16:45:41Z", 'started_at': "2017-06-17T16:45:41Z",
'ended_at': "2017-06-17T16:46:38Z", 'ended_at': "2017-06-17T16:46:38Z",
'user': '0' 'automatic_user': '0'
}], "Check trip is returned in result"); }], "Check trip is returned in result");
}) })
.fail(function (error) { .fail(function (error) {
...@@ -602,13 +602,13 @@ ...@@ -602,13 +602,13 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, [{ deepEqual(result, [{
'path': '/vehicle/V_example/', 'automatic_path': '/vehicle/V_example/',
'reference': '/0/vehicle/V_example/', 'reference': '/0/vehicle/V_example/',
'id': '/0/vehicle/V_example/', 'id': '/0/vehicle/V_example/',
'type': 'vehicle', 'type': 'vehicle',
'started_at': null, 'started_at': null,
'ended_at': null, 'ended_at': null,
'user': '0' 'automatic_user': '0'
}], "Check vehicle list is returned"); }], "Check vehicle list is returned");
}) })
.fail(function (error) { .fail(function (error) {
...@@ -658,21 +658,21 @@ ...@@ -658,21 +658,21 @@
}) })
.then(function (result) { .then(function (result) {
deepEqual(result, [{ deepEqual(result, [{
'path': '/vehicle/V_example/', 'automatic_path': '/vehicle/V_example/',
'reference': '/0/vehicle/V_example/', 'reference': '/0/vehicle/V_example/',
'id': '/0/vehicle/V_example/', 'id': '/0/vehicle/V_example/',
'type': 'vehicle', 'type': 'vehicle',
'started_at': null, 'started_at': null,
'ended_at': null, 'ended_at': null,
'user': '0' 'automatic_user': '0'
}, { }, {
'path': '/vehicle/V_example2/', 'automatic_path': '/vehicle/V_example2/',
'reference': '/0/vehicle/V_example2/', 'reference': '/0/vehicle/V_example2/',
'id': '/0/vehicle/V_example2/', 'id': '/0/vehicle/V_example2/',
'type': 'vehicle', 'type': 'vehicle',
'started_at': null, 'started_at': null,
'ended_at': null, 'ended_at': null,
'user': '0' 'automatic_user': '0'
}], "Check vehicle list is returned"); }], "Check vehicle list is returned");
}) })
.fail(function (error) { .fail(function (error) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment