From 65a60ddad12498a410a1779ad3c234f9fef24507 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Wed, 29 May 2024 13:05:04 +0300 Subject: [PATCH] [Develop | ADDED]: Add belongsTo configuration for all entities and initialize it in results. --- .../landing-utils/parsingFunctions.class.ts | 14 +- .../result/resultLanding.component.html | 6 +- .../result/resultLanding.component.ts | 4 +- utils/entities/dataProviderInfo.ts | 357 +++++++++--------- utils/entities/organizationInfo.ts | 2 + utils/entities/projectInfo.ts | 13 +- utils/entities/resultLandingInfo.ts | 88 +++-- utils/result-preview/result-preview.ts | 1 + 8 files changed, 274 insertions(+), 211 deletions(-) diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index 00e90aa8..961c9209 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -39,7 +39,7 @@ export class ParsingFunctions { let fundedByProject: Project = { "id": "", "acronym": "", "title": "", - "funderShortname": "", "funderName": "", + "funderShortname": "", "funderName": "", "funderJurisdiction": "", "funding": "", "code": "", "provenanceAction": "", "validated": false }; @@ -61,8 +61,7 @@ export class ParsingFunctions { } if (relation.hasOwnProperty("funding")) { - let funding: { "funderName": string, "funderShortname": string, "stream": string }; - funding = this.parseFundingTrees(relation.funding); + let funding = this.parseFundingTrees(relation.funding); if (funding.funderName) { fundedByProject['funderName'] = funding.funderName; @@ -70,6 +69,9 @@ export class ParsingFunctions { if (funding.funderShortname) { fundedByProject['funderShortname'] = funding.funderShortname; } + if(funding.funderJurisdiction) { + fundedByProject['funderJurisdiction'] = funding.funderJurisdiction; + } if (funding.stream) { fundedByProject['funding'] = funding.stream; } @@ -79,10 +81,11 @@ export class ParsingFunctions { } // publication & research data : for fundedByProjects | project landing : for funding - public parseFundingTrees(fundingTree: any): { "funderName": string, "funderShortname": string, "stream": string } { - let funding: { "funderName": string, "funderShortname": string, "stream": string } = { + public parseFundingTrees(fundingTree: any): any { + let funding: { "funderName": string, "funderShortname": string, "funderJurisdiction": string, "stream": string } = { "funderName": "", "funderShortname": "", + "funderJurisdiction": "", "stream": "" }; let length = Array.isArray(fundingTree) ? fundingTree.length : 1; @@ -93,6 +96,7 @@ export class ParsingFunctions { if (fundingData.hasOwnProperty("funder")) { funding.funderShortname = fundingData['funder'].shortname; funding.funderName = fundingData['funder'].name; + funding.funderJurisdiction = fundingData['funder'].jurisdiction; } funding.stream = this.addFundingLevel0(fundingData, funding.stream); diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index 487895c3..45d17250 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -2,7 +2,9 @@ - +
+
@@ -1200,4 +1202,4 @@ - \ No newline at end of file + diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index 0638d469..59b3c41e 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -515,6 +515,9 @@ export class ResultLandingComponent { this.resultLandingInfo = data; this.id = this.resultLandingInfo.objIdentifier; + let typeId = this.identifier?.id?'pid':'id'; + let id = this.identifier?.id?this.identifier.id:this.id; + this.resultLandingInfo.setBelongsTo(typeId, id); //old // this.viewsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoViews", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly views"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; // this.downloadsFrameUrl = this.properties.framesAPIURL + 'merge.php?com=query&data=[{"query":"resRepoDownloads", "resTitle":"' + this.id + '", "table":"","fields":[{"fld":"sum","agg":"sum","type":"column","yaxis":1,"c":false}],"xaxis":{"name":"month","agg":"sum"},"group":" ","color":"","type":"chart","size":200,"sort":"xaxis","xStyle":{"r":-30,"s":"6","l":"-","ft":"-","wt":"-"},"title":"","subtitle":"","xaxistitle":"Repository","yaxisheaders":["Monthly downloads"],"generalxaxis":"","theme":0,"in":[],"filters":[{"name":"","values":[""],"to":"-1"}]}]&info_types=["column"]&stacking=normal&steps=false&fontFamily=Courier&spacing=[5,0,0,0]&style=[{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"rgba(0, 0, 0, 1)","size":"18"},{"color":"000000","size":""},{"color":"000000","size":""}]&backgroundColor=rgba(255,255,255,1)&colors[]=rgba(67, 67, 72, 1)&colors[]=rgba(144, 237, 125, 1)&colors[]=rgba(247, 163, 92, 1)&colors[]=rgba(128, 133, 233, 1)&colors[]=rgba(241, 92, 128, 1)&colors[]=rgba(228, 211, 84, 1)&colors[]=rgba(43, 144, 143, 1)&colors[]=rgba(244, 91, 91, 1)&colors[]=rgba(145, 232, 225, 1)&xlinew=0&ylinew=1&legends=true&tooltips=true&persistent=false'; @@ -592,7 +595,6 @@ export class ResultLandingComponent { this.setActiveTab(); this.cdr.detectChanges(); - if (contexts) { if (this.communityId && this.communityId == "enermaps" && properties.enermapsURL) { this.enermapsId = ParsingFunctions.getEnermapsConceptId(contexts); diff --git a/utils/entities/dataProviderInfo.ts b/utils/entities/dataProviderInfo.ts index 449bcc64..693d08c3 100644 --- a/utils/entities/dataProviderInfo.ts +++ b/utils/entities/dataProviderInfo.ts @@ -1,202 +1,205 @@ import {properties} from "../../../../environments/environment"; -import {Measure} from "./resultLandingInfo"; +import {BelongsTo, Measure} from "./resultLandingInfo"; export class DataproviderProvenance { - provenance: Map; + provenance: Map; constructor() { this.provenance = new Map(); this.provenance.set("opendoar____::", {"urlPrefix": properties.openDoarURL, "name": "OpenDOAR"});//, "idRegexPrefix": ""}); this.provenance.set("re3data_____::", {"urlPrefix": properties.r3DataURL, "name": "re3data.org"}); this.provenance.set("fairsharing_::", {"urlPrefix": properties.fairSharingURL, "name": "FAIRsharing"}); - this.provenance.set("eosc________::", {"urlPrefix": properties.eoscMarketplaceURL, "name": "EOSC Service Catalogue"}); + this.provenance.set("eosc________::", { + "urlPrefix": properties.eoscMarketplaceURL, + "name": "EOSC Service Catalogue" + }); } } export class DataProviderInfo { - relcanId; - objIdentifier: string; - record; - title: { "name": string, "url": string }; - officialName: string; - type: string; - registry: boolean; - compatibility: { "info": string, "name": string, "id": string }; - oaiPmhURL: string; - openDoarId: string; - r3DataId: string; - provenance: Map; - originalId: string; - countries: string[]; - journal: {"journal": "", "issn": string, "lissn": string, "eissn": string}; - description: string; - subjects: string[]; - jurisdiction: string; - thematic: boolean; - contentpolicy: string; - identifiers: Map; //key is the classname + relcanId; + objIdentifier: string; + record; + title: { "name": string, "url": string }; + officialName: string; + type: string; + registry: boolean; + compatibility: { "info": string, "name": string, "id": string }; + oaiPmhURL: string; + openDoarId: string; + r3DataId: string; + provenance: Map; + originalId: string; + countries: string[]; + journal: { "journal": "", "issn": string, "lissn": string, "eissn": string }; + description: string; + subjects: string[]; + jurisdiction: string; + thematic: boolean; + contentpolicy: string; + identifiers: Map; //key is the classname fundedContent: string; // search query measure: Measure; //collected from datasource api // aggregationStatus: {"fundedContent": string, "indexRecords": string, "fulltexts": string, "lastUpdateDate": string}; - aggregationStatus: {"fulltexts": string}; + aggregationStatus: { "fulltexts": string }; - tabs: {"name": string, "content": string}[]; - tabs2: string[] =[]; - tabsInTypes = { - "publicationsTab": new Set( - [ "aggregator::datarepository", - "aggregator::pubsrepository::institutional", - "aggregator::pubsrepository::unknown", - "aggregator::pubsrepository::journals", - "crissystem", - "datarepository::unknown", - "infospace", - "pubsrepository::institutional", - "pubsrepository::journal", - "pubsrepository::unknown", - "scholarcomminfra", - "pubsrepository::thematic", - "pubscatalogue::unknown", - "orprepository" - ]), - "datasetsTab": new Set( - [ "aggregator::datarepository", - "aggregator::pubsrepository::institutional", - "aggregator::pubsrepository::unknown", - "aggregator::pubsrepository::journals", - "crissystem", - "datarepository::unknown", - "infospace", - "pubsrepository::institutional", - "pubsrepository::journal", - "pubsrepository::unknown", - "scholarcomminfra", - "pubsrepository::thematic", - "pubscatalogue::unknown", - "orprepository" - ]), - "statisticsTab": new Set( - [ "aggregator::datarepository", - "aggregator::pubsrepository::institutional", - "aggregator::pubsrepository::unknown", - "aggregator::pubsrepository::journals", - "crissystem", - "datarepository::unknown", - "pubsrepository::institutional", - "pubsrepository::journal", - "pubsrepository::unknown", - "pubsrepository::thematic", - "pubscatalogue::unknown", - "orprepository" - ]), - // "organizationsTab": new Set( - // [ "entityregistry::projects", - // "entityregistry::repositories" - // ]), - "projectsTab": new Set(["entityregistry::projects"]), - "datasourcesTab": new Set(["entityregistry::repositories"]), - "relatedDatasourcesTab": new Set( - [ "aggregator::pubsrepository::unknown", - "aggregator::pubsrepository::journals", - "aggregator::pubsrepository::institutional", - "aggregator::datarepository" - ]), - "softwareTab": new Set( - [ - "aggregator::datarepository", - "aggregator::pubsrepository::institutional", - "aggregator::pubsrepository::unknown", - "aggregator::pubsrepository::journals", - "crissystem", - "datarepository::unknown", - "infospace", - "pubsrepository::institutional", - "pubsrepository::journal", - "pubsrepository::unknown", - "scholarcomminfra", - "pubsrepository::thematic", - "pubscatalogue::unknown", - "softwarerepository", - "aggregator::softwarerepository", - "orprepository" - ]), - "orpsTab": new Set( - [ - "aggregator::datarepository", - "aggregator::pubsrepository::institutional", - "aggregator::pubsrepository::unknown", - "aggregator::pubsrepository::journals", - "crissystem", - "datarepository::unknown", - "infospace", - "pubsrepository::institutional", - "pubsrepository::journal", - "pubsrepository::unknown", - "scholarcomminfra", - "pubsrepository::thematic", - "pubscatalogue::unknown", - "softwarerepository", - "aggregator::softwarerepository", - "orprepository" - ]), - "metricsTab": new Set( - [ "aggregator::datarepository", - "aggregator::pubsrepository::institutional", - "aggregator::pubsrepository::unknown", - "aggregator::pubsrepository::journals", - "crissystem", - "datarepository::unknown", - "infospace", - "pubsrepository::institutional", - "pubsrepository::journal", - "websource", - "pubsrepository::unknown", - "scholarcomminfra", - "pubsrepository::thematic", - "pubscatalogue::unknown", - "softwarerepository", - "aggregator::softwarerepository", - "orprepository" - ]) + tabs: { "name": string, "content": string }[]; + tabs2: string[] = []; + tabsInTypes = { + "publicationsTab": new Set( + ["aggregator::datarepository", + "aggregator::pubsrepository::institutional", + "aggregator::pubsrepository::unknown", + "aggregator::pubsrepository::journals", + "crissystem", + "datarepository::unknown", + "infospace", + "pubsrepository::institutional", + "pubsrepository::journal", + "pubsrepository::unknown", + "scholarcomminfra", + "pubsrepository::thematic", + "pubscatalogue::unknown", + "orprepository" + ]), + "datasetsTab": new Set( + ["aggregator::datarepository", + "aggregator::pubsrepository::institutional", + "aggregator::pubsrepository::unknown", + "aggregator::pubsrepository::journals", + "crissystem", + "datarepository::unknown", + "infospace", + "pubsrepository::institutional", + "pubsrepository::journal", + "pubsrepository::unknown", + "scholarcomminfra", + "pubsrepository::thematic", + "pubscatalogue::unknown", + "orprepository" + ]), + "statisticsTab": new Set( + ["aggregator::datarepository", + "aggregator::pubsrepository::institutional", + "aggregator::pubsrepository::unknown", + "aggregator::pubsrepository::journals", + "crissystem", + "datarepository::unknown", + "pubsrepository::institutional", + "pubsrepository::journal", + "pubsrepository::unknown", + "pubsrepository::thematic", + "pubscatalogue::unknown", + "orprepository" + ]), + // "organizationsTab": new Set( + // [ "entityregistry::projects", + // "entityregistry::repositories" + // ]), + "projectsTab": new Set(["entityregistry::projects"]), + "datasourcesTab": new Set(["entityregistry::repositories"]), + "relatedDatasourcesTab": new Set( + ["aggregator::pubsrepository::unknown", + "aggregator::pubsrepository::journals", + "aggregator::pubsrepository::institutional", + "aggregator::datarepository" + ]), + "softwareTab": new Set( + [ + "aggregator::datarepository", + "aggregator::pubsrepository::institutional", + "aggregator::pubsrepository::unknown", + "aggregator::pubsrepository::journals", + "crissystem", + "datarepository::unknown", + "infospace", + "pubsrepository::institutional", + "pubsrepository::journal", + "pubsrepository::unknown", + "scholarcomminfra", + "pubsrepository::thematic", + "pubscatalogue::unknown", + "softwarerepository", + "aggregator::softwarerepository", + "orprepository" + ]), + "orpsTab": new Set( + [ + "aggregator::datarepository", + "aggregator::pubsrepository::institutional", + "aggregator::pubsrepository::unknown", + "aggregator::pubsrepository::journals", + "crissystem", + "datarepository::unknown", + "infospace", + "pubsrepository::institutional", + "pubsrepository::journal", + "pubsrepository::unknown", + "scholarcomminfra", + "pubsrepository::thematic", + "pubscatalogue::unknown", + "softwarerepository", + "aggregator::softwarerepository", + "orprepository" + ]), + "metricsTab": new Set( + ["aggregator::datarepository", + "aggregator::pubsrepository::institutional", + "aggregator::pubsrepository::unknown", + "aggregator::pubsrepository::journals", + "crissystem", + "datarepository::unknown", + "infospace", + "pubsrepository::institutional", + "pubsrepository::journal", + "websource", + "pubsrepository::unknown", + "scholarcomminfra", + "pubsrepository::thematic", + "pubscatalogue::unknown", + "softwarerepository", + "aggregator::softwarerepository", + "orprepository" + ]) - }; + }; - resultsBy: string; - resultTypes = { - "collectedFrom": new Set( - [ "aggregator::datarepository", - "aggregator::pubsrepository::institutional", - "aggregator::pubsrepository::unknown", - "aggregator::pubsrepository::journals", - "entityregistry::projects", - "entityregistry::repositories", - "infospace", - "scholarcomminfra", - "pubscatalogue::unknown", - "aggregator::softwarerepository" - ]), - "hostedBy": new Set( - [ "crissystem", - "datarepository::unknown", - "pubsrepository::institutional", - "pubsrepository::journal", - "pubsrepository::unknown", - "pubsrepository::thematic", - "softwarerepository", - "orprepository" - ]) - }; + resultsBy: string; + resultTypes = { + "collectedFrom": new Set( + ["aggregator::datarepository", + "aggregator::pubsrepository::institutional", + "aggregator::pubsrepository::unknown", + "aggregator::pubsrepository::journals", + "entityregistry::projects", + "entityregistry::repositories", + "infospace", + "scholarcomminfra", + "pubscatalogue::unknown", + "aggregator::softwarerepository" + ]), + "hostedBy": new Set( + ["crissystem", + "datarepository::unknown", + "pubsrepository::institutional", + "pubsrepository::journal", + "pubsrepository::unknown", + "pubsrepository::thematic", + "softwarerepository", + "orprepository" + ]) + }; - organizations: {"acronym": string, "name": string, "id": string}[] = []; - //publications: any; - //datasets: any; - statistics: any; - //projects: any; - datasources: any; + organizations: { "acronym": string, "name": string, "id": string }[] = []; + //publications: any; + //datasets: any; + statistics: any; + //projects: any; + datasources: any; - //relatedDatasources: Map; - relatedDatasources: {"id": string, "name": string, "count": number}[] = []; + //relatedDatasources: Map; + relatedDatasources: { "id": string, "name": string, "count": number }[] = []; } diff --git a/utils/entities/organizationInfo.ts b/utils/entities/organizationInfo.ts index 5194f076..71827c89 100644 --- a/utils/entities/organizationInfo.ts +++ b/utils/entities/organizationInfo.ts @@ -1,3 +1,5 @@ +import {BelongsTo} from "./resultLandingInfo"; + export interface OrganizationProject { name: string; id: string; diff --git a/utils/entities/projectInfo.ts b/utils/entities/projectInfo.ts index e66736fe..642ba39a 100644 --- a/utils/entities/projectInfo.ts +++ b/utils/entities/projectInfo.ts @@ -1,4 +1,5 @@ -import {Measure} from "./resultLandingInfo"; +import {BelongsTo, Measure} from "./resultLandingInfo"; +import {StringUtils} from "../string-utils.class"; export class ProjectInfo { id:string; @@ -23,4 +24,14 @@ export class ProjectInfo { totalDatasets: number; publicationsStatus: any; measure: Measure; + belongsTo: boolean = true; + message: string; + + setBelongsTo(id: string) { + this.belongsTo = !BelongsTo.project || BelongsTo.project.fields.findIndex(field => BelongsTo.check(this, field)) != -1; + this.message = !this.belongsTo?BelongsTo.project.message:null; + if(this.message) { + this.message = this.message.replace('((id))', id); + } + } } diff --git a/utils/entities/resultLandingInfo.ts b/utils/entities/resultLandingInfo.ts index 16eb7ae1..cf170c18 100644 --- a/utils/entities/resultLandingInfo.ts +++ b/utils/entities/resultLandingInfo.ts @@ -6,6 +6,9 @@ import { Project, RelationResult } from "../result-preview/result-preview"; +import {isArray} from "rxjs/internal-compatibility"; +import {OpenaireEntities} from "../properties/searchFields"; +import {StringUtils} from "../string-utils.class"; export interface Id { type: "pmid" | "doi" | "pmc" | "handle" | "openaire" | "swhid"; @@ -30,18 +33,6 @@ export interface Context { } export interface Measure { - // /** @deprecated*/ - // downloads?: string; - // /** @deprecated*/ - // views?: string; - // /** @deprecated*/ - // influence?: string; - // /** @deprecated*/ - // popularity?: string; - // /** @deprecated*/ - // citations?: string; - // /** @deprecated*/ - // impulse?: string; bip?: Metric[] counts?: Metric[] countsPerDatasource?: MetricPerDatasource[]; @@ -61,12 +52,46 @@ export interface Metric { value: any } +class Field { + path: string[]; + value: string; +} + +export class BelongsTo { + public static result: BelongsTo = null; + public static project: BelongsTo = null; + public static organization: BelongsTo = null; + public static datasource: BelongsTo = null; + + fields: Field[]; + message: string; + + public static check(element: any, field: Field): boolean { + if (field) { + field = Object.assign({}, field); + let json: any = element; + if (field.path.length > 0) { + if (Array.isArray(json)) { + return json.findIndex(value => BelongsTo.check(value, field)) != -1; + } else { + json = json[field.path[0]]; + field.path = field.path.slice(1); + return BelongsTo.check(json, field); + } + } + console.log(json, field.value) + return json == field.value; + } + return false; + } +} + export class ResultLandingInfo { relcanId; objIdentifier: string; // PUBLICATION, DATASET, SOFTWARE, ORP record; - resultType: "publication"|"dataset"|"other"|"software"; + resultType: "publication" | "dataset" | "other" | "software"; // PUBLICATION, DATASET, SOFTWARE, ORP, DELETED_BY_INFERENCE title: string; accessMode: string; @@ -79,26 +104,26 @@ export class ResultLandingInfo { languages: string[]; countries: string[]; description: string; - + hostedBy_collectedFrom: HostedByCollectedFrom[]; - + // PUBLICATION, DATASET, SOFTWARE, ORP fundedByProjects: Project[]; - + underCurationMessage: boolean; publisher: string; journal: Journal; - + subjects: string[]; otherSubjects: Map; classifiedSubjects: Map; // - fos: {"id": string, "label": string}[] = []; + fos: { "id": string, "label": string }[] = []; sdg: string[]; eoscSubjects: any[]; oaRoutes: OARoutes; publiclyFunded: boolean; - + // // percentage is for trust // relatedResearchResults: RelationResult[]; // // percentage is for similarity @@ -159,22 +184,35 @@ export class ResultLandingInfo { relatedClassFilters: Set = new Set(); contexts: Context[]; - + deletedByInferenceIds: string[]; - + // PUBLICATION, DATASET, ORP references: Reference[]; - + // PUBLICATION bioentities: Map>; //> organizations: Organization[]; openCitations: { "url": string, "title": string, "year": string, "doi": string, "authors": string[] }[]; - + // DATASET subtitle: string; - + // SOFTWARE programmingLanguages: string[]; - measure: Measure; + measure: Measure; + + belongsTo: boolean = true; + message: string; + + setBelongsTo(typeId: string, id: string) { + this.belongsTo = !BelongsTo.result || BelongsTo.result.fields.findIndex(field => BelongsTo.check(this, field)) != -1; + this.message = !this.belongsTo ? BelongsTo.result.message : null; + if (this.message) { + this.message = this.message.replace('((result))', StringUtils.getEntityName(this.resultType)); + this.message = this.message.replace('((type_id))', typeId); + this.message = this.message.replace('((id))', id); + } + } } diff --git a/utils/result-preview/result-preview.ts b/utils/result-preview/result-preview.ts index c8a38e1d..0362be0b 100644 --- a/utils/result-preview/result-preview.ts +++ b/utils/result-preview/result-preview.ts @@ -43,6 +43,7 @@ export interface Project { title: string; funderShortname: string; funderName: string; + funderJurisdiction?: string funding?: string; code: string; validated?: boolean;