Project

General

Profile

« Previous | Next » 

Revision 55573

[angular7: Library]: Move uoa-services-library project to Angular 7 (using webpack)

View differences:

searchOrps.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 {DOI, StringUtils} from '../utils/string-utils.class';
10 11
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class';
11 12
import{EnvProperties} from '../utils/properties/env-properties';
13
import {map} from "rxjs/operators";
12 14

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

  
18
    constructor(private http: Http ) {}
20
    constructor(private http: HttpClient ) {}
19 21

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

  
......
35 37

  
36 38

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

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

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

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

  
65 67

  
66 68
        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']))
69
                    //.map(res => <any> res.json())
70
                    .pipe(map(res => this.parseRefineResults(id, res['refineResults'])))
69 71
    }
70 72

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

  
89 91

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

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

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

  
125 127
        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'])]);
128
                    //.map(res => <any> res.json())
129
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
128 130
    }
129 131

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

  
133 135
        let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json";
134 136
        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'])]);
137
                    //.map(res => <any> res.json())
138
                    .pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
137 139
    }
138 140

  
139 141
    parseResults(data: any): SearchResult[] {
......
347 349
    numOfOrps(url: string, properties:EnvProperties):any {
348 350

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

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

Also available in: Unified diff