1
|
import {Injectable} from '@angular/core';
|
2
|
import {Http, Response} from '@angular/http';
|
3
|
import {Observable} from 'rxjs/Observable';
|
4
|
import {DatasetInfo} from '../../utils/entities/datasetInfo';
|
5
|
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
|
6
|
import 'rxjs/add/observable/of';
|
7
|
import 'rxjs/add/operator/do';
|
8
|
import 'rxjs/add/operator/share';
|
9
|
import { CacheService } from '../../shared/cache.service';
|
10
|
|
11
|
@Injectable()
|
12
|
export class DatasetService {
|
13
|
|
14
|
constructor(private http: Http, public _cache: CacheService) {}
|
15
|
|
16
|
datasetInfo: DatasetInfo;
|
17
|
|
18
|
getDatasetInfo (id: string):any {
|
19
|
console.info("getDatasetInfo in service");
|
20
|
|
21
|
let url = OpenaireProperties. getSearchAPIURLLast()+'datasets/'+id+"?format=json";
|
22
|
let key = url;
|
23
|
if (this._cache.has(key)) {
|
24
|
return Observable.of(this._cache.get(key)).map(res => this.parseDatasetInfo(res));
|
25
|
}
|
26
|
|
27
|
return this.http.get(url)
|
28
|
.map(res => <any> res.json())
|
29
|
.do(res => console.info(res['result']['metadata']['oaf:entity']))
|
30
|
.map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity']['oaf:result']])
|
31
|
.map(res => [res[1],
|
32
|
res[1]['title'],
|
33
|
res[1]['rels']['rel'],
|
34
|
res[1]['children'],
|
35
|
res[1]['pid'],
|
36
|
res[1]['subject'],
|
37
|
res[1]['bestlicense'],
|
38
|
res[1]['collectedfrom'],
|
39
|
res[1]['context'],
|
40
|
res[1]['resulttype'],
|
41
|
res[0]
|
42
|
]).do(res => {
|
43
|
this._cache.set(key, res);
|
44
|
})
|
45
|
.map(res => this.parseDatasetInfo(res));
|
46
|
}
|
47
|
|
48
|
private handleError (error: Response) {
|
49
|
// in a real world app, we may send the error to some remote logging infrastructure
|
50
|
// instead of just logging it to the console
|
51
|
console.log(error);
|
52
|
return Observable.throw(error || 'Server error');
|
53
|
}
|
54
|
|
55
|
parseDatasetInfo (data: any):any {
|
56
|
this.datasetInfo = new DatasetInfo();
|
57
|
|
58
|
if(data[0] != null) {
|
59
|
this.datasetInfo.date = data[0].dateofacceptance.substring(0,4);
|
60
|
this.datasetInfo.dateofacceptance = data[0].dateofacceptance;
|
61
|
this.datasetInfo.publisher = data[0].publisher;
|
62
|
if(!Array.isArray(data[0].description)) {
|
63
|
this.datasetInfo.description = data[0].description;
|
64
|
} else {
|
65
|
this.datasetInfo.description = data[0].description[0];
|
66
|
}
|
67
|
this.datasetInfo.embargoEndDate = data[0].embargoenddate;
|
68
|
}
|
69
|
this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""};
|
70
|
if(data[0]['bestlicense'].hasOwnProperty("classid")) {
|
71
|
this.datasetInfo.title.accessMode = data[0]['bestlicense'].classid;
|
72
|
}
|
73
|
if(data[1] != null) {
|
74
|
if(Array.isArray(data[1])) {
|
75
|
this.datasetInfo.title['name'] = data[1][0].content;
|
76
|
} else {
|
77
|
this.datasetInfo.title['name'] = data[1].content;
|
78
|
}
|
79
|
}
|
80
|
|
81
|
if(data[2] != null) {
|
82
|
let mydata;
|
83
|
let counter = 0;
|
84
|
let length = data[2].length!=undefined ? data[2].length : 1;
|
85
|
|
86
|
for(let i=0; i<length; i++) {
|
87
|
mydata = data[2].length!=undefined ? data[2][i] : data[2];
|
88
|
if(mydata.hasOwnProperty("to")) {
|
89
|
if(mydata['to'].class == "hasAuthor") {
|
90
|
if(this.datasetInfo.authors == undefined) {
|
91
|
this.datasetInfo.authors = new Array<{"name": string, "id": string}>();
|
92
|
}
|
93
|
|
94
|
this.datasetInfo.authors[mydata.ranking-1] = {"name": "", "id": ""};
|
95
|
this.datasetInfo.authors[mydata.ranking-1]['name'] = mydata.fullname;
|
96
|
this.datasetInfo.authors[mydata.ranking-1]['id'] = /*OpenaireProperties.getsearchLinkToPerson()+*/mydata['to'].content;
|
97
|
} else if(mydata['to'].class == "isProducedBy") {
|
98
|
if(this.datasetInfo.fundedByProjects == undefined) {
|
99
|
this.datasetInfo.fundedByProjects = new Array<
|
100
|
{ "id": string, "acronym": string, "title": string,
|
101
|
"funderShortname": string, "funderName": string,
|
102
|
"funding": string, "inline": boolean
|
103
|
}>();
|
104
|
}
|
105
|
|
106
|
counter = this.datasetInfo.fundedByProjects.length;
|
107
|
|
108
|
this.datasetInfo.fundedByProjects[counter] = {
|
109
|
"id": "", "acronym": "", "title": "",
|
110
|
"funderShortname": "", "funderName": "",
|
111
|
"funding": "", "inline": false
|
112
|
}
|
113
|
|
114
|
this.datasetInfo.fundedByProjects[counter]['id'] =
|
115
|
/*OpenaireProperties.getsearchLinkToProject()+*/mydata['to'].content;
|
116
|
this.datasetInfo.fundedByProjects[counter]['acronym'] = mydata.acronym;
|
117
|
this.datasetInfo.fundedByProjects[counter]['title'] = mydata.title;
|
118
|
|
119
|
if(mydata.hasOwnProperty("funding")) {
|
120
|
let length1 = Array.isArray(mydata['funding']) ? mydata['funding'].length : 1;
|
121
|
|
122
|
for(let j=0; j<length1; j++) {
|
123
|
let funding;
|
124
|
let mydata1 = Array.isArray(mydata['funding']) ? mydata['funding'][j] : mydata['funding'];
|
125
|
|
126
|
if(mydata1.hasOwnProperty("funder")) {
|
127
|
this.datasetInfo.fundedByProjects[counter]['funderShortname'] = mydata1['funder'].shortname;
|
128
|
this.datasetInfo.fundedByProjects[counter]['funderName'] = mydata1['funder'].name;
|
129
|
}
|
130
|
|
131
|
if(mydata1.hasOwnProperty("funding_level_2")) {
|
132
|
funding = mydata1['funding_level_2'].content;
|
133
|
} else if(mydata1.hasOwnProperty("funding_level_1")) {
|
134
|
funding = mydata1['funding_level_1'].content;
|
135
|
} else if(mydata1.hasOwnProperty("funding_level_0")) {
|
136
|
funding = mydata1['funding_level_0'].content;
|
137
|
}
|
138
|
|
139
|
if(funding != undefined) {
|
140
|
funding = funding.split("::");
|
141
|
|
142
|
if(this.datasetInfo.fundedByProjects[counter]['funding'] != "") {
|
143
|
this.datasetInfo.fundedByProjects[counter]['funding'] += ", "+funding[1];
|
144
|
} else {
|
145
|
this.datasetInfo.fundedByProjects[counter]['funding'] = funding[1];
|
146
|
}
|
147
|
for(let i=2; i<funding.length; i++) {
|
148
|
this.datasetInfo.fundedByProjects[counter]['funding'] += " | " + funding[i];
|
149
|
}
|
150
|
}
|
151
|
}
|
152
|
}
|
153
|
} else if(mydata['to'].class == "isRelatedTo") {
|
154
|
let provenanceAction: string;
|
155
|
if(mydata.provenanceaction in this.datasetInfo.provenanceVocabulary) {
|
156
|
provenanceAction = this.datasetInfo.provenanceVocabulary[mydata.provenanceaction];
|
157
|
} else {
|
158
|
provenanceAction = "Other"
|
159
|
}
|
160
|
/*
|
161
|
if(this.datasetInfo.relatedResearchResults == undefined) {
|
162
|
this.datasetInfo.relatedResearchResults = new Array<{
|
163
|
"name": string, "id": string, "date": string,
|
164
|
"trust": string, "class": string}>();
|
165
|
}
|
166
|
*/
|
167
|
if(this.datasetInfo.relatedResearchResults == undefined) {
|
168
|
this.datasetInfo.relatedResearchResults =
|
169
|
new Map<string, { "name": string, "id": string, "date": string,
|
170
|
"trust": string, "class": string}[]>();
|
171
|
}
|
172
|
|
173
|
if(!this.datasetInfo.relatedResearchResults.has(provenanceAction)) {
|
174
|
this.datasetInfo.relatedResearchResults.set(provenanceAction,
|
175
|
new Array<{ "name": string, "id": string, "date": string,
|
176
|
"trust": string, "class": string}>());
|
177
|
}
|
178
|
|
179
|
counter = this.datasetInfo.relatedResearchResults.get(provenanceAction).length;
|
180
|
this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter] = {"name": "", "id": "", "date": "", "trust": "", "class": ""}
|
181
|
|
182
|
//let url;
|
183
|
if(mydata['resulttype'].classname == "publication") {
|
184
|
//url = OpenaireProperties.getsearchLinkToPublication()+mydata['to'].content;
|
185
|
this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['class'] = "publication";
|
186
|
} else {
|
187
|
//url = OpenaireProperties.getsearchLinkToDataset()+mydata['to'].content;
|
188
|
this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['class'] = "dataset";
|
189
|
}
|
190
|
|
191
|
this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['id'] = mydata['to'].content;
|
192
|
//this.datasetInfo.relatedResearchResults[counter]['url'] = url;
|
193
|
let titleName = Array.isArray(mydata['title']) ? mydata['title'][0].content : mydata['title'].content;
|
194
|
this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['name'] = titleName;
|
195
|
this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
|
196
|
this.datasetInfo.relatedResearchResults.get(provenanceAction)[counter]['trust'] = Math.round(mydata.trust*100)+"%";
|
197
|
|
198
|
} else if(mydata['to'].class == "hasAmongTopNSimilarDocuments") {
|
199
|
if(this.datasetInfo.similarResearchResults == undefined) {
|
200
|
this.datasetInfo.similarResearchResults = new Array<{
|
201
|
"name": string, "id": string, "date": string,
|
202
|
"trust": string, "class": string}>();
|
203
|
}
|
204
|
|
205
|
counter = this.datasetInfo.similarResearchResults.length;
|
206
|
this.datasetInfo.similarResearchResults[counter] = {"name": "", "id": "", "date": "", "trust": "", "class": ""}
|
207
|
|
208
|
//let url;
|
209
|
if(mydata['resulttype'].classname == "publication") {
|
210
|
//url = OpenaireProperties.getsearchLinkToPublication()+mydata['to'].content;
|
211
|
this.datasetInfo.similarResearchResults[counter]['class'] = "publication";
|
212
|
} else {
|
213
|
//url = OpenaireProperties.getsearchLinkToDataset()+mydata['to'].content;
|
214
|
this.datasetInfo.similarResearchResults[counter]['class'] = "dataset";
|
215
|
}
|
216
|
|
217
|
this.datasetInfo.similarResearchResults[counter]['id'] = mydata['to'].content;
|
218
|
//this.datasetInfo.similarResearchResults[counter]['url'] = url;
|
219
|
let titleName = Array.isArray(mydata['title']) ? mydata['title'][0].content : mydata['title'].content;
|
220
|
this.datasetInfo.similarResearchResults[counter]['name'] = titleName;
|
221
|
this.datasetInfo.similarResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
|
222
|
this.datasetInfo.similarResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%";
|
223
|
|
224
|
|
225
|
}
|
226
|
}
|
227
|
}
|
228
|
|
229
|
if(this.datasetInfo.authors != undefined) {
|
230
|
this.datasetInfo.authors = this.datasetInfo.authors.filter(function (item) {
|
231
|
return (item != undefined);
|
232
|
});
|
233
|
}
|
234
|
}
|
235
|
|
236
|
if(data[3] != null) {
|
237
|
if(data[3].hasOwnProperty("instance")) {
|
238
|
this.datasetInfo.downloadFrom = new Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>();
|
239
|
this.datasetInfo.publishedIn = new Map<string, {"url": string[], "accessMode": string[], "bestAccessMode": string}>()
|
240
|
|
241
|
let length = data[3]['instance'].length!=undefined ? data[3]['instance'].length : 1;
|
242
|
|
243
|
let counter = 0;
|
244
|
let counter1 = 0;
|
245
|
let counter2 = 0;
|
246
|
let mydata;
|
247
|
for(let i=0; i<length; i++) {
|
248
|
mydata = data[3]['instance'].length!=undefined ? data[3]['instance'][i] : data[3]['instance'];
|
249
|
|
250
|
if(this.datasetInfo.type == undefined) {
|
251
|
if(mydata.hasOwnProperty("instancetype")) {
|
252
|
if(mydata['instancetype'].classname != null
|
253
|
&& mydata['instancetype'].classname != ""
|
254
|
&& mydata['instancetype'].classname != "Unknown"){
|
255
|
this.datasetInfo.type = mydata['instancetype'].classname;
|
256
|
}
|
257
|
}
|
258
|
}
|
259
|
|
260
|
if(mydata.hasOwnProperty("webresource")) {
|
261
|
let url;
|
262
|
if(mydata['webresource'].length == undefined) {
|
263
|
url = mydata['webresource'].url;
|
264
|
} else{
|
265
|
url = mydata['webresource'][0].url;
|
266
|
}
|
267
|
|
268
|
if(!this.datasetInfo.downloadFrom.has(url) && mydata.hasOwnProperty("hostedby")) {
|
269
|
if(mydata['hostedby'].name != "other resources" && mydata['hostedby'].name != "Unknown Repository") {
|
270
|
let key: string = mydata['hostedby'].name;
|
271
|
|
272
|
if(!this.datasetInfo.downloadFrom.has(key)) {
|
273
|
this.datasetInfo.downloadFrom.set(key, {"url": null, "accessMode": null, "bestAccessMode": null});
|
274
|
}
|
275
|
|
276
|
if(this.datasetInfo.downloadFrom.get(key)['url'] == null) {
|
277
|
this.datasetInfo.downloadFrom.get(key)['url'] = new Array<string>();
|
278
|
}
|
279
|
|
280
|
counter2 = this.datasetInfo.downloadFrom.get(key)['url'].length;
|
281
|
this.datasetInfo.downloadFrom.get(key)['url'][counter2] = url;
|
282
|
|
283
|
if(this.datasetInfo.downloadFrom.get(key)['accessMode'] == null) {
|
284
|
this.datasetInfo.downloadFrom.get(key)['accessMode'] = new Array<string>();
|
285
|
}
|
286
|
|
287
|
if(mydata.hasOwnProperty("licence")) {
|
288
|
this.datasetInfo.downloadFrom.get(key)['accessMode'].push(mydata['licence'].classid);
|
289
|
//this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = mydata['licence'].classid;
|
290
|
|
291
|
switch (this.datasetInfo.downloadFrom.get(key)['bestAccessMode']) {
|
292
|
case null:
|
293
|
this.datasetInfo.downloadFrom.get(key)['bestAccessMode'] = mydata['licence'].classid;
|
294
|
break;
|
295
|
case "CLOSED":
|
296
|
if(mydata['licence'].classid == "OPEN" ||
|
297
|
mydata['licence'].classid == "EMBARGO" ||
|
298
|
mydata['licence'].classid == "RESTRICTED") {
|
299
|
this.datasetInfo.downloadFrom.get(key)['bestAccessMode'] = mydata['licence'].classid;
|
300
|
}
|
301
|
break;
|
302
|
case "RESTRICTED":
|
303
|
if(mydata['licence'].classid == "OPEN" ||
|
304
|
mydata['licence'].classid == "EMBARGO") {
|
305
|
this.datasetInfo.downloadFrom.get(key)['bestAccessMode'] = mydata['licence'].classid;
|
306
|
}
|
307
|
break;
|
308
|
case "EMBARGO":
|
309
|
if(mydata['licence'].classid == "OPEN") {
|
310
|
this.datasetInfo.downloadFrom.get(key)['bestAccessMode'] = mydata['licence'].classid;
|
311
|
}
|
312
|
break;
|
313
|
}
|
314
|
} else {
|
315
|
//this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = "";
|
316
|
this.datasetInfo.downloadFrom.get(key)['accessMode'].push("");
|
317
|
}
|
318
|
} else {
|
319
|
if(data[0] != null && data[0].hasOwnProperty("source")) {
|
320
|
let key: string;
|
321
|
if(Array.isArray(data[0].source)) {
|
322
|
if(!this.datasetInfo.publishedIn.has(data[0]['source'][counter1])) {
|
323
|
key = data[0]['source'][counter1];
|
324
|
}
|
325
|
} else {
|
326
|
if(!this.datasetInfo.publishedIn.has(data[0]['source'])) {
|
327
|
key = data[0]['source'];
|
328
|
}
|
329
|
}
|
330
|
|
331
|
this.datasetInfo.publishedIn.set(key, {"url": null, "accessMode": null, "bestAccessMode": null});
|
332
|
|
333
|
if(this.datasetInfo.publishedIn.get(key)['url'] == null) {
|
334
|
this.datasetInfo.publishedIn.get(key)['url'] = new Array<string>();
|
335
|
}
|
336
|
|
337
|
counter2 = this.datasetInfo.publishedIn.get(key)['url'].length;
|
338
|
this.datasetInfo.publishedIn.get(key)['url'][counter2] = url;
|
339
|
|
340
|
if(this.datasetInfo.publishedIn.get(key)['accessMode'] == null) {
|
341
|
this.datasetInfo.publishedIn.get(key)['accessMode'] = new Array<string>();
|
342
|
}
|
343
|
|
344
|
if(mydata.hasOwnProperty("licence")) {
|
345
|
//this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = mydata['licence'].classid;
|
346
|
this.datasetInfo.publishedIn.get(key)['accessMode'].push(mydata['licence'].classid);
|
347
|
switch (this.datasetInfo.publishedIn.get(key)['bestAccessMode']) {
|
348
|
case null:
|
349
|
this.datasetInfo.publishedIn.get(key)['bestAccessMode'] = mydata['licence'].classid;
|
350
|
break;
|
351
|
case "CLOSED":
|
352
|
if(mydata['licence'].classid == "OPEN" ||
|
353
|
mydata['licence'].classid == "EMBARGO" ||
|
354
|
mydata['licence'].classid == "RESTRICTED") {
|
355
|
this.datasetInfo.publishedIn.get(key)['bestAccessMode'] = mydata['licence'].classid;
|
356
|
}
|
357
|
break;
|
358
|
case "RESTRICTED":
|
359
|
if(mydata['licence'].classid == "OPEN" ||
|
360
|
mydata['licence'].classid == "EMBARGO") {
|
361
|
this.datasetInfo.publishedIn.get(key)['bestAccessMode'] = mydata['licence'].classid;
|
362
|
}
|
363
|
break;
|
364
|
case "EMBARGO":
|
365
|
if(mydata['licence'].classid == "OPEN") {
|
366
|
this.datasetInfo.publishedIn.get(key)['bestAccessMode'] = mydata['licence'].classid;
|
367
|
}
|
368
|
break;
|
369
|
}
|
370
|
} else {
|
371
|
//this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = "";
|
372
|
this.datasetInfo.publishedIn.get(key)['accessMode'].push("");
|
373
|
}
|
374
|
counter1++;
|
375
|
}
|
376
|
}
|
377
|
if(this.datasetInfo.title != undefined) {
|
378
|
if(this.datasetInfo.title['url'] == undefined) {
|
379
|
this.datasetInfo.title['url'] = url;
|
380
|
}
|
381
|
|
382
|
switch (this.datasetInfo.title['licence']) {
|
383
|
case undefined:
|
384
|
this.datasetInfo.title['licence'] = mydata['licence'].classid;
|
385
|
this.datasetInfo.title['url'] = url;
|
386
|
break;
|
387
|
case "CLOSED":
|
388
|
if(mydata['licence'].classid == "OPEN" ||
|
389
|
mydata['licence'].classid == "EMBARGO" ||
|
390
|
mydata['licence'].classid == "RESTRICTED") {
|
391
|
this.datasetInfo.title['licence'] = mydata['licence'].classid;
|
392
|
this.datasetInfo.title['url'] = url;
|
393
|
}
|
394
|
break;
|
395
|
case "RESTRICTED":
|
396
|
if(mydata['licence'].classid == "OPEN" ||
|
397
|
mydata['licence'].classid == "EMBARGO") {
|
398
|
this.datasetInfo.title['licence'] = mydata['licence'].classid;
|
399
|
this.datasetInfo.title['url'] = url;
|
400
|
}
|
401
|
break;
|
402
|
case "EMBARGO":
|
403
|
if(mydata['licence'].classid == "OPEN") {
|
404
|
this.datasetInfo.title['licence'] = mydata['licence'].classid;
|
405
|
this.datasetInfo.title['url'] = url;
|
406
|
}
|
407
|
break;
|
408
|
}
|
409
|
}
|
410
|
}
|
411
|
}
|
412
|
}
|
413
|
}
|
414
|
}
|
415
|
|
416
|
if(data[4] != null) {
|
417
|
let counter = 0;
|
418
|
this.datasetInfo.identifiers = new Map<string, string[]>();
|
419
|
|
420
|
if(data[4].hasOwnProperty("classname") && data[4]['classname'] != "") {
|
421
|
if(data[4].classname == "doi" || data[4].classname == "pmc") {
|
422
|
if(!this.datasetInfo.identifiers.has(data[4].classname)) {
|
423
|
this.datasetInfo.identifiers.set(data[4].classname, new Array<string>());
|
424
|
}
|
425
|
counter = this.datasetInfo.identifiers.get(data[4].classname).length;
|
426
|
this.datasetInfo.identifiers.get(data[4].classname)[counter] = data[4].content;
|
427
|
}
|
428
|
} else {
|
429
|
for(let i=0; i<data[4].length; i++) {
|
430
|
if(data[4][i].classname == "doi" || data[4][i].classname == "pmc") {
|
431
|
if(!this.datasetInfo.identifiers.has(data[4][i].classname)) {
|
432
|
this.datasetInfo.identifiers.set(data[4][i].classname, new Array<string>());
|
433
|
}
|
434
|
counter = this.datasetInfo.identifiers.get(data[4][i].classname).length;
|
435
|
this.datasetInfo.identifiers.get(data[4][i].classname)[counter] = data[4][i].content;
|
436
|
}
|
437
|
}
|
438
|
}
|
439
|
}
|
440
|
|
441
|
if(data[5] != null) {
|
442
|
let mydata;
|
443
|
let length = data[7].length!=undefined ? data[5].length : 1;
|
444
|
|
445
|
for(let i=0; i<length; i++) {
|
446
|
mydata = data[7].length!=undefined ? data[5][i] : data[5];
|
447
|
|
448
|
if(mydata.classid != "") {
|
449
|
if(mydata.inferred == true) {
|
450
|
if(this.datasetInfo.classifiedSubjects == undefined) {
|
451
|
this.datasetInfo.classifiedSubjects = new Map<string, string[]>();
|
452
|
}
|
453
|
|
454
|
if(!this.datasetInfo.classifiedSubjects.has(mydata.classname)) {
|
455
|
this.datasetInfo.classifiedSubjects.set(mydata.classname, new Array<string>());
|
456
|
}
|
457
|
|
458
|
this.datasetInfo.classifiedSubjects.get(mydata.classname).push(mydata.content);
|
459
|
} else {
|
460
|
if(mydata.classid == "keyword") {
|
461
|
if(this.datasetInfo.subjects == undefined) {
|
462
|
this.datasetInfo.subjects = new Array<string>();
|
463
|
}
|
464
|
|
465
|
this.datasetInfo.subjects.push(mydata.content);
|
466
|
} else {
|
467
|
if(this.datasetInfo.otherSubjects == undefined) {
|
468
|
this.datasetInfo.otherSubjects = new Map<string, string[]>();
|
469
|
}
|
470
|
|
471
|
if(!this.datasetInfo.otherSubjects.has(mydata.classname)) {
|
472
|
this.datasetInfo.otherSubjects.set(mydata.classname, new Array<string>());
|
473
|
}
|
474
|
this.datasetInfo.otherSubjects.get(mydata.classname).push(mydata.content);
|
475
|
}
|
476
|
}
|
477
|
}
|
478
|
}
|
479
|
}
|
480
|
|
481
|
if(data[6] != null) {
|
482
|
this.datasetInfo.bestlicense = data[6].classid;
|
483
|
}
|
484
|
|
485
|
if(data[7] != null) {
|
486
|
this.datasetInfo.collectedFrom = new Array<{"name": string, "id": string}>();
|
487
|
|
488
|
let mydata;
|
489
|
let length = data[7].length!=undefined ? data[7].length : 1;
|
490
|
for(let i=0; i<length; i++) {
|
491
|
mydata = data[7].length!=undefined ? data[7][i] : data[7];
|
492
|
//let link = OpenaireProperties.getsearchLinkToDataProvider();
|
493
|
this.datasetInfo.collectedFrom[i] = {"name": "", "id": ""};
|
494
|
this.datasetInfo.collectedFrom[i]['name'] = mydata.name;
|
495
|
this.datasetInfo.collectedFrom[i]['id'] = /*link+*/mydata.id;
|
496
|
}
|
497
|
}
|
498
|
|
499
|
if(this.datasetInfo.publisher != null
|
500
|
&& this.datasetInfo.identifiers != null
|
501
|
&& this.datasetInfo.identifiers.has("doi")) {
|
502
|
|
503
|
if( this.datasetInfo.downloadFrom == null) {
|
504
|
this.datasetInfo.downloadFrom = new Map<string,{"url": string[], "accessMode": string[], "bestAccessMode": string}>();
|
505
|
}
|
506
|
|
507
|
this.datasetInfo.downloadFrom.set(this.datasetInfo.publisher, {"url": null, "accessMode": null, "bestAccessMode": null});
|
508
|
|
509
|
let url = OpenaireProperties.getDoiURL()+this.datasetInfo.identifiers.get("doi");
|
510
|
this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'] = new Array<string>();
|
511
|
this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'] = new Array<string>();
|
512
|
|
513
|
this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'][0] = url;
|
514
|
this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'][0] = "";
|
515
|
|
516
|
if(this.datasetInfo.title != undefined && this.datasetInfo.title['url'] == "") {
|
517
|
this.datasetInfo.title['url'] = url;
|
518
|
}
|
519
|
}
|
520
|
|
521
|
if(data[8] != null) {
|
522
|
this.datasetInfo.contexts = new Array<
|
523
|
{ "labelContext": string, "labelCategory": string, "labelConcept": string, "inline": boolean}>();
|
524
|
|
525
|
let position = 0;
|
526
|
let labels = "";
|
527
|
let mydata;
|
528
|
let length = data[8].length!=undefined ? data[8].length : 1;
|
529
|
for(let i=0; i<length; i++) {
|
530
|
mydata = data[8].length!=undefined ? data[8][i] : data[8];
|
531
|
|
532
|
if(mydata.hasOwnProperty("type") && mydata['type'] == "community") {
|
533
|
if(mydata.hasOwnProperty("category")) {
|
534
|
if(mydata['category'].hasOwnProperty("concept")) {
|
535
|
let mydata1;
|
536
|
let length1 = mydata['category']['concept'].length!=undefined ? mydata['category']['concept'].length : 1;
|
537
|
for(let j=0; j<length1; j++) {
|
538
|
mydata1 = length1 > 1 ? mydata['category']['concept'][j] : mydata['category']['concept'];
|
539
|
|
540
|
this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
|
541
|
this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
|
542
|
this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;;
|
543
|
this.datasetInfo.contexts[position]['labelConcept'] = mydata1.label;
|
544
|
|
545
|
position++;
|
546
|
}
|
547
|
} else {
|
548
|
this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
|
549
|
this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
|
550
|
this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;;
|
551
|
this.datasetInfo.contexts[position]['labelConcept'] = null;
|
552
|
}
|
553
|
} else {
|
554
|
this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
|
555
|
this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
|
556
|
this.datasetInfo.contexts[position]['labelCategory'] = null;
|
557
|
this.datasetInfo.contexts[position]['labelConcept'] = null;
|
558
|
}
|
559
|
}
|
560
|
}
|
561
|
}
|
562
|
|
563
|
if(data[9] != null && this.datasetInfo.type == undefined) {
|
564
|
if(data[9].hasOwnProperty('classname')) {
|
565
|
this.datasetInfo.type = data[9].classname;
|
566
|
}
|
567
|
}
|
568
|
|
569
|
if(data[10] != null && data[10] == "under curation") {
|
570
|
this.datasetInfo.underCurationMessage = true;
|
571
|
} else {
|
572
|
this.datasetInfo.underCurationMessage = false;
|
573
|
}
|
574
|
|
575
|
//this.printdatasetInfo();
|
576
|
return this.datasetInfo;
|
577
|
|
578
|
}
|
579
|
|
580
|
printDatasetInfo() {
|
581
|
console.info("DATE: "+this.datasetInfo.date);
|
582
|
console.info("PUBLISHER: "+this.datasetInfo.publisher);
|
583
|
console.info("DESCRIPTION: "+this.datasetInfo.description);
|
584
|
|
585
|
console.info("TITLE: "+this.datasetInfo.title);
|
586
|
|
587
|
console.info("AUTHORS: "+this.datasetInfo.authors);
|
588
|
console.info("\nFUNDED BY PROJECTS:");
|
589
|
if(this.datasetInfo.fundedByProjects != undefined) {
|
590
|
this.datasetInfo.fundedByProjects.forEach(function (value, key, map) {
|
591
|
console.info(key + " = " + value);
|
592
|
});
|
593
|
} else {
|
594
|
console.info("undefined");
|
595
|
}
|
596
|
console.info("\n");
|
597
|
/*
|
598
|
console.info("\nRELATED RESEARCH DATA:");
|
599
|
if(this.datasetInfo.relatedResearchData != undefined) {
|
600
|
this.datasetInfo.relatedResearchData.forEach(function (value, key, map) {
|
601
|
console.info(key + " = " + value);
|
602
|
});
|
603
|
} else {
|
604
|
console.info("undefined");
|
605
|
}
|
606
|
console.info("\n");
|
607
|
|
608
|
console.info("\nSIMILAR datasetS:");
|
609
|
if(this.datasetInfo.similarPublications != undefined) {
|
610
|
this.datasetInfo.similarPublications.forEach(function (value, key, map) {
|
611
|
console.info(key + " = " + value);
|
612
|
});
|
613
|
} else {
|
614
|
console.info("undefined");
|
615
|
}
|
616
|
console.info("\n");
|
617
|
*/
|
618
|
console.info("TYPE: "+this.datasetInfo.type);
|
619
|
console.info("\nDOWNLOAD FROM:");
|
620
|
if(this.datasetInfo.downloadFrom != undefined) {
|
621
|
this.datasetInfo.downloadFrom.forEach(function (value, key, map) {
|
622
|
console.info(key + " = " + value);
|
623
|
});
|
624
|
} else {
|
625
|
console.info("undefined");
|
626
|
}
|
627
|
console.info("\n");
|
628
|
|
629
|
console.info("\nIDENTIFIERS:");
|
630
|
if(this.datasetInfo.identifiers != undefined) {
|
631
|
this.datasetInfo.identifiers.forEach(function (value, key, map) {
|
632
|
console.info(key + " = " + value);
|
633
|
});
|
634
|
} else {
|
635
|
console.info("undefined");
|
636
|
}
|
637
|
console.info("\n");
|
638
|
|
639
|
console.info("SUBJECTS: "+this.datasetInfo.subjects);
|
640
|
console.info("\nCLASSIFIED OBJECTS:");
|
641
|
if(this.datasetInfo.classifiedSubjects != undefined) {
|
642
|
this.datasetInfo.classifiedSubjects.forEach(function (value, key, map) {
|
643
|
console.info(key + " = " + value);
|
644
|
});
|
645
|
} else {
|
646
|
console.info("undefined");
|
647
|
}
|
648
|
console.info("\n");
|
649
|
|
650
|
console.info("BEST LICENSE: "+this.datasetInfo.bestlicense);
|
651
|
|
652
|
console.info("\nCOLLECTED FROM:");
|
653
|
if(this.datasetInfo.collectedFrom != undefined) {
|
654
|
this.datasetInfo.collectedFrom.forEach(function (value, key, map) {
|
655
|
console.info(key + " = " + value);
|
656
|
});
|
657
|
} else {
|
658
|
console.info("undefined");
|
659
|
}
|
660
|
console.info("\n");
|
661
|
|
662
|
console.info("\nDOWNLOAD FROM:");
|
663
|
if(this.datasetInfo.downloadFrom != undefined) {
|
664
|
this.datasetInfo.downloadFrom.forEach(function (value, key, map) {
|
665
|
console.info(key + " = " + value);
|
666
|
});
|
667
|
} else {
|
668
|
console.info("undefined");
|
669
|
}
|
670
|
console.info("\n");
|
671
|
}
|
672
|
}
|