diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index 66c0bb7d..13cf27d8 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -8,6 +8,14 @@ import {StringUtils} from "../../utils/string-utils.class"; providedIn: 'root' }) export class ParsingFunctions { + public eoscSubjects = [ + {label: 'EOSC::Jupyter Notebook', link: 'https://marketplace.eosc-portal.eu/services/egi-notebooks?q=Jupyter+Notebook', value: 'Jupyter Notebook'}, + {label: 'EOSC::RO-crate', link: 'https://marketplace.eosc-portal.eu/services/rohub?q=RO-crate', value: 'RO-crate'}, + {label: 'EOSC::Galaxy Workflow', link: 'https://marketplace.eosc-portal.eu/services/european-galaxy-server?q=Galaxy+Workflow', value: 'Galaxy Workflow'}, + {label: 'EOSC::Twitter Data', link: 'https://marketplace.eosc-portal.eu/services/verbal-aggression-analyser-va-analyser?q=Twitter+Data', value: 'Twitter Data'} + ] + public eoscSubjectsFound = []; + public notebookInSubjects: boolean = false; private notebookKeyword: string = "eosc jupyter notebook"; private notebook_label: string = "EOSC"; @@ -563,7 +571,7 @@ export class ParsingFunctions { } // publication & dataset landing : for subjects and otherSubjects and classifiedSubjects - parseAllSubjects(_subjects: any): [string[], Map, Map, string[], string[]] { + parseAllSubjects(_subjects: any): [string[], Map, Map, string[], string[], any[]] { let subjects: string[]; let otherSubjects: Map; let classifiedSubjects: Map; @@ -575,6 +583,7 @@ export class ParsingFunctions { for (let i = 0; i < length; i++) { subject = Array.isArray(_subjects) ? _subjects[i] : _subjects; + console.log(subject); if (subject.classid != "") { if (subject.inferred && subject.inferred == true) { if(subject.classid === "SDG") { @@ -591,75 +600,50 @@ export class ParsingFunctions { if (classifiedSubjects == undefined) { classifiedSubjects = new Map(); } + + // TODO: remove this when data are ok! + if(subject.classname == 'eosc') { + subject.classname = 'EOSC'; + } if (!classifiedSubjects.has(subject.classname)) { classifiedSubjects.set(subject.classname, new Array()); } - classifiedSubjects.get(subject.classname).push(subject.content+""); + let content: string = subject.content+""; + let found: boolean = false; + // looping through our declared array + this.eoscSubjects.forEach(item => { + if(content && content == item.label) { + found = true; + this.eoscSubjectsFound.push(item); + classifiedSubjects.get(subject.classname).push(item.value); + } + }); + if(!found) { + classifiedSubjects.get(subject.classname).push(content); + } } } else { if (subject.classid == "keyword") { let content: string = subject.content+""; - // console.log("keyword subject: "+content); - - if(content && content.toLowerCase().includes(this.notebookKeyword)) { - // console.log("included in keyword subject: "+content); - // console.log("included"); - this.notebookInSubjects = true; - - if (classifiedSubjects == undefined) { - classifiedSubjects = new Map(); - } - if (!classifiedSubjects.has(subject.classname)) { - classifiedSubjects.set(this.notebook_label, new Array()); - } - classifiedSubjects.get(this.notebook_label).push(this.notebook_value); - } else { - if (subjects == undefined) { - subjects = new Array(); - } - subjects.push(content); - } + if (subjects == undefined) { + subjects = new Array(); + } + subjects.push(content); } else { let content: string = subject.content+""; let classname: string = subject.classname + ""; - // console.log("other subject: "+classname + ": " +content); - - if( (content && content.toLowerCase().includes(this.notebookKeyword) || - (classname && classname.toLowerCase().includes(this.notebookKeyword)))) { - // console.log("included in other subject: "+classname + ": "+content); - // console.log("included"); - - this.notebookInSubjects = true; - - if (classifiedSubjects == undefined) { - classifiedSubjects = new Map(); - } - if (!classifiedSubjects.has(subject.classname)) { - classifiedSubjects.set(this.notebook_label, new Array()); - } - classifiedSubjects.get(this.notebook_label).push(this.notebook_value); - } else { - // if (otherSubjects == undefined) { - // otherSubjects = new Map(); - // } - // - // if (!otherSubjects.has(subject.classname)) { - // otherSubjects.set(subject.classname, new Array()); - // } - // otherSubjects.get(classname).push(content); - - if (subjects == undefined) { - subjects = new Array(); - } - subjects.push(content); - } + if (subjects == undefined) { + subjects = new Array(); + } + subjects.push(content); } } } } - return [subjects, otherSubjects, classifiedSubjects, fos, sdg]; + console.log(this.eoscSubjectsFound); + return [subjects, otherSubjects, classifiedSubjects, fos, sdg, this.eoscSubjectsFound]; } parseContexts(_contexts: any): Context[] { diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index 9b819d09..35d238b6 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -367,15 +367,32 @@
- - + +
diff --git a/landingPages/result/resultLanding.component.ts b/landingPages/result/resultLanding.component.ts index 66a8b7bc..fcd12fa0 100644 --- a/landingPages/result/resultLanding.component.ts +++ b/landingPages/result/resultLanding.component.ts @@ -548,7 +548,7 @@ export class ResultLandingComponent { } public get hasRightSidebarInfo(): boolean { - return (this.resultLandingInfo.showEgiNotebookButton && properties.adminToolsPortalType == 'explore' + return (this.resultLandingInfo.eoscSubjects && this.resultLandingInfo.eoscSubjects.length && properties.adminToolsPortalType == 'explore' && (properties.environment == 'beta' || properties.environment == 'development')) || (this.resultLandingInfo.sdg && this.resultLandingInfo.sdg.length > 0) diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index 92bfc07e..917d104a 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -331,7 +331,7 @@ export class ResultLandingService { // res['result']['metadata']['oaf:entity']['oaf:result']['subject'] if(data[7] != null) { - let subjectResults: [string[], Map, Map, string[], string[]] = this.parsingFunctions.parseAllSubjects(data[7]); + let subjectResults: [string[], Map, Map, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[7]); this.resultLandingInfo.subjects = subjectResults[0]; this.resultLandingInfo.otherSubjects = subjectResults[1]; this.resultLandingInfo.classifiedSubjects = subjectResults[2]; @@ -346,7 +346,7 @@ export class ResultLandingService { }) } - this.resultLandingInfo.showEgiNotebookButton = this.parsingFunctions.notebookInSubjects; + this.resultLandingInfo.eoscSubjects = subjectResults[5]; } this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( diff --git a/utils/entities/resultLandingInfo.ts b/utils/entities/resultLandingInfo.ts index f1a15378..c47c002c 100644 --- a/utils/entities/resultLandingInfo.ts +++ b/utils/entities/resultLandingInfo.ts @@ -62,7 +62,7 @@ export class ResultLandingInfo { classifiedSubjects: Map; // fos: string[]; sdg: string[]; - showEgiNotebookButton: boolean = false; + eoscSubjects: any[]; // // percentage is for trust // relatedResearchResults: RelationResult[];