--- a/common/corpus-common-addon/app/services/lexvo-resolver.js Wed Jun 08 21:40:22 2016 +0200
+++ b/common/corpus-common-addon/app/services/lexvo-resolver.js Thu Jun 09 17:11:14 2016 +0200
@@ -1,61 +1,26 @@
-import Ember from 'ember';
-import store from 'corpus-common-addon/utils/store';
-import * as constants from 'corpus-common-addon/utils/constants'
+import * as constants from 'corpus-common-addon/utils/constants';
-export default Ember.Service.extend({
- env: function() {
- return Ember.getOwner(this).resolveRegistration('config:environment')
- },
- _getStoreKey: function(id) {
- return 'lexvo:'+id;
- },
- getName: function(id) {
+import ResolverService from 'corpus-common-addon/services/resolver-service';
- if(!id) {
- return new Ember.RSVP.Promise(function(resolve/*, reject*/) {
- resolve("");
- });
- }
+export default ResolverService.extend({
- var lexvoId = id;
- if(id.startsWith(constants.LEXVO_BASE_URL)) {
- lexvoId = id.slice(constants.LEXVO_BASE_URL.length);
- }
- var namePromise = null;
-
- var storeKey = this._getStoreKey(id);
- var name = store.get(storeKey);
+ storeKeyBase: 'lexvo',
+ apiPath: '/api/v1/lexvo/',
+ resDocRoot: 'lexvoids',
- if(!name) {
- //TODO: handle error !!!
- namePromise = this.queryName(lexvoId)
- .then( function(response) {
- return store.set(storeKey, response);
- });
- }
- else {
- namePromise = new Ember.RSVP.Promise(function(resolve/*, reject*/) {
- resolve(name);
- });
- }
- return namePromise;
- },
+ init() {
+ this._super(...arguments);
+ console.log("LEXVO", this);
+ },
- // make the query for the name.
- // return a Promise
- queryName: function(id) {
- return new Ember.RSVP.Promise(function(resolve, reject) {
- Ember.$.ajax({
- //TODO Configuration ?
- url: this.env().baseURL.replace(/\/$/,"") + "/api/v1/lexvo/"+id,
- success: function(lexvoDoc) {
- var names = lexvoDoc.lexvoids;
- resolve((id in names)?names[id]:null);
- },
- error: function(req, status, error) {
- reject(status + ":" + error);
+ processId: function(id) {
+ var lexvoId = id;
+ if(id.startsWith(constants.LEXVO_BASE_URL)) {
+ lexvoId = id.slice(constants.LEXVO_BASE_URL.length);
}
- });
- }.bind(this));
- }
+ return lexvoId;
+ },
+
+ getReturnDictKey: function(id) { return id; }
+
});