Project

General

Profile

« Previous | Next » 

Revision 44907

in services use function console.log instead of console.error | re-enable cache for project & organization service | in services add result in cache before custom parsing

View differences:

dataProvider.service.ts
20 20
        let url = OpenaireProperties.getSearchAPIURLLast() + 'datasources/' +id +"?format=json";
21 21
        let key = url;
22 22
        if (this._cache.has(key)) {
23
          return Observable.of(this._cache.get(key));
23
          return Observable.of(this._cache.get(key)).map(res => this.parseDataProviderInfo(res));
24 24
        }
25 25
        return this.http.get(url)
26 26
                    .map(res => <any> res.json())
......
30 30
                                 res['oaf:datasource']['openairecompatibility'],
31 31
                                 res['oaf:datasource']['accessinfopackage'],
32 32
                                 res['oaf:datasource']['rels']['rel']
33
                     ]).map(res => this.parseDataProviderInfo(res)).do(res => {
34
                      this._cache.set(key, res);
35
                    })
36
                    .do(res => {
37
                      this._cache.set(key, res);
38
                    });
33
                     ]).do(res => {
34
                       this._cache.set(key, res);
35
                     })
36
                     .map(res => this.parseDataProviderInfo(res));
39 37

  
40 38
    }
41 39

  
......
58 56
    private handleError (error: Response) {
59 57
    // in a real world app, we may send the error to some remote logging infrastructure
60 58
    // instead of just logging it to the console
61
        console.error(error);
59
        console.log(error);
62 60
        return Observable.throw(error  || 'Server error');
63 61
    }
64 62

  
......
141 139
            let length = data[4].length!=undefined ? data[4].length : 1;
142 140

  
143 141
            for(let i=0; i<length; i++) {
144
                mydata = length > 1 ? data[4][i] : data[4];
142
                mydata = data[4].length!=undefined ? data[4][i] : data[4];
145 143
                if(mydata.hasOwnProperty("to")) {
146 144
                    if(mydata['to'].class == "provides" && mydata['to'].type == "organization") {
147 145
                        //if(this.dataProviderInfo.organizations == undefined) {

Also available in: Unified diff