From 93f9b9ef7df1a0af0c5d68991e747f6613c13ad1 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 9 Oct 2019 13:28:23 +0000 Subject: [PATCH] [Trunk | Library]: 1. resultLandingInfo.ts: Remove 'projectsProvenanceVocabulary' and 'researchResultsProvenanceVocabulary' - vocabulary API is used now. 2. resultLanding.service.ts: Create method 'getProvenanceActionVocabulary()' to get provenance action term from vocabulary and use it in 'parseResultLandingInfo()'. 3. resultLanding.component.ts: Before the request of 'ResultLandingInfo', request 'provenance action terms' from vocabulary API. 4. fundedBy.component.ts: Add provenance action label as is in tooltip & add class 'uk-light' in tooltip & use 'uk-text-small' instead of 'uk-text-meta' for provenance label. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57330 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../landing-utils/fundedBy.component.ts | 17 ++++------ .../landing-utils/parsingFunctions.class.ts | 7 ++-- .../result/resultLanding.component.ts | 18 ++++++++-- landingPages/result/resultLanding.service.ts | 34 +++++++++++++------ utils/entities/resultLandingInfo.ts | 22 ------------ 5 files changed, 48 insertions(+), 50 deletions(-) diff --git a/landingPages/landing-utils/fundedBy.component.ts b/landingPages/landing-utils/fundedBy.component.ts index 9cb60767..f5e78cff 100644 --- a/landingPages/landing-utils/fundedBy.component.ts +++ b/landingPages/landing-utils/fundedBy.component.ts @@ -79,10 +79,10 @@ export class FundedByComponent { public buildFundingTooltip(item: { "id": string, "acronym": string, "title": string, "funderShortname": string, "funderName": string, "funding": string, "code": string, "provenanceAction": string, inline: boolean}) { - let tooltipContent: string = "
"; + let tooltipContent: string = "
"; if(item.title) { - tooltipContent += "
"+item.title+"
"; + tooltipContent += "

"+item.title+"

"; } if(item.code || item.funderName || item.funderShortname || item.funding) { @@ -111,16 +111,11 @@ export class FundedByComponent { if(item.code || item.funderName || item.funderShortname || item.funding) { tooltipContent += "

"; } - tooltipContent += ""; - if(item.provenanceAction == 'Repository') { - tooltipContent += "Link provided by Repository"; - } else if(item.provenanceAction == 'OpenAIRE') { - tooltipContent += "Link inferred by OpenAIRE"; - } else if(item.provenanceAction == 'USer') { - tooltipContent += "Link claimed by User"; - } + tooltipContent += ""; + tooltipContent += item.provenanceAction; tooltipContent += ""; - tooltipContent+="
" + tooltipContent+="
"; + return tooltipContent; } diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index c08f37f7..4b75a72b 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -10,7 +10,7 @@ export class ParsingFunctions { "funding": string, "code": string, "provenanceAction": string, "inline": boolean }[], - relation: any, projectsProvenanceVocabulary: any): + relation: any, provenanceActionVocabulary: any): { "id": string, "acronym": string, "title": string, "funderShortname": string, "funderName": string, "funding": string, "code": string, @@ -39,8 +39,8 @@ export class ParsingFunctions { fundedByProject['title'] = relation.title; fundedByProject['code'] = relation.code; - if(relation.provenanceaction in projectsProvenanceVocabulary) { - fundedByProject['provenanceAction'] = projectsProvenanceVocabulary[relation.provenanceaction]; + if(provenanceActionVocabulary != null && relation.provenanceaction in provenanceActionVocabulary) { + fundedByProject['provenanceAction'] = provenanceActionVocabulary[relation.provenanceaction]; } } else { fundedByProject['id'] = ""; @@ -535,7 +535,6 @@ export class ParsingFunctions { contexts[position]['labelCategory'] = category.label; contexts[position]['labelConcept'] = null; position++; - console.info(contexts); } } } else { diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index 83a2d590..7c70f95e 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -134,7 +134,7 @@ export class ResultLandingComponent { this.metricsClicked = false; if (this.id) { - this.getResultLandingInfo(this.id); + this.getProvenanceVocabularyAndResultLandingInfo(); } else { this.showLoading = false; @@ -192,14 +192,26 @@ export class ResultLandingComponent { ); } - private getResultLandingInfo(id: string) { + private getProvenanceVocabularyAndResultLandingInfo() { this.warningMessage = ''; this.errorMessage = ''; this.showLoading = true; this.resultLandingInfo = null; - this.infoSub = this._resultLaningService.getResultLandingInfo(this.id, this.type, this.properties).subscribe( + this._resultLaningService.getProvenanceActionVocabulary(this.properties).subscribe( + provenanceActionVocabulary => { + this.getResultLandingInfo(provenanceActionVocabulary); + }, err => { + this.getResultLandingInfo(null); + this.handleError("Error getting provenance action vocabulary for "+this.type+" with id: " + this.id, err); + } + ); + + } + + private getResultLandingInfo(provenanceActionVocabulary: any) { + this.infoSub = this._resultLaningService.getResultLandingInfo(this.id, this.type, provenanceActionVocabulary, this.properties).subscribe( data => { this.resultLandingInfo = data; this.seoService.createLinkForCanonicalURL(this.properties.baseLink + this.linkToLandingPage + this.resultLandingInfo.record["result"]["header"]["dri:objIdentifier"]); diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index dc35b1df..9af7c624 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -4,7 +4,7 @@ import {throwError} from 'rxjs'; import {ResultLandingInfo} from '../../utils/entities/resultLandingInfo'; import {EnvProperties} from '../../utils/properties/env-properties'; import {ParsingFunctions} from '../landing-utils/parsingFunctions.class'; -import {map} from "rxjs/operators"; +import {map, tap} from "rxjs/operators"; @Injectable() export class ResultLandingService { @@ -16,7 +16,7 @@ export class ResultLandingService { public parsingFunctions: ParsingFunctions; resultLandingInfo: ResultLandingInfo; - getResultLandingInfo (id: string, type: string, properties: EnvProperties): any { + getResultLandingInfo (id: string, type: string, provenanceActionVocabulary: any, properties: EnvProperties): any { let url = properties.searchAPIURLLAst; if (type === 'publication') { url += 'publications/'; @@ -50,7 +50,23 @@ export class ResultLandingService { res[0], // 13 res[2] // 14 ])) - .pipe(map(res => this.parseResultLandingInfo(res, properties))); + .pipe(map(res => this.parseResultLandingInfo(res, provenanceActionVocabulary, properties))); + } + + getProvenanceActionVocabulary (properties: EnvProperties): any { + let url = properties.vocabulariesAPI+"dnet:provenanceActions.json"; + + return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) + .pipe(map(res => res['terms'])) + .pipe(map(res => this.parseProvenanceActionVocabulary(res, properties))); + } + + parseProvenanceActionVocabulary(terms: any, properties: EnvProperties) { + var provenanceActionVocabulary: {} = {}; + for(let term of terms) { + provenanceActionVocabulary[term.code] = term.englishName; + } + return provenanceActionVocabulary; } private handleError (error: HttpErrorResponse) { @@ -60,7 +76,7 @@ export class ResultLandingService { return throwError(error || 'Server error'); } - parseResultLandingInfo (data: any, properties: EnvProperties): any { + parseResultLandingInfo (data: any, provenanceActionVocabulary: any, properties: EnvProperties): any { this.resultLandingInfo = new ResultLandingInfo(); // res @@ -105,13 +121,11 @@ export class ResultLandingService { relation = Array.isArray(data[2]) ? data[2][i] : data[2]; if(relation.hasOwnProperty("to")) { if(relation['to'].class == "isProducedBy") { - this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation, this.resultLandingInfo.projectsProvenanceVocabulary); + this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation, provenanceActionVocabulary); } else if(relation['to'].class == "isRelatedTo") { - let provenanceAction: string; - if(relation.provenanceaction in this.resultLandingInfo.researchResultsProvenanceVocabulary) { - provenanceAction = this.resultLandingInfo.researchResultsProvenanceVocabulary[relation.provenanceaction]; - } else { - provenanceAction = "Other"; + let provenanceAction: string = ""; + if(provenanceActionVocabulary != null && relation.provenanceaction in provenanceActionVocabulary) { + provenanceAction = provenanceActionVocabulary[relation.provenanceaction]; } this.resultLandingInfo.relatedResearchResults = this.parsingFunctions.parseRelatedResearchResults(this.resultLandingInfo.relatedResearchResults, relation, provenanceAction); diff --git a/utils/entities/resultLandingInfo.ts b/utils/entities/resultLandingInfo.ts index a8a4b059..faec1721 100644 --- a/utils/entities/resultLandingInfo.ts +++ b/utils/entities/resultLandingInfo.ts @@ -20,25 +20,6 @@ export class ResultLandingInfo { "accessMode": string[], "bestAccessMode": string, "type": string, "year":string}[]; - projectsProvenanceVocabulary: { "sysimport:crosswalk:repository": string, - "sysimport:crosswalk:entityregistry": string, - "sysimport:crosswalk:datasetarchive": string, - "iis": string, - "sysimport:mining:repository": string, - "user:claim:pid": string, - "user:claim:search": string, - "user:claim:datacite": string - } = { - "sysimport:crosswalk:repository": "Repository", - "sysimport:crosswalk:entityregistry": "Repository", - "sysimport:crosswalk:datasetarchive": "Repository", - "iis": "OpenAIRE", - "sysimport:mining:repository": "OpenAIRE", - "user:claim:pid": "User", - "user:claim:search": "User", - "user:claim:datacite": "User" - }; - fundedByProjects: { "id": string, "acronym": string, "title": string, "funderShortname": string, "funderName": string, "funding": string, "code": string, "provenanceAction": string, "inline": boolean}[]; @@ -53,9 +34,6 @@ export class ResultLandingInfo { otherSubjects: Map; classifiedSubjects: Map; // - researchResultsProvenanceVocabulary: {"iis": string, "sysimport": string, "user": string} = - {"iis": "Inferred", "sysimport": "Harvested", "user": "Claimed"}; - // percentage is for trust relatedResearchResults: Map; // percentage is for similarity