diff --git a/src/app/entities/datasetInfo.ts b/src/app/entities/datasetInfo.ts new file mode 100644 index 00000000..47ac8120 --- /dev/null +++ b/src/app/entities/datasetInfo.ts @@ -0,0 +1,26 @@ +export class DatasetInfo { + title: { "name": string, "url": string, "accessMode": string}; + authors: { "name": string, "url": string}[]; + date: string; + embargoEndDate: string; + type: string; + downloadFrom: Map; //key is name + publishedIn: Map; //key is name + identifiers: Map; + publisher: string; + subjects: string[]; + classifiedSubjects: Map; + description: string; + bestlicense: string; + collectedFrom: { "name": string, "url": string}[]; + fundedByProjects: { "url": string, "acronym": string, "title": string, + "funderShortname": string, "funderName": string, + "funding": string, "new": boolean}[]; + //relatedPublications: { "name": string, "url": string, "date": string, "trust": string}[]; + //relatedResearchData: { "name": string, "url": string, "date": string, "trust": string}[]; + //similarPublications: { "name": string, "url": string, "date": string, "trust": string}[]; + //similarDatasets: { "name": string, "url": string, "date": string, "trust": string}[]; + relatedResearchResults: { "name": string, "url": string, "date": string, "trust": string, "class": string}[]; + similarResearchResults: {"name": string, "url": string, "date": string, "trust": string, "class": string}[]; + contexts: { "labelContext": string, "labelCategory": string, "labelConcept": string}[]; +} diff --git a/src/app/entities/personInfo.ts b/src/app/entities/personInfo.ts new file mode 100644 index 00000000..046e6f1f --- /dev/null +++ b/src/app/entities/personInfo.ts @@ -0,0 +1,9 @@ +export class PersonInfo { + fullname: string; + firstname: string; + secondnames: string; + country: string; + + publications: any; + researchData: any; +} diff --git a/src/app/landingPages/dataset/dataset.component.ts b/src/app/landingPages/dataset/dataset.component.ts new file mode 100644 index 00000000..8af4dcaf --- /dev/null +++ b/src/app/landingPages/dataset/dataset.component.ts @@ -0,0 +1,326 @@ +import {Component, ViewChild} from '@angular/core'; +import {JSONP_PROVIDERS} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {DatasetService} from '../../services/dataset.service'; +import {DatasetInfo} from '../../entities/datasetInfo'; +import { RouteParams} from '@angular/router-deprecated'; +import { InlineClaimContextComponent} from '../../claimPages/inlineClaimContext/inlineClaimContext.component'; +import { InlineClaimProjectComponent} from '../../claimPages/inlineClaimProject/inlineClaimProject.component'; + +import {TabPagingComponent} from '../tabPaging.component.ts'; +import {TabTableComponent} from '../tabTable.component.ts'; +import {ShowTitleComponent} from '../showTitle.component.ts'; +import {ShowAuthorsComponent} from '../showAuthors.component.ts'; +import {ShowIdentifiersComponent} from '../showIdentifiers.component.ts'; +import {ShowSubjectsComponent} from '../showSubjects.component.ts'; + +@Component({ + selector: 'dataset', + template: ` +
+
+
+ +
+ + +
+ +
+ + + +
+
+ `, + providers:[JSONP_PROVIDERS, DatasetService], + directives:[InlineClaimContextComponent, InlineClaimProjectComponent, + TabTableComponent, ShowTitleComponent, ShowAuthorsComponent, + ShowIdentifiersComponent, ShowSubjectsComponent] +}) + +export class DatasetComponent { + constructor (private _datasetService: DatasetService, private _routeParams: RouteParams) { + console.info('dataset constructor'); + this.params = _routeParams; + } + ngOnInit() { + this.getDatasetInfo(); + } + + private datasetInfo: DatasetInfo; + private params: RouteParams; + + private showStyle: boolean = false; + private showAllReferences: boolean = false; + private showAllRelResData: boolean = false; + private showAllSimilPubl: boolean = false; + private showAllBioentities: boolean = false; + + private result ; + private claimInline:string = "none" ; + + @ViewChild (InlineClaimProjectComponent) inlineClaimProject : InlineClaimProjectComponent ; + @ViewChild (InlineClaimContextComponent) inlineClaimContext : InlineClaimContextComponent ; + + public warningMessage = ""; + public errorMessage = ""; + + getDatasetInfo() { + this.warningMessage = ''; + this.errorMessage="" + if(this.params.get("datasetId")==null || this.params.get("datasetId")==''){ + this.warningMessage="No valid dataset id"; + console.info("novalid"); + }else{ + console.info("do request"); + this._datasetService.getDatasetInfo(this.params.get("datasetId")).subscribe( + data => { + this.datasetInfo = data; + + this.result = [] + let result_ ={id: this.params.get("datasetId"), type :"dataset", source : "openaire", title: this.datasetInfo.title,url: '', result: '', accessRights: this.datasetInfo.bestlicense, embargoEndDate: ''}; + this.result.push(result_); + }, + err => { + console.error(err) + console.info("error"); + + this.errorMessage = 'No dataset found'; + } + ); + } + } + + /********** Methods for Inline Claim of project / dataset ******/ + toggleClaimProject(){ + this.inlineClaimProject.toggle(); + } + projectAdded($event){ + var projects =$event.value; + if(projects){ + for(var i=0; i < projects.length; i++){ + + if(this.datasetInfo.fundedByProjects == undefined) { + this.datasetInfo.fundedByProjects = new Array< + { "url": string, "acronym": string, "title": string, + "funderShortname": string, "funderName": string, + "funding": string, "new": boolean + }>(); + } + var project =projects[i]; + + let counter = this.datasetInfo.fundedByProjects.length; + this.datasetInfo.fundedByProjects[counter]['url'] = + "http://localhost:3000/project?projectId="+project.projectId; + this.datasetInfo.fundedByProjects[counter]['acronym'] = project.projectAcronym; + this.datasetInfo.fundedByProjects[counter]['title'] = project.projectName; + this.datasetInfo.fundedByProjects[counter]['funderShortname'] = project.selectedFunderId; + this.datasetInfo.fundedByProjects[counter]['funderName'] = project.selectedFunderName; + this.datasetInfo.fundedByProjects[counter]['new'] = true; + } + } + } + toggleClaimContext(){ + this.inlineClaimContext.toggle(); + } + contextAdded($event){ + var contexts =$event.value; + if(contexts){ + for(var i=0; i < contexts.length; i++){ + } + } + } +} diff --git a/src/app/landingPages/person/person.component.ts b/src/app/landingPages/person/person.component.ts new file mode 100644 index 00000000..b4e4d5f0 --- /dev/null +++ b/src/app/landingPages/person/person.component.ts @@ -0,0 +1,137 @@ +import {Component} from '@angular/core'; +import {JSONP_PROVIDERS} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import { RouteParams } from '@angular/router-deprecated'; +import {PersonService} from '../../services/person.service'; +import {PersonInfo} from '../../entities/personInfo'; + +@Component({ + selector: 'person', + template: ` + +
+
+
+
+

{{personInfo.fullname}}

+
+ + +
+ +
+ + + +
+
    +
  • +
    +
    Share - Bookmark
    +
    +
    +
    +
  • +
+
+
+
+
+ + `, + providers:[JSONP_PROVIDERS, PersonService] +}) + +export class PersonComponent { + constructor (private _personService: PersonService, + private _routeParams: RouteParams) { + console.info('person constructor'); + this.params = _routeParams; + } + + ngOnInit() { + console.info('person init'); + this.getPersonInfo(); + } + + personInfo: PersonInfo; + params: RouteParams; + + public warningMessage = ""; + public errorMessage = ""; + + getPersonInfo () { + console.info("inside getProjectInfo of component"); + + this.warningMessage = ''; + this.errorMessage="" + if(this.params.get("personId")==null || this.params.get("personId")==''){ + this.warningMessage="No valid person id"; + console.info("novalid"); + } else { + console.info("do request"); + + this._personService.getPersonInfo(this.params.get('personId')).subscribe( + data => { + this.personInfo = data; + }, + err => { + console.error(err) + console.info("error"); + + this.errorMessage = 'No person found'; + } + ); + } + } +} diff --git a/src/app/landingPages/showAuthors.component.ts b/src/app/landingPages/showAuthors.component.ts new file mode 100644 index 00000000..cf6fa8db --- /dev/null +++ b/src/app/landingPages/showAuthors.component.ts @@ -0,0 +1,52 @@ +import {Component, Input} from '@angular/core'; +import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated'; + + +@Component({ + selector: 'showAuthors', + template: ` + + + + + {{item['name']}}; + + + ... + + + + {{item['name']}}; + + + + + + view all {{authors.length}} authors + + + + View less authors + + + + ` + , + directives: [ + ...ROUTER_DIRECTIVES + ] + }) + +export class ShowAuthorsComponent { + @Input() authors: { [key: string]: string }[]; + private showAll: boolean = false; + + constructor (private _router: Router) { + console.info('showAuthors constructor'); + } + + ngOnInit() { + } +} diff --git a/src/app/landingPages/showIdentifiers.component.ts b/src/app/landingPages/showIdentifiers.component.ts new file mode 100644 index 00000000..8b662355 --- /dev/null +++ b/src/app/landingPages/showIdentifiers.component.ts @@ -0,0 +1,48 @@ +import {Component, Input} from '@angular/core'; +import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated'; + + +@Component({ + selector: 'showIdentifiers', + template: ` +
+
Identifiers:
+
+
    +
  • +
    +
    + + +
    +
    +
  • +
+
+
+ + ` + , + directives: [ + ...ROUTER_DIRECTIVES + ] + }) + +export class ShowIdentifiersComponent { + @Input() identifiers: Map;//Map; + + constructor (private _router: Router) { + console.info('showIdentifiers constructor'); + } + + ngOnInit() { + } +} diff --git a/src/app/landingPages/showSubjects.component.ts b/src/app/landingPages/showSubjects.component.ts new file mode 100644 index 00000000..da180fd7 --- /dev/null +++ b/src/app/landingPages/showSubjects.component.ts @@ -0,0 +1,57 @@ +import {Component, Input} from '@angular/core'; +import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated'; + + +@Component({ + selector: 'showSubjects', + template: ` +
+
+ Subjects: +
+
+
{{subjects}}
+
-
+
+ +
+ +
+ Show additional classifications + +
+
+ Hide additional classifications + +
+
+ +
+
+ Classified by OpenAIRE into +
+ {{key}}: {{classifiedSubjects.get(key)}} +
+
+
+
+
+ ` + , + directives: [ + ...ROUTER_DIRECTIVES + ] + }) + +export class ShowSubjectsComponent { + @Input() subjects: string[]; + @Input() classifiedSubjects: Map; + private showClassifiedSbj: boolean = false; + + constructor (private _router: Router) { + console.info('showSubjects constructor'); + } + + ngOnInit() { + } +} diff --git a/src/app/landingPages/showTitle.component.ts b/src/app/landingPages/showTitle.component.ts new file mode 100644 index 00000000..805d58db --- /dev/null +++ b/src/app/landingPages/showTitle.component.ts @@ -0,0 +1,34 @@ +import {Component, Input} from '@angular/core'; +import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated'; + + +@Component({ + selector: 'showTitle', + template: ` +

+
+ +
+
+
+
+
+
+

+ ` + , + directives: [ + ...ROUTER_DIRECTIVES + ] + }) + +export class ShowTitleComponent { + @Input() title: { [key: string]: string }; + + constructor (private _router: Router) { + console.info('title constructor'); + } + + ngOnInit() { + } +} diff --git a/src/app/landingPages/tabPaging.component.ts b/src/app/landingPages/tabPaging.component.ts new file mode 100644 index 00000000..b9709214 --- /dev/null +++ b/src/app/landingPages/tabPaging.component.ts @@ -0,0 +1,33 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated'; + + +@Component({ + selector: 'tabPaging', + template: ` + + ` + , + directives: [ + ...ROUTER_DIRECTIVES + ] + }) + +export class TabPagingComponent { + @Input() showAll: boolean; + @Input() length: number; + @Output() changeShowAll: EventEmitter = new EventEmitter(); + + constructor (private _router: Router) { + console.info('publication:paging constructor'); + } + + ngOnInit() { + } +} diff --git a/src/app/landingPages/tabTable.component.ts b/src/app/landingPages/tabTable.component.ts new file mode 100644 index 00000000..e65588a6 --- /dev/null +++ b/src/app/landingPages/tabTable.component.ts @@ -0,0 +1,58 @@ +import {Component, Input} from '@angular/core'; +import {Router, ROUTER_DIRECTIVES} from '@angular/router-deprecated'; + + +@Component({ + selector: 'tabTable', + template: ` + + + + + + + + + + + + + +
TitleTrust
+ + + {{item['name']}} + +

{{item['name']}}

+ + ({{item['date']}}) + +
+
+
+ {{item['trust']}} +
+
+
+

no trust found

+
+
+ ` + , + directives: [ + ...ROUTER_DIRECTIVES + ] + }) + +export class TabTableComponent { + @Input() info: { "name": string, "url": string, "date": string, "trust": string}[];//Map; + + constructor (private _router: Router) { + console.info('tabTable constructor'); + } + + ngOnInit() { + } +} diff --git a/src/app/services/dataset.service.ts b/src/app/services/dataset.service.ts new file mode 100644 index 00000000..bf870efd --- /dev/null +++ b/src/app/services/dataset.service.ts @@ -0,0 +1,616 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {DatasetInfo} from '../entities/datasetInfo'; + +@Injectable() +export class DatasetService { + + constructor(private http: Http) {} + + datasetInfo: DatasetInfo; + + getDatasetInfo (id: string):any { + console.info("getDatasetInfo in service"); + + //let url = 'http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id; + //let url = 'http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id; + let url = 'http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/datasets/'+id; + + + return this.http.get(url) + .map(res => res.json()) + .do(res => console.info(res['result']['metadata']['oaf:entity'])) + .map(res => res['result']['metadata']['oaf:entity']['oaf:result']) + .map(res => [res, + res['title'], + res['rels']['rel'], + res['children'], + res['pid'], + res['subject'], + res['bestlicense'], + res['collectedfrom'], + res['context'], + res['resulttype'] + ]) + .map(res => this.parseDatasetInfo(res)); + + } + + private handleError (error: Response) { + // in a real world app, we may send the error to some remote logging infrastructure + // instead of just logging it to the console + console.error(error); + return Observable.throw(error || 'Server error'); + } + + parseDatasetInfo (data: any):any { + this.datasetInfo = new DatasetInfo(); + + if(data[0] != null) { + this.datasetInfo.date = data[0].dateofacceptance.substring(0,4); + this.datasetInfo.publisher = data[0].publisher; + if(!Array.isArray(data[0].description)) { + this.datasetInfo.description = data[0].description; + } else { + this.datasetInfo.description = data[0].description[0]; + } + this.datasetInfo.embargoEndDate = data[0].embargoenddate; + } + + if(data[1] != null) { + this.datasetInfo.title = {"name": "", "url": "", "accessMode": ""}; + if(Array.isArray(data[1])) { + this.datasetInfo.title['name'] = data[1][0].content; + } else { + this.datasetInfo.title['name'] = data[1].content; + } + } + + if(data[2] != null) { + let mydata; + let counter = 0; + let length = data[2].length!=undefined ? data[2].length : 1; + + for(let i=0; i 1 ? data[2][i] : data[2]; + if(mydata.hasOwnProperty("to")) { + if(mydata['to'].class == "hasAuthor") { + if(this.datasetInfo.authors == undefined) { + this.datasetInfo.authors = new Array<{"name": string, "url": string}>(); + } + + this.datasetInfo.authors[mydata.ranking-1] = {"name": "", "url": ""}; + this.datasetInfo.authors[mydata.ranking-1]['name'] = mydata.fullname; + this.datasetInfo.authors[mydata.ranking-1]['url'] = "https://beta.openaire.eu/search/person?personId="+mydata['to'].content; + } else if(mydata['to'].class == "isProducedBy") { + if(this.datasetInfo.fundedByProjects == undefined) { + this.datasetInfo.fundedByProjects = new Array< + { "url": string, "acronym": string, "title": string, + "funderShortname": string, "funderName": string, + "funding": string, "new": boolean + }>(); + } + + counter = this.datasetInfo.fundedByProjects.length; + + this.datasetInfo.fundedByProjects[counter] = { + "url": "", "acronym": "", "title": "", + "funderShortname": "", "funderName": "", + "funding": "", "new": false + } + + this.datasetInfo.fundedByProjects[counter]['url'] = + "http://localhost:3000/project?projectId="+mydata['to'].content; + this.datasetInfo.fundedByProjects[counter]['acronym'] = mydata.acronym; + this.datasetInfo.fundedByProjects[counter]['title'] = mydata.title; + + if(mydata.hasOwnProperty("funding")) { + let length1 = Array.isArray(mydata['funding']) ? mydata['funding'].length : 1; + + for(let j=0; j 1 ? mydata['funding'][j] : mydata['funding']; + + if(mydata1.hasOwnProperty("funder")) { + this.datasetInfo.fundedByProjects[counter]['funderShortname'] = mydata1['funder'].shortname; + this.datasetInfo.fundedByProjects[counter]['funderName'] = mydata1['funder'].name; + } + + if(mydata1.hasOwnProperty("funding_level_2")) { + funding = mydata1['funding_level_2'].content; + } else if(mydata1.hasOwnProperty("funding_level_1")) { + funding = mydata1['funding_level_1'].content; + } else if(mydata1.hasOwnProperty("funding_level_0")) { + funding = mydata1['funding_level_0'].content; + } + + if(funding != undefined) { + funding = funding.split("::"); + + if(this.datasetInfo.fundedByProjects[counter]['funding'] != "") { + this.datasetInfo.fundedByProjects[counter]['funding'] += ", "+funding[1]; + } else { + this.datasetInfo.fundedByProjects[counter]['funding'] = funding[1]; + } + for(let i=2; i(); + } + + let url = "http://localhost:3000/publication?articleId="+mydata['to'].content; + let counter = this.datasetInfo.similarPublications.length; + + this.datasetInfo.similarPublications[counter] = {"name": "", "url": "", "date": "", "trust": ""}; + this.datasetInfo.similarPublications[counter]['url'] = url; + this.datasetInfo.similarPublications[counter]['name'] = mydata['title'].content; + this.datasetInfo.similarPublications[counter]['date'] = mydata.dateofacceptance.substring(0,4); + this.datasetInfo.similarPublications[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + } else if(mydata.hasOwnProperty('resulttype') && mydata['resulttype'].classname == "dataset") { + if(this.datasetInfo.similarDatasets == undefined) { + this.datasetInfo.similarDatasets = new Array< + { "name": string, "url": string, "date": string, "trust": string}>(); + } + + let url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content; + let counter = this.datasetInfo.similarDatasets.length; + + this.datasetInfo.similarDatasets[counter] = {"name": "", "url": "", "date": "", "trust": ""}; + this.datasetInfo.similarDatasets[counter]['url'] = url; + this.datasetInfo.similarDatasets[counter]['name'] = mydata['title'].content; + this.datasetInfo.similarDatasets[counter]['date'] = mydata.dateofacceptance.substring(0,4); + this.datasetInfo.similarDatasets[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + }*/ + + if(this.datasetInfo.similarResearchResults == undefined) { + this.datasetInfo.similarResearchResults = new Array<{ + "name": string, "url": string, "date": string, + "trust": string, "class": string}>(); + } + + counter = this.datasetInfo.similarResearchResults.length; + this.datasetInfo.similarResearchResults[counter] = {"name": "", "url": "", "date": "", "trust": "", "class": ""} + + let url; + if(mydata['resulttype'].classname == "publication") { + url = "http://localhost:3000/publication?articleId="+mydata['to'].content; + this.datasetInfo.similarResearchResults[counter]['class'] = "publication"; + } else { + url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content; + this.datasetInfo.similarResearchResults[counter]['class'] = "dataset"; + } + + this.datasetInfo.similarResearchResults[counter]['url'] = url; + this.datasetInfo.similarResearchResults[counter]['name'] = mydata['title'].content; + this.datasetInfo.similarResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);; + this.datasetInfo.similarResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + + + } else if(mydata['to'].class == "isRelatedTo") { + /*if(mydata.hasOwnProperty('resulttype')) { + if(mydata['resulttype'].classname == "publication") { + if(this.datasetInfo.relatedPublications == undefined) { + this.datasetInfo.relatedPublications = new Array<{ + "name": string, "url": string, "date": string, "trust": string}>(); + } + let url = "http://localhost:3000/publication?articleId="+mydata['to'].content; + counter = this.datasetInfo.relatedPublications.length; + + this.datasetInfo.relatedPublications[counter] = {"name": "", "url": "", "date": "", "trust": ""} + + this.datasetInfo.relatedPublications[counter]['url'] = url; + this.datasetInfo.relatedPublications[counter]['name'] = mydata['title'].content; + this.datasetInfo.relatedPublications[counter]['date'] = mydata.dateofacceptance.substring(0,4);; + this.datasetInfo.relatedPublications[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + } else { + if(this.datasetInfo.relatedResearchData == undefined) { + this.datasetInfo.relatedResearchData = new Array<{ + "name": string, "url": string, "date": string, "trust": string}>(); + } + let url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content; + counter = this.datasetInfo.relatedResearchData.length; + + this.datasetInfo.relatedResearchData[counter] = {"name": "", "url": "", "date": "", "trust": ""} + + this.datasetInfo.relatedResearchData[counter]['url'] = url; + this.datasetInfo.relatedResearchData[counter]['name'] = mydata['title'].content; + this.datasetInfo.relatedResearchData[counter]['date'] = mydata.dateofacceptance.substring(0,4);; + this.datasetInfo.relatedResearchData[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + } + }*/ + + if(this.datasetInfo.relatedResearchResults == undefined) { + this.datasetInfo.relatedResearchResults = new Array<{ + "name": string, "url": string, "date": string, + "trust": string, "class": string}>(); + } + + counter = this.datasetInfo.relatedResearchResults.length; + this.datasetInfo.relatedResearchResults[counter] = {"name": "", "url": "", "date": "", "trust": "", "class": ""} + + let url; + if(mydata['resulttype'].classname == "publication") { + url = "http://localhost:3000/publication?articleId="+mydata['to'].content; + this.datasetInfo.relatedResearchResults[counter]['class'] = "publication"; + } else { + url = "http://localhost:3000/dataset?datasetId="+mydata['to'].content; + this.datasetInfo.relatedResearchResults[counter]['class'] = "dataset"; + } + + this.datasetInfo.relatedResearchResults[counter]['url'] = url; + this.datasetInfo.relatedResearchResults[counter]['name'] = mydata['title'].content; + this.datasetInfo.relatedResearchResults[counter]['date'] = mydata.dateofacceptance.substring(0,4);; + this.datasetInfo.relatedResearchResults[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + + } + } + } + + this.datasetInfo.authors = this.datasetInfo.authors.filter(function (item) { + return (item != undefined); + }); + } + + if(data[3] != null) { + if(data[3].hasOwnProperty("instance")) { + this.datasetInfo.downloadFrom = new Map(); + this.datasetInfo.publishedIn = new Map() + + let length = data[3]['instance'].length!=undefined ? data[3]['instance'].length : 1; + + let counter = 0; + let counter1 = 0; + let counter2 = 0; + let mydata; + for(let i=0; i 1 ? data[3]['instance'][i] : data[3]['instance']; + + if(mydata.hasOwnProperty("webresource")) { + let url; + if(mydata['webresource'].length == undefined) { + url = mydata['webresource'].url; + } else{ + url = mydata['webresource'][0].url; + } + + if(!this.datasetInfo.downloadFrom.has(url) && mydata.hasOwnProperty("hostedby")) { + if(mydata['hostedby'].name != "other resources" && mydata['hostedby'].name != "Unknown Repository") { + if(!this.datasetInfo.downloadFrom.has(mydata['hostedby'].name)) { + this.datasetInfo.downloadFrom.set(mydata['hostedby'].name, {"url": null, "accessMode": null}); + } + + if(this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'] == null) { + this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'] = new Array(); + } + + counter2 = this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'].length; + this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['url'][counter2] = url; + + if(this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'] == null) { + this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'] = new Array(); + } + + if(mydata.hasOwnProperty("licence")) { + this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = mydata['licence'].classid; + } else { + this.datasetInfo.downloadFrom.get(mydata['hostedby'].name)['accessMode'][counter2] = ""; + } + } else { + if(data[0] != null && data[0].hasOwnProperty("source")) { + let key: string; + if(Array.isArray(data[0].source)) { + if(!this.datasetInfo.publishedIn.has(data[0]['source'][counter1])) { + key = data[0]['source'][counter1]; + } + } else { + if(!this.datasetInfo.publishedIn.has(data[0]['source'])) { + key = data[0]['source']; + } + } + + this.datasetInfo.publishedIn.set(key, {"url": null, "accessMode": null}); + + if(this.datasetInfo.publishedIn.get(key)['url'] == null) { + this.datasetInfo.publishedIn.get(key)['url'] = new Array(); + } + + counter2 = this.datasetInfo.publishedIn.get(key)['url'].length; + this.datasetInfo.publishedIn.get(key)['url'][counter2] = url; + + if(this.datasetInfo.publishedIn.get(key)['accessMode'] == null) { + this.datasetInfo.publishedIn.get(key)['accessMode'] = new Array(); + } + + if(mydata.hasOwnProperty("licence")) { + this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = mydata['licence'].classid; + } else { + this.datasetInfo.publishedIn.get(key)['accessMode'][counter2] = ""; + } + counter1++; + } + } + if(this.datasetInfo.title != undefined) { + if(this.datasetInfo.title['url'] == undefined) { + this.datasetInfo.title['url'] = url; + } + + switch (this.datasetInfo.title['licence']) { + case undefined: + this.datasetInfo.title['licence'] = mydata['licence'].classid; + this.datasetInfo.title['url'] = url; + break; + case "CLOSED": + if(mydata['licence'].classid == "OPEN" || + mydata['licence'].classid == "EMBARGO" || + mydata['licence'].classid == "RESTRICTED") { + this.datasetInfo.title['licence'] = mydata['licence'].classid; + this.datasetInfo.title['url'] = url; + } + break; + case "RESTRICTED": + if(mydata['licence'].classid == "OPEN" || + mydata['licence'].classid == "EMBARGO") { + this.datasetInfo.title['licence'] = mydata['licence'].classid; + this.datasetInfo.title['url'] = url; + } + break; + case "EMBARGO": + if(mydata['licence'].classid == "OPEN") { + this.datasetInfo.title['licence'] = mydata['licence'].classid; + this.datasetInfo.title['url'] = url; + } + break; + } + } + } + } + } + } + } + + if(data[4] != null) { + let counter = 0; + this.datasetInfo.identifiers = new Map(); + + if(data[4].hasOwnProperty("classname") && data[4]['classname'] != "") { + if(data[4].classname == "doi" || data[4].classname == "pmc") { + if(!this.datasetInfo.identifiers.has(data[4].classname)) { + this.datasetInfo.identifiers.set(data[4].classname, new Array()); + } + counter = this.datasetInfo.identifiers.get(data[4].classname).length; + this.datasetInfo.identifiers.get(data[4].classname)[counter] = data[4].content; + } + } else { + for(let i=0; i()); + } + counter = this.datasetInfo.identifiers.get(data[4][i].classname).length; + this.datasetInfo.identifiers.get(data[4][i].classname)[counter] = data[4][i].content; + } + } + } + } + + if(data[5] != null) { + this.datasetInfo.classifiedSubjects = new Map(); + this.datasetInfo.subjects = new Array(); + + let mydata; + let length = data[5].length!=undefined ? data[5].length : 1; + + for(let i=0; i 1 ? data[5][i] : data[5]; + + if(mydata.classid != "") { + if(mydata.inferred == true) { + if(!this.datasetInfo.classifiedSubjects.has(mydata.classid)) { + this.datasetInfo.classifiedSubjects.set(mydata.classid, new Array()); + } + + let counter = this.datasetInfo.classifiedSubjects.get(mydata.classid).length; + this.datasetInfo.classifiedSubjects.get(mydata.classid)[counter] = mydata.content; + } else { + let counter = this.datasetInfo.subjects.length; + this.datasetInfo.subjects[counter] = mydata.content; + } + } + } + } + + if(data[6] != null) { + this.datasetInfo.bestlicense = data[6].classid; + } + + if(data[7] != null) { + this.datasetInfo.collectedFrom = new Array<{"name": string, "url": string}>(); + + let mydata; + let length = data[7].length!=undefined ? data[7].length : 1; + for(let i=0; i 1 ? data[7][i] : data[7]; + let link = "https://beta.openaire.eu/search/dataprovider?datasourceId="; + this.datasetInfo.collectedFrom[i] = {"name": "", "url": ""}; + this.datasetInfo.collectedFrom[i]['name'] = mydata.name; + this.datasetInfo.collectedFrom[i]['url'] = link+mydata.id; + } + } + + if(this.datasetInfo.publisher != null + && this.datasetInfo.identifiers != null + && this.datasetInfo.identifiers.has("doi")) { + + if( this.datasetInfo.downloadFrom == null) { + this.datasetInfo.downloadFrom = new Map(); + } + + this.datasetInfo.downloadFrom.set(this.datasetInfo.publisher, {"url": null, "accessMode": null}); + + let url = "http://dx.doi.org/"+this.datasetInfo.identifiers.get("doi"); + this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'] = new Array(); + this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'] = new Array(); + + this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['url'][0] = url; + this.datasetInfo.downloadFrom.get(this.datasetInfo.publisher)['accessMode'][0] = ""; + + if(this.datasetInfo.title != undefined && this.datasetInfo.title['url'] == "") { + this.datasetInfo.title['url'] = url; + } + } + + if(data[8] != null) { + this.datasetInfo.contexts = new Array< + { "labelContext": string, "labelCategory": string, "labelConcept": string}>(); + + let position = 0; + let labels = ""; + let mydata; + let length = data[8].length!=undefined ? data[8].length : 1; + for(let i=0; i 1 ? data[8][i] : data[8]; + + if(mydata.hasOwnProperty("type") && mydata['type'] == "community") { + if(mydata.hasOwnProperty("category")) { + if(mydata['category'].hasOwnProperty("concept")) { + let mydata1; + let length1 = mydata['category']['concept'].length!=undefined ? mydata['category']['concept'].length : 1; + for(let j=0; j 1 ? mydata['category']['concept'][j] : mydata['category']['concept']; + + this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""}; + this.datasetInfo.contexts[position]['labelContext'] = mydata.label; + this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;; + this.datasetInfo.contexts[position]['labelConcept'] = mydata1.label; + + position++; + } + } else { + this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""}; + this.datasetInfo.contexts[position]['labelContext'] = mydata.label; + this.datasetInfo.contexts[position]['labelCategory'] = mydata['category'].label;; + this.datasetInfo.contexts[position]['labelConcept'] = null; + } + } else { + this.datasetInfo.contexts[position] = {"labelContext": "", "labelCategory": "", "labelConcept": ""}; + this.datasetInfo.contexts[position]['labelContext'] = mydata.label; + this.datasetInfo.contexts[position]['labelCategory'] = null; + this.datasetInfo.contexts[position]['labelConcept'] = null; + } + } + } + } + + if(data[9] != null) { + if(data[9].hasOwnProperty('classname')) { + this.datasetInfo.type = data[9].classname; + } + } + + + //this.printdatasetInfo(); + return this.datasetInfo; + + } + + printDatasetInfo() { + console.info("DATE: "+this.datasetInfo.date); + console.info("PUBLISHER: "+this.datasetInfo.publisher); + console.info("DESCRIPTION: "+this.datasetInfo.description); + + console.info("TITLE: "+this.datasetInfo.title); + + console.info("AUTHORS: "+this.datasetInfo.authors); + console.info("\nFUNDED BY PROJECTS:"); + if(this.datasetInfo.fundedByProjects != undefined) { + this.datasetInfo.fundedByProjects.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); +/* + console.info("\nRELATED RESEARCH DATA:"); + if(this.datasetInfo.relatedResearchData != undefined) { + this.datasetInfo.relatedResearchData.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nSIMILAR datasetS:"); + if(this.datasetInfo.similarPublications != undefined) { + this.datasetInfo.similarPublications.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); +*/ + console.info("TYPE: "+this.datasetInfo.type); + console.info("\nDOWNLOAD FROM:"); + if(this.datasetInfo.downloadFrom != undefined) { + this.datasetInfo.downloadFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nIDENTIFIERS:"); + if(this.datasetInfo.identifiers != undefined) { + this.datasetInfo.identifiers.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("SUBJECTS: "+this.datasetInfo.subjects); + console.info("\nCLASSIFIED OBJECTS:"); + if(this.datasetInfo.classifiedSubjects != undefined) { + this.datasetInfo.classifiedSubjects.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("BEST LICENSE: "+this.datasetInfo.bestlicense); + + console.info("\nCOLLECTED FROM:"); + if(this.datasetInfo.collectedFrom != undefined) { + this.datasetInfo.collectedFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nDOWNLOAD FROM:"); + if(this.datasetInfo.downloadFrom != undefined) { + this.datasetInfo.downloadFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + } +} diff --git a/src/app/services/person.service.ts b/src/app/services/person.service.ts new file mode 100644 index 00000000..2c376751 --- /dev/null +++ b/src/app/services/person.service.ts @@ -0,0 +1,54 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {PersonInfo} from '../entities/personInfo'; + +@Injectable() +export class PersonService { + + constructor(private http: Http) {} + + personInfo: PersonInfo; + + getPersonInfo (id: string):any { + console.info("getPersonInfo in service"); + + //let url = 'http://rudie.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/projects/'+id; + //let url = 'http://scoobydoo.di.uoa.gr:8181/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/projects/'+id; + let url = 'http://astero.di.uoa.gr:8080/dnet-functionality-services-2.0.0-SNAPSHOT/rest/v2.0/api/people/'+id; + + return this.http.get(url) + .map(res => res.json()) + .map(res => res['result']['metadata']['oaf:entity']['oaf:person']) + .map(res => this.parsePersonInfo(res)); + + } + + private handleError (error: Response) { + // in a real world app, we may send the error to some remote logging infrastructure + // instead of just logging it to the console + console.error(error); + return Observable.throw(error || 'Server error'); + } + + parsePersonInfo (data: any):any { + console.info("parsePersonInfo"); + this.personInfo = new PersonInfo(); + + if(data != null) { + if(data.hasOwnProperty('firstname')) { + this.personInfo.firstname = data.firstname; + } + if(data.hasOwnProperty('secondnames')) { + this.personInfo.secondnames = data.secondnames; + } + if(data.hasOwnProperty('fullname')) { + this.personInfo.fullname = data.fullname; + } + } + + return this.personInfo; + + } + +}