Project

General

Profile

« Previous | Next » 

Revision 55964

[Library|Trunk]

Merge into trunk branch angular7 rev 55729

View differences:

ISVocabularies.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, HttpErrorResponse} from "@angular/common/http";
4
import {Observable, throwError,  of } from 'rxjs';
4 5
import {AutoCompleteValue} from '../../searchPages/searchUtils/searchHelperClasses.class';
5
import 'rxjs/add/observable/of';
6
import 'rxjs/add/operator/do';
7
import 'rxjs/add/operator/share';
8 6

  
9 7
import{EnvProperties} from '../properties/env-properties';
8
import {catchError, map} from "rxjs/operators";
10 9

  
11 10
@Injectable()
12 11
export class ISVocabulariesService {
13
    constructor(private http: Http ) {}
12
    constructor(private http: HttpClient ) {}
14 13

  
15 14
    getVocabularyByType(field:string,entity:string, properties:EnvProperties):any{
16 15
      //console.log("getVocabulary field: "+ field + " for entity: "+ entity);
......
34 33
        return this.getVocabularyFromService(vocabulary, properties);
35 34

  
36 35
      }else if ( field == "type" && (entity == "software" || entity == "other")){
37
        return Observable.of([]);
36
        return of([]);
38 37

  
39 38
      }else if( field == "access" && (entity == "publication" || entity == "dataset" ||  entity == "software" || entity == "other")){
40 39
        // file= "accessMode.json";
......
81 80
        //     return results;
82 81
        //   });
83 82
        return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
84
                    .map(res => <any> res.json())
85
                    .map(res => res['terms'])
86
                    .map(res => this.parse(res))
87
                    .catch(this.handleError);
83
                    //.map(res => <any> res.json())
84
                    .pipe(map(res => res['terms']))
85
                    .pipe(map(res => this.parse(res)))
86
                    .pipe(catchError(this.handleError));
88 87

  
89 88
    }
90 89

  
......
100 99
        return array;
101 100

  
102 101
    }
103
private handleError (error: Response) {
102
private handleError (error: HttpErrorResponse) {
104 103
      // in a real world app, we may send the error to some remote logging infrastructure
105 104
      // instead of just logging it to the console
106 105
      console.log(error);
107
      return Observable.throw(error  || 'Server error');
106
      return throwError(error  || 'Server error');
108 107
    }
109 108
}

Also available in: Unified diff