Project

General

Profile

« Previous | Next » 

Revision 55964

[Library|Trunk]

Merge into trunk branch angular7 rev 55729

View differences:

searchOrps.service.ts
1 1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import {SearchResult}     from '../utils/entities/searchResult';
2
import {HttpClient} from "@angular/common/http";
3
import {SearchResult} from '../utils/entities/searchResult';
5 4
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
6
import 'rxjs/add/observable/of';
7
import 'rxjs/add/operator/do';
8
import 'rxjs/add/operator/share';
9 5
import {DOI, StringUtils} from '../utils/string-utils.class';
10
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class';
11
import{EnvProperties} from '../utils/properties/env-properties';
6
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class';
7
import {EnvProperties} from '../utils/properties/env-properties';
8
import {map} from "rxjs/operators";
12 9

  
13 10
@Injectable()
14 11
export class SearchOrpsService {
15 12
    private sizeOfDescription: number = 270;
16 13
    public parsingFunctions: ParsingFunctions = new ParsingFunctions();
17 14

  
18
    constructor(private http: Http ) {}
15
    constructor(private http: HttpClient ) {}
19 16

  
20 17
    searchOrps (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[], properties:EnvProperties ):any {
21 18

  
......
35 32

  
36 33

  
37 34
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
38
                    .map(res => <any> res.json())
35
                    //.map(res => <any> res.json())
39 36
                    //.do(res => console.info(res))
40
                    .map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]);
37
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]));
41 38
    }
42 39
    searchOrpById (id: string , properties:EnvProperties):any {
43 40

  
44 41
        let url = properties.searchAPIURLLAst+"other/"+id+"?format=json";
45 42

  
46 43
         return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
47
                    .map(res => <any> res.json())
48
                    .map(res => this.parseResults(res, properties));
44
                    //.map(res => <any> res.json())
45
                    .pipe(map(res => this.parseResults(res, properties)));
49 46
    }
50 47

  
51 48
    searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any {
......
64 61

  
65 62

  
66 63
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
67
                    .map(res => <any> res.json())
68
                    .map(res => this.parseRefineResults(id, res['refineResults']))
64
                    //.map(res => <any> res.json())
65
                    .pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
69 66
    }
70 67

  
71 68
    searchOrpsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
......
88 85

  
89 86

  
90 87
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
91
                    .map(res => <any> res.json())
88
                    //.map(res => <any> res.json())
92 89
                    //.do(res => console.info(res))
93

  
94
                    .map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]);
90
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "other")]));
95 91
    }
96 92
    advancedSearchOrps (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any {
97 93
      let url = properties.searchResourcesAPIURL;
......
113 109
      url += "&format=json";
114 110

  
115 111
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
116
      .map(res => <any> res.json())
112
      //.map(res => <any> res.json())
117 113
      //.do(res => console.info(res))
118
      .map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
114
      .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
119 115
    }
120 116
    searchOrpsForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
121 117
        let link = properties.searchAPIURLLAst;
......
123 119
        let url = link+params+"/other"+"?format=json";
124 120

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

  
130 126
    searchOrpsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any {
......
132 128

  
133 129
        let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
134 130
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
135
                    .map(res => <any> res.json())
136
                    .map(res => [res['meta'].total, this.parseResults(res['results'], properties)]);
131
                    //.map(res => <any> res.json())
132
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)]));
137 133
    }
138 134

  
139 135
    parseResults(data: any, properties: EnvProperties): SearchResult[] {
......
351 347
    numOfOrps(url: string, properties:EnvProperties):any {
352 348

  
353 349
      return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
354
                  .map(res => <any> res.json())
355
                  .map(res => res.total);
350
                  //.map(res => <any> res.json())
351
                  .pipe(map(res => res['total']));
356 352
    }
357 353

  
358 354
    numOfEntityOrps(id: string, entity: string, properties:EnvProperties):any {

Also available in: Unified diff