Project

General

Profile

« Previous | Next » 

Revision 55964

[Library|Trunk]

Merge into trunk branch angular7 rev 55729

View differences:

software.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 {SoftwareInfo} from '../../utils/entities/softwareInfo';
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 SoftwareService {
14 11

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

  
......
26 23

  
27 24

  
28 25
    return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
29
                    .map(res => <any> res.json())
30
                    .map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result'], res])
31
                    .map(res => [res[1],
26
                    //.map(res => <any> res.json())
27
                    .pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result'], res]))
28
                    .pipe(map(res => [res[1],
32 29
                                 res[1]['title'],
33 30
                                 res[1]['rels']['rel'],
34 31
                                 res[1]['children'],
......
45 42
                                 res[1]['programmingLanguage'],
46 43
                                 res[2],
47 44
                                res[1]['journal'] //15
48
                    ]).map(res => this.parseSoftwareInfo(res, properties));
45
                    ]))
46
                    .pipe(map(res => this.parseSoftwareInfo(res, properties)));
49 47
  }
50 48

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

  
58 56
  parseSoftwareInfo (data: any, properties: EnvProperties):any {

Also available in: Unified diff