cms/app-client/mirage/config.js
author ymh <ymh.work@gmail.com>
Fri, 09 Dec 2016 11:41:15 +0100
changeset 467 762fc0eb4946
parent 466 a8effb60ccb6
child 474 245b4df137d3
permissions -rw-r--r--
Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
import ENV from 'app-client/config/environment';
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
import _ from 'lodash/lodash';
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
import * as constants from 'corpus-common-addon/utils/constants';
466
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
     4
import Collection from 'ember-cli-mirage/orm/collection';
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
export default function() {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
    // These comments are here to help you get started. Feel free to delete them.
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
    /*
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
      Config (with defaults).
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
      Note: these only affect routes defined *after* them!
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
    */
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    // this.urlPrefix = '';    // make this `http://localhost:8080`, for example, if your API is on a different server
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
    // this.namespace = '';    // make this `api`, for example, if your API is namespaced
319
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    17
    this.namespace = (ENV.APP.backRootURL || ENV.rootURL).replace(/\/$/,'')+'/api/v1';
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    // this.timing = 400;      // delay for each request, automatically set to 0 during testing
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
    this.get('/documents', function({ documents }) {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
        return this.serialize(documents.all(), 'sparse-document');
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
    });
245
c9dd78a43b07 Transcript model and erializer
Chloe Laisne <chloe.laisne@gmail.com>
parents: 173
diff changeset
    23
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    this.get('/documents/:id', ({documents}, request) => {
319
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    25
        let id = decodeURIComponent(decodeURIComponent(request.params.id));
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
        return documents.find(id);
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
    });
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
    this.get('/documents/:id/transcript',  ({transcripts}, request) => {
319
78990a8a069b Work on front and back integration, correct the expected data format
ymh <ymh.work@gmail.com>
parents: 318
diff changeset
    30
        let id = decodeURIComponent(decodeURIComponent(request.params.id));
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
        return transcripts.find(id).transcript;
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
    });
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
467
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    34
    this.get('/stats/languages', ({languages}, request) => {
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    35
      let qParams = request.queryParams['discourse'];
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    36
      if(qParams) {
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    37
        var res = [];
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    38
        let allLanguages = languages.all().models;
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    39
        let i=0;
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    40
        while(i<allLanguages.length && res.length < (allLanguages.length/Math.pow(2,qParams.length))) {
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    41
          let d = allLanguages[i++];
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    42
          d.count = Math.max(Math.floor(d.count / 2), 1);
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    43
          res.push(d);
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    44
        }
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    45
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    46
        return new Collection('language', res);
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    47
      } else {
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    48
        return languages.all();
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    49
      }
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    50
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    51
    });
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    53
    this.get('/stats/geostats', 'geostats');
274
53a6985443f8 geostats endpoint + mapvar
Chloe Laisne <chloe.laisne@gmail.com>
parents: 261
diff changeset
    54
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    55
    this.get('/stats/themes', 'themes');
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
466
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    57
    this.get('/stats/discourses', ({discourses}, request) => {
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    58
467
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    59
      let qParams = request.queryParams['discourse'];
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    60
      if(qParams) {
466
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    61
        var res = [];
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    62
        let allDiscourses = discourses.all().models;
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    63
        let i=0;
467
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    64
        while(i<allDiscourses.length && res.length < (allDiscourses.length/Math.pow(2,qParams.length))) {
466
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    65
          let d = allDiscourses[i++];
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    66
          if(!_.contains(request.queryParams.discourse, d.id)) {
467
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    67
            d.count = Math.max(Math.floor(d.count / 2), 1);
466
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    68
            res.push(d);
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    69
          }
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    70
        }
467
762fc0eb4946 Migrate d3js to v4 and correct d3js visualisations i.e. bug 3.20. Breadcrumb navigation for the language treemap has been improved
ymh <ymh.work@gmail.com>
parents: 466
diff changeset
    71
466
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    72
        return new Collection('discourse', res);
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    73
      } else {
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    74
        return discourses.all();
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    75
      }
a8effb60ccb6 correct discourse display and update
ymh <ymh.work@gmail.com>
parents: 447
diff changeset
    76
    });
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
307
07b44a378ad8 Add the datestats api
ymh <ymh.work@gmail.com>
parents: 305
diff changeset
    78
    this.get('/stats/datestats', 'datestats');
07b44a378ad8 Add the datestats api
ymh <ymh.work@gmail.com>
parents: 305
diff changeset
    79
424
feb0d3e0fef9 add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    80
    this.get('/stats/dateminmax', 'dateminmax');
feb0d3e0fef9 add dynamic date range calculation for dates, and add color gradient component, add color gradient for language and chrono
ymh <ymh.work@gmail.com>
parents: 329
diff changeset
    81
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    82
    this.get('/resolvers/lexvo/:ids', ({lexvos}, request) => {
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
        var langIds = decodeURIComponent(request.params.ids);
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
        var resMap = _.reduce(langIds.split(','), function(res, id) {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
            var fullId = id;
329
0a2c2ad49d75 Improvce language visualization. Generalize language node selection, change language query parameters, add resolution of node name (corpus-) to lexvo controler
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    86
            if(!_.startsWith(fullId, constants.LEXVO_BASE_URL) && !_.startsWith(fullId, constants.LANGUAGES_NODE_PREFIX)) {
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
                fullId = constants.LEXVO_BASE_URL + id;
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
            }
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
            var lexvoRes = lexvos.find(fullId);
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
            res[id] = lexvoRes?lexvoRes.name:null;
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
            return res;
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
        }, {});
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
        return {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
            'lexvoids': resMap
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
        };
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
    });
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
    98
    this.get('/resolvers/bnf/:ids', ({ bnfs }, request) => {
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
        var bnfIds = decodeURIComponent(request.params.ids);
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
        var resMap = _.reduce(bnfIds.split(','), function(res, id) {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
            var fullId = id;
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
            if(_.startsWith(fullId, constants.BNF_BASE_URL)) {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
                fullId = fullId.slice(constants.BNF_BASE_URL.length);
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
            } else if (_.startsWith(fullId, constants.BNF_ARK_BASE_URL)) {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
                fullId = fullId.slice(constants.BNF_ARK_BASE_URL.length);
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
            } else if (!_.startsWith(fullId, constants.BNF_ARK_BASE_ID)) {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
                fullId = constants.BNF_ARK_BASE_ID + fullId;
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
            }
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
            var bnfRes = bnfs.find(fullId);
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
            res[id] = bnfRes?bnfRes.label:null;
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
            return res;
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
        }, {});
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
        return {
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
            'bnfids': resMap
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
        };
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
    });
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
305
ff6cf3fc5f40 api reorganisation and propagation if the changes + some code cleaning
ymh <ymh.work@gmail.com>
parents: 304
diff changeset
   118
    this.get('/resolvers/geonames/:ids', ({ geonames }, request) => {
304
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   119
        var geonamesIds = decodeURIComponent(request.params.ids);
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   120
        var resMap = _.reduce(geonamesIds.split(','), function(res, id) {
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   121
            var code = id;
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   122
            var m = code.match(constants.GEONAMES_BASE_URLS);
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   123
            if(m) {
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   124
                code = code.slice(m[0].length);
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   125
            }
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   126
            code = code.replace(/\/+$/, '');
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   127
            var geonamesRes = geonames.find(code);
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   128
            res[id] = geonamesRes?geonamesRes.label:null;
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   129
            return res;
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   130
        }, {});
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   131
        return {
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   132
            'geonamesids': resMap
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   133
        };
20071981ba2a add location and geonames resolvers and api
ymh <ymh.work@gmail.com>
parents: 278
diff changeset
   134
    });
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
447
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   136
    this.get('/resolvers/viaf/:ids', ({viafs}, request) => {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   137
        var viafIds = decodeURIComponent(request.params.ids);
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   138
        var resMap = _.reduce(viafIds.split(','), function(res, id) {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   139
            var fullId = id;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   140
            if(!_.startsWith(fullId, constants.VIAF_BASE_URL)) {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   141
                fullId = constants.VIAF_BASE_URL + id;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   142
            }
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   143
            var viafRes = viafs.find(fullId);
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   144
            res[id] = viafRes?viafRes.name:null;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   145
            return res;
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   146
        }, {});
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   147
        return {
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   148
            'viafids': resMap
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   149
        };
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   150
    });
38d5789e30d0 Improce notice data display, correct m3.23
ymh <ymh.work@gmail.com>
parents: 424
diff changeset
   151
173
cf7b221238fd Work on test fixtures:
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
}