From e1c520d65f45925585569550c7e142a68545e031 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 7 Jan 2022 12:16:23 +0200 Subject: [PATCH] [Library]: Altmetrics bug fix (more checks for previous commit) (from landing page with identifiers to landing page without: ERROR) | Updated parsing of relations in result landing page #7231. 1. result-preview.component.ts: Display relationName (added in beforeTitlte). 2. resultLandingInfo.ts: Added field "relatedResults" (replaced other structures for relations) and "relatedClassFilters". 3. resultLanding.component.html: a. In tab "Related research" show all relations. b. [Bug fix] Added check when accessing resultLandingInfo.identifiers for altmetrics. 4. resultLanding.module.ts: Import MatFormFieldModule and MatSelectModule for filtering relations in tab which shows all relations. 5. result-preview.ts: a. Added in class RelationResult "percentageName" (e.g. trust) and "relationName" (e.g. IsSupplementedBy) fields. b. Added in class ResultPreview "relationName" field (e.g. IsSupplementedBy). c. In method "relationResultConvert()", removed "relation" from parameters (included in RelationResult). 6. resultLanding.service.ts: a. Updated parsing of relations (parse all relations for research results). b. Updated sorting of relations. 7. resultLanding.component.ts: Handle updated relations and show them in one tab all together. 8. parsingFunctions.class.ts: Updated parsing of relations - parse all relations for results and keep the relationName and the percentageName. --- .../landing-utils/parsingFunctions.class.ts | 64 +++- .../result/resultLanding.component.html | 344 +++++++++++------- .../result/resultLanding.component.ts | 37 +- landingPages/result/resultLanding.module.ts | 4 +- landingPages/result/resultLanding.service.ts | 24 +- utils/entities/resultLandingInfo.ts | 68 +++- .../result-preview.component.ts | 6 + utils/result-preview/result-preview.ts | 8 +- 8 files changed, 395 insertions(+), 160 deletions(-) diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index 30eec877..d692e6af 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -425,7 +425,69 @@ export class ParsingFunctions { similarResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "similarity")); return similarResearchResults; } - + + parseResults(researchResults: RelationResult[], relation, provenanceAction: string): RelationResult[] { + if (researchResults == undefined) { + researchResults = []; + } + + let researchResult: RelationResult = { + name: "", + id: "", + date: "", + percentage: null, + percentageName: null, + class: "", + provenanceAction: provenanceAction, + relationName: "" + }; + + researchResult.relationName = relation.to.class; + + if(relation['resulttype']) { + if (relation['resulttype'].classname == "publication") { + researchResult['class'] = "publication"; + } else if (relation['resulttype'].classname == "dataset") { + researchResult['class'] = "dataset"; + } else if (relation['resulttype'].classname == "software") { + researchResult['class'] = "software"; + } else if (relation['resulttype'].classname == "other") { + researchResult['class'] = "other"; + } + } + researchResult['id'] = relation['to'].content; + let titleName = Array.isArray(relation['title']) ? relation['title'][0].content : (relation['title']?relation['title'].content:null); + researchResult['name'] = titleName; + if(!researchResult['name']) { + researchResult['name'] = "[no title available]"; + } + if (relation.hasOwnProperty("dateofacceptance")) { + var date: string = ((Array.isArray(relation.dateofacceptance)) ? (relation.dateofacceptance[0]) : (relation.dateofacceptance)) + ""; // transform to string in case it is an integer + researchResult['date'] = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date; + } + //researchResult['date'] = relation.dateofacceptance.substring(0,4);; + let percentageName: string; + if(relation.trust) { + percentageName = "trust"; + } else if(relation.similarity) { + percentageName = "similarity"; + } + if(percentageName) { + researchResult['percentage'] = Math.round(relation[percentageName] * 100); + researchResult['percentageName'] = percentageName; + } + researchResults.push(researchResult); + return researchResults; + } + + parseResearchResults(researchResults: RelationResult[], relation: any, percentageName: string = "trust"): RelationResult[] { + if (researchResults == undefined) { + researchResults = []; + } + researchResults.push(this.parseRelatedOrSimilarResearchResult(relation, percentageName)); + return researchResults; + } + // publication & dataset & software & orp landing : for relatedResearchResults and similarResearchResults parseRelatedOrSimilarResearchResult(relation: any, percentageName: string, provenanceAction: string = null): RelationResult { let researchResult: RelationResult = { diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index dd06f087..c8940683 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -146,7 +146,7 @@
- +
@@ -291,108 +291,185 @@ - -
-
-
-
Supplementary Outcomes
- - -
    -
  • - -
  • -
- - -
-
-
Outcomes Supplemented by this {{getTypeName()}}
- - -
    -
  • - -
  • -
- - -
-
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
{{header}}
+ + Filter by relation: + + All relations + {{relatedClass}} + + + + + + + + + + + + + + +
    +
  • + +
  • +
+ +
- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-
-
Related research
- - -
    -
  • - -
  • -
- - -
-
-
Similar Outcomes
- - -
    -
  • - -
  • -
- - -
+
-
@@ -476,18 +553,36 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + 0) { this.activeTab = 'references'; - } else if ((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) || - (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) { - this.activeTab = 'supplementary'; - } else if ((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) || - (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) { - this.activeTab = 'related'; + // } else if ((this.resultLandingInfo.supplementaryResearchResults && this.resultLandingInfo.supplementaryResearchResults.length > 0) || + // (this.resultLandingInfo.supplementedByResearchResults && this.resultLandingInfo.supplementedByResearchResults.length > 0)) { + // this.activeTab = 'supplementary'; + // } else if ((this.resultLandingInfo.relatedResearchResults && this.resultLandingInfo.relatedResearchResults.length > 0) || + // (this.resultLandingInfo.similarResearchResults && this.resultLandingInfo.similarResearchResults.length > 0)) { + // this.activeTab = 'related'; + } else if (this.resultLandingInfo.relatedResults && this.resultLandingInfo.relatedResults.length > 0) { + this.activeTab = "all_related"; } else if (this.resultLandingInfo.bioentities && this.bioentitiesNum > 0) { this.activeTab = 'bioentities'; } else if(this.enermapsId && this.properties.enermapsURL) { @@ -417,6 +422,10 @@ export class ResultLandingComponent { if(this.communityId && this.communityId == "enermaps" && properties.enermapsURL){ this.enermapsId = ParsingFunctions.getEnermapsConceptId(this.resultLandingInfo.contexts); } + + this.relatedClassSelected = ""; + this.filteredRelatedResults = this.resultLandingInfo.relatedResults; + this.showLoading = false; this.setActiveTab(); }, @@ -579,7 +588,7 @@ export class ResultLandingComponent { } public getResultPreview(result: RelationResult): ResultPreview { - return ResultPreview.relationResultConvert(result, this.relation); + return ResultPreview.relationResultConvert(result); } updateUrlWithType(pid) { @@ -675,10 +684,11 @@ export class ResultLandingComponent { || (resultLandingInfo.organizations && resultLandingInfo.organizations.length > 0) || resultLandingInfo.bioentities || (resultLandingInfo.references && resultLandingInfo.references.length > 0) - || (resultLandingInfo.relatedResearchResults && resultLandingInfo.relatedResearchResults.length > 0) - || (resultLandingInfo.similarResearchResults && resultLandingInfo.similarResearchResults.length > 0) - || (resultLandingInfo.supplementaryResearchResults && resultLandingInfo.supplementaryResearchResults.length > 0) - || (resultLandingInfo.supplementedByResearchResults && resultLandingInfo.supplementedByResearchResults.length > 0) + // || (resultLandingInfo.relatedResearchResults && resultLandingInfo.relatedResearchResults.length > 0) + // || (resultLandingInfo.similarResearchResults && resultLandingInfo.similarResearchResults.length > 0) + // || (resultLandingInfo.supplementaryResearchResults && resultLandingInfo.supplementaryResearchResults.length > 0) + // || (resultLandingInfo.supplementedByResearchResults && + || (resultLandingInfo.relatedResults && resultLandingInfo.relatedResults.length > 0) ) ); // console.log("rich content " + allow) @@ -754,4 +764,9 @@ export class ResultLandingComponent { public enrichContexts(contextsWithLink: any) { this.contextsWithLink = contextsWithLink; } + + public relatedClassChanged() { + this.relatedPage = 1; + this.filteredRelatedResults = this.resultLandingInfo.relatedResults.filter(result => !this.relatedClassSelected || result.relationName.toLowerCase() == this.relatedClassSelected.toLowerCase()); + } } diff --git a/landingPages/result/resultLanding.module.ts b/landingPages/result/resultLanding.module.ts index 901c02d8..486697c5 100644 --- a/landingPages/result/resultLanding.module.ts +++ b/landingPages/result/resultLanding.module.ts @@ -29,6 +29,8 @@ import {FeedbackModule} from "../feedback/feedback.module"; import {TabsModule} from "../../utils/tabs/tabs.module"; import {LoadingModule} from "../../utils/loading/loading.module"; import {OrcidModule} from "../../orcid/orcid.module"; +import {MatFormFieldModule} from "@angular/material/form-field"; +import {MatSelectModule} from "@angular/material/select"; @NgModule({ imports: [ @@ -37,7 +39,7 @@ import {OrcidModule} from "../../orcid/orcid.module"; MetricsModule, AltMetricsModule, Schema2jsonldModule, SEOServiceModule, DeletedByInferenceModule, ShowAuthorsModule, HelperModule, ResultLandingUtilsModule, AlertModalModule, AnnotationModule, LandingHeaderModule, NoLoadPaging, ResultPreviewModule, FeedbackModule, TabsModule, LoadingModule, - OrcidModule + OrcidModule, MatFormFieldModule, MatSelectModule ], declarations: [ ResultLandingComponent diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index 700be798..fdc27957 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -187,21 +187,19 @@ export class ResultLandingService { if(relation.hasOwnProperty("to")) { if(relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") { this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation, provenanceActionVocabulary); - } else if(relation['to'].class && relation['to'].class.toLowerCase() == "isrelatedto") { + } + if(relation['to'].scheme && relation['to'].scheme == "dnet:result_result_relations") { + let relationName = relation.to.class; + if(!this.resultLandingInfo.relatedClassFilters.has(relationName)) { + this.resultLandingInfo.relatedClassFilters.add(relationName); + } + 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); - } else if(relation['to'].class && relation['to'].class.toLowerCase() == "hasamongtopnsimilardocuments") { - this.resultLandingInfo.similarResearchResults = this.parsingFunctions.parseSimilarResearchResults(this.resultLandingInfo.similarResearchResults, relation); - } else if(relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") { - this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation); - } else if(relation['to'].class && relation['to'].class.toLowerCase() == "issupplementedby") { - this.resultLandingInfo.supplementaryResearchResults = this.parsingFunctions.parseSupplementaryResearchResults(this.resultLandingInfo.supplementaryResearchResults, relation); - } else if(relation['to'].class && relation['to'].class.toLowerCase() == "issupplementto") { - this.resultLandingInfo.supplementedByResearchResults = this.parsingFunctions.parseSupplementedByResearchResults(this.resultLandingInfo.supplementedByResearchResults, relation); + this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction); } } } @@ -395,10 +393,8 @@ export class ResultLandingService { return (item != undefined && item.fullName != undefined); }); } - this.resultLandingInfo.relatedResearchResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResearchResults); - this.resultLandingInfo.similarResearchResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.similarResearchResults); - this.resultLandingInfo.supplementaryResearchResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.supplementaryResearchResults); - this.resultLandingInfo.supplementedByResearchResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.supplementedByResearchResults); + + this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults); return this.resultLandingInfo; } diff --git a/utils/entities/resultLandingInfo.ts b/utils/entities/resultLandingInfo.ts index 561c9de4..d3158508 100644 --- a/utils/entities/resultLandingInfo.ts +++ b/utils/entities/resultLandingInfo.ts @@ -51,15 +51,65 @@ export class ResultLandingInfo { classifiedSubjects: Map; // showEgiNotebookButton: boolean = false; - // percentage is for trust - relatedResearchResults: RelationResult[]; - // percentage is for similarity - similarResearchResults: RelationResult[]; - //isSupplementedBy - supplementaryResearchResults: RelationResult[]; - //isSupplementTo - supplementedByResearchResults: RelationResult[]; - + // // percentage is for trust + // relatedResearchResults: RelationResult[]; + // // percentage is for similarity + // similarResearchResults: RelationResult[]; + // //isSupplementedBy + // supplementaryResearchResults: RelationResult[]; + // //isSupplementTo + // supplementedByResearchResults: RelationResult[]; + // + // // IsPartOf + // parentResearchResults: RelationResult[]; + // // HasPart + // childrenResearchResults: RelationResult[]; + // // Reviews + // reviewedByResearchResults: RelationResult[]; + // // IsReviewedBy + // reviewerResearchResults: RelationResult[]; + // // References + // referencedByResearchResults: RelationResult[]; + // // IsReferencedBy + // refererResearchResults: RelationResult[]; + // // IsIdenticalTo + // identicalResearchResults: RelationResult[]; + // // IsContinuedBy + // continuatorResearchResults: RelationResult[]; + // // Continues + // continuedByResearchResults: RelationResult[]; + // // IsDocumentedBy + // documentaryResearchResults: RelationResult[]; + // // Documents + // documentedByResearchResults: RelationResult[]; + // // IsCompiledBy + // compilerResearchResults: RelationResult[]; + // // Compiles + // compiledByResearchResults: RelationResult[]; + // // IsPreviousVersionOf + // newerResearchResults: RelationResult[]; + // // IsNewVersionOf + // previousResearchResults: RelationResult[]; + // // IsVersionOf + // versionedByResearchResults: RelationResult[]; + // // HasVersion + // isVersionResearchResults: RelationResult[]; + // // IsSourceOf + // derivedResearchResults: RelationResult[]; + // // IsDerivedFrom + // sourceResearchResults: RelationResult[]; + // // IsVariantFormOf + // originalResearchResults: RelationResult[]; + // // IsOriginalFormOf + // variantResearchResults: RelationResult[]; + // // IsObsoletedBy + // obsoleteResearchResults: RelationResult[]; + // // Obsolete + // obsoletedByResearchResults: RelationResult[]; + + relatedResults: RelationResult[]; + relatedClassFilters: Set = new Set(); + contexts: { "labelContext": string, "idContext": string, "labelCategory": string, "idCategory": string, "labelConcept": string, "idConcept": string}[]; diff --git a/utils/result-preview/result-preview.component.ts b/utils/result-preview/result-preview.component.ts index 0f2eca11..f27706df 100644 --- a/utils/result-preview/result-preview.component.ts +++ b/utils/result-preview/result-preview.component.ts @@ -112,6 +112,12 @@ export class ResultPreviewComponent implements OnInit, OnChanges { if(this.result.provenanceAction) { this.beforeTitle.push(this.result.provenanceAction); } + if(this.result.relationName) { + this.beforeTitle.push(this.result.relationName); + } + // if(this.result.percentage) { + // this.beforeTitle.push((this.result.relation ? this.result.relation+": " : "") + this.result.percentage.toString() + "%"); + // } } public getTypeName(type: string): string { diff --git a/utils/result-preview/result-preview.ts b/utils/result-preview/result-preview.ts index b1d5d860..a3de23c5 100644 --- a/utils/result-preview/result-preview.ts +++ b/utils/result-preview/result-preview.ts @@ -28,8 +28,10 @@ export interface RelationResult { id: string; date: string; percentage: number; + percentageName?: string; class: string provenanceAction?: string; + relationName?: string; } export interface Project { @@ -131,6 +133,7 @@ export class ResultPreview { types: string[]; // Relation result + relationName: string; relation: string; percentage: number; provenanceAction: string; @@ -217,7 +220,7 @@ export class ResultPreview { return resultPreview; } - public static relationResultConvert(result: RelationResult, relation: string = 'trust'): ResultPreview { + public static relationResultConvert(result: RelationResult): ResultPreview { let resultPreview: ResultPreview = new ResultPreview(); resultPreview.id = result.id; resultPreview.title = result.name; @@ -225,7 +228,8 @@ export class ResultPreview { if(result.date) { resultPreview.year = result.date.toString(); } - resultPreview.relation = relation; + resultPreview.relationName = result.relationName; + resultPreview.relation = result.percentageName; resultPreview.percentage = result.percentage; resultPreview.provenanceAction = result.provenanceAction; return resultPreview;