Project

General

Profile

1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import {PublicationInfo} from '../utils/entities/publicationInfo';
5
import {OpenaireProperties} from '../utils/properties/openaireProperties';
6

    
7
@Injectable()
8
export class PublicationService {
9

    
10
    constructor(private http: Http) {}
11

    
12
    publicationInfo: PublicationInfo;
13

    
14
    getPublicationInfo (id: string):any {
15
        console.info("getPublicationInfo in service");
16
        let url = OpenaireProperties.getSearchAPIURL() + 'publications/' +id;
17

    
18
        return this.http.get(url)
19
                    .map(res => <any> res.json())
20
                    .map(res => res['result']['metadata']['oaf:entity'])
21
                    .map(res => [res['oaf:result'],
22
                                 res['oaf:result']['title'],
23
                                 res['oaf:result']['rels']['rel'],
24
                                 res['oaf:result']['children'],
25
                                 res['oaf:result']['pid'],
26
                                 res['oaf:result']['journal'],
27
                                 res['oaf:result']['language'],
28
                                 res['oaf:result']['subject'],
29
                                 res['oaf:result']['bestlicense'],
30
                                 res['oaf:result']['collectedfrom'],
31
                                 (res['extraInfo']!= undefined && res['extraInfo']['citations']!= undefined)? res['extraInfo']['citations']['citation']:null,
32
                                 res['oaf:result']['context']
33
                    ])
34
                    .map(res => this.parsePublicationInfo(res));
35
    }
36

    
37
    private handleError (error: Response) {
38
    // in a real world app, we may send the error to some remote logging infrastructure
39
    // instead of just logging it to the console
40
        console.error(error);
41
        return Observable.throw(error  || 'Server error');
42
    }
43

    
44
    parsePublicationInfo (data: any):any {
45
        this.publicationInfo = new PublicationInfo();
46

    
47
        if(data[0] != null) {
48
            this.publicationInfo.date = data[0].dateofacceptance.substring(0,4);
49
            this.publicationInfo.publisher = data[0].publisher;
50
            if(!Array.isArray(data[0].description)) {
51
                this.publicationInfo.description = data[0].description;
52
            } else {
53
                this.publicationInfo.description = data[0].description[0];
54
            }
55
            this.publicationInfo.embargoEndDate = data[0].embargoenddate;
56
        }
57

    
58
        if(data[1] != null) {
59
            this.publicationInfo.title = {"name": "", "url": "", "accessMode": ""};
60

    
61
            if(Array.isArray(data[1])) {
62
                this.publicationInfo.title['name'] = data[1][0].content;
63
            } else {
64
                this.publicationInfo.title['name'] = data[1].content;
65
            }
66
        }
67

    
68
        if(data[2] != null) {
69
            let mydata;
70
            let counter = 0;
71
            let length = data[2].length!=undefined ? data[2].length : 1;
72

    
73
            for(let i=0; i<length; i++) {
74
                mydata = length > 1 ? data[2][i] : data[2];
75
                if(mydata.hasOwnProperty("to")) {
76
                    if(mydata['to'].class == "hasAuthor") {
77
                        if(this.publicationInfo.authors == undefined) {
78
                            this.publicationInfo.authors = new Array<{"name": string, "url": string}>();
79
                        }
80

    
81
                        this.publicationInfo.authors[mydata.ranking-1] = {"name": "", "url": ""};
82
                        this.publicationInfo.authors[mydata.ranking-1]['name'] = mydata.fullname;
83
                        this.publicationInfo.authors[mydata.ranking-1]['url'] = OpenaireProperties.getsearchLinkToPerson() +mydata['to'].content;
84
                    } else if(mydata['to'].class == "isProducedBy") {
85
                        if(this.publicationInfo.fundedByProjects == undefined) {
86
                            this.publicationInfo.fundedByProjects = new Array<
87
                                { "url": string, "acronym": string, "title": string,
88
                                  "funderShortname": string, "funderName": string,
89
                                  "funding": string, "code": string, "inline": boolean
90
                                }>();
91
                        }
92

    
93
                        counter = this.publicationInfo.fundedByProjects.length;
94

    
95
                        this.publicationInfo.fundedByProjects[counter] = {
96
                            "url": "", "acronym": "", "title": "",
97
                            "funderShortname": "", "funderName": "",
98
                            "funding": "", "code": "", "inline": false
99
                        }
100

    
101
                        this.publicationInfo.fundedByProjects[counter]['url'] =
102
                            OpenaireProperties.getsearchLinkToProject() + mydata['to'].content;
103
                        this.publicationInfo.fundedByProjects[counter]['acronym'] = mydata.acronym;
104
                        this.publicationInfo.fundedByProjects[counter]['title'] = mydata.title;
105
                        this.publicationInfo.fundedByProjects[counter]['code'] = mydata.code;
106

    
107
                        if(mydata.hasOwnProperty("funding")) {
108
                            let length1 = Array.isArray(mydata['funding']) ? mydata['funding'].length : 1;
109

    
110
                            for(let j=0; j<length1; j++) {
111
                                let funding;
112
                                let mydata1 = Array.isArray(mydata['funding']) ? mydata['funding'][j] : mydata['funding'];
113

    
114
                                if(mydata1.hasOwnProperty("funder")) {
115
                                    this.publicationInfo.fundedByProjects[counter]['funderShortname'] = mydata1['funder'].shortname;
116
                                    this.publicationInfo.fundedByProjects[counter]['funderName'] = mydata1['funder'].name;
117
                                }
118

    
119
                                if(mydata1.hasOwnProperty("funding_level_2")) {
120
                                    funding = mydata1['funding_level_2'].content;
121
                                } else if(mydata1.hasOwnProperty("funding_level_1")) {
122
                                    funding = mydata1['funding_level_1'].content;
123
                                } else if(mydata1.hasOwnProperty("funding_level_0")) {
124
                                    funding = mydata1['funding_level_0'].content;
125
                                }
126

    
127
                                if(funding != undefined) {
128
                                    funding = funding.split("::");
129

    
130
                                    if(this.publicationInfo.fundedByProjects[counter]['funding'] != "") {
131
                                        this.publicationInfo.fundedByProjects[counter]['funding'] += ", "+funding[1];
132
                                    } else {
133
                                        this.publicationInfo.fundedByProjects[counter]['funding'] = funding[1];
134
                                    }
135
                                    for(let i=2; i<funding.length; i++) {
136
                                        this.publicationInfo.fundedByProjects[counter]['funding'] += " | " + funding[i];
137
                                    }
138
                                }
139
                            }
140
                        }
141
                    } else if(mydata['to'].class == "isRelatedTo") {
142
                        if(this.publicationInfo.relatedResearchResults == undefined) {
143
                            this.publicationInfo.relatedResearchResults = new Array<{
144
                                "name": string, "url": string, "date": string,
145
                                "trust": string, "class": string}>();
146
                        }
147

    
148
                        counter = this.publicationInfo.relatedResearchResults.length;
149
                        this.publicationInfo.relatedResearchResults[counter] = {"name": "", "url": "", "date": "", "trust": "", "class": ""}
150

    
151
                        let url;
152
                        if(mydata['resulttype'].classname == "publication") {
153
                            url = OpenaireProperties.getsearchLinkToPublication() + mydata['to'].content;
154
                            this.publicationInfo.relatedResearchResults[counter]['class'] = "publication";
155
                        } else {
156
                            url = OpenaireProperties.getsearchLinkToDataset() + mydata['to'].content;
157
                            this.publicationInfo.relatedResearchResults[counter]['class'] = "dataset";
158
                        }
159

    
160
                        this.publicationInfo.relatedResearchResults[counter]['url'] = url;
161
                        this.publicationInfo.relatedResearchResults[counter]['name'] = mydata['title'].content;
162
                        this.publicationInfo.relatedResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
163
                        this.publicationInfo.relatedResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%";
164

    
165
                    } else if(mydata['to'].class == "hasAmongTopNSimilarDocuments") {
166
                        if(this.publicationInfo.similarResearchResults == undefined) {
167
                            this.publicationInfo.similarResearchResults = new Array<{
168
                                "name": string, "url": string, "date": string,
169
                                "trust": string, "class": string}>();
170
                        }
171

    
172
                        counter = this.publicationInfo.similarResearchResults.length;
173
                        this.publicationInfo.similarResearchResults[counter] = {"name": "", "url": "", "date": "", "trust": "", "class": ""}
174

    
175
                        let url;
176
                        if(mydata['resulttype'].classname == "publication") {
177
                            url = OpenaireProperties.getsearchLinkToPublication() + mydata['to'].content;
178
                            this.publicationInfo.similarResearchResults[counter]['class'] = "publication";
179
                        } else {
180
                            url = OpenaireProperties.getsearchLinkToDataset() + mydata['to'].content;
181
                            this.publicationInfo.similarResearchResults[counter]['class'] = "dataset";
182
                        }
183

    
184
                        this.publicationInfo.similarResearchResults[counter]['url'] = url;
185
                        this.publicationInfo.similarResearchResults[counter]['name'] = mydata['title'].content;
186
                        this.publicationInfo.similarResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
187
                        this.publicationInfo.similarResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%";
188
                    }
189
                }
190
            }
191

    
192
            if(this.publicationInfo.authors != undefined) {
193
                this.publicationInfo.authors = this.publicationInfo.authors.filter(function (item) {
194
                    return (item != undefined);
195
                });
196
            }
197
        }
198

    
199
        if(data[3] != null) {
200
            if(data[3].hasOwnProperty("instance")) {
201
                this.publicationInfo.downloadFrom = new Map<string, {"url": string[], "accessMode": string[]}>();
202
                this.publicationInfo.publishedIn = new Map<string, {"url": string[], "accessMode": string[]}>();
203

    
204
                this.publicationInfo.types = new Array<string>();
205

    
206
                let length = data[3]['instance'].length!=undefined ? data[3]['instance'].length : 1;
207

    
208
                let types = new Set<string>();
209
                let counter = 0;
210
                let counter1 = 0;
211
                let counter2 = 0;
212
                let mydata;
213
                for(let i=0; i<length; i++) {
214
                    mydata = length > 1 ? data[3]['instance'][i] : data[3]['instance'];
215

    
216
                    if(mydata.hasOwnProperty("instancetype")) {
217
                        if(!types.has(mydata['instancetype'].classname)) {
218
                            this.publicationInfo.types[counter] = mydata['instancetype'].classname;
219
                            types.add(mydata['instancetype'].classname);
220
                            counter++;
221
                        }
222
                    }
223

    
224
                    if(mydata.hasOwnProperty("webresource")) {
225
                        let url;
226
                        if(mydata['webresource'].length == undefined) {
227
                            url = mydata['webresource'].url;
228
                        } else{
229
                            url = mydata['webresource'][0].url;
230
                        }
231

    
232
                        if(mydata.hasOwnProperty("hostedby")) {
233
                            if(mydata['hostedby'].name != "other resources" && mydata['hostedby'].name != "Unknown Repository") {
234
                                if(!this.publicationInfo.downloadFrom.has(mydata['hostedby'].name)) {
235
                                    this.publicationInfo.downloadFrom.set(mydata['hostedby'].name, {"url": null, "accessMode": null});
236
                                }
237

    
238
                                if(this.publicationInfo.downloadFrom.get(mydata['hostedby'].name)['url'] == null) {
239
                                    this.publicationInfo.downloadFrom.get(mydata['hostedby'].name)['url'] = new Array<string>();
240
                                }
241

    
242
                                counter2 = this.publicationInfo.downloadFrom.get(mydata['hostedby'].name)['url'].length;
243
                                this.publicationInfo.downloadFrom.get(mydata['hostedby'].name)['url'][counter2] = url;
244

    
245
                                if(this.publicationInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'] == null) {
246
                                    this.publicationInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'] = new Array<string>();
247
                                }
248

    
249
                                if(mydata.hasOwnProperty("licence")) {
250
                                    this.publicationInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = mydata['licence'].classid;
251
                                } else {
252
                                    this.publicationInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = "";
253
                                }
254
                            } else {
255
                                if(data[0] != null && data[0].hasOwnProperty("source")) {
256
                                    let key: string;
257
                                    if(Array.isArray(data[0].source)) {
258
                                        if(!this.publicationInfo.publishedIn.has(data[0]['source'][counter1])) {
259
                                            key = data[0]['source'][counter1];
260
                                        }
261
                                    } else {
262
                                        if(!this.publicationInfo.publishedIn.has(data[0]['source'])) {
263
                                            key = data[0]['source'];
264
                                        }
265
                                    }
266

    
267
                                    this.publicationInfo.publishedIn.set(key, {"url": null, "accessMode": null});
268

    
269
                                    if(this.publicationInfo.publishedIn.get(key)['url'] == null) {
270
                                        this.publicationInfo.publishedIn.get(key)['url'] = new Array<string>();
271
                                    }
272

    
273
                                    counter2 = this.publicationInfo.publishedIn.get(key)['url'].length;
274
                                    this.publicationInfo.publishedIn.get(key)['url'][counter2] = url;
275

    
276
                                    if(this.publicationInfo.publishedIn.get(key)['accessMode'] == null) {
277
                                        this.publicationInfo.publishedIn.get(key)['accessMode'] = new Array<string>();
278
                                    }
279

    
280
                                    if(mydata.hasOwnProperty("licence")) {
281
                                        this.publicationInfo.publishedIn.get(key)['accessMode'][counter2] = mydata['licence'].classid;
282
                                    } else {
283
                                        this.publicationInfo.publishedIn.get(key)['accessMode'][counter2] = "";
284
                                    }
285
                                    counter1++;
286
                                }
287
                            }
288
                            if(this.publicationInfo.title != undefined) {
289
                                if(this.publicationInfo.title['url'] == "") {
290
                                    this.publicationInfo.title['url'] = url;
291
                                }
292

    
293
                                switch (this.publicationInfo.title['accessMode']) {
294
                                    case undefined:
295
                                        this.publicationInfo.title['accessMode'] = mydata['accessMode'].classid;
296
                                        this.publicationInfo.title['url'] = url;
297
                                        break;
298
                                    case "CLOSED":
299
                                        if(mydata['licence'].classid == "OPEN" ||
300
                                            mydata['licence'].classid == "EMBARGO" ||
301
                                            mydata['licence'].classid == "RESTRICTED") {
302
                                                this.publicationInfo.title['accessMode'] = mydata['licence'].classid;
303
                                                this.publicationInfo.title['url'] = url;
304
                                        }
305
                                        break;
306
                                    case "RESTRICTED":
307
                                        if(mydata['licence'].classid == "OPEN" ||
308
                                            mydata['licence'].classid == "EMBARGO") {
309
                                                this.publicationInfo.title['accessMode'] = mydata['licence'].classid;
310
                                                this.publicationInfo.title['url'] = url;
311
                                        }
312
                                        break;
313
                                    case "EMBARGO":
314
                                        if(mydata['licence'].classid == "OPEN") {
315
                                                this.publicationInfo.title['accessMode'] = mydata['licence'].classid;
316
                                                this.publicationInfo.title['url'] = url;
317
                                        }
318
                                        break;
319
                                }
320
                            }
321
                        }
322
                    }
323
                }
324
            }
325

    
326
            if(data[3].hasOwnProperty("externalreference")) {
327
                let length = Array.isArray(data[3]['externalreference']) ? data[3]['externalreference'].length : 1;
328

    
329
                let mydata;
330
                for(let i=0; i<length; i++) {
331
                    mydata = Array.isArray(data[3]['externalreference']) ? data[3]['externalreference'][i] : data[3]['externalreference'];
332

    
333
                    if(mydata.hasOwnProperty("qualifier")) {
334
                        if(mydata['qualifier'].classid == "accessionNumber") {
335

    
336
                            if(this.publicationInfo.bioentities == undefined) {
337
                                this.publicationInfo.bioentities = new Map<string, Map<string, string>>();
338
                            }
339

    
340
                            if(!this.publicationInfo.bioentities.has(mydata.sitename)) {
341
                                this.publicationInfo.bioentities.set(mydata.sitename, new Map<string, string>());
342
                            }
343
                            this.publicationInfo.bioentities.get(mydata.sitename).set(mydata.refidentifier, mydata.url);
344

    
345
                        } else if(mydata['qualifier'].classid == "software") {
346

    
347
                            if(this.publicationInfo.software == undefined) {
348
                                this.publicationInfo.software = new Array<{"name": string, "url": string}>();
349
                            }
350

    
351
                            this.publicationInfo.software.push({"name": mydata.sitename, "url": mydata.url});
352
                        }
353
                    }
354
                }
355
            }
356
        }
357

    
358
        if(data[4] != null) {
359
            let counter = 0;
360
            this.publicationInfo.identifiers = new Map<string, string[]>();
361

    
362
            if(data[4].hasOwnProperty("classname") && data[4]['classname'] != "") {
363
                if(data[4].classname == "doi" || data[4].classname == "pmc") {
364
                    if(!this.publicationInfo.identifiers.has(data[4].classname)) {
365
                        this.publicationInfo.identifiers.set(data[4].classname, new Array<string>());
366
                    }
367
                    counter = this.publicationInfo.identifiers.get(data[4].classname).length;
368
                    this.publicationInfo.identifiers.get(data[4].classname)[counter] = data[4].content;
369
                }
370
            } else {
371
                for(let i=0; i<data[4].length; i++) {
372
                    if(data[4][i].classname == "doi" || data[4][i].classname == "pmc") {
373
                        if(!this.publicationInfo.identifiers.has(data[4][i].classname)) {
374
                            this.publicationInfo.identifiers.set(data[4][i].classname, new Array<string>());
375
                        }
376
                        counter = this.publicationInfo.identifiers.get(data[4][i].classname).length;
377
                        this.publicationInfo.identifiers.get(data[4][i].classname)[counter] = data[4][i].content;
378
                    }
379
                }
380
            }
381
        }
382

    
383
        if(data[5] != null) {
384
            this.publicationInfo.journal = {"journal": "", "issn": "", "lissn": ""}
385

    
386
            this.publicationInfo.journal['journal'] = data[5].content;
387
            this.publicationInfo.journal['issn'] = data[5].issn;
388
            this.publicationInfo.journal['lissn'] = data[5].lissn;
389
        }
390

    
391
        if(data[6] != null) {
392
            this.publicationInfo.languages = new Array<string>();
393

    
394
            if(data[6].hasOwnProperty("classname")) {
395
                this.publicationInfo.languages[0] = data[6].classname;
396
            } else {
397
                for(let i=0; i<data[6].length; i++) {
398
                    this.publicationInfo.languages[i] = data[6][i].classname;
399
                }
400
            }
401
        }
402

    
403
        if(data[7] != null) {
404
            let mydata;
405
            let length = data[7].length!=undefined ? data[7].length : 1;
406

    
407
            for(let i=0; i<length; i++) {
408
                mydata = length > 1 ? data[7][i] : data[7];
409

    
410
                if(mydata.classid != "") {
411
                    if(mydata.inferred == true) {
412
                        if(this.publicationInfo.classifiedSubjects == undefined) {
413
                            this.publicationInfo.classifiedSubjects = new Map<string, string[]>();
414
                        }
415

    
416
                        if(!this.publicationInfo.classifiedSubjects.has(mydata.classname)) {
417
                            this.publicationInfo.classifiedSubjects.set(mydata.classname, new Array<string>());
418
                        }
419

    
420
                        this.publicationInfo.classifiedSubjects.get(mydata.classname).push(mydata.content);
421
                    } else {
422
                        if(mydata.classid == "keyword") {
423
                            if(this.publicationInfo.subjects == undefined) {
424
                                this.publicationInfo.subjects = new Array<string>();
425
                            }
426

    
427
                            let counter = this.publicationInfo.subjects.length;
428
                            this.publicationInfo.subjects[counter] = mydata.content;
429
                        } else {
430
                            if(this.publicationInfo.otherSubjects == undefined) {
431
                                this.publicationInfo.otherSubjects = new Map<string, string[]>();
432
                            }
433

    
434
                            if(!this.publicationInfo.otherSubjects.has(mydata.classname)) {
435
                                this.publicationInfo.otherSubjects.set(mydata.classname, new Array<string>());
436
                            }
437
                            this.publicationInfo.otherSubjects.get(mydata.classname).push(mydata.content);
438
                        }
439
                    }
440
                }
441
            }
442
        }
443

    
444
        if(data[8] != null) {
445
            this.publicationInfo.bestlicense = data[8].classid;
446
        }
447

    
448
        if(data[9] != null) {
449
            this.publicationInfo.collectedFrom = new Array<{"name": string, "url": string}>();
450

    
451
            let mydata;
452
            let length = data[9].length!=undefined ? data[9].length : 1;
453
            for(let i=0; i<length; i++) {
454
                mydata = length > 1 ? data[9][i] : data[9];
455
                let link = OpenaireProperties.getsearchLinkToDataProvider();
456
                this.publicationInfo.collectedFrom[i] = {"name": "", "url": ""};
457
                this.publicationInfo.collectedFrom[i]['name'] = mydata.name;
458
                this.publicationInfo.collectedFrom[i]['url'] = link+mydata.id;
459
            }
460
        }
461

    
462
        if(this.publicationInfo.publisher != null
463
            && this.publicationInfo.identifiers != null
464
            && this.publicationInfo.identifiers.has('doi')) {
465

    
466
            if( this.publicationInfo.downloadFrom == null) {
467
                this.publicationInfo.downloadFrom = new Map<string, {"url": string[], "accessMode": string[]}>();
468
            }
469

    
470
            let key: string;
471
            if(this.publicationInfo.journal != null) {
472
                key = this.publicationInfo.publisher + "/ "+this.publicationInfo.journal['journal'];
473
            } else {
474
                key = this.publicationInfo.publisher;
475
            }
476
            this.publicationInfo.downloadFrom.set(key, {"url": null, "accessMode": null});
477

    
478
            let url = OpenaireProperties.getDoiURL()+this.publicationInfo.identifiers.get("doi")[0];
479

    
480
            this.publicationInfo.downloadFrom.get(key)['url'] = new Array<string>();
481
            this.publicationInfo.downloadFrom.get(key)['accessMode'] = new Array<string>();
482

    
483
            this.publicationInfo.downloadFrom.get(key)['url'][0] = url;
484
            this.publicationInfo.downloadFrom.get(key)['accessMode'][0] = "";
485

    
486
            if(this.publicationInfo.title != undefined && this.publicationInfo.title['url'] == "") {
487
                this.publicationInfo.title['url'] = url;
488
            }
489
        }
490

    
491
        if(data[10] != null) {
492
            this.publicationInfo.references = new Array<{"name": string, "url": string}>();
493

    
494
            let mydata;
495
            let length = data[10].length!=undefined ? data[10].length : 1;
496
            for(let i=0; i<length; i++) {
497
                mydata = length > 1 ? data[10][i] : data[10];
498

    
499
                let url;
500
                if(mydata.hasOwnProperty("id")) {
501
                    let mydata1;
502
                    let length1 = mydata['id'].length!=undefined ? mydata['id'].length : 1;
503
                    for(let j=0; j<length1; j++) {
504
                        mydata1 = length1 > 1 ? mydata['id'][j] : mydata['id'];
505

    
506
                        if(mydata1.type == "pmid") {
507
                            url = OpenaireProperties.getPmidURL()+mydata1.value;
508
                        }
509
                    }
510
                }
511

    
512
                this.publicationInfo.references[mydata.position-1] = { "name": "", "url": ""};
513
                this.publicationInfo.references[mydata.position-1]['name'] = mydata.rawText;
514
                this.publicationInfo.references[mydata.position-1]['url'] = url;
515
            }
516
        }
517

    
518
        if(data[11] != null) {
519
            this.publicationInfo.contexts = new Array<
520
                { "labelContext": string, "labelCategory": string, "labelConcept": string, inline:boolean}>();
521

    
522
            let position = 0;
523
            let labels = "";
524
            let mydata;
525
            let length = data[11].length!=undefined ? data[11].length : 1;
526
            for(let i=0; i<length; i++) {
527
                mydata = length > 1 ? data[11][i] : data[11];
528

    
529
                if(mydata.hasOwnProperty("type") && mydata['type'] == "community") {
530
                    if(mydata.hasOwnProperty("category")) {
531
                        if(mydata['category'].hasOwnProperty("concept")) {
532
                            let mydata1;
533
                            let length1 = mydata['category']['concept'].length!=undefined ? mydata['category']['concept'].length : 1;
534
                            for(let j=0; j<length1; j++) {
535
                                mydata1 = length1 > 1 ? mydata['category']['concept'][j] : mydata['category']['concept'];
536

    
537
                                this.publicationInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false };
538
                                this.publicationInfo.contexts[position]['labelContext'] = mydata.label;
539
                                this.publicationInfo.contexts[position]['labelCategory'] = mydata['category'].label;;
540
                                this.publicationInfo.contexts[position]['labelConcept'] = mydata1.label;
541

    
542
                                position++;
543
                            }
544
                        } else {
545
                            this.publicationInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
546
                            this.publicationInfo.contexts[position]['labelContext'] = mydata.label;
547
                            this.publicationInfo.contexts[position]['labelCategory'] = mydata['category'].label;;
548
                            this.publicationInfo.contexts[position]['labelConcept'] = null;
549
                         }
550
                    } else {
551
                        this.publicationInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": "", inline: false};
552
                        this.publicationInfo.contexts[position]['labelContext'] = mydata.label;
553
                        this.publicationInfo.contexts[position]['labelCategory'] = null;
554
                        this.publicationInfo.contexts[position]['labelConcept'] = null;
555
                        this.publicationInfo.contexts[position]['new'] = false;
556
                    }
557
                }
558
            }
559
        }
560

    
561
        //this.printPublicationInfo();
562
        return this.publicationInfo;
563

    
564
    }
565

    
566
    printPublicationInfo() {
567
        console.info("DATE: "+this.publicationInfo.date);
568
        console.info("PUBLISHER: "+this.publicationInfo.publisher);
569
        console.info("DESCRIPTION: "+this.publicationInfo.description);
570

    
571
        console.info("TITLE: "+this.publicationInfo.title);
572

    
573
        console.info("AUTHORS: "+this.publicationInfo.authors);
574
        console.info("\nFUNDED BY PROJECTS:");
575
        if(this.publicationInfo.fundedByProjects != undefined) {
576
            this.publicationInfo.fundedByProjects.forEach(function (value, key, map) {
577
                console.info(key + " = " + value);
578
            });
579
        } else {
580
            console.info("undefined");
581
        }
582
        console.info("\n");
583
/*
584
        console.info("\nRELATED RESEARCH DATA:");
585
        if(this.publicationInfo.relatedResearchData != undefined) {
586
            this.publicationInfo.relatedResearchData.forEach(function (value, key, map) {
587
                console.info(key + " = " + value);
588
            });
589
        } else {
590
            console.info("undefined");
591
        }
592
        console.info("\n");
593

    
594
        console.info("\nSIMILAR PUBLICATIONS:");
595
        if(this.publicationInfo.similarPublications != undefined) {
596
            this.publicationInfo.similarPublications.forEach(function (value, key, map) {
597
                console.info(key + " = " + value);
598
            });
599
        } else {
600
            console.info("undefined");
601
        }
602
        console.info("\n");
603
*/
604
        console.info("TYPES: "+this.publicationInfo.types);
605
        console.info("\nDOWNLOAD FROM:");
606
        if(this.publicationInfo.downloadFrom != undefined) {
607
            this.publicationInfo.downloadFrom.forEach(function (value, key, map) {
608
                console.info(key + " = " + value);
609
            });
610
        } else {
611
            console.info("undefined");
612
        }
613
        console.info("\n");
614
        console.info("\nBIOENTITIES:");
615
        if(this.publicationInfo.bioentities != undefined) {
616
            this.publicationInfo.bioentities.forEach(function (value, key, map) {
617
                value.forEach(function (value1, key1, map1) {
618
                    console.info(key + " = " + key1 + " = " + value1);
619
                })
620
            })
621
        } else {
622
            console.info("undefined");
623
        }
624
        console.info("\n");
625

    
626
        console.info("\nIDENTIFIERS:");
627
        if(this.publicationInfo.identifiers != undefined) {
628
            this.publicationInfo.identifiers.forEach(function (value, key, map) {
629
                console.info(key + " = " + value);
630
            });
631
        } else {
632
            console.info("undefined");
633
        }
634
        console.info("\n");
635

    
636
        console.info("JOURNAL: "+this.publicationInfo.journal);
637

    
638

    
639
        console.info("LANGUAGES: "+this.publicationInfo.languages);
640

    
641

    
642
        console.info("SUBJECTS: "+this.publicationInfo.subjects);
643
        console.info("\nCLASSIFIED OBJECTS:");
644
        if(this.publicationInfo.classifiedSubjects != undefined) {
645
            this.publicationInfo.classifiedSubjects.forEach(function (value, key, map) {
646
                console.info(key + " = " + value);
647
            });
648
        } else {
649
            console.info("undefined");
650
        }
651
        console.info("\n");
652

    
653
        console.info("BEST LICENSE: "+this.publicationInfo.bestlicense);
654

    
655
        console.info("\nCOLLECTED FROM:");
656
        if(this.publicationInfo.collectedFrom != undefined) {
657
            this.publicationInfo.collectedFrom.forEach(function (value, key, map) {
658
                console.info(key + " = " + value);
659
            });
660
        } else {
661
            console.info("undefined");
662
        }
663
        console.info("\n");
664

    
665
        console.info("\nREFERENCES:");
666
        if(this.publicationInfo.references != undefined) {
667
            for(let i in this.publicationInfo.references) {
668
                for(let key in this.publicationInfo.references[i]) {
669
                    console.info(key+" : "+this.publicationInfo.references[i][key]);
670
                }
671
            }
672
        } else {
673
            console.info("undefined");
674
        }
675
    }
676

    
677
}
(10-10/21)