From 2c278542137600224a0e1cc5cf92b7b01e7328f0 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 30 Aug 2022 11:35:42 +0300 Subject: [PATCH] [Library | new-theme]: #7963 - Parse field "eoscifguidelines" in result landing page to get eosc subjects. 1. resultLanding.service.ts: Added in parsing field "eoscifgiudelines" (resultLandingInfo.eoscSubjects). 2. parsingFunctions.class.ts: Added method "parseEoscSubjects()" | Method "checkAndAddEoscSubject()" updated - do not add eosc subjects in classifiedSubjects. 3. resultLanding.component.html: In added [eoscSubjects]="resultLandingInfo.eoscSubjects". 4. showSubjects.component.ts: Added @Input() eoscSubjects: any[]; and show them as classifiedSubjects too. --- .../landing-utils/parsingFunctions.class.ts | 46 +++++++++------ .../landing-utils/showSubjects.component.ts | 32 ++++++++++- .../result/resultLanding.component.html | 3 +- landingPages/result/resultLanding.service.ts | 56 +++++++++++-------- 4 files changed, 92 insertions(+), 45 deletions(-) diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index a42b5b15..74294251 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -569,7 +569,29 @@ export class ParsingFunctions { } return identifiers; } - + + // publication & dataset landing : for subjects and otherSubjects and classifiedSubjects + parseEoscSubjects(_subjects: any): any[] { + let eoscSubjectsFound = []; + let setOfEoscSubjects: Set = new Set(); + + let subject; + let length = Array.isArray(_subjects) ? _subjects.length : 1; + + for (let i = 0; i < length; i++) { + subject = Array.isArray(_subjects) ? _subjects[i] : _subjects; + let content: string = subject.code+""; + let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content); + let found: boolean = checkAndAddEoscSubjectResp["found"]; + if(found) { + setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; + eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; + } + } + + return eoscSubjectsFound; + } + // publication & dataset landing : for subjects and otherSubjects and classifiedSubjects parseAllSubjects(_subjects: any, vocabulary: any): [string[], Map, Map, string[], string[], any[]] { let eoscSubjectsFound = []; @@ -589,11 +611,10 @@ export class ParsingFunctions { if (subject.classid != "") { if (subject.classid == "keyword") { let content: string = subject.content+""; - let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content); + let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content); let found: boolean = checkAndAddEoscSubjectResp["found"]; if(found) { setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; - classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"]; eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; } else { if (subjects == undefined) { @@ -619,11 +640,10 @@ export class ParsingFunctions { } let content: string = subject.content+""; - let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content); + let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content); let found: boolean = checkAndAddEoscSubjectResp["found"]; if(found) { setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; - classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"]; eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; } else { if (!classifiedSubjects.has(subject.classname)) { @@ -634,11 +654,10 @@ export class ParsingFunctions { } } else { let content: string = subject.content+""; - let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, classifiedSubjects, eoscSubjectsFound, subject, content); + let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content); let found: boolean = checkAndAddEoscSubjectResp["found"]; if(found) { setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; - classifiedSubjects = checkAndAddEoscSubjectResp["classifiedSubjects"]; eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; } else { let classname: string = subject.classname + ""; @@ -653,29 +672,20 @@ export class ParsingFunctions { return [subjects, otherSubjects, classifiedSubjects, fos, sdg, eoscSubjectsFound]; } - checkAndAddEoscSubject(setOfEoscSubjects: Set, classifiedSubjects, eoscSubjectsFound, subject, content) { + checkAndAddEoscSubject(setOfEoscSubjects: Set, eoscSubjectsFound, subject, content) { let found: boolean = false; if(!setOfEoscSubjects.has(content)) { // looping through our declared array this.eoscSubjects.forEach(item => { if (content && content == item.label) { - if (classifiedSubjects == undefined) { - classifiedSubjects = new Map(); - } - - if (!classifiedSubjects.has("EOSC")) { - classifiedSubjects.set("EOSC", new Array()); - } - found = true; eoscSubjectsFound.push(item); setOfEoscSubjects.add(content); - classifiedSubjects.get("EOSC").push(item.value); } }); } - return {"found": found, "setOfEoscSubject": setOfEoscSubjects, "classifiedSubjects": classifiedSubjects, "eoscSubjectsFound": eoscSubjectsFound}; + return {"found": found, "setOfEoscSubject": setOfEoscSubjects, "eoscSubjectsFound": eoscSubjectsFound}; } parseContexts(_contexts: any): Context[] { diff --git a/landingPages/landing-utils/showSubjects.component.ts b/landingPages/landing-utils/showSubjects.component.ts index b28b2f9d..1b9aa981 100644 --- a/landingPages/landing-utils/showSubjects.component.ts +++ b/landingPages/landing-utils/showSubjects.component.ts @@ -13,11 +13,12 @@ import {properties} from "../../../../environments/environment"; @Component({ selector: 'showSubjects', template: ` - +
Subjects by Vocabulary
+ @@ -73,10 +74,30 @@ import {properties} from "../../../../environments/environment";

+ + +
+

+ + + + EOSC: + + + + {{subject.value}} + + + +

+
+
- +
+
` @@ -86,6 +107,7 @@ export class ShowSubjectsComponent { @Input() subjects: string[]; @Input() otherSubjects: Map; @Input() classifiedSubjects: Map; + @Input() eoscSubjects: any[]; isLarge: boolean = false; isClassifiedLarge: boolean = false; properties = properties; @@ -156,6 +178,12 @@ export class ShowSubjectsComponent { } }); } + if(typeof document !== "undefined" && this.eoscSubjects && this.classifiedContent) { + let tag = this.classifiedContent.find(tag => tag.nativeElement.id === "content_eosc"); + if(tag && tag.nativeElement.offsetHeight > overflow) { + this.isClassifiedLarge = true; + } + } } public getKeys(map) { diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index a84498a3..c60ac428 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -283,7 +283,8 @@ resultLandingInfo.classifiedSubjects" class="uk-margin-medium-bottom"> + [classifiedSubjects]="resultLandingInfo.classifiedSubjects" + [eoscSubjects]="resultLandingInfo.eoscSubjects"> diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index ff67ac01..5a1adcb7 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -87,16 +87,17 @@ export class ResultLandingService { res[1]['oaf:result']['pid'], // 4 res[1]['oaf:result']['journal'], // 5 res[1]['oaf:result']['language'], // 6 - res[1]['oaf:result']['subject'], // 7 - res[1]['oaf:result']['context'], // 8 - res[1]['oaf:result']['creator'], // 9 - res[1]['oaf:result']['country'] , // 10 - res[1]['oaf:result']['programmingLanguage'], // 11 - software + res[1]['oaf:result']['eoscifgiudelines'], // 7 + res[1]['oaf:result']['subject'], // 8 + res[1]['oaf:result']['context'], // 9 + res[1]['oaf:result']['creator'], // 10 + res[1]['oaf:result']['country'] , // 11 + res[1]['oaf:result']['programmingLanguage'], // 12 - software //res[1]['oaf:result']['resulttype'], (res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['references'] !== undefined) - ? res[1]['extraInfo']['references']['reference'] : null, // 12 - res[0], // 13 - res[2], // 14 + ? res[1]['extraInfo']['references']['reference'] : null, // 13 + res[0], // 14 + res[2], // 15 ])) .pipe(map(res => this.parseResultLandingInfo(res, provenanceActionVocabulary, subjectsVocabulary, relationsVocabulary, properties))); } @@ -128,8 +129,8 @@ export class ResultLandingService { this.resultLandingInfo = new ResultLandingInfo(); // res - this.resultLandingInfo.record = data[14]; - this.resultLandingInfo.objIdentifier = data[14]["result"]["header"]["dri:objIdentifier"]; + this.resultLandingInfo.record = data[15]; + this.resultLandingInfo.objIdentifier = data[15]["result"]["header"]["dri:objIdentifier"]; this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result"); this.resultLandingInfo.resultType = data[0].resulttype.classid; @@ -332,13 +333,18 @@ export class ResultLandingService { } // res['result']['metadata']['oaf:entity']['oaf:result']['country'] - if(data[10] != null) { - this.resultLandingInfo.countries = this.parsingFunctions.parseCountries(data[10]); + if(data[11] != null) { + this.resultLandingInfo.countries = this.parsingFunctions.parseCountries(data[11]); + } + + // res['result']['metadata']['oaf:entity']['oaf:result']['eoscifguidelines'] + if(data[7] != null) { + this.resultLandingInfo.eoscSubjects = this.parsingFunctions.parseEoscSubjects(data[7]); } // res['result']['metadata']['oaf:entity']['oaf:result']['subject'] - if(data[7] != null) { - let subjectResults: [string[], Map, Map, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[7], subjectsVocabulary); + if(data[8] != null) { + let subjectResults: [string[], Map, Map, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[8], subjectsVocabulary); this.resultLandingInfo.subjects = subjectResults[0]; this.resultLandingInfo.otherSubjects = subjectResults[1]; this.resultLandingInfo.classifiedSubjects = subjectResults[2]; @@ -353,7 +359,9 @@ export class ResultLandingService { }) } - this.resultLandingInfo.eoscSubjects = subjectResults[5]; + if(!this.resultLandingInfo.eoscSubjects) { + this.resultLandingInfo.eoscSubjects = subjectResults[5]; + } } this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( @@ -361,34 +369,34 @@ export class ResultLandingService { this.resultLandingInfo.journal, this.resultLandingInfo.identifiers); // res['result']['metadata']['oaf:entity']['oaf:result']['programmingLanguage'] - if(data[11] != null) { - this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[11]); + if(data[12] != null) { + this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[12]); } // res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference'] - if(data[12] != null) { - this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[12]); + if(data[13] != null) { + this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]); } // res['result']['metadata']['oaf:entity']['oaf:result']['context'] - if(data[8] != null) { - this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[8]); + if(data[9] != null) { + this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[9]); } // res['result']['header']['dri:status'] - if(data[13] != null && data[13] == "under curation") { + if(data[14] != null && data[14] == "under curation") { this.resultLandingInfo.underCurationMessage = true; } else { this.resultLandingInfo.underCurationMessage = false; } // res['result']['metadata']['oaf:entity']['oaf:result']['creator'] - if(data[9] != null) { + if(data[10] != null) { if(this.resultLandingInfo.authors == undefined) { this.resultLandingInfo.authors = new Array<{"fullName": string, "orcid": string, "orcid_pending": string}>(); } - let authors = data[9]; + let authors = data[10]; let length = Array.isArray(authors) ? authors.length : 1; for(let i=0; i