Project

General

Profile

« Previous | Next » 

Revision 55964

[Library|Trunk]

Merge into trunk branch angular7 rev 55729

View differences:

orp.service.ts
1 1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
2
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
3
import {throwError} from 'rxjs';
4 4
import {OrpInfo} from '../../utils/entities/orpInfo';
5
import 'rxjs/add/observable/of';
6
import 'rxjs/add/operator/do';
7
import 'rxjs/add/operator/share';
8
import{EnvProperties} from '../../utils/properties/env-properties';
5
import {EnvProperties} from '../../utils/properties/env-properties';
6
import {ParsingFunctions} from '../landing-utils/parsingFunctions.class';
7
import {map} from "rxjs/operators";
9 8

  
10
import { ParsingFunctions } from '../landing-utils/parsingFunctions.class';
11

  
12 9
@Injectable()
13 10
export class OrpService {
14 11

  
15
  constructor(private http: Http ) {
12
  constructor(private http: HttpClient ) {
16 13
    this.parsingFunctions = new ParsingFunctions();
17 14
  }
18 15

  
......
25 22
    let key = url;
26 23

  
27 24
    return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
28
                    .map(res => <any> res.json())
29
                    .map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'],res])
30
                    .map(res => [res[1]['oaf:result'],  //0
25
                    //.map(res => <any> res.json())
26
                    .pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'],res]))
27
                    .pipe(map(res => [res[1]['oaf:result'],  //0
31 28
                                 res[1]['oaf:result']['title'],   //1
32 29
                                 res[1]['oaf:result']['rels']['rel'], //2
33 30
                                 res[1]['oaf:result']['children'],  //3
......
43 40
                                 res[2],  //13
44 41
                                 (res[1]['extraInfo']!= undefined && res[1]['extraInfo']['citations']!= undefined)? res[1]['extraInfo']['citations']['citation']:null, //14
45 42
                                  res[1]['oaf:result']['journal'] //15
46
                    ]).map(res => this.parseOrpInfo(res, properties));
43
                    ]))
44
                    .pipe(map(res => this.parseOrpInfo(res, properties)));
47 45
  }
48 46

  
49
  private handleError (error: Response) {
47
  private handleError (error: HttpErrorResponse) {
50 48
  // in a real world app, we may send the error to some remote logging infrastructure
51 49
  // instead of just logging it to the console
52 50
    console.log(error);
53
    return Observable.throw(error  || 'Server error');
51
    return throwError(error  || 'Server error');
54 52
  }
55 53

  
56 54
  parseOrpInfo (data: any, properties: EnvProperties):any {

Also available in: Unified diff