1
|
import {Injectable} from '@angular/core';
|
2
|
import {HttpClient} from "@angular/common/http";
|
3
|
import {SearchResult} from '../utils/entities/searchResult';
|
4
|
import {RefineResultsUtils} from './servicesUtils/refineResults.class';
|
5
|
|
6
|
|
7
|
|
8
|
import {StringUtils} from '../utils/string-utils.class';
|
9
|
import{EnvProperties} from '../utils/properties/env-properties';
|
10
|
import {map} from "rxjs/operators";
|
11
|
|
12
|
@Injectable()
|
13
|
export class SearchDataprovidersService {
|
14
|
private sizeOfDescription: number = 270;
|
15
|
|
16
|
constructor(private http: HttpClient ) {}
|
17
|
|
18
|
searchDataproviders (params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties, usedBy: string="search" ):any {
|
19
|
let link = properties.searchAPIURLLAst+"datasources";
|
20
|
|
21
|
let url = link+"?";
|
22
|
if(params!= null && params != '' ) {
|
23
|
url += params;
|
24
|
}
|
25
|
if(refineParams!= null && refineParams != '' ) {
|
26
|
url += refineParams;
|
27
|
}
|
28
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
29
|
|
30
|
|
31
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
32
|
//.map(res => <any> res.json())
|
33
|
//.do(res => console.info(res))
|
34
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource", usedBy)]));
|
35
|
}
|
36
|
//((oaftype exact datasource) and(collectedfromdatasourceid exact "openaire____::47ce9e9f4fad46e732cff06419ecaabb"))
|
37
|
advancedSearchDataproviders (params: string, page: number, size: number, properties: EnvProperties, refineParams:string=null, refineFields:string[] =null, refineQuery:string = null, depositQuery:boolean = false ):any {
|
38
|
let url = properties.searchAPIURLLAst+"resources"+(depositQuery?'':2)+"/?format=json";
|
39
|
|
40
|
if(params!= null && params != '' ) {
|
41
|
url +="&query=(" + params + ")";
|
42
|
|
43
|
}
|
44
|
if(refineParams!= null && refineParams != '' ) {
|
45
|
url += refineParams;
|
46
|
}
|
47
|
if(refineQuery) {
|
48
|
url += "&" + refineQuery;
|
49
|
}
|
50
|
url += "&page="+(page-1)+"&size="+size;
|
51
|
|
52
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
53
|
//.map(res => <any> res.json())
|
54
|
//.do(res => console.info(res))
|
55
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
|
56
|
}
|
57
|
|
58
|
searchCompatibleDataprovidersTable ( properties:EnvProperties):any {
|
59
|
let size: number = 0;
|
60
|
let url: string= properties.searchResourcesAPIURL;
|
61
|
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
|
62
|
url += "&page=0&size=0&format=json";
|
63
|
|
64
|
|
65
|
|
66
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
67
|
//.map(res => <any> res.json())
|
68
|
.pipe(map(res => res['meta'].total));
|
69
|
}
|
70
|
|
71
|
searchCompatibleDataproviders (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
|
72
|
let url: string = properties.searchResourcesAPIURL;
|
73
|
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
|
74
|
if(params!= null && params != '' ) {
|
75
|
url += params;
|
76
|
}
|
77
|
if(refineParams!= null && refineParams != '' ) {
|
78
|
url += refineParams;
|
79
|
}
|
80
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
81
|
|
82
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
83
|
//.map(res => <any> res.json())
|
84
|
//.do(res => console.info(res))
|
85
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
|
86
|
}
|
87
|
|
88
|
searchEntityRegistriesTable (properties:EnvProperties):any {
|
89
|
let size: number = 0;
|
90
|
let url: string= properties.searchResourcesAPIURL;
|
91
|
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
|
92
|
url += "&page=0&size=0&format=json";
|
93
|
|
94
|
|
95
|
|
96
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
97
|
//.map(res => <any> res.json())
|
98
|
.pipe(map(res => res['meta'].total));
|
99
|
}
|
100
|
|
101
|
searchEntityRegistries (params: string,refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties ):any {
|
102
|
let url = properties.searchResourcesAPIURL;
|
103
|
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
|
104
|
if(params!= null && params != '' ) {
|
105
|
url += params;
|
106
|
}
|
107
|
if(refineParams!= null && refineParams != '' ) {
|
108
|
url += refineParams;
|
109
|
}
|
110
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
111
|
|
112
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
113
|
//.map(res => <any> res.json())
|
114
|
//.do(res => console.info(res))
|
115
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
|
116
|
}
|
117
|
|
118
|
searchJournalsTable ( properties:EnvProperties):any {
|
119
|
let size: number = 0;
|
120
|
let url: string= properties.searchResourcesAPIURL;
|
121
|
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
|
122
|
url += "&page=0&size=0&format=json";
|
123
|
|
124
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)//.map(res => <any> res.json())
|
125
|
.pipe(map(res => res['meta'].total));
|
126
|
}
|
127
|
|
128
|
searchJournals (params: string,refineParams:string, page: number, size: number, refineFields:string[] , properties:EnvProperties):any {
|
129
|
let url: string = properties.searchResourcesAPIURL;
|
130
|
//url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
|
131
|
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
|
132
|
|
133
|
if(params!= null && params != '' ) {
|
134
|
url += params;
|
135
|
}
|
136
|
if(refineParams!= null && refineParams != '' ) {
|
137
|
url += refineParams;
|
138
|
}
|
139
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
140
|
|
141
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
142
|
//.map(res => <any> res.json())
|
143
|
//.do(res => console.info(res))
|
144
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]));
|
145
|
}
|
146
|
|
147
|
searchDataprovidersForDeposit (id: string,type:string, page: number, size: number, properties:EnvProperties):any {
|
148
|
let link = properties.searchResourcesAPIURL;
|
149
|
var compatibilities = "";
|
150
|
if(type == "Research Data"){
|
151
|
//compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid = openaire2.0_data)"
|
152
|
compatibilities = " and (datasourcecompatibilityid = openaire2.0_data)";
|
153
|
}else if(type == "Publications"){
|
154
|
//compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)"
|
155
|
compatibilities = " and (datasourcecompatibilityid <> openaire2.0_data)";
|
156
|
}
|
157
|
let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+compatibilities+" ":"")+") and (relorganizationid exact \""+id+"\")";
|
158
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
159
|
|
160
|
|
161
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
162
|
//.map(res => <any> res.json())
|
163
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
164
|
}
|
165
|
|
166
|
searchDataprovidersForDepositSearch(params: string, refineParams:string, page: number, size: number, refineFields:string[], properties:EnvProperties, usedBy: string="search" ):any {
|
167
|
let link = properties.searchResourcesAPIURL;
|
168
|
let url = link+"?query=((deletedbyinference = false) AND (oaftype exact datasource)) "+params;
|
169
|
if(refineParams!= null && refineParams != '' ) {
|
170
|
url += refineParams;
|
171
|
}
|
172
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
173
|
|
174
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
175
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results']), RefineResultsUtils.parse(res['refineResults'],
|
176
|
refineFields, "datasource", usedBy)]));
|
177
|
}
|
178
|
|
179
|
searchDataProvidersBySubjects(keyword:string, type:string, page: number, size: number, properties:EnvProperties):any {
|
180
|
let link = properties.searchResourcesAPIURL;
|
181
|
var compatibilities = "";
|
182
|
if(type == "Research Data"){
|
183
|
compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid = openaire2.0_data)"
|
184
|
}else if(type == "Publications"){
|
185
|
compatibilities = " and (datasourcecompatibilityid <> UNKNOWN) and (datasourcecompatibilityid <> openaire2.0_data)"
|
186
|
}
|
187
|
let url = link+"?query=(((deletedbyinference = false) AND (oaftype exact datasource)) "+((compatibilities && compatibilities.length > 0)?" "+
|
188
|
compatibilities+" ":"")+") "+
|
189
|
" and (datasourcesubject all "+'"'+keyword+'"'+") " ;
|
190
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
191
|
|
192
|
|
193
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
194
|
//.map(res => <any> res.json())
|
195
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
196
|
|
197
|
}
|
198
|
|
199
|
getDataProvidersforEntityRegistry(datasourceId: string, page: number, size: number , properties:EnvProperties):any {
|
200
|
let url = properties.searchResourcesAPIURL;
|
201
|
var basicQuery = "(oaftype exact datasource) "
|
202
|
url += "?query=";
|
203
|
if(datasourceId!= null && datasourceId != '' ) {
|
204
|
url +=" ( "+basicQuery+ " ) " +" and (collectedfromdatasourceid exact \"" + datasourceId + "\" or resulthostingdatasourceid exact \""+ datasourceId + "\")";
|
205
|
}else{
|
206
|
url +=" ( "+basicQuery+ " ) ";
|
207
|
}
|
208
|
|
209
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
210
|
|
211
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
212
|
//.map(res => <any> res.json())
|
213
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
214
|
}
|
215
|
searchDataprovidersForEntity (params: string, page: number, size: number, properties:EnvProperties):any {
|
216
|
let link = properties.searchAPIURLLAst;
|
217
|
let url = link+params+"/datasources?format=json";
|
218
|
|
219
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
220
|
//.map(res => <any> res.json())
|
221
|
.pipe(map(res => [res['meta'].total, this.parseResults(res['results'])]));
|
222
|
}
|
223
|
/*
|
224
|
searchDataprovidersCSV (params: string, refineParams:string, page: number, size: number):any {
|
225
|
|
226
|
let link = OpenaireProperties. getSearchAPIURLLast()+"datasources";
|
227
|
|
228
|
let url = link+"?";
|
229
|
if(params!= null && params != '' ) {
|
230
|
url += params;
|
231
|
}
|
232
|
if(refineParams!= null && refineParams != '' ) {
|
233
|
url += refineParams;
|
234
|
}
|
235
|
url += "&page="+(page-1)+"&size="+size+"&format=json";
|
236
|
|
237
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
238
|
.map(res => <any> res.json())
|
239
|
//.do(res => console.info(res))
|
240
|
|
241
|
.map(res => this.parseResultsCSV(res['results']));
|
242
|
}
|
243
|
*/
|
244
|
/*
|
245
|
searchEntityRegistriesCSV (params: string,refineParams:string, page: number, size: number):any {
|
246
|
let url = properties.searchAPIURLLAst;
|
247
|
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))"
|
248
|
if(params!= null && params != '' ) {
|
249
|
url += params;
|
250
|
}
|
251
|
if(refineParams!= null && refineParams != '' ) {
|
252
|
url += refineParams;
|
253
|
}
|
254
|
url += "&page="+(page - 1)+"&size="+size+"&format=json";
|
255
|
|
256
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
257
|
.map(res => <any> res.json())
|
258
|
//.do(res => console.info(res))
|
259
|
|
260
|
.map(res => this.parseResultsCSV(res['results']));
|
261
|
}
|
262
|
*/
|
263
|
/*
|
264
|
searchCompatibleDataprovidersCSV (params: string,refineParams:string, page: number, size: number):any {
|
265
|
let url = properties.searchAPIURLLAst;
|
266
|
url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"
|
267
|
if(params!= null && params != '' ) {
|
268
|
url += params;
|
269
|
}
|
270
|
if(refineParams!= null && refineParams != '' ) {
|
271
|
url += refineParams;
|
272
|
}
|
273
|
url += "&page="+(page - 1)+"&size="+size+"&format=json";
|
274
|
|
275
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
276
|
.map(res => <any> res.json())
|
277
|
//.do(res => console.info(res))
|
278
|
|
279
|
.map(res => this.parseResultsCSV(res['results']));
|
280
|
}
|
281
|
*/
|
282
|
|
283
|
|
284
|
parseResults(data: any): SearchResult[] {
|
285
|
let results: SearchResult[] = [];
|
286
|
|
287
|
let length = Array.isArray(data) ? data.length : 1;
|
288
|
|
289
|
for(let i=0; i<length; i++) {
|
290
|
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
|
291
|
|
292
|
var result: SearchResult = new SearchResult();
|
293
|
|
294
|
result['title'] = {"name": '', "accessMode": '', "sc39": ''};
|
295
|
|
296
|
result['title'].name = resData.officialname;
|
297
|
result['englishname'] = resData.englishname;
|
298
|
|
299
|
//result['title'].url = OpenaireProperties.getsearchLinkToDataProvider();
|
300
|
//result['title'].url += Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
301
|
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
302
|
|
303
|
result['type'] = this.getDataproviderType(resData);
|
304
|
|
305
|
if(!Array.isArray(resData['description'])) {
|
306
|
result.description = (resData['description']) ? String(resData['description']) : "";
|
307
|
} else {
|
308
|
result.description = (resData['description'][0]) ? String(resData['description'][0]) : "";
|
309
|
}
|
310
|
|
311
|
if (result.description && result.description.length > this.sizeOfDescription) {
|
312
|
result.description = result.description.substring(0, this.sizeOfDescription) + "...";
|
313
|
}
|
314
|
|
315
|
let typeid: string = resData['datasourcetype'].classid;
|
316
|
//console.info(typeid);
|
317
|
if(typeid != "entityregistry" && typeid != "entityregistry::projects" && typeid != "entityregistry::repositories") {
|
318
|
|
319
|
if(resData.hasOwnProperty('accessinfopackage')) {
|
320
|
let OAIPMHURL: string;
|
321
|
if(Array.isArray(resData['accessinfopackage'])) {
|
322
|
OAIPMHURL = resData['accessinfopackage'][0];
|
323
|
} else {
|
324
|
OAIPMHURL = resData['accessinfopackage'];
|
325
|
}
|
326
|
|
327
|
if(OAIPMHURL != '' && OAIPMHURL != 'unknown') {
|
328
|
result['OAIPMHURL'] = OAIPMHURL;
|
329
|
}
|
330
|
}
|
331
|
let compatibility = this.getDataproviderCompatibility(resData);
|
332
|
result['compatibility'] = compatibility.classname;
|
333
|
if(compatibility.classid == "UNKNOWN") {
|
334
|
result['compatibilityUNKNOWN'] = true;
|
335
|
}
|
336
|
} else {
|
337
|
result['compatibility'] = "";
|
338
|
}
|
339
|
|
340
|
result['websiteURL'] = resData.websiteurl;
|
341
|
|
342
|
let res:[string[], {"name":string, "id":string}[]] = this.getDataproviderCountriesOrganizations(resData, true, true);
|
343
|
result['organizations'] = res[1];
|
344
|
result['countries'] = res[0];
|
345
|
result['subjects'] = this.getDataproviderSubjects(resData);
|
346
|
//console.log(result['subjects']);
|
347
|
results.push(result);
|
348
|
}
|
349
|
|
350
|
return results;
|
351
|
}
|
352
|
getDataproviderSubjects(resData: any): string [] {
|
353
|
var subjects:string [] = [];
|
354
|
|
355
|
let length = Array.isArray(resData['subjects']) ? resData['subjects'].length : 1;
|
356
|
for(let i=0; i<length; i++) {
|
357
|
let subject = Array.isArray(resData['subjects']) ? resData['subjects'][i] :resData['subjects'];
|
358
|
if(subject && subject.content) {
|
359
|
subjects.push(subject.content);
|
360
|
}
|
361
|
}
|
362
|
return subjects;
|
363
|
}
|
364
|
getDataproviderType(resData: any): string {
|
365
|
if(resData['datasourcetype'].hasOwnProperty("classname")) {
|
366
|
return resData['datasourcetype'].classname;
|
367
|
} else {
|
368
|
return '';
|
369
|
}
|
370
|
}
|
371
|
|
372
|
getDataproviderCompatibility(resData: any): {"classid": string, "classname": string} {
|
373
|
if(resData.hasOwnProperty('openairecompatibility')) {
|
374
|
return {"classid": resData['openairecompatibility'].classid, "classname": resData['openairecompatibility'].classname};
|
375
|
} else {
|
376
|
return {"classid": "", "classname": ""};
|
377
|
}
|
378
|
}
|
379
|
|
380
|
getDataproviderCountriesOrganizations(resData: any, getCountries: boolean, getOrganizations: boolean): [string[], {"name": string, "id": string}[]] {
|
381
|
let countries: string[] = [];
|
382
|
let organizations: {"name": string, "id": string}[] = [];
|
383
|
|
384
|
if(resData['rels'].hasOwnProperty("rel")) {
|
385
|
let countriesSet: Set<string> = new Set<string>();
|
386
|
|
387
|
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
388
|
|
389
|
for(let i=0; i<relLength; i++) {
|
390
|
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][i] : resData['rels']['rel'];
|
391
|
|
392
|
if(relation.hasOwnProperty("to")) {
|
393
|
if(relation['to'].class == "isProvidedBy" && relation['to'].type == "organization") {
|
394
|
if(getOrganizations) {
|
395
|
let item: {"name":string, "id":string} = {"name": "", "id": ""};
|
396
|
//item['name'] = relation.legalname;
|
397
|
if(relation.legalshortname) {
|
398
|
item['name'] = relation.legalshortname;
|
399
|
} else {
|
400
|
item['name'] = relation.legalname;
|
401
|
}
|
402
|
if(!item['name']) {
|
403
|
item['name'] = "[no title available]";
|
404
|
}
|
405
|
item['id'] = /*OpenaireProperties.getsearchLinkToOrganization()+*/relation['to'].content;
|
406
|
organizations.push(item);
|
407
|
}
|
408
|
|
409
|
if(getCountries) {
|
410
|
if(relation.hasOwnProperty('country') &&
|
411
|
relation.country.hasOwnProperty('classname')) {
|
412
|
if(!countriesSet.has(relation.country.classname)) {
|
413
|
countriesSet.add(relation.country.classname);
|
414
|
countries.push(relation.country.classname);
|
415
|
}
|
416
|
}
|
417
|
}
|
418
|
}
|
419
|
}
|
420
|
}
|
421
|
}
|
422
|
return [countries, organizations];
|
423
|
}
|
424
|
/*
|
425
|
parseResultsCSV(data: any): any {
|
426
|
let results: any = [];
|
427
|
let length = Array.isArray(data) ? data.length : 1;
|
428
|
|
429
|
for(let i=0; i<length; i++) {
|
430
|
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:datasource'] : data['result']['metadata']['oaf:entity']['oaf:datasource'];
|
431
|
|
432
|
var result: any = [];
|
433
|
|
434
|
result.push(this.quote(resData.officialname));
|
435
|
result.push(this.quote(this.getDataproviderType(resData)));
|
436
|
result.push(this.quote(this.getDataproviderCountriesOrganizations(resData, true, false)[0]));
|
437
|
result.push(this.quote(this.getDataproviderCompatibility(resData)));
|
438
|
results.push(result);
|
439
|
}
|
440
|
return results;
|
441
|
}
|
442
|
*/
|
443
|
numOfDataproviders(url: string, properties:EnvProperties):any {
|
444
|
//let url = OpenaireProperties. getSearchAPIURLLast()+params+(params.indexOf("?") == -1 ?"?":"&")+"format=json";
|
445
|
|
446
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
447
|
//.map(res => <any> res.json())
|
448
|
.pipe(map(res => res['total']));
|
449
|
}
|
450
|
|
451
|
numOfEntityDataproviders(id: string, entity: string, properties:EnvProperties):any {
|
452
|
var parameters = "";
|
453
|
if(entity == "organization") {
|
454
|
parameters = "organizations/"+id+"/datasources/count";
|
455
|
}
|
456
|
|
457
|
let url = properties.searchAPIURLLAst+parameters+"?format=json";
|
458
|
return this.numOfDataproviders(url, properties);
|
459
|
}
|
460
|
|
461
|
numOfSearchDataproviders(params: string, properties:EnvProperties, refineQuery:string=null):any {
|
462
|
let url: string = properties.searchAPIURLLAst+"datasources/count?format=json";
|
463
|
if(params != "") {
|
464
|
url += "&q=" + StringUtils.URIEncode(params);
|
465
|
}
|
466
|
if(refineQuery!= null && refineQuery != '' ) {
|
467
|
url += refineQuery;
|
468
|
}
|
469
|
|
470
|
return this.numOfDataproviders(url, properties);
|
471
|
}
|
472
|
numOfSearchDataproviders2(params: string, properties:EnvProperties, refineQuery:string=null):any {
|
473
|
let url: string = properties.searchAPIURLLAst+"resources2/?format=json&size=0&type=datasources";
|
474
|
if(params != "") {
|
475
|
url += "&query=" +params;
|
476
|
}
|
477
|
if(refineQuery!= null && refineQuery != '' ) {
|
478
|
url += refineQuery;
|
479
|
}
|
480
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
481
|
.pipe(map(res => res['meta']['total']));
|
482
|
}
|
483
|
/*
|
484
|
private quote(word: any): string {
|
485
|
return '"'+word+'"';
|
486
|
}
|
487
|
*/
|
488
|
getDataprovidersTableResults (queryType:string, properties:EnvProperties):any {
|
489
|
let size: number = 0;
|
490
|
let url: string= properties.searchAPIURLLAst;
|
491
|
if(queryType == "compatible"){
|
492
|
url += '?query=((oaftype exact datasource) not (datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other) not(datasourcetypeuiid exact "pubsrepository::journal") not(datasourcetypeuiid exact "aggregator::pubsrepository::journals"))';
|
493
|
}else if(queryType=="registries"){
|
494
|
url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))";
|
495
|
}else if(queryType=="journals"){
|
496
|
url += '?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) and (datasourcetypeuiid exact "pubsrepository::journal" or datasourcetypeuiid exact "aggregator::pubsrepository::journals" ))';
|
497
|
|
498
|
}
|
499
|
|
500
|
url += "&page=0&size=0&format=json";
|
501
|
|
502
|
|
503
|
|
504
|
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
505
|
//.map(res => <any> res.json())
|
506
|
.pipe(map(res => res['meta'].total));
|
507
|
}
|
508
|
}
|