Project

General

Profile

« Previous | Next » 

Revision 55964

[Library|Trunk]

Merge into trunk branch angular7 rev 55729

View differences:

contexts.service.ts
1

  
2
import {throwError as observableThrowError, Observable} from 'rxjs';
1 3
import {Injectable} from '@angular/core';
2 4
import {Jsonp, URLSearchParams, RequestOptions, Headers} from '@angular/http';
3 5
import {Http, Response} from '@angular/http';
4
import {Observable}     from 'rxjs/Observable';
6
import { HttpClient } from '@angular/common/http';
5 7
import {Claim}           from '../claim';
6 8
import {AutoCompleteValue} from '../../../searchPages/searchUtils/searchHelperClasses.class';
7
import 'rxjs/add/observable/of';
8
import 'rxjs/add/operator/do';
9
import 'rxjs/add/operator/share';
9
import {catchError, map} from "rxjs/operators";
10 10
import { COOKIE  } from '../../../login/utils/helper.class';
11 11
@Injectable()
12 12
export class ContextsService {
13
  constructor(private http: Http ) {
13
  constructor(private http: HttpClient ) {
14 14
  }
15 15

  
16 16
  public getCommunities( apiUrl:string):any {
......
19 19
  let key = url;
20 20
    //console.info('ContextsService: request communities  '+url);
21 21
      return this.http.get(url)
22
                    .map(res => <any> res.json()).map(res => this.parseCommunities(res, true) )
22
                    //.map(res => <any> res.json())
23
                    .pipe(map(res => this.parseCommunities(res, true) ))
23 24
                    // .do(request => console.info("Get claims: offset = "))
24
                    .catch(this.handleError);
25
                    .pipe(catchError(this.handleError));
25 26
  }
26 27
  public getPublicCommunities( apiUrl:string):any {
27 28
    let  url   = apiUrl + 's/';
......
29 30
    let key = url;
30 31
    //console.info('ContextsService: request communities  '+url);
31 32
    return this.http.get(url)
32
      .map(res => <any> res.json()).map(res => this.parseCommunities(res, false) )
33
      // .do(request => console.info("Get claims: offset = "))
34
      .catch(this.handleError);
33
      .pipe(map(res => this.parseCommunities(res, true) ));
35 34
  }
36 35
  parseCommunities(data, getall){
37 36
    var communities = [];
......
52 51

  
53 52

  
54 53
      return this.http.get(url)
55
                    .map(request => <any> request.json())
54
                    //.map(request => <any> request.json())
56 55
                    // .do(request => console.info("Get claims: offset = " ))
57
                    .catch(this.handleError);;
56
                    .pipe(catchError(this.handleError));
58 57
  }
59 58
  public getConcepts(categoryId :string, keyword: string, parsing:boolean, apiUrl:string):any {
60 59
    //console.info('ContextsService:  request concept for category  with id '+categoryId + ' and keyword '+ keyword);
......
63 62

  
64 63

  
65 64
      return this.http.get(url )
66
                    .map(request => <any> request.json())
67
                    .catch(this.handleError)
68
                    .map(res => (parsing)?this.parse(res):res);
65
                    //.map(request => <any> request.json())
66
                    .pipe(catchError(this.handleError))
67
                    .pipe(map(res => (parsing)?this.parse(res):res));
69 68
                    // .do(res => console.info("Result is "+ res.length ));
70 69
  }
71 70
  public getSubConcepts(subConceptID :string, keyword: string, parsing:boolean, apiUrl:string):any {
......
75 74

  
76 75

  
77 76
      return this.http.get(url )
78
                    .map(request => <any> request.json())
79
                    .catch(this.handleError)
80
                    .map(res => (parsing)?this.parseSubConcepts(res):res);
77
                    //.map(request => <any> request.json())
78
                    .pipe(catchError(this.handleError))
79
                    .pipe(map(res => (parsing)?this.parseSubConcepts(res):res));
81 80
                    // .do(res => console.info("Result is "+ res.length ));
82 81
  }
83 82
  parse (data: any):any {
......
130 129
    // in a real world app, we may send the error to some remote logging infrastructure
131 130
    // instead of just logging it to the console
132 131
    console.log(error);
133
    return Observable.throw(error  || 'Server error');
132
    return observableThrowError(error  || 'Server error');
134 133
  }
135 134
  private getAuthOptions():RequestOptions{
136 135
  let headers = new Headers();

Also available in: Unified diff