Project

General

Profile

« Previous | Next » 

Revision 43487

adding missing files from previous incomplete commit ( r43486)

View differences:

modules/uoa-services-portal/trunk/src/app/services/dataset.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import {DatasetInfo} from '../entities/datasetInfo';
5

  
6
@Injectable()
7
export class DatasetService {
8

  
9
    constructor(private http: Http) {}
10

  
11
    datasetInfo: DatasetInfo;
12

  
13
    getDatasetInfo (id: string):any {
14
        console.info("getDatasetInfo in service");
15

  
16
        //let url = 'http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id;
17
        //let url = 'http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id;
18
        let url = 'http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id;
19

  
20

  
21
        return this.http.get(url)
22
                    .map(res => <any> res.json())
23
                    .do(res => console.info(res['result']['metadata']['oaf:entity']))
24
                    .map(res => res['result']['metadata']['oaf:entity']['oaf:result'])
25
                    .map(res => [res,
26
                                 res['title'],
27
                                 res['rels']['rel'],
28
                                 res['children'],
29
                                 res['pid'],
30
                                 res['subject'],
31
                                 res['bestlicense'],
32
                                 res['collectedfrom'],
33
                                 res['context'],
34
                                 res['resulttype']
35
                    ])
36
                    .map(res => this.parseDatasetInfo(res));
37

  
38
    }
39

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

  
47
    parseDatasetInfo (data: any):any {
48
        this.datasetInfo = new DatasetInfo();
49

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

  
61
        if(data[1] != null) {
62
            this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""};
63
            if(Array.isArray(data[1])) {
64
                this.datasetInfo.title['name'] = data[1][0].content;
65
            } else {
66
                this.datasetInfo.title['name'] = data[1].content;
67
            }
68
        }
69

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

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

  
83
                        this.datasetInfo.authors[mydata.ranking-1] = {"name": "", "url": ""};
84
                        this.datasetInfo.authors[mydata.ranking-1]['name'] = mydata.fullname;
85
                        this.datasetInfo.authors[mydata.ranking-1]['url'] = "https://beta.openaire.eu/search/person?personId="+mydata['to'].content;
86
                    } else if(mydata['to'].class == "isProducedBy") {
87
                        if(this.datasetInfo.fundedByProjects == undefined) {
88
                            this.datasetInfo.fundedByProjects = new Array<
89
                                { "url": string, "acronym": string, "title": string,
90
                                  "funderShortname": string, "funderName": string,
91
                                  "funding": string, "new": boolean
92
                                }>();
93
                        }
94

  
95
                        counter = this.datasetInfo.fundedByProjects.length;
96

  
97
                        this.datasetInfo.fundedByProjects[counter] = {
98
                            "url": "", "acronym": "", "title": "",
99
                            "funderShortname": "", "funderName": "",
100
                            "funding": "", "new": false
101
                        }
102

  
103
                        this.datasetInfo.fundedByProjects[counter]['url'] =
104
                            "http://localhost:3000/project?projectId="+mydata['to'].content;
105
                        this.datasetInfo.fundedByProjects[counter]['acronym'] = mydata.acronym;
106
                        this.datasetInfo.fundedByProjects[counter]['title'] = mydata.title;
107

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

  
111
                            for(let j=0; j<length1; j++) {
112
                                let funding;
113
                                let mydata1 = length1 > 1 ? mydata['funding'][j] : mydata['funding'];
114

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

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

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

  
131
                                    if(this.datasetInfo.fundedByProjects[counter]['funding'] != "") {
132
                                        this.datasetInfo.fundedByProjects[counter]['funding'] += ", "+funding[1];
133
                                    } else {
134
                                        this.datasetInfo.fundedByProjects[counter]['funding'] = funding[1];
135
                                    }
136
                                    for(let i=2; i<funding.length; i++) {
137
                                        this.datasetInfo.fundedByProjects[counter]['funding'] += " | " + funding[i];
138
                                    }
139
                                }
140
                            }
141
                        }
142
                    } else if(mydata['to'].class == "hasAmongTopNSimilarDocuments") {
143
                        /*if(mydata.hasOwnProperty('resulttype') && mydata['resulttype'].classname == "publication") {
144
                            if(this.datasetInfo.similarPublications == undefined) {
145
                                this.datasetInfo.similarPublications = new Array<
146
                                    { "name": string, "url": string, "date": string, "trust": string}>();
147
                            }
148

  
149
                            let url = "http://localhost:3000/publication?articleId="+mydata['to'].content;
150
                            let counter = this.datasetInfo.similarPublications.length;
151

  
152
                            this.datasetInfo.similarPublications[counter] = {"name": "", "url": "", "date": "", "trust": ""};
153
                            this.datasetInfo.similarPublications[counter]['url'] = url;
154
                            this.datasetInfo.similarPublications[counter]['name'] = mydata['title'].content;
155
                            this.datasetInfo.similarPublications[counter]['date'] = mydata.dateofacceptance.substring(0,4);
156
                            this.datasetInfo.similarPublications[counter]['trust'] = Math.round(mydata.trust*100)+"%";
157
                        } else if(mydata.hasOwnProperty('resulttype') && mydata['resulttype'].classname == "dataset") {
158
                            if(this.datasetInfo.similarDatasets == undefined) {
159
                                this.datasetInfo.similarDatasets = new Array<
160
                                    { "name": string, "url": string, "date": string, "trust": string}>();
161
                            }
162

  
163
                            let url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content;
164
                            let counter = this.datasetInfo.similarDatasets.length;
165

  
166
                            this.datasetInfo.similarDatasets[counter] = {"name": "", "url": "", "date": "", "trust": ""};
167
                            this.datasetInfo.similarDatasets[counter]['url'] = url;
168
                            this.datasetInfo.similarDatasets[counter]['name'] = mydata['title'].content;
169
                            this.datasetInfo.similarDatasets[counter]['date'] = mydata.dateofacceptance.substring(0,4);
170
                            this.datasetInfo.similarDatasets[counter]['trust'] = Math.round(mydata.trust*100)+"%";
171
                        }*/
172

  
173
                        if(this.datasetInfo.similarResearchResults == undefined) {
174
                            this.datasetInfo.similarResearchResults = new Array<{
175
                                "name": string, "url": string, "date": string,
176
                                "trust": string, "class": string}>();
177
                        }
178

  
179
                        counter = this.datasetInfo.similarResearchResults.length;
180
                        this.datasetInfo.similarResearchResults[counter] = {"name": "", "url": "", "date": "", "trust": "", "class": ""}
181

  
182
                        let url;
183
                        if(mydata['resulttype'].classname == "publication") {
184
                            url = "http://localhost:3000/publication?articleId="+mydata['to'].content;
185
                            this.datasetInfo.similarResearchResults[counter]['class'] = "publication";
186
                        } else {
187
                            url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content;
188
                            this.datasetInfo.similarResearchResults[counter]['class'] = "dataset";
189
                        }
190

  
191
                        this.datasetInfo.similarResearchResults[counter]['url'] = url;
192
                        this.datasetInfo.similarResearchResults[counter]['name'] = mydata['title'].content;
193
                        this.datasetInfo.similarResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
194
                        this.datasetInfo.similarResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%";
195

  
196

  
197
                    } else if(mydata['to'].class == "isRelatedTo") {
198
                        /*if(mydata.hasOwnProperty('resulttype')) {
199
                            if(mydata['resulttype'].classname == "publication") {
200
                                if(this.datasetInfo.relatedPublications == undefined) {
201
                                    this.datasetInfo.relatedPublications = new Array<{
202
                                        "name": string, "url": string, "date": string, "trust": string}>();
203
                                }
204
                                let url = "http://localhost:3000/publication?articleId="+mydata['to'].content;
205
                                counter = this.datasetInfo.relatedPublications.length;
206

  
207
                                this.datasetInfo.relatedPublications[counter] = {"name": "", "url": "", "date": "", "trust": ""}
208

  
209
                                this.datasetInfo.relatedPublications[counter]['url'] = url;
210
                                this.datasetInfo.relatedPublications[counter]['name'] = mydata['title'].content;
211
                                this.datasetInfo.relatedPublications[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
212
                                this.datasetInfo.relatedPublications[counter]['trust'] = Math.round(mydata.trust*100)+"%";
213
                            } else {
214
                                if(this.datasetInfo.relatedResearchData == undefined) {
215
                                    this.datasetInfo.relatedResearchData = new Array<{
216
                                        "name": string, "url": string, "date": string, "trust": string}>();
217
                                }
218
                                let url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content;
219
                                counter = this.datasetInfo.relatedResearchData.length;
220

  
221
                                this.datasetInfo.relatedResearchData[counter] = {"name": "", "url": "", "date": "", "trust": ""}
222

  
223
                                this.datasetInfo.relatedResearchData[counter]['url'] = url;
224
                                this.datasetInfo.relatedResearchData[counter]['name'] = mydata['title'].content;
225
                                this.datasetInfo.relatedResearchData[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
226
                                this.datasetInfo.relatedResearchData[counter]['trust'] = Math.round(mydata.trust*100)+"%";
227
                            }
228
                        }*/
229

  
230
                        if(this.datasetInfo.relatedResearchResults == undefined) {
231
                            this.datasetInfo.relatedResearchResults = new Array<{
232
                                "name": string, "url": string, "date": string,
233
                                "trust": string, "class": string}>();
234
                        }
235

  
236
                        counter = this.datasetInfo.relatedResearchResults.length;
237
                        this.datasetInfo.relatedResearchResults[counter] = {"name": "", "url": "", "date": "", "trust": "", "class": ""}
238

  
239
                        let url;
240
                        if(mydata['resulttype'].classname == "publication") {
241
                            url = "http://localhost:3000/publication?articleId="+mydata['to'].content;
242
                            this.datasetInfo.relatedResearchResults[counter]['class'] = "publication";
243
                        } else {
244
                            url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content;
245
                            this.datasetInfo.relatedResearchResults[counter]['class'] = "dataset";
246
                        }
247

  
248
                        this.datasetInfo.relatedResearchResults[counter]['url'] = url;
249
                        this.datasetInfo.relatedResearchResults[counter]['name'] = mydata['title'].content;
250
                        this.datasetInfo.relatedResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);;
251
                        this.datasetInfo.relatedResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%";
252

  
253
                    }
254
                }
255
            }
256

  
257
            this.datasetInfo.authors = this.datasetInfo.authors.filter(function (item) {
258
                return (item != undefined);
259
            });
260
        }
261

  
262
        if(data[3] != null) {
263
            if(data[3].hasOwnProperty("instance")) {
264
                this.datasetInfo.downloadFrom = new Map<string, {"url": string[], "accessMode": string[]}>();
265
                this.datasetInfo.publishedIn = new Map<string, {"url": string[], "accessMode": string[]}>()
266

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

  
269
                let counter = 0;
270
                let counter1 = 0;
271
                let counter2 = 0;
272
                let mydata;
273
                for(let i=0; i<length; i++) {
274
                    mydata = length > 1 ? data[3]['instance'][i] : data[3]['instance'];
275

  
276
                    if(mydata.hasOwnProperty("webresource")) {
277
                        let url;
278
                        if(mydata['webresource'].length == undefined) {
279
                            url = mydata['webresource'].url;
280
                        } else{
281
                            url = mydata['webresource'][0].url;
282
                        }
283

  
284
                        if(!this.datasetInfo.downloadFrom.has(url) && mydata.hasOwnProperty("hostedby")) {
285
                            if(mydata['hostedby'].name != "other resources" && mydata['hostedby'].name != "Unknown Repository") {
286
                                if(!this.datasetInfo.downloadFrom.has(mydata['hostedby'].name)) {
287
                                    this.datasetInfo.downloadFrom.set(mydata['hostedby'].name, {"url": null, "accessMode": null});
288
                                }
289

  
290
                                if(this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'] == null) {
291
                                    this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'] = new Array<string>();
292
                                }
293

  
294
                                counter2 = this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'].length;
295
                                this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'][counter2] = url;
296

  
297
                                if(this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'] == null) {
298
                                    this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'] = new Array<string>();
299
                                }
300

  
301
                                if(mydata.hasOwnProperty("licence")) {
302
                                    this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = mydata['licence'].classid;
303
                                } else {
304
                                    this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = "";
305
                                }
306
                            } else {
307
                                if(data[0] != null && data[0].hasOwnProperty("source")) {
308
                                    let key: string;
309
                                    if(Array.isArray(data[0].source)) {
310
                                        if(!this.datasetInfo.publishedIn.has(data[0]['source'][counter1])) {
311
                                            key = data[0]['source'][counter1];
312
                                        }
313
                                    } else {
314
                                        if(!this.datasetInfo.publishedIn.has(data[0]['source'])) {
315
                                            key = data[0]['source'];
316
                                        }
317
                                    }
318

  
319
                                    this.datasetInfo.publishedIn.set(key, {"url": null, "accessMode": null});
320

  
321
                                    if(this.datasetInfo.publishedIn.get(key)['url'] == null) {
322
                                        this.datasetInfo.publishedIn.get(key)['url'] = new Array<string>();
323
                                    }
324

  
325
                                    counter2 = this.datasetInfo.publishedIn.get(key)['url'].length;
326
                                    this.datasetInfo.publishedIn.get(key)['url'][counter2] = url;
327

  
328
                                    if(this.datasetInfo.publishedIn.get(key)['accessMode'] == null) {
329
                                        this.datasetInfo.publishedIn.get(key)['accessMode'] = new Array<string>();
330
                                    }
331

  
332
                                    if(mydata.hasOwnProperty("licence")) {
333
                                        this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = mydata['licence'].classid;
334
                                    } else {
335
                                        this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = "";
336
                                    }
337
                                    counter1++;
338
                                }
339
                            }
340
                            if(this.datasetInfo.title != undefined) {
341
                                if(this.datasetInfo.title['url'] == undefined) {
342
                                    this.datasetInfo.title['url'] = url;
343
                                }
344

  
345
                                switch (this.datasetInfo.title['licence']) {
346
                                    case undefined:
347
                                        this.datasetInfo.title['licence'] = mydata['licence'].classid;
348
                                        this.datasetInfo.title['url'] = url;
349
                                        break;
350
                                    case "CLOSED":
351
                                        if(mydata['licence'].classid == "OPEN" ||
352
                                            mydata['licence'].classid == "EMBARGO" ||
353
                                            mydata['licence'].classid == "RESTRICTED") {
354
                                                this.datasetInfo.title['licence'] = mydata['licence'].classid;
355
                                                this.datasetInfo.title['url'] = url;
356
                                        }
357
                                        break;
358
                                    case "RESTRICTED":
359
                                        if(mydata['licence'].classid == "OPEN" ||
360
                                            mydata['licence'].classid == "EMBARGO") {
361
                                                this.datasetInfo.title['licence'] = mydata['licence'].classid;
362
                                                this.datasetInfo.title['url'] = url;
363
                                        }
364
                                        break;
365
                                    case "EMBARGO":
366
                                        if(mydata['licence'].classid == "OPEN") {
367
                                                this.datasetInfo.title['licence'] = mydata['licence'].classid;
368
                                                this.datasetInfo.title['url'] = url;
369
                                        }
370
                                        break;
371
                                }
372
                            }
373
                        }
374
                    }
375
                }
376
            }
377
        }
378

  
379
        if(data[4] != null) {
380
            let counter = 0;
381
            this.datasetInfo.identifiers = new Map<string, string[]>();
382

  
383
            if(data[4].hasOwnProperty("classname") && data[4]['classname'] != "") {
384
                if(data[4].classname == "doi" || data[4].classname == "pmc") {
385
                    if(!this.datasetInfo.identifiers.has(data[4].classname)) {
386
                        this.datasetInfo.identifiers.set(data[4].classname, new Array<string>());
387
                    }
388
                    counter = this.datasetInfo.identifiers.get(data[4].classname).length;
389
                    this.datasetInfo.identifiers.get(data[4].classname)[counter] = data[4].content;
390
                }
391
            } else {
392
                for(let i=0; i<data[4].length; i++) {
393
                    if(data[4][i].classname == "doi" || data[4][i].classname == "pmc") {
394
                        if(!this.datasetInfo.identifiers.has(data[4][i].classname)) {
395
                            this.datasetInfo.identifiers.set(data[4][i].classname, new Array<string>());
396
                        }
397
                        counter = this.datasetInfo.identifiers.get(data[4][i].classname).length;
398
                        this.datasetInfo.identifiers.get(data[4][i].classname)[counter] = data[4][i].content;
399
                    }
400
                }
401
            }
402
        }
403

  
404
        if(data[5] != null) {
405
            this.datasetInfo.classifiedSubjects = new Map<string, string[]>();
406
            this.datasetInfo.subjects = new Array<string>();
407

  
408
            let mydata;
409
            let length = data[5].length!=undefined ? data[5].length : 1;
410

  
411
            for(let i=0; i<length; i++) {
412
                mydata = length > 1 ? data[5][i] : data[5];
413

  
414
                if(mydata.classid != "") {
415
                    if(mydata.inferred == true) {
416
                        if(!this.datasetInfo.classifiedSubjects.has(mydata.classid)) {
417
                            this.datasetInfo.classifiedSubjects.set(mydata.classid, new Array<string>());
418
                        }
419

  
420
                        let counter = this.datasetInfo.classifiedSubjects.get(mydata.classid).length;
421
                        this.datasetInfo.classifiedSubjects.get(mydata.classid)[counter] = mydata.content;
422
                    } else {
423
                        let counter = this.datasetInfo.subjects.length;
424
                        this.datasetInfo.subjects[counter] = mydata.content;
425
                    }
426
                }
427
            }
428
        }
429

  
430
        if(data[6] != null) {
431
            this.datasetInfo.bestlicense = data[6].classid;
432
        }
433

  
434
        if(data[7] != null) {
435
            this.datasetInfo.collectedFrom = new Array<{"name": string, "url": string}>();
436

  
437
            let mydata;
438
            let length = data[7].length!=undefined ? data[7].length : 1;
439
            for(let i=0; i<length; i++) {
440
                mydata = length > 1 ? data[7][i] : data[7];
441
                let link = "https://beta.openaire.eu/search/dataprovider?datasourceId=";
442
                this.datasetInfo.collectedFrom[i] = {"name": "", "url": ""};
443
                this.datasetInfo.collectedFrom[i]['name'] = mydata.name;
444
                this.datasetInfo.collectedFrom[i]['url'] = link+mydata.id;
445
            }
446
        }
447

  
448
        if(this.datasetInfo.publisher != null
449
            && this.datasetInfo.identifiers != null
450
            && this.datasetInfo.identifiers.has("doi")) {
451

  
452
            if( this.datasetInfo.downloadFrom == null) {
453
                this.datasetInfo.downloadFrom = new Map<string,{"url": string[], "accessMode": string[]}>();
454
            }
455

  
456
            this.datasetInfo.downloadFrom.set(this.datasetInfo.publisher, {"url": null, "accessMode": null});
457

  
458
            let url = "http://dx.doi.org/"+this.datasetInfo.identifiers.get("doi");
459
            this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'] = new Array<string>();
460
            this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'] = new Array<string>();
461

  
462
            this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'][0] = url;
463
            this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'][0] = "";
464

  
465
            if(this.datasetInfo.title != undefined && this.datasetInfo.title['url'] == "") {
466
                this.datasetInfo.title['url'] = url;
467
            }
468
        }
469

  
470
        if(data[8] != null) {
471
            this.datasetInfo.contexts = new Array<
472
                { "labelContext": string, "labelCategory": string, "labelConcept": string}>();
473

  
474
            let position = 0;
475
            let labels = "";
476
            let mydata;
477
            let length = data[8].length!=undefined ? data[8].length : 1;
478
            for(let i=0; i<length; i++) {
479
                mydata = length > 1 ? data[8][i] : data[8];
480

  
481
                if(mydata.hasOwnProperty("type") && mydata['type'] == "community") {
482
                    if(mydata.hasOwnProperty("category")) {
483
                        if(mydata['category'].hasOwnProperty("concept")) {
484
                            let mydata1;
485
                            let length1 = mydata['category']['concept'].length!=undefined ? mydata['category']['concept'].length : 1;
486
                            for(let j=0; j<length1; j++) {
487
                                mydata1 = length1 > 1 ? mydata['category']['concept'][j] : mydata['category']['concept'];
488

  
489
                                this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""};
490
                                this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
491
                                this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;;
492
                                this.datasetInfo.contexts[position]['labelConcept'] = mydata1.label;
493

  
494
                                position++;
495
                            }
496
                        } else {
497
                            this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""};
498
                            this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
499
                            this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;;
500
                            this.datasetInfo.contexts[position]['labelConcept'] = null;
501
                        }
502
                    } else {
503
                        this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""};
504
                        this.datasetInfo.contexts[position]['labelContext'] = mydata.label;
505
                        this.datasetInfo.contexts[position]['labelCategory'] = null;
506
                        this.datasetInfo.contexts[position]['labelConcept'] = null;
507
                    }
508
                }
509
            }
510
        }
511

  
512
        if(data[9] != null) {
513
            if(data[9].hasOwnProperty('classname')) {
514
                this.datasetInfo.type = data[9].classname;
515
            }
516
        }
517

  
518

  
519
        //this.printdatasetInfo();
520
        return this.datasetInfo;
521

  
522
    }
523

  
524
    printDatasetInfo() {
525
        console.info("DATE: "+this.datasetInfo.date);
526
        console.info("PUBLISHER: "+this.datasetInfo.publisher);
527
        console.info("DESCRIPTION: "+this.datasetInfo.description);
528

  
529
        console.info("TITLE: "+this.datasetInfo.title);
530

  
531
        console.info("AUTHORS: "+this.datasetInfo.authors);
532
        console.info("\nFUNDED BY PROJECTS:");
533
        if(this.datasetInfo.fundedByProjects != undefined) {
534
            this.datasetInfo.fundedByProjects.forEach(function (value, key, map) {
535
                console.info(key + " = " + value);
536
            });
537
        } else {
538
            console.info("undefined");
539
        }
540
        console.info("\n");
541
/*
542
        console.info("\nRELATED RESEARCH DATA:");
543
        if(this.datasetInfo.relatedResearchData != undefined) {
544
            this.datasetInfo.relatedResearchData.forEach(function (value, key, map) {
545
                console.info(key + " = " + value);
546
            });
547
        } else {
548
            console.info("undefined");
549
        }
550
        console.info("\n");
551

  
552
        console.info("\nSIMILAR datasetS:");
553
        if(this.datasetInfo.similarPublications != undefined) {
554
            this.datasetInfo.similarPublications.forEach(function (value, key, map) {
555
                console.info(key + " = " + value);
556
            });
557
        } else {
558
            console.info("undefined");
559
        }
560
        console.info("\n");
561
*/
562
        console.info("TYPE: "+this.datasetInfo.type);
563
        console.info("\nDOWNLOAD FROM:");
564
        if(this.datasetInfo.downloadFrom != undefined) {
565
            this.datasetInfo.downloadFrom.forEach(function (value, key, map) {
566
                console.info(key + " = " + value);
567
            });
568
        } else {
569
            console.info("undefined");
570
        }
571
        console.info("\n");
572

  
573
        console.info("\nIDENTIFIERS:");
574
        if(this.datasetInfo.identifiers != undefined) {
575
            this.datasetInfo.identifiers.forEach(function (value, key, map) {
576
                console.info(key + " = " + value);
577
            });
578
        } else {
579
            console.info("undefined");
580
        }
581
        console.info("\n");
582

  
583
        console.info("SUBJECTS: "+this.datasetInfo.subjects);
584
        console.info("\nCLASSIFIED OBJECTS:");
585
        if(this.datasetInfo.classifiedSubjects != undefined) {
586
            this.datasetInfo.classifiedSubjects.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("BEST LICENSE: "+this.datasetInfo.bestlicense);
595

  
596
        console.info("\nCOLLECTED FROM:");
597
        if(this.datasetInfo.collectedFrom != undefined) {
598
            this.datasetInfo.collectedFrom.forEach(function (value, key, map) {
599
                console.info(key + " = " + value);
600
            });
601
        } else {
602
            console.info("undefined");
603
        }
604
        console.info("\n");
605

  
606
        console.info("\nDOWNLOAD FROM:");
607
        if(this.datasetInfo.downloadFrom != undefined) {
608
            this.datasetInfo.downloadFrom.forEach(function (value, key, map) {
609
                console.info(key + " = " + value);
610
            });
611
        } else {
612
            console.info("undefined");
613
        }
614
        console.info("\n");
615
    }
616
}
modules/uoa-services-portal/trunk/src/app/services/person.service.ts
1
import {Injectable} from '@angular/core';
2
import {Http, Response} from '@angular/http';
3
import {Observable}     from 'rxjs/Observable';
4
import {PersonInfo} from '../entities/personInfo';
5

  
6
@Injectable()
7
export class PersonService {
8

  
9
    constructor(private http: Http) {}
10

  
11
    personInfo: PersonInfo;
12

  
13
    getPersonInfo (id: string):any {
14
        console.info("getPersonInfo in service");
15

  
16
        //let url = 'http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/projects/'+id;
17
        //let url = 'http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/projects/'+id;
18
        let url = 'http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/people/'+id;
19

  
20
        return this.http.get(url)
21
                    .map(res => <any> res.json())
22
                    .map(res => res['result']['metadata']['oaf:entity']['oaf:person'])
23
                    .map(res => this.parsePersonInfo(res));
24

  
25
    }
26

  
27
    private handleError (error: Response) {
28
    // in a real world app, we may send the error to some remote logging infrastructure
29
    // instead of just logging it to the console
30
        console.error(error);
31
        return Observable.throw(error  || 'Server error');
32
    }
33

  
34
    parsePersonInfo (data: any):any {
35
        console.info("parsePersonInfo");
36
        this.personInfo = new PersonInfo();
37

  
38
        if(data != null) {
39
            if(data.hasOwnProperty('firstname')) {
40
                this.personInfo.firstname = data.firstname;
41
            }
42
            if(data.hasOwnProperty('secondnames')) {
43
                this.personInfo.secondnames = data.secondnames;
44
            }
45
            if(data.hasOwnProperty('fullname')) {
46
                this.personInfo.fullname = data.fullname;
47
            }
48
        }
49

  
50
        return this.personInfo;
51

  
52
    }
53

  
54
}
modules/uoa-services-portal/trunk/src/app/entities/datasetInfo.ts
1
export class DatasetInfo {
2
    title: { "name": string, "url": string, "accessMode": string};
3
    authors: { "name": string, "url": string}[];
4
    date: string;
5
    embargoEndDate: string;
6
    type: string;
7
    downloadFrom: Map<string, {"url": string[], "accessMode": string[]}>;   //key is name
8
    publishedIn: Map<string, {"url": string[], "accessMode": string[]}>;    //key is name
9
    identifiers: Map<string, string[]>;
10
    publisher: string;
11
    subjects: string[];
12
    classifiedSubjects: Map<string, string[]>;
13
    description: string;
14
    bestlicense: string;
15
    collectedFrom: { "name": string, "url": string}[];
16
    fundedByProjects: { "url": string, "acronym": string, "title": string,
17
                        "funderShortname": string, "funderName": string,
18
                        "funding": string, "new": boolean}[];
19
    //relatedPublications: { "name": string, "url": string, "date": string, "trust": string}[];
20
    //relatedResearchData: { "name": string, "url": string, "date": string, "trust": string}[];
21
    //similarPublications: { "name": string, "url": string, "date": string, "trust": string}[];
22
    //similarDatasets: { "name": string, "url": string, "date": string, "trust": string}[];
23
    relatedResearchResults: { "name": string, "url": string, "date": string, "trust": string, "class": string}[];
24
    similarResearchResults: {"name": string, "url": string, "date": string, "trust": string, "class": string}[];
25
    contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string}[];
26
}
modules/uoa-services-portal/trunk/src/app/entities/personInfo.ts
1
export class PersonInfo {
2
    fullname: string;
3
    firstname: string;
4
    secondnames: string;
5
    country: string;
6

  
7
    publications: any;
8
    researchData: any;
9
}
modules/uoa-services-portal/trunk/src/app/landingPages/tabPaging.component.ts
1
import {Component, Input, Output, EventEmitter} from '@angular/core';
2
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
3

  
4

  
5
@Component({
6
    selector: 'tabPaging',
7
    template: `
8
        <div class="panel panel-default" *ngIf="!showAll && length > 10">
9
            <div class="panel-heading">
10
                <a (click)="changeShowAll.emit({value: true});">
11
                    <div class="text-right">view all {{length}}</div>
12
                </a>
13
            </div>
14
        </div>
15
    `
16
    ,
17
        directives: [
18
          ...ROUTER_DIRECTIVES
19
        ]
20
    })
21

  
22
export class TabPagingComponent {
23
    @Input() showAll: boolean;
24
    @Input() length: number;
25
    @Output() changeShowAll: EventEmitter<any> = new EventEmitter();
26

  
27
    constructor (private _router: Router) {
28
        console.info('publication:paging constructor');
29
    }
30

  
31
    ngOnInit() {
32
    }
33
}
modules/uoa-services-portal/trunk/src/app/landingPages/tabTable.component.ts
1
import {Component, Input} from '@angular/core';
2
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
3

  
4

  
5
@Component({
6
    selector: 'tabTable',
7
    template: `
8
        <table class="table table-striped">
9
            <thead>
10
                <tr>
11
                    <th>Title</th>
12
                    <th>Trust</th>
13
                </tr>
14
            </thead>
15
            <tbody>
16
                <tr *ngFor="let item of info" class="{{item['class']}}">
17
                    <td *ngIf="item != undefined">
18
                        <span *ngIf="item['class'] == 'dataset'" class="glyphicon glyphicon-star" aria-hidden="true">
19

  
20
                        </span>
21
                        <a *ngIf="item['url'] != '' && item['name'] != ''" class="custom-external" href="{{item['url']}}" target="_blank">
22
                            {{item['name']}}
23
                        </a>
24
                        <p *ngIf="item['url'] == '' && item['name'] != ''">{{item['name']}}</p>
25
                        <span *ngIf="item['date'] != ''">
26
                            ({{item['date']}})
27
                        </span>
28
                    </td>
29
                    <td>
30
                        <div *ngIf="item['trust'] != ''" class="progress">
31
                            <div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="29" aria-valuemin="0" aria-valuemax="100" [style.width] = "item['trust']">
32
                                {{item['trust']}}
33
                            </div>
34
                        </div>
35
                        <div *ngIf="item['trust'] == ''">
36
                            <p>no trust found</p>
37
                        </div>
38
                    </td>
39
                </tr>
40
            </tbody>
41
        </table>
42
    `
43
    ,
44
        directives: [
45
          ...ROUTER_DIRECTIVES
46
        ]
47
    })
48

  
49
export class TabTableComponent {
50
    @Input() info: { "name": string, "url": string, "date": string, "trust": string}[];//Map<string, string[]>;
51

  
52
    constructor (private _router: Router) {
53
        console.info('tabTable constructor');
54
    }
55

  
56
    ngOnInit() {
57
    }
58
}
modules/uoa-services-portal/trunk/src/app/landingPages/dataset/dataset.component.ts
1
import {Component, ViewChild} from '@angular/core';
2
import {JSONP_PROVIDERS}  from '@angular/http';
3
import {Observable}       from 'rxjs/Observable';
4
import {DatasetService} from '../../services/dataset.service';
5
import {DatasetInfo} from '../../entities/datasetInfo';
6
import { RouteParams} from '@angular/router-deprecated';
7
import { InlineClaimContextComponent} from '../../claimPages/inlineClaimContext/inlineClaimContext.component';
8
import { InlineClaimProjectComponent} from '../../claimPages/inlineClaimProject/inlineClaimProject.component';
9

  
10
import {TabPagingComponent} from '../tabPaging.component.ts';
11
import {TabTableComponent} from '../tabTable.component.ts';
12
import {ShowTitleComponent} from '../showTitle.component.ts';
13
import {ShowAuthorsComponent} from '../showAuthors.component.ts';
14
import {ShowIdentifiersComponent} from '../showIdentifiers.component.ts';
15
import {ShowSubjectsComponent} from '../showSubjects.component.ts';
16

  
17
@Component({
18
    selector: 'dataset',
19
    template: `
20
        <div class="container dataset">
21
            <div class="container-header" >
22
                <div *ngIf="datasetInfo != null" >
23
                    <showTitle [title]="datasetInfo.title"></showTitle>
24
                </div>
25
                <div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
26
                <div *ngIf="errorMessage.length > 0" class="alert alert-danger" role="alert">{{errorMessage}}</div>
27
            </div>
28

  
29
            <div class="row row-offcanvas row-offcanvas-right" >
30

  
31
                <div class="col-xs-6 col-sm-9 sidebar-offcanvas" *ngIf="datasetInfo != null">
32
                    <div>
33
                        <showAuthors [authors]="datasetInfo.authors"></showAuthors>
34
                        <span *ngIf="datasetInfo.date != ''">({{datasetInfo.date}})</span>
35
                    </div>
36

  
37
                    <dl class="dl-horizontal">
38
                        <dt *ngIf="datasetInfo.publisher != undefined && datasetInfo.publisher != ''">Publisher: </dt>
39
                        <dd *ngIf="datasetInfo.publisher != undefined && datasetInfo.publisher != ''">{{datasetInfo.publisher}}</dd>
40
                        <dt *ngIf="datasetInfo.type != undefined"> Type: </dt>
41
                        <dd *ngIf="datasetInfo.type != undefined">{{datasetInfo.type}}</dd>
42
                        <dt *ngIf="datasetInfo.embargoEndDate != undefined && datasetInfo.embargoEndDate != ''">Embargo end date: </dt>
43
                        <dd *ngIf="datasetInfo.embargoEndDate != undefined && datasetInfo.embargoEndDate != ''">{{datasetInfo.embargoEndDate}}</dd>
44

  
45
                        <showIdentifiers [identifiers]="datasetInfo.identifiers"></showIdentifiers>
46
                        <showSubjects [subjects]="datasetInfo.subjects" [classifiedSubjects]="datasetInfo.classifiedSubjects"></showSubjects>
47
                    </dl>
48

  
49
                    <blockquote *ngIf="datasetInfo.description != ''">
50
                        <div class="text-justify" [innerHTML]="datasetInfo.description"></div>
51
                    </blockquote>
52

  
53
                    <ul class="nav nav-tabs">
54
                        <li class="active">
55
                            <!--a data-toggle="tab" href="#relatedPublicationsTab">
56
                                Related Publications
57
                                <span *ngIf="datasetInfo.isRelatedTo == undefined" class="badge">0</span>
58
                                <span *ngIf="datasetInfo.isRelatedTo != undefined" class="badge">
59
                                    {{datasetInfo.relatedPublications.length}}
60
                                </span>
61
                            </a>
62
                        </li>
63

  
64
                        <li role="presentation">
65
                             <a data-toggle="tab" href="#dataTab">
66
                                 Related Research Results
67
                                 <span *ngIf="datasetInfo.relatedResearchData == undefined" class="badge">0</span>
68
                                 <span *ngIf="datasetInfo.relatedResearchData != undefined" class="badge">
69
                                     {{datasetInfo.relatedResearchData.length}}
70
                                 </span>
71
                             </a>
72
                         </li-->
73

  
74
                             <a data-toggle="tab" href="#relatedTab">
75
                                 Related Research Results
76
                                 <span *ngIf="datasetInfo.relatedResearchResults == undefined" class="badge">0</span>
77
                                 <span *ngIf="datasetInfo.relatedResearchResults != undefined" class="badge">
78
                                     {{datasetInfo.relatedResearchResults.length}}
79
                                 </span>
80
                             </a>
81
                         </li>
82

  
83
                        <li role="presentation">
84
                            <a data-toggle="tab" href="#similarTab">
85
                                Similar Research Results
86
                                <span *ngIf="datasetInfo.similarResearchResults == undefined" class="badge">0</span>
87
                                <span *ngIf="datasetInfo.similarResearchResults != undefined" class="badge">
88
                                    {{datasetInfo.similarResearchResults.length}}
89
                                </span>
90
                            </a>
91
                        </li>
92

  
93
                    </ul>
94

  
95
                    <div class="tab-content">
96
                        <!--div id="relatedPublicationsTab" class="tab-pane fade in active panel-body">
97
                            <div *ngIf="datasetInfo.isRelatedTo == undefined" class = "alert alert-info " >
98
                                 There are no related publications
99
                             </div>
100
                             <div *ngIf="datasetInfo.isRelatedTo != undefined">
101
                                <p>
102
                                    The results below are discovered through our pilot algorithms.
103
                                    <a href="mailto:">Let us know how we are doing!</a>
104
                                </p>
105
                                <tabTable [info]="datasetInfo.isRelatedTo"></tabTable>
106

  
107
                            </div>
108
                        </div-->
109

  
110
                        <div id="relatedTab" class="tab-pane fade in active panel-body">
111
                            <div *ngIf="datasetInfo.relatedResearchResults == undefined" class = "alert alert-info " >
112
                                There are no related research results
113
                            </div>
114
                            <div *ngIf="datasetInfo.relatedResearchResults != undefined">
115
                                <p>
116
                                    The results below are discovered through our pilot algorithms.
117
                                    <a href="mailto:">Let us know how we are doing!</a>
118
                                </p>
119
                                <tabTable [info]="datasetInfo.relatedResearchResults"></tabTable>
120

  
121
                            </div>
122
                        </div>
123

  
124

  
125
                        <div id="similarTab" class="tab-pane fade panel-body">
126
                            <div  *ngIf="datasetInfo.similarResearchResults == undefined"  class = "alert alert-info " >
127
                                There are no similar research results
128
                            </div>
129
                            <div *ngIf="datasetInfo.similarResearchResults != undefined">
130
                                <p>
131
                                    The results below are discovered through our pilot algorithms.
132
                                    <a href="mailto:">Let us know how we are doing!</a>
133
                                </p>
134

  
135
                                <tabTable [info]="datasetInfo.similarResearchResults"></tabTable>
136

  
137
                            </div>
138
                        </div>
139
                    </div>
140
                </div>
141
                <div class="col-xs-12 col-sm-3" *ngIf="datasetInfo != null">
142
                    <ul class="list-group mainFunctionsBlock">
143
                        <li class="list-group-item">
144
                            <dl class="functionsSection">
145
                                <dt  >Share - Bookmark</dt>
146
                                <dd>
147
                                </dd>
148
                            </dl>
149
                        </li>
150
                        <li class="list-group-item" *ngIf="datasetInfo.collectedFrom != undefined">
151
                            <dl class="functionsSection">
152
                                <dt>Collected from</dt>
153
                                <dd  *ngFor="let item of datasetInfo.collectedFrom">
154
                                    <a href="{{item['url']}}">
155
                                        {{item['name']}}
156
                                    </a>
157
                                </dd>
158
                            </dl>
159
                        </li>
160
                        <li class="list-group-item" *ngIf="datasetInfo.downloadFrom != undefined && datasetInfo.downloadFrom.size > 0">
161
                            <dl class="functionsSection">
162
                                <dt class="title">Download from</dt>
163
                                <dd class="line" *ngFor="let key of datasetInfo.downloadFrom.keys()">
164
                                    <div *ngIf="datasetInfo.downloadFrom.get(key)['url'].length > 1">
165
                                        {{key}}
166
                                        <span *ngFor="let url of datasetInfo.downloadFrom.get(key)['url']; let i=index;">
167
                                            <a href="{{url}}">
168
                                                [{{i+1}}]
169
                                            </a>
170
                                        </span>
171
                                    </div>
172
                                    <a *ngIf="datasetInfo.downloadFrom.get(key)['url'].length == 1" href="{{datasetInfo.downloadFrom.get(key)['url']}}">
173
                                        {{key}}
174
                                    </a>
175
                                </dd>
176
                            </dl>
177
                        </li>
178

  
179

  
180
                        <li class="list-group-item">
181
                            <dl class="functionsSection" *ngIf="datasetInfo.fundedByProjects != undefined">
182
                                <dt class="title">Funded By</dt>
183
                                <dd
184
                                    title="{{item['title']}}
185
                                    |   Project Code: {{item['acronym']}}
186
                                    |   Funder: {{item['funderName']}} ({{item['funderShortname']}})
187
                                    |   Funding: {{item['funding']}}"
188
                                    class="line" *ngFor="let item of datasetInfo.fundedByProjects">
189
                                        <a *ngIf="!item['new']" href="{{item['url']}}">
190
                                            {{item['funderShortname']?item['funderShortname']:item['funderName']}}
191
                                            | {{ item['acronym']?item['acronym']:item['title']}}
192
                                        </a>
193

  
194
                                        <a *ngIf="item['new']" href="{{item['url']}}">
195
                                            <mark>
196
                                                {{item['funderShortname']?item['funderShortname']:item['funderName']}}
197
                                                | {{ item['acronym']?item['acronym']:item['title']}}
198
                                            </mark>
199
                                        </a>
200
                                </dd>
201
                            </dl>
202
                            <!--dl class="functionsSection" *ngIf="datasetInfo.fundedByProjects == undefined">
203
                                <dt class="title">Funded By</dt>
204
                            </dl-->
205
                            <button (click)="toggleClaimProject()"  class = "btn btn-default   btn-xs" >Add more Projects</button>
206
                            <inline-claim-project *ngIf="result "  inline="true" inlineType ="dataset" [inlineEntity]="result"  (projectAdded)="projectAdded($event)" ></inline-claim-project>
207
                        </li>
208
                        <!--li class="list-group-item">
209
                            <dl class="functionsSection" *ngIf="datasetInfo.contexts != undefined">
210
                                <dt class="title">Related to </dt>
211
                                <dd class="line" *ngFor="let item of datasetInfo.contexts">
212
                                    <span>{{item['labelContext']}}</span>
213
                                    <span *ngIf="item['labelCategory'] != null">-> {{item['labelCategory']}}</span>
214
                                    <span *ngIf="item['labelConcept'] != null">: {{item['labelConcept']}}</span>
215
                                </dd>
216
                            </dl>
217
                            <dl class="functionsSection" *ngIf="datasetInfo.contexts == undefined">
218
                                <dt class="title">Related to </dt>
219
                            </dl>
220
                            <button (click)=" toggleClaimContext()" class = "btn btn-default   btn-xs" >Add Contexts</button>
221
                            <inline-claim-context   inline="true" inlineType ="dataset" [inlineEntity]="result"  ></inline-claim-context>
222
                        </li-->
223
                    </ul>
224
                </div>
225
            </div>
226
        </div>
227
    `,
228
    providers:[JSONP_PROVIDERS, DatasetService],
229
    directives:[InlineClaimContextComponent, InlineClaimProjectComponent,
230
        TabTableComponent, ShowTitleComponent, ShowAuthorsComponent,
231
        ShowIdentifiersComponent, ShowSubjectsComponent]
232
})
233

  
234
export class DatasetComponent {
235
    constructor (private _datasetService: DatasetService, private _routeParams: RouteParams) {
236
        console.info('dataset constructor');
237
        this.params = _routeParams;
238
    }
239
    ngOnInit() {
240
        this.getDatasetInfo();
241
    }
242

  
243
    private datasetInfo: DatasetInfo;
244
    private params: RouteParams;
245

  
246
    private showStyle: boolean = false;
247
    private showAllReferences: boolean = false;
248
    private showAllRelResData: boolean = false;
249
    private showAllSimilPubl: boolean = false;
250
    private showAllBioentities: boolean = false;
251

  
252
    private result ;
253
    private claimInline:string = "none" ;
254

  
255
    @ViewChild (InlineClaimProjectComponent) inlineClaimProject : InlineClaimProjectComponent ;
256
    @ViewChild (InlineClaimContextComponent) inlineClaimContext : InlineClaimContextComponent ;
257

  
258
    public warningMessage = "";
259
    public errorMessage = "";
260

  
261
    getDatasetInfo() {
262
        this.warningMessage = '';
263
        this.errorMessage=""
264
        if(this.params.get("datasetId")==null || this.params.get("datasetId")==''){
265
            this.warningMessage="No valid dataset id";
266
            console.info("novalid");
267
        }else{
268
            console.info("do request");
269
            this._datasetService.getDatasetInfo(this.params.get("datasetId")).subscribe(
270
                data => {
271
                    this.datasetInfo = data;
272

  
273
                    this.result = []
274
                    let result_  ={id: this.params.get("datasetId"), type :"dataset", source : "openaire", title: this.datasetInfo.title,url: '', result: '', accessRights: this.datasetInfo.bestlicense, embargoEndDate: ''};
275
                    this.result.push(result_);
276
                },
277
                err => {
278
                    console.error(err)
279
                    console.info("error");
280

  
281
                    this.errorMessage = 'No dataset found';
282
                }
283
            );
284
        }
285
    }
286

  
287
    /********** Methods for Inline Claim  of project / dataset ******/
288
    toggleClaimProject(){
289
        this.inlineClaimProject.toggle();
290
    }
291
    projectAdded($event){
292
        var projects =$event.value;
293
        if(projects){
294
            for(var i=0; i < projects.length; i++){
295

  
296
                if(this.datasetInfo.fundedByProjects == undefined) {
297
                    this.datasetInfo.fundedByProjects = new Array<
298
                        { "url": string, "acronym": string, "title": string,
299
                          "funderShortname": string, "funderName": string,
300
                          "funding": string, "new": boolean
301
                        }>();
302
                }
303
                var project =projects[i];
304

  
305
                let counter = this.datasetInfo.fundedByProjects.length;
306
                this.datasetInfo.fundedByProjects[counter]['url'] =
307
                    "http://localhost:3000/project?projectId="+project.projectId;
308
                this.datasetInfo.fundedByProjects[counter]['acronym'] = project.projectAcronym;
309
                this.datasetInfo.fundedByProjects[counter]['title'] = project.projectName;
310
                this.datasetInfo.fundedByProjects[counter]['funderShortname'] = project.selectedFunderId;
311
                this.datasetInfo.fundedByProjects[counter]['funderName'] = project.selectedFunderName;
312
                this.datasetInfo.fundedByProjects[counter]['new'] = true;
313
            }
314
        }
315
    }
316
    toggleClaimContext(){
317
        this.inlineClaimContext.toggle();
318
    }
319
    contextAdded($event){
320
        var contexts =$event.value;
321
        if(contexts){
322
            for(var i=0; i < contexts.length; i++){
323
            }
324
        }
325
    }
326
}
modules/uoa-services-portal/trunk/src/app/landingPages/person/person.component.ts
1
import {Component} from '@angular/core';
2
import {JSONP_PROVIDERS}  from '@angular/http';
3
import {Observable}       from 'rxjs/Observable';
4
import { RouteParams } from '@angular/router-deprecated';
5
import {PersonService} from '../../services/person.service';
6
import {PersonInfo} from '../../entities/personInfo';
7

  
8
@Component({
9
    selector: 'person',
10
    template: `
11

  
12
    <div>
13
        <div class="container person">
14
            <div class="container-header" >
15
                <div *ngIf="personInfo != null">
16
                    <h3>{{personInfo.fullname}}</h3>
17
                </div>
18
                <div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
19
                <div *ngIf="errorMessage.length > 0" class="alert alert-danger" role="alert">{{errorMessage}}</div>
20
            </div>
21

  
22
            <div class="row row-offcanvas row-offcanvas-right" >
23

  
24
                <div class="col-xs-6 col-sm-9 sidebar-offcanvas" *ngIf="personInfo != null">
25
                    <dl class="dl-horizontal">
26
                        <dt *ngIf="personInfo.secondnames != undefined && personInfo.secondnames != ''">Last name: </dt>
27
                        <dd *ngIf="personInfo.secondnames != undefined && personInfo.secondnames != ''">{{personInfo.secondnames}}</dd>
28
                        <dt *ngIf="personInfo.firstname != undefined && personInfo.firstname != ''">First name: </dt>
29
                        <dd *ngIf="personInfo.firstname != undefined && personInfo.firstname != ''">{{personInfo.firstname}}</dd>
30
                        <dt *ngIf="personInfo.country != undefined && personInfo.country != ''">Country: </dt>
31
                        <dd *ngIf="personInfo.country != undefined && personInfo.country != ''">{{personInfo.country}}</dd>
32
                    </dl>
33

  
34
                    <ul class="nav nav-tabs">
35
                        <li class="active">
36
                            <a data-toggle="tab" href="#publicationsTab">
37
                                Publications
38
                            </a>
39
                        </li>
40
                        <li role="presentation">
41
                            <a data-toggle="tab" href="#researchDataTab">
42
                                Research Data
43
                            </a>
44
                        </li>
45
                    </ul>
46

  
47
                    <div class="tab-content">
48
                        <div id="publicationsTab" class="tab-pane fade in active panel-body">
49

  
50
                            <div *ngIf="personInfo.publications == undefined" class = "alert alert-info " >
51
                                There are no publications
52
                            </div>
53

  
54
                            <div *ngIf="personInfo.publications != undefined">
55
                                <p>
56
                                    The results below are discovered through our pilot algorithms.
57
                                    <a href="mailto:">Let us know how we are doing!</a>
58
                                </p>
59
                            </div>
60
                        </div>
61

  
62
                        <div id="researchDataTab" class="tab-pane fade panel-body">
63
                            <div *ngIf="personInfo.researchData == undefined" class = "alert alert-info ">
64
                                There are no research data
65
                            </div>
66
                            <div *ngIf="personInfo.researchData != undefined">
67
                                <p>
68
                                    The results below are discovered through our pilot algorithms.
69
                                    <a href="mailto:">Let us know how we are doing!</a>
70
                                </p>
71
                            </div>
72
                        </div>
73
                    </div>
74
                </div>
75

  
76
                <div class="col-xs-12 col-sm-3" *ngIf="personInfo != null">
77
                    <ul class="list-group mainFunctionsBlock">
78
                        <li class="list-group-item">
79
                            <dl class="functionsSection">
80
                                <dt  >Share - Bookmark</dt>
81
                                <dd>
82
                                </dd>
83
                            </dl>
84
                        </li>
85
                    </ul>
86
                </div>
87
            </div>
88
        </div>
89
    </div>
90

  
91
     `,
92
    providers:[JSONP_PROVIDERS, PersonService]
93
})
94

  
95
export class PersonComponent {
96
    constructor (private _personService: PersonService,
97
        private _routeParams: RouteParams) {
98
            console.info('person constructor');
99
            this.params = _routeParams;
100
        }
101

  
102
    ngOnInit() {
103
        console.info('person init');
104
        this.getPersonInfo();
105
    }
106

  
107
    personInfo: PersonInfo;
108
    params: RouteParams;
109

  
110
    public warningMessage = "";
111
    public errorMessage = "";
112

  
113
    getPersonInfo ()  {
114
        console.info("inside getProjectInfo of component");
115

  
116
        this.warningMessage = '';
117
        this.errorMessage=""
118
        if(this.params.get("personId")==null || this.params.get("personId")==''){
119
            this.warningMessage="No valid person id";
120
            console.info("novalid");
121
        } else {
122
            console.info("do request");
123

  
124
            this._personService.getPersonInfo(this.params.get('personId')).subscribe(
125
                data => {
126
                    this.personInfo = data;
127
                },
128
                err => {
129
                    console.error(err)
130
                    console.info("error");
131

  
132
                    this.errorMessage = 'No person found';
133
                }
134
            );
135
        }
136
    }
137
}
modules/uoa-services-portal/trunk/src/app/landingPages/showTitle.component.ts
1
import {Component, Input} from '@angular/core';
2
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
3

  
4

  
5
@Component({
6
    selector: 'showTitle',
7
    template: `
8
        <h2 *ngIf="title != undefined">
9
            <div *ngIf="title['url'] != undefined">
10
                <a class="custom-external" href="{{title['url']}}" target="_blank">
11
                    <div [innerHTML]="title['name']"></div>
12
                </a>
13
            </div>
14
            <div *ngIf="title['url'] == undefined">
15
                <div [innerHTML]="title['name']"></div>
16
            </div>
17
        </h2>
18
    `
19
    ,
20
        directives: [
21
          ...ROUTER_DIRECTIVES
22
        ]
23
    })
24

  
25
export class ShowTitleComponent {
26
    @Input() title: { [key: string]: string };
27

  
28
    constructor (private _router: Router) {
29
        console.info('title constructor');
30
    }
31

  
32
    ngOnInit() {
33
    }
34
}
modules/uoa-services-portal/trunk/src/app/landingPages/showSubjects.component.ts
1
import {Component, Input} from '@angular/core';
2
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
3

  
4

  
5
@Component({
6
    selector: 'showSubjects',
7
    template: `
8
        <div *ngIf="subjects != undefined">
9
            <dt *ngIf="subjects.length > 0 || classifiedSubjects.size > 0">
10
                Subjects:
11
            </dt>
12
            <dd>
13
                <div *ngIf="subjects.length > 0"> {{subjects}} </div>
14
                <div *ngIf="subjects.length == 0 && classifiedSubjects.size > 0"> - </div>
15
            </dd>
16

  
17
            <dd class="col-md-offset-1" *ngIf="classifiedSubjects.size > 0">
18
                <a (click)="showClassifiedSbj = !showClassifiedSbj;">
19
                    <div *ngIf="!showClassifiedSbj">
20
                        Show additional classifications
21
                        <span  class="glyphicon glyphicon-plus" aria-hidden="true"></span>
22
                    </div>
23
                    <div *ngIf="showClassifiedSbj">
24
                        Hide additional classifications
25
                        <span class="glyphicon glyphicon-minus" aria-hidden="true"></span>
26
                    </div>
27
                </a>
28

  
29
                <div class="well" *ngIf="showClassifiedSbj">
30
                    <div *ngFor="let key of classifiedSubjects.keys()">
31
                        Classified by OpenAIRE into
32
                        <div>
33
                            {{key}}: {{classifiedSubjects.get(key)}}
34
                        </div>
35
                    </div>
36
                </div>
37
            </dd>
38
        </div>
39
    `
40
    ,
41
        directives: [
42
          ...ROUTER_DIRECTIVES
43
        ]
44
    })
45

  
46
export class ShowSubjectsComponent {
47
    @Input() subjects: string[];
48
    @Input() classifiedSubjects: Map<string, string[]>;
49
    private showClassifiedSbj: boolean = false;
50

  
51
    constructor (private _router: Router) {
52
        console.info('showSubjects constructor');
53
    }
54

  
55
    ngOnInit() {
56
    }
57
}
modules/uoa-services-portal/trunk/src/app/landingPages/showAuthors.component.ts
1
import {Component, Input} from '@angular/core';
2
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
3

  
4

  
5
@Component({
6
    selector: 'showAuthors',
7
    template: `
8
        <span *ngIf="authors != undefined">
9
            <div *ngIf="showAll">
10
                <a class="text-muted" (click)="showAll = !showAll;">View less authors</a>
11
            </div>
12
            <span *ngFor="let item of authors.slice(0,30)">
13
                <a class="custom-external" href="{{item['url']}}" target="_blank">
14
                    {{item['name']}};
15
                </a>
16
            </span>
17
            <span *ngIf="!showAll && authors.length > 30">	... </span>
18
            <span *ngIf="showAll">
19
                <span *ngFor="let item of authors.slice(30)">
20
                    <a class="custom-external" href="{{item['url']}}" target="_blank">
21
                        {{item['name']}};
22
                    </a>
23
                </span>
24
            </span>
25
            <span *ngIf="!showAll && authors.length > 30">
26
                <a class="text-muted" (click)="showAll = !showAll;">
27
                    view all {{authors.length}} authors
28
                </a>
29
            </span>
30
            <span *ngIf="showAll">
31
                <a class="text-muted" (click)="showAll = !showAll;">View less authors</a>
32
            </span>
33
        </span>
34

  
35
    `
36
    ,
37
        directives: [
38
          ...ROUTER_DIRECTIVES
39
        ]
40
    })
41

  
42
export class ShowAuthorsComponent {
43
    @Input() authors: { [key: string]: string }[];
44
    private showAll: boolean = false;
45

  
46
    constructor (private _router: Router) {
47
        console.info('showAuthors constructor');
48
    }
49

  
50
    ngOnInit() {
51
    }
52
}
modules/uoa-services-portal/trunk/src/app/landingPages/showIdentifiers.component.ts
1
import {Component, Input} from '@angular/core';
2
import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated';
3

  
4

  
5
@Component({
6
    selector: 'showIdentifiers',
7
    template: `
8
        <div *ngIf="identifiers != undefined && identifiers.size > 0">
9
            <dt>Identifiers:</dt>
10
            <dd>
11
                <ul class="list-inline">
12
                    <li *ngFor="let key of identifiers.keys()">
13
                        <div *ngFor="let item of identifiers.get(key)">
14
                            <div [ngSwitch]="key">
15
                                <template [ngSwitchWhen]="'doi'">
16
                                        <a class="custom-external" href="http://dx.doi.org/{{item}}" target="_blank">
17
                                            {{key}}: {{item}}
18
                                        </a>
19
                                </template>
20
                                <template [ngSwitchWhen]="'pmc'">
21
                                    <a class="custom-external" href="http://europepmc.org/articles/{{item}}" target="_blank">
22
                                        {{key}}: {{item}}
23
                                    </a>
24
                                </template>
25
                            </div>
26
                        </div>
27
                    </li>
28
                </ul>
29
            </dd>
30
        </div>
31

  
32
    `
33
    ,
34
        directives: [
35
          ...ROUTER_DIRECTIVES
36
        ]
37
    })
38

  
39
export class ShowIdentifiersComponent {
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff