Project

General

Profile

« Previous | Next » 

Revision 55964

[Library|Trunk]

Merge into trunk branch angular7 rev 55729

View differences:

searchDatacite.service.ts
1

  
2
import {throwError as observableThrowError, Observable} from 'rxjs';
1 3
import {Injectable} from '@angular/core';
2 4
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import 'rxjs/add/observable/of';
5
import 'rxjs/add/operator/do';
6
import 'rxjs/add/operator/share';
5
import { HttpClient } from '@angular/common/http';
6

  
7

  
8

  
7 9
import{EnvProperties} from '../../../utils/properties/env-properties';
8 10
import { ClaimResult} from  '../claimEntities.class';
11
import {map} from "rxjs/operators";
9 12

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

  
14 17
  searchDataciteResults (term: string, size : number, page : number, properties:EnvProperties, parse:boolean = false):any {
15 18
    //console.info("In search datacite results "+term+ " "+properties.searchDataciteAPIURL);
......
17 20
    let key = url;
18 21

  
19 22
    return this.http.get( ( properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
20
                     .map(request => <any> request.json())
21
                     .map(request => (parse?this.parse(request.data):request))
23
                     //.map(request => <any> request.json())
24
                     .pipe(map(request => (parse?this.parse(request['data']):request)))
22 25
                      //.catch(this.handleError);
23 26
    }
24 27
    getDataciteResultByDOI (doi: string, properties:EnvProperties, parse:boolean = false):any {
......
26 29
      let key = url;
27 30

  
28 31
      return this.http.get( (properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
29
                       .map(request => <any> request.json())
30
                       .map(request => (parse?this.parse(request.data):request))
32
                       //.map(request => <any> request.json())
33
                       .pipe(map(request => (parse?this.parse(request['data']):request)))
31 34

  
32 35
                      //  .do(items => console.log("Datacite Results: total results = "+items.meta.total+" doi = "+doi))
33 36

  
......
39 42
    // in a real world app, we may send the error to some remote logging infrastructure
40 43
    // instead of just logging it to the console
41 44
    console.log(error);
42
    return Observable.throw(error  || 'Server error');
45
    return observableThrowError(error  || 'Server error');
43 46
  }
44 47
  private extractData(res: Response) {
45 48
    if (res.status < 200 || res.status >= 300) {

Also available in: Unified diff