Revision 61321
Added by Konstantina Galouni over 2 years ago
dataProvider.service.ts | ||
---|---|---|
36 | 36 |
//let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); |
37 | 37 |
//let options = new RequestOptions({headers: headers}); |
38 | 38 |
|
39 |
const options = { |
|
40 |
headers: new HttpHeaders({ |
|
41 |
'Content-Type': 'application/json', |
|
42 |
'accept': 'application/json'}) |
|
43 |
}; |
|
39 |
// const options = { |
|
40 |
// headers: new HttpHeaders({ |
|
41 |
// 'Content-Type': 'application/json', |
|
42 |
// 'accept': 'application/json'}) |
|
43 |
// }; |
|
44 |
// |
|
45 |
// let page: number = 0; |
|
46 |
// let size: number = 1; |
|
47 |
// return this.http.post(properties.datasourcesAPI+page+"/"+size+"?requestSortBy=id&order=ASCENDING", JSON.stringify({ "id": original_id }), options) |
|
48 |
// //.map(res => <any> res.json()) |
|
49 |
// .pipe(map(res => res['datasourceInfo'])) |
|
50 |
// .pipe(map(res => this.parseDataproviderAggregationStatus(res))); |
|
44 | 51 |
|
45 |
let page: number = 0; |
|
46 |
let size: number = 1; |
|
47 |
return this.http.post(properties.datasourcesAPI+page+"/"+size+"?requestSortBy=id&order=ASCENDING", JSON.stringify({ "id": original_id }), options) |
|
48 |
//.map(res => <any> res.json()) |
|
49 |
.pipe(map(res => res['datasourceInfo'])) |
|
50 |
.pipe(map(res => this.parseDataproviderAggregationStatus(res))); |
|
52 |
return this.http.get(properties.datasourcesAPI+original_id) |
|
53 |
.pipe(map(res => res['api'])) |
|
54 |
.pipe(map(res => this.parseDataproviderAggregationStatus(res))); |
|
51 | 55 |
} |
52 | 56 |
|
53 | 57 |
private handleError (error: HttpErrorResponse) { |
... | ... | |
57 | 61 |
return throwError(error || 'Server error'); |
58 | 62 |
} |
59 | 63 |
|
60 |
parseDataproviderAggregationStatus(data: any): any { |
|
61 |
var aggregationStatus: {"fundedContent": string, "indexRecords": string, "fulltexts": string, "lastUpdateDate": string} = null; |
|
62 |
if(data != null && data[0] != null) { |
|
63 |
aggregationStatus = {"fundedContent": "-1", "indexRecords": "-1", "fulltexts": "-1", "lastUpdateDate": null}; |
|
64 |
aggregationStatus.fundedContent = data[0].fundedContent; |
|
65 |
aggregationStatus.indexRecords = data[0].indexRecords; |
|
66 |
aggregationStatus.fulltexts = data[0].fulltexts; |
|
64 |
parseDataproviderAggregationStatus(apis: any): any { |
|
65 |
// var aggregationStatus: {"fundedContent": string, "indexRecords": string, "fulltexts": string, "lastUpdateDate": string} = null; |
|
66 |
// if(data != null && data[0] != null) { |
|
67 |
// aggregationStatus = {"fundedContent": "-1", "indexRecords": "-1", "fulltexts": "-1", "lastUpdateDate": null}; |
|
68 |
// aggregationStatus.fundedContent = data[0].fundedContent; |
|
69 |
// aggregationStatus.indexRecords = data[0].indexRecords; |
|
70 |
// aggregationStatus.fulltexts = data[0].fulltexts; |
|
71 |
// |
|
72 |
// if(data[0].hasOwnProperty("aggregationHistory")) { |
|
73 |
// let length = Array.isArray(data[0]["aggregationHistory"]) ? data[0]["aggregationHistory"].length : 1; |
|
74 |
// |
|
75 |
// for(let i=0; i<length; i++) { |
|
76 |
// var aggregationHistory = Array.isArray(data[0]["aggregationHistory"]) ? data[0]["aggregationHistory"][i] : data[0]["aggregationHistory"]; |
|
77 |
// if(aggregationHistory && aggregationHistory.indexedVersion == true) { |
|
78 |
// aggregationStatus.lastUpdateDate = aggregationHistory.date; |
|
79 |
// break; |
|
80 |
// } |
|
81 |
// } |
|
82 |
// } |
|
83 |
// } |
|
67 | 84 |
|
68 |
if(data[0].hasOwnProperty("aggregationHistory")) { |
|
69 |
let length = Array.isArray(data[0]["aggregationHistory"]) ? data[0]["aggregationHistory"].length : 1; |
|
85 |
var aggregationStatus: {"fulltexts": string} = null; |
|
86 |
if(apis != null) { |
|
87 |
aggregationStatus = {"fulltexts": "-1"}; |
|
70 | 88 |
|
71 |
for(let i=0; i<length; i++) { |
|
72 |
var aggregationHistory = Array.isArray(data[0]["aggregationHistory"]) ? data[0]["aggregationHistory"][i] : data[0]["aggregationHistory"]; |
|
73 |
if(aggregationHistory && aggregationHistory.indexedVersion == true) { |
|
74 |
aggregationStatus.lastUpdateDate = aggregationHistory.date; |
|
75 |
break; |
|
76 |
} |
|
77 |
} |
|
89 |
let mostRecentDate = null; |
|
90 |
let length = Array.isArray(apis) ? apis.length : 1; |
|
91 |
|
|
92 |
for (let i = 0; i < length; i++) { |
|
93 |
let api = Array.isArray(apis) ? apis[i] : apis; |
|
94 |
if(api.compatibility == "files" && (mostRecentDate == null || mostRecentDate < api.lastDownloadDate)) { |
|
95 |
aggregationStatus.fulltexts = api.lastDownloadTotal; |
|
96 |
mostRecentDate = api.lastDownloadDate; |
|
78 | 97 |
} |
79 | 98 |
} |
80 |
return aggregationStatus; |
|
99 |
} |
|
100 |
|
|
101 |
return aggregationStatus; |
|
81 | 102 |
} |
82 | 103 |
|
83 | 104 |
parseDataProviderInfo (data: any):any { |
Also available in: Unified diff
[Branch angular-11 | Library]:
1. dataProviderInfo.ts: Added field "fundedContent" and updated "aggregationStatus: {"fulltexts": string};".
2. searchResearchResults.service.ts: Added method "countCollectedResultsWithFundingInfo()" to get number of research outcomes related to any project and collected from specific datasoure.
3. dataProvider.service.ts: Updated methods "getDataproviderAggregationStatus()" and "parseDataproviderAggregationStatus()" to parse "fulltexts" (new GET API call used).
4. dataProvider.component.ts: Added method "countResultsWithFundingInfo()" and updated method "hasAggregationStatusInfo()".
5. dataProvider.component.html: Deleted info "Latest data aggregation" and show "dataProviderInfo.fundedContent" instead of "dataProviderInfo.aggregationStatus.fundedContent".