From 0a78e4e143367b9d18c4d829fa7797c03a385332 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 29 Jun 2016 13:25:51 +0000 Subject: [PATCH] Adding components for landing pages of project + publication and the services git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@43062 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/entities/projectInfo.ts | 15 + src/app/entities/publicationInfo.ts | 21 + .../landingPages/project/project.component.ts | 89 ++++ .../publication/publication.component.ts | 186 ++++++++ src/app/services/project.service.ts | 102 ++++ src/app/services/publication.service.ts | 449 ++++++++++++++++++ 6 files changed, 862 insertions(+) create mode 100644 src/app/entities/projectInfo.ts create mode 100644 src/app/entities/publicationInfo.ts create mode 100644 src/app/landingPages/project/project.component.ts create mode 100644 src/app/landingPages/publication/publication.component.ts create mode 100644 src/app/services/project.service.ts create mode 100644 src/app/services/publication.service.ts diff --git a/src/app/entities/projectInfo.ts b/src/app/entities/projectInfo.ts new file mode 100644 index 00000000..17ff7c69 --- /dev/null +++ b/src/app/entities/projectInfo.ts @@ -0,0 +1,15 @@ +export class ProjectInfo { + acronym: string; + title: string; + callIdentifier: string; + funder: string; + funding: string; + contractNum: string; + startDate: string; + endDate: string; + openAccessMandate: string; + specialClause39: string; + organizations: string[]; + url: string; + urlInfo: string; +} diff --git a/src/app/entities/publicationInfo.ts b/src/app/entities/publicationInfo.ts new file mode 100644 index 00000000..a1cfd63e --- /dev/null +++ b/src/app/entities/publicationInfo.ts @@ -0,0 +1,21 @@ +export class PublicationInfo { + title: string; + authors: string[]; + date: string; + types: string[]; + downloadFrom: Map; + bioentities: Map>; + identifiers: Map; + publisher: string; + journal: string; + languages: string[]; + subjects: string[]; + classifiedSubjects: Map; + description: string; + bestlicense: string; + collectedFrom: Map; + fundedByProjects: Map; + relatedResearchData: Map;//{ [key: string]: string }[]; + similarPublications: Map;//{ [key: string]: string }[]; + references: { [key: string]: string }[]; +} diff --git a/src/app/landingPages/project/project.component.ts b/src/app/landingPages/project/project.component.ts new file mode 100644 index 00000000..a2cc50f2 --- /dev/null +++ b/src/app/landingPages/project/project.component.ts @@ -0,0 +1,89 @@ +import {Component} from '@angular/core'; +import {JSONP_PROVIDERS} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import { RouteParams } from '@angular/router-deprecated'; +import {ProjectService} from '../../services/project.service'; +import {ProjectInfo} from '../../entities/projectInfo'; + +@Component({ + selector: 'project', + template: ` + +
+

{{projectInfo.acronym}}

+

+ Title + {{projectInfo.title}} +

+

+ Funding + {{projectInfo.funding}} +

+

+ Call + {{projectInfo.callIdentifier}} +

+

+ Contract (GA) number + {{projectInfo.contractNum}} +

+

+ Start Date + {{projectInfo.startDate}} +

+

+ End Date + {{projectInfo.endDate}} +

+

+ Open Access mandate + {{projectInfo.openAccessMandate}} +

+

+ Special Clause 39 + {{projectInfo.specialClause39}} +

+

+ Organizations + {{projectInfo.organizations}} +

+

+ More information + {{projectInfo.urlInfo}} +

+ +
+ + `, + providers:[JSONP_PROVIDERS, ProjectService] +}) +export class ProjectComponent { + constructor (private _projectService: ProjectService, + private _routeParams: RouteParams) { + console.info('project constructor'); + this.params = _routeParams; + } + ngOnInit() { + console.info('project init'); + this.getProjectInfo(); +} + + results : String[]; + orcidresults : String[]; + resultsNum : number ; + + projectInfo: ProjectInfo; + params: RouteParams; + + getProjectInfo () { + console.info("inside getProjectInfo of component"); + + this._projectService.getProjectInfo(this.params.get('projectId')).subscribe( + data => { + this.projectInfo = data; + }, + err => console.error(err) + ); + } + +} diff --git a/src/app/landingPages/publication/publication.component.ts b/src/app/landingPages/publication/publication.component.ts new file mode 100644 index 00000000..ea917d5c --- /dev/null +++ b/src/app/landingPages/publication/publication.component.ts @@ -0,0 +1,186 @@ +import {Component} from '@angular/core'; +import {JSONP_PROVIDERS} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {PublicationService} from '../../services/publication.service'; +import {PublicationInfo} from '../../entities/publicationInfo'; + +import { RouteParams} from '@angular/router-deprecated'; + +@Component({ + selector: 'publication', + //directives: [...ROUTER_DIRECTIVES], + template: ` + +
+ +

{{publicationInfo.title}}

+ +

+ {{publicationInfo.authors}} ({{publicationInfo.date}}) +

+
+ +
Publisher:
+ {{publicationInfo.publisher}} + +
+
+ +
Journal:
+ {{publicationInfo.journal}} + +
+
+ +
Languages:
+ {{publicationInfo.languages}} + +
+
+
Types:
+ {{publicationInfo.types}} +
+
+ +
Subjects:
+ {{publicationInfo.subjects}} +
+
+
Identifiers:
+ + {{key}}: {{publicationInfo.identifiers.get(key)}} + +
+
+ + {{publicationInfo.description}} + +
+ + + + +
+
+

REFERENCES

+ +
+

+ + {{item['text']}} + +

+

+ {{item['text']}} +

+ +
+ +
+
+

dataTab

+ + + + + + + + + + + + + + + + + + + +
+ +
+

similarTab

+

Some content in similarTab.

+
+
+

YO men

+
+ + + + + + + +
+ + `, + providers:[JSONP_PROVIDERS, PublicationService] +}) +export class PublicationComponent { + constructor (private _publicationService: PublicationService, private _routeParams: RouteParams) { + console.info('publication constructor'); + this.params = _routeParams; + } + ngOnInit() { + console.info('publication init'); + this.getPublicationInfo(); +} + + results : String[]; + orcidresults : String[]; + resultsNum : number ; + + publicationInfo: PublicationInfo; + params: RouteParams; + + getPublicationInfo() { + console.info("inside getPublicationInfo of component"); + + this._publicationService.getPublicationInfo(this.params.get("articleId")).subscribe( + data => { + this.publicationInfo = data; + }, + err => console.error(err) + ); + } + +} diff --git a/src/app/services/project.service.ts b/src/app/services/project.service.ts new file mode 100644 index 00000000..1e5bfff9 --- /dev/null +++ b/src/app/services/project.service.ts @@ -0,0 +1,102 @@ +import {Injectable} from '@angular/core'; +import {Http, Response} from '@angular/http'; +import {Observable} from 'rxjs/Observable'; +import {ProjectInfo} from '../entities/projectInfo'; + +@Injectable() +export class ProjectService { + + constructor(private http: Http) {} + + projectInfo: ProjectInfo; + + getProjectInfo (id: string):any { + console.info("getProjectInfo 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; + + return this.http.get(url) + .map(res => res.json()) + .map(res => [res['result']['metadata']['oaf:entity']['oaf:project'], + res['result']['metadata']['oaf:entity']['oaf:project']['fundingtree'], + res['result']['metadata']['oaf:entity']['oaf:project']['rels']['rel']]) + .map(res => this.parseProjectInfo(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'); + } + + parseProjectInfo (data: any):any { + this.projectInfo = new ProjectInfo(); + + if(data[0] != null) { + this.projectInfo.acronym = data[0].acronym; + this.projectInfo.title = data[0].title; + this.projectInfo.callIdentifier = data[0].callidentifier; + this.projectInfo.contractNum = data[0].code; + this.projectInfo.startDate = data[0].startdate; + this.projectInfo.endDate = data[0].enddate; + this.projectInfo.openAccessMandate = data[0].oamandatepublications; + this.projectInfo.specialClause39 = data[0].ecsc39; + } + if(data[1] != null) { + if(data[1]['funder'] != null) { + this.projectInfo.funder = data[1]['funder'].shortname; + } + + let funding; + this.projectInfo.funding = ""; + + if(data[1]['funding_level_2'] != null) { + funding = data[1]['funding_level_2'].id; + } else if(data[1]['funding_level_1'] != null) { + funding = data[1]['funding_level_1'].id; + } else if(data[1]['funding_level_0'] != null) { + funding = data[1]['funding_level_0'].id; + } + + if(funding != undefined) { + funding = funding.split("::"); + for(let i=1; i(); + + if(data[2].hasOwnProperty("legalshortname")) { + this.projectInfo.organizations[0] = data[2].legalshortname; + } else if(data[2].hasOwnProperty("legalname")) { + this.projectInfo.organizations[0] = data[2].legalname; + } else { + for(let i=0; i res.json()) + .do(res => console.info(res['result']['metadata']['oaf:entity'])) + .do(res => console.info(res['result']['metadata']['oaf:entity']['oaf:result']['children']['instance'])) + .map(res => [res['result']['metadata']['oaf:entity']['oaf:result'], + res['result']['metadata']['oaf:entity']['oaf:result']['title'], + res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel'], + res['result']['metadata']['oaf:entity']['oaf:result']['children'], + res['result']['metadata']['oaf:entity']['oaf:result']['pid'], + res['result']['metadata']['oaf:entity']['oaf:result']['journal'], + res['result']['metadata']['oaf:entity']['oaf:result']['language'], + res['result']['metadata']['oaf:entity']['oaf:result']['subject'], + res['result']['metadata']['oaf:entity']['oaf:result']['bestlicense'], + res['result']['metadata']['oaf:entity']['oaf:result']['collectedfrom'], + res['result']['metadata']['oaf:entity']['extraInfo']['citations']['citation'] + ]) + .map(res => this.parsePublicationInfo(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'); + } + + parsePublicationInfo (data: any):any { + this.publicationInfo = new PublicationInfo(); + + if(data[0] != null) { + this.publicationInfo.date = data[0].dateofacceptance.substring(0,4); + this.publicationInfo.publisher = data[0].publisher; + this.publicationInfo.description = data[0].description; + } + + if(data[1] != null) { + this.publicationInfo.title = data[1].content; + } + + if(data[2] != null) { + let mydata; + let funding; + 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.publicationInfo.authors == undefined) { + this.publicationInfo.authors = new Array(); + } + this.publicationInfo.authors[mydata.ranking-1] = mydata.fullname; + } else if(mydata['to'].class == "isProducedBy") { + if(this.publicationInfo.fundedByProjects == undefined) { + this.publicationInfo.fundedByProjects = new Map(); + } + + this.publicationInfo.fundedByProjects.set(mydata.code, new Array()); + this.publicationInfo.fundedByProjects.get(mydata.code)[0] = mydata.acronym; + this.publicationInfo.fundedByProjects.get(mydata.code)[1] = mydata.title; + if(mydata.hasOwnProperty("funding")) { + if(mydata['funding'].hasOwnProperty("funder")) { + this.publicationInfo.fundedByProjects.get(mydata.code)[2] = mydata['funding']['funder'].shortname; + this.publicationInfo.fundedByProjects.get(mydata.code)[3] = mydata['funding']['funder'].name; + } + if(mydata['funding'].hasOwnProperty("funding_level_2")) { + funding = mydata['funding']['funding_level_2'].content; + //this.publicationInfo.fundedByProjects.get(mydata.code)[4] = mydata['funding']['funding_level_2'].content; + } else if(mydata['funding'].hasOwnProperty("funding_level_1")) { + funding = mydata['funding']['funding_level_1'].content; + //this.publicationInfo.fundedByProjects.get(mydata.code)[4] = mydata['funding']['funding_level_1'].content; + } else if(mydata['funding'].hasOwnProperty("funding_level_0")) { + funding = mydata['funding']['funding_level_0'].content; + //this.publicationInfo.fundedByProjects.get(mydata.code)[4] = mydata['funding']['funding_level_0'].content; + } + + if(funding != undefined) { + funding = funding.split("::"); + this.publicationInfo.fundedByProjects.get(mydata.code)[4] = funding[1]; + + for(let i=2; i();//Array<{}>(); + } + /* + this.publicationInfo.relatedResearchData[counter] = {}; + this.publicationInfo.relatedResearchData[counter]['title'] = mydata['title'].content; + this.publicationInfo.relatedResearchData[counter]['year'] = mydata.dateofacceptance.substring(0,4); + this.publicationInfo.relatedResearchData[counter]['trust'] = Math.round(mydata.trust*100)+"%"; + let link = "https://beta.openaire.eu/search/publication?articleId="; + this.publicationInfo.relatedResearchData[counter]['link'] = link+mydata['to'].content; + + counter++; + */ + + let url = "https://beta.openaire.eu/search/publication?articleId="+mydata['to'].content; + this.publicationInfo.relatedResearchData.set(url, new Array()); + this.publicationInfo.relatedResearchData.get(url)[0] = mydata['title'].content; + this.publicationInfo.relatedResearchData.get(url)[1] = mydata.dateofacceptance.substring(0,4); + this.publicationInfo.relatedResearchData.get(url)[2] = Math.round(mydata.trust*100)+"%"; + + } else if(mydata['to'].class == "hasAmongTopNSimilarDocuments") { + if(this.publicationInfo.similarPublications == undefined) { + this.publicationInfo.similarPublications = new Map(); + } + + let url = "https://beta.openaire.eu/search/publication?articleId="+mydata['to'].content; + this.publicationInfo.similarPublications.set(url, new Array()); + this.publicationInfo.similarPublications.get(url)[0] = mydata['title'].content; + this.publicationInfo.similarPublications.get(url)[1] = mydata.dateofacceptance.substring(0,4); + this.publicationInfo.similarPublications.get(url)[2] = Math.round(mydata.trust*100)+"%"; + } + } + } + + + //for(let i in this.publicationInfo.relatedResearchData) { + // for(let key in this.publicationInfo.relatedResearchData[i]) { + // console.info(key+" : "+this.publicationInfo.relatedResearchData[i][key]); + // } + //} + + } + + if(data[3] != null) { + if(data[3].hasOwnProperty("instance")) { + this.publicationInfo.downloadFrom = new Map(); + this.publicationInfo.types = new Array(); + + let length = data[3]['instance'].length!=undefined ? data[3]['instance'].length : 1; + + let types = new Set(); + let counter = 0; + let mydata; + for(let i=0; i 1 ? data[3]['instance'][i] : data[3]['instance']; + + if(mydata.hasOwnProperty("instancetype")) { + if(!types.has(mydata['instancetype'].classname)) { + this.publicationInfo.types[counter] = mydata['instancetype'].classname; + types.add(mydata['instancetype'].classname); + counter++; + } + } + if(!this.publicationInfo.downloadFrom.has(mydata.id)) { + this.publicationInfo.downloadFrom.set(mydata.id, new Array()); + } + + if(mydata.hasOwnProperty("licence")) { + this.publicationInfo.downloadFrom.get(mydata.id)[0] = mydata['licence'].classid; + } + if(mydata.hasOwnProperty("hostedby")) { + this.publicationInfo.downloadFrom.get(mydata.id)[1] = mydata['hostedby'].name; + } + if(mydata.hasOwnProperty("webresource")) { + this.publicationInfo.downloadFrom.get(mydata.id)[2] = mydata['webresource'].url; + } + } + } + + if(data[3].hasOwnProperty("externalreference")) { + this.publicationInfo.bioentities = new Map>(); + + let length = data[3]['externalreference'].length!=undefined ? data[3]['externalreference'].length : 1; + + let mydata; + for(let i=0; i 1 ? data[3]['externalreference'][i] : data[3]['externalreference']; + + if(!this.publicationInfo.bioentities.has(mydata.sitename)) { + this.publicationInfo.bioentities.set(mydata.sitename, new Map()); + } + this.publicationInfo.bioentities.get(mydata.sitename).set(mydata.refidentifier, mydata.url); + } + } + } + + if(data[4] != null) { + this.publicationInfo.identifiers = new Map(); + + if(data[4].hasOwnProperty("classname")) { + this.publicationInfo.identifiers.set(data[4].classname, data[4].content); + } else { + for(let i=0; i(); + + if(data[6].hasOwnProperty("classname")) { + this.publicationInfo.languages[0] = data[6].classname; + } else { + for(let i=0; i(); + this.publicationInfo.subjects = new Array(); + + let mydata; + let length = data[7].length!=undefined ? data[7].length : 1; + + for(let i=0; i 1 ? data[7][i] : data[7]; + + if(mydata.inferred == true) { + if(!this.publicationInfo.classifiedSubjects.has(mydata.classid)) { + this.publicationInfo.classifiedSubjects.set(mydata.classid, new Array()); + } + + let counter = this.publicationInfo.classifiedSubjects.get(mydata.classid).length; + this.publicationInfo.classifiedSubjects.get(mydata.classid)[counter] = mydata.content; + } else { + let counter = this.publicationInfo.subjects.length; + this.publicationInfo.subjects[counter] = mydata.content; + } + + } + } + + if(data[8] != null) { + this.publicationInfo.bestlicense = data[8].classid; + } + + if(data[9] != null) { + this.publicationInfo.collectedFrom = new Map(); + + let mydata; + let length = data[9].length!=undefined ? data[9].length : 1; + for(let i=0; i 1 ? data[9][i] : data[9]; + let link = "https://beta.openaire.eu/search/dataprovider?datasourceId="; + this.publicationInfo.collectedFrom.set(mydata.name, link+mydata.id); + } + } + + if(this.publicationInfo.journal != null + && this.publicationInfo.identifiers != null + && this.publicationInfo.identifiers.has("doi")) { + + if( this.publicationInfo.downloadFrom == null) { + this.publicationInfo.downloadFrom = new Map(); + } + + let doi = this.publicationInfo.identifiers.get("doi"); + if(!this.publicationInfo.downloadFrom.has(doi)) { + this.publicationInfo.downloadFrom.set(doi, new Array()); + } + + this.publicationInfo.downloadFrom.get(doi)[0] = ""; + this.publicationInfo.downloadFrom.get(doi)[1] = this.publicationInfo.publisher+"/ "+this.publicationInfo.journal; + this.publicationInfo.downloadFrom.get(doi)[2] = "http://dx.doi.org/"+doi; + } + + if(data[10] != null) { + this.publicationInfo.references = /*{};*/new Array<{[key: string]: string}>(); + + let mydata; + let length = data[10].length!=undefined ? data[10].length : 1; + for(let i=0; i 1 ? data[10][i] : data[10]; + + let url; + if(mydata.hasOwnProperty("id")) { + let mydata1; + let length1 = mydata['id'].length!=undefined ? mydata['id'].length : 1; + for(let j=0; j 1 ? mydata['id'][j] : mydata['id']; + + if(mydata1.type == "pmid") { + url = "http://www.ncbi.nlm.nih.gov/pubmed/"+mydata1.value; + } + } + } + + this.publicationInfo.references[mydata.position-1] = {}; + this.publicationInfo.references[mydata.position-1]['text'] = mydata.rawText; + this.publicationInfo.references[mydata.position-1]['url'] = url; + } + } + + this.printPublicationInfo(); + return this.publicationInfo; + + } + + printPublicationInfo() { + console.info("DATE: "+this.publicationInfo.date); + console.info("PUBLISHER: "+this.publicationInfo.publisher); + console.info("DESCRIPTION: "+this.publicationInfo.description); + + console.info("TITLE: "+this.publicationInfo.title); + + console.info("AUTHORS: "+this.publicationInfo.authors); + console.info("\nFUNDED BY PROJECTS:"); + if(this.publicationInfo.fundedByProjects != undefined) { + this.publicationInfo.fundedByProjects.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + /*for(let i in this.publicationInfo.relatedResearchData) { + for(let key in this.publicationInfo.relatedResearchData[i]) { + console.info(key+" : "+this.publicationInfo.relatedResearchData[i][key]); + } + }*/ + console.info("\nRELATED RESEARCH DATA:"); + if(this.publicationInfo.relatedResearchData != undefined) { + this.publicationInfo.relatedResearchData.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nSIMILAR PUBLICATIONS:"); + if(this.publicationInfo.similarPublications != undefined) { + this.publicationInfo.similarPublications.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("TYPES: "+this.publicationInfo.types); + console.info("\nDOWNLOAD FROM:"); + if(this.publicationInfo.downloadFrom != undefined) { + this.publicationInfo.downloadFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + console.info("\nBIOENTITIES:"); + if(this.publicationInfo.bioentities != undefined) { + this.publicationInfo.bioentities.forEach(function (value, key, map) { + value.forEach(function (value1, key1, map1) { + console.info(key + " = " + key1 + " = " + value1); + }) + }) + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nIDENTIFIERS:"); + if(this.publicationInfo.identifiers != undefined) { + this.publicationInfo.identifiers.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("JOURNAL: "+this.publicationInfo.journal); + + + console.info("LANGUAGES: "+this.publicationInfo.languages); + + + console.info("SUBJECTS: "+this.publicationInfo.subjects); + console.info("\nCLASSIFIED OBJECTS:"); + if(this.publicationInfo.classifiedSubjects != undefined) { + this.publicationInfo.classifiedSubjects.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("BEST LICENSE: "+this.publicationInfo.bestlicense); + + console.info("\nCOLLECTED FROM:"); + if(this.publicationInfo.collectedFrom != undefined) { + this.publicationInfo.collectedFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nDOWNLOAD FROM:"); + if(this.publicationInfo.downloadFrom != undefined) { + this.publicationInfo.downloadFrom.forEach(function (value, key, map) { + console.info(key + " = " + value); + }); + } else { + console.info("undefined"); + } + console.info("\n"); + + console.info("\nREFERENCES:"); + if(this.publicationInfo.references != undefined) { + for(let i in this.publicationInfo.references) { + for(let key in this.publicationInfo.references[i]) { + console.info(key+" : "+this.publicationInfo.references[i][key]); + } + } + } else { + console.info("undefined"); + } + } + +}