Revision 55964
Added by Argiro Kokogiannaki almost 5 years ago
searchPublications.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 |
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'; |
|
7 |
|
|
8 |
import {SearchResult} from '../utils/entities/searchResult'; |
|
2 |
import {HttpClient} from "@angular/common/http"; |
|
3 |
import {SearchResult} from '../utils/entities/searchResult'; |
|
9 | 4 |
import {RefineResultsUtils} from './servicesUtils/refineResults.class'; |
10 | 5 |
import {DOI, StringUtils} from '../utils/string-utils.class'; |
11 |
import { ParsingFunctions } from '../landingPages/landing-utils/parsingFunctions.class'; |
|
12 |
import{EnvProperties} from '../utils/properties/env-properties'; |
|
6 |
import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.class'; |
|
7 |
import {EnvProperties} from '../utils/properties/env-properties'; |
|
8 |
import {map} from "rxjs/operators"; |
|
13 | 9 |
|
14 | 10 |
|
15 | 11 |
@Injectable() |
... | ... | |
17 | 13 |
private sizeOfDescription: number = 270; |
18 | 14 |
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); |
19 | 15 |
|
20 |
constructor(private http: Http ) {} |
|
16 |
constructor(private http: HttpClient ) {}
|
|
21 | 17 |
|
22 | 18 |
searchPublications (params: string, refineParams:string, page: number, size: number, sortBy: string, refineFields:string[] , properties:EnvProperties):any { |
23 | 19 |
let link = properties.searchAPIURLLAst+"publications"; |
... | ... | |
36 | 32 |
|
37 | 33 |
|
38 | 34 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
39 |
.map(res => <any> res.json()) |
|
40 |
// .do(res => console.info(res)) |
|
41 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]); |
|
35 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")])); |
|
42 | 36 |
} |
43 | 37 |
searchPublicationById (id: string, properties:EnvProperties ):any { |
44 | 38 |
|
45 | 39 |
let url = properties.searchAPIURLLAst+"publications/"+id+"?format=json"; |
46 | 40 |
|
47 | 41 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
48 |
.map(res => <any> res.json()) |
|
49 |
.map(res => this.parseResults(res, properties)); |
|
42 |
.pipe(map(res => this.parseResults(res, properties))); |
|
50 | 43 |
} |
51 | 44 |
|
52 | 45 |
searchAggregators (id: string, params: string, refineParams:string, page: number, size: number, properties:EnvProperties ):any { |
... | ... | |
65 | 58 |
|
66 | 59 |
|
67 | 60 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
68 |
.map(res => <any> res.json()) |
|
69 |
.map(res => this.parseRefineResults(id, res['refineResults']));
|
|
61 |
//.map(res => <any> res.json())
|
|
62 |
.pipe(map(res => this.parseRefineResults(id, res['refineResults'])));
|
|
70 | 63 |
} |
71 | 64 |
|
72 | 65 |
searchPublicationsByDois (DOIs: string[], refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any { |
... | ... | |
89 | 82 |
url += "&page="+(page-1)+"&size="+size; |
90 | 83 |
|
91 | 84 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
92 |
.map(res => <any> res.json()) |
|
85 |
//.map(res => <any> res.json())
|
|
93 | 86 |
//.do(res => console.info(res)) |
94 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]);
|
|
87 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties),RefineResultsUtils.parse(res['refineResults'],refineFields, "publication")]));
|
|
95 | 88 |
} |
96 | 89 |
|
97 | 90 |
advancedSearchPublications (params: string, page: number, size: number, sortBy: string, properties:EnvProperties ):any { |
... | ... | |
113 | 106 |
url += "&format=json"; |
114 | 107 |
|
115 | 108 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
116 |
.map(res => <any> res.json()) |
|
109 |
//.map(res => <any> res.json())
|
|
117 | 110 |
//.do(res => console.info(res)) |
118 |
|
|
119 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]); |
|
111 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)])); |
|
120 | 112 |
} |
121 | 113 |
searchPublicationsForEntity (params: string, page: number, size: number, properties:EnvProperties):any { |
122 | 114 |
let link = properties.searchAPIURLLAst; |
... | ... | |
126 | 118 |
|
127 | 119 |
|
128 | 120 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
129 |
.map(res => <any> res.json()) |
|
130 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]); |
|
121 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)])); |
|
131 | 122 |
} |
132 | 123 |
|
133 | 124 |
searchPublicationsForDataproviders(params: string, page: number, size: number, properties:EnvProperties):any { |
134 | 125 |
let link = properties.searchAPIURLLAst; |
135 | 126 |
let url = link+params+ "&page="+(page-1)+"&size="+size + "&format=json"; |
136 | 127 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
137 |
.map(res => <any> res.json()) |
|
138 |
.map(res => [res['meta'].total, this.parseResults(res['results'], properties)]); |
|
128 |
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'], properties)])); |
|
139 | 129 |
} |
140 | 130 |
/* |
141 | 131 |
searchPublicationsCSV (params: string, refineParams:string, page: number, size: number):any { |
... | ... | |
463 | 453 |
numOfPublications(url: string, properties:EnvProperties): any { |
464 | 454 |
|
465 | 455 |
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) |
466 |
.map(res => <any> res.json()) |
|
467 |
.map(res => res.total);
|
|
456 |
//.map(res => <any> res.json())
|
|
457 |
.pipe(map(res => res['total']));
|
|
468 | 458 |
} |
469 | 459 |
|
470 | 460 |
numOfEntityPublications(id: string, entity: string, properties:EnvProperties):any { |
Also available in: Unified diff
[Library|Trunk]
Merge into trunk branch angular7 rev 55729