Project

General

Profile

« Previous | Next » 

Revision 55964

[Library|Trunk]

Merge into trunk branch angular7 rev 55729

View differences:

searchDataproviders.service.ts
1 1
import {Injectable} from '@angular/core';
2 2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
3
import {HttpClient} from "@angular/common/http";
4
import {Observable}     from 'rxjs';
4 5
import {SearchResult}     from '../utils/entities/searchResult';
5 6
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
6
import 'rxjs/add/observable/of';
7
import 'rxjs/add/operator/do';
8
import 'rxjs/add/operator/share';
7

  
8

  
9

  
9 10
import {StringUtils} from '../utils/string-utils.class';
10 11
import{EnvProperties} from '../utils/properties/env-properties';
12
import {map} from "rxjs/operators";
11 13

  
12 14
@Injectable()
13 15
export class SearchDataprovidersService {
14
    constructor(private http: Http ) {}
16
    constructor(private http: HttpClient ) {}
15 17

  
16 18
    searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
17 19

  
......
28 30

  
29 31

  
30 32
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
31
                    .map(res => <any> res.json())
33
                    //.map(res => <any> res.json())
32 34
                    //.do(res => console.info(res))
33
                    .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
35
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
34 36
    }
35 37
    //((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
36 38
    advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties ):any {
......
47 49
      url += "&page="+(page-1)+"&size="+size+"&format=json";
48 50

  
49 51
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
50
      .map(res => <any> res.json())
52
      //.map(res => <any> res.json())
51 53
      //.do(res => console.info(res))
52
      .map(res => [res['meta'].total, this.parseResults(res['results'])])
54
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]))
53 55
    }
54 56

  
55 57
    searchCompatibleDataprovidersTable ( properties:EnvProperties):any {
......
60 62

  
61 63

  
62 64

  
63
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
64

  
65
                        .map(res => res['meta'].total);
65
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
66
                      //.map(res => <any> res.json())
67
                      .pipe(map(res => res['meta'].total));
66 68
    }
67 69

  
68 70
    searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
......
77 79
      url += "&page="+(page-1)+"&size="+size+"&format=json";
78 80

  
79 81
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
80
      .map(res => <any> res.json())
82
      //.map(res => <any> res.json())
81 83
      //.do(res => console.info(res))
82
      .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
84
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
83 85
    }
84 86

  
85 87
    searchEntityRegistriesTable (properties:EnvProperties):any {
......
90 92

  
91 93

  
92 94

  
93
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
94
                        .map(res => res['meta'].total);
95
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
96
                      //.map(res => <any> res.json())
97
                      .pipe(map(res => res['meta'].total));
95 98
    }
96 99

  
97 100
    searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
......
106 109
      url += "&page="+(page-1)+"&size="+size+"&format=json";
107 110

  
108 111
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
109
      .map(res => <any> res.json())
112
      //.map(res => <any> res.json())
110 113
      //.do(res => console.info(res))
111
      .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
114
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
112 115
    }
113 116

  
114 117
    searchJournalsTable ( properties:EnvProperties):any {
......
117 120
      url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
118 121
      url += "&page=0&size=0&format=json";
119 122

  
120
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
121
                        .map(res => res['meta'].total);
123
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)//.map(res => <any> res.json())
124
                        .pipe(map(res => res['meta'].total));
122 125
    }
123 126

  
124 127
    searchJournals (params: string,refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties):any {
......
135 138
      url += "&page="+(page-1)+"&size="+size+"&format=json";
136 139

  
137 140
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
138
      .map(res => <any> res.json())
141
      //.map(res => <any> res.json())
139 142
      //.do(res => console.info(res))
140
      .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]);
143
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
141 144
    }
142 145

  
143 146
    searchDataprovidersForDeposit (id: string,type:string, page: number, size: number, properties:EnvProperties):any {
......
155 158

  
156 159

  
157 160
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
158
                    .map(res => <any> res.json())
159
                    .map(res => [res['meta'].total, this.parseResults(res['results'])]);
161
                    //.map(res => <any> res.json())
162
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
160 163
    }
161 164
    searchDataProvidersBySubjects(keyword:string, type:string, page: number, size: number, properties:EnvProperties):any {
162 165
      let link = properties.searchResourcesAPIURL;
......
173 176

  
174 177

  
175 178
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
176
                  .map(res => <any> res.json())
177
                  .map(res => [res['meta'].total, this.parseResults(res['results'])]);
179
                  //.map(res => <any> res.json())
180
                  .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
178 181

  
179 182
    }
180 183

  
......
191 194
      url += "&page="+(page-1)+"&size="+size+"&format=json";
192 195

  
193 196
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
194
      .map(res => <any> res.json())
195
      .map(res => [res['meta'].total, this.parseResults(res['results'])]);
197
      //.map(res => <any> res.json())
198
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
196 199
    }
197 200
    searchDataprovidersForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
198 201
        let link = properties.searchAPIURLLAst;
199 202
        let url = link+params+"/datasources?format=json";
200 203

  
201 204
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
202
                    .map(res => <any> res.json())
203
                    .map(res => [res['meta'].total, this.parseResults(res['results'])]);
205
                    //.map(res => <any> res.json())
206
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
204 207
    }
205 208
/*
206 209
    searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any {
......
411 414
        //let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
412 415

  
413 416
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
414
                    .map(res => <any> res.json())
415
                    .map(res => res.total);
417
                    //.map(res => <any> res.json())
418
                    .pipe(map(res => res['total']));
416 419
    }
417 420

  
418 421
    numOfEntityDataproviders(id: string, entity: string, properties:EnvProperties):any {
......
454 457

  
455 458

  
456 459

  
457
  return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url).map(res => <any> res.json())
458

  
459
                    .map(res => res['meta'].total);
460
  return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
461
                  //.map(res => <any> res.json())
462
                  .pipe(map(res => res['meta'].total));
460 463
}
461 464
}

Also available in: Unified diff