From f675fba83bffc7013c0442fb6a6931cfd3ba9814 Mon Sep 17 00:00:00 2001 From: argirok Date: Wed, 9 Oct 2024 09:54:41 +0300 Subject: [PATCH] [new-search-json | WIP ] continue parsing research results, start parsing result landing --- .../landing-utils/parsingFunctions.class.ts | 15 +- .../showIdentifiers.component.ts | 8 +- landingPages/result/resultLanding.service.ts | 608 +++++++++--------- services/searchResearchResults.service.ts | 61 +- 4 files changed, 350 insertions(+), 342 deletions(-) diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index 0f60174c..f3bba63e 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -28,7 +28,10 @@ export class ParsingFunctions { public open = 'open_access'; public closed = 'closed_access'; public unknown = 'unknown_access'; - + // public identifierTypes = ["doi", "pmc" , "handle", "pmid", "re3data", "swhid", "ROR", "ISNI", "Wikidata", "FundRef"]; + //TODO what are the names of Identifiers types e.g doi = Digital Object Identifier + public identifierTypes = ["Digital Object Identifier", "pmc", "Handle", "PubMed ID", "re3data", "swhid", + "ROR", "International Standard Name Identifier", "Wikidata", "FundRef"]; private instanceWithDoiExists: boolean = false; constructor() { @@ -595,9 +598,7 @@ export class ParsingFunctions { let identifiers = new Map(); if (pid.hasOwnProperty("type") && pid['type'] != "") { - if (pid.type == "doi" || pid.type == "pmc" || pid.type == "handle" || pid.type == "pmid" || pid.type == "re3data" - || pid.type == "swhid" - || pid.type == "ROR" || pid.type == "ISNI" || pid.type == "Wikidata" || pid.type == "FundRef") { + if (this.identifierTypes.indexOf(pid.type) !=-1) { if (!identifiers.has(pid.type)) { identifiers.set(pid.type, new Array()); } @@ -605,9 +606,7 @@ export class ParsingFunctions { } } else { for (let i = 0; i < pid.length; i++) { - if (pid[i].type == "doi" || pid[i].type == "pmc" || pid[i].type == "handle" || pid[i].type == "pmid" || pid[i].type == "re3data" - || pid[i].type == "swhid" - || pid[i].type == "ROR" || pid[i].type == "ISNI" || pid[i].type == "Wikidata" || pid[i].type == "FundRef") { + if (this.identifierTypes.indexOf(pid[i].type) !=-1) { if (!identifiers.has(pid[i].type)) { identifiers.set(pid[i].type, new Array()); } @@ -617,7 +616,7 @@ export class ParsingFunctions { } return identifiers; } - + // publication & dataset landing : for subjects and otherSubjects and classifiedSubjects parseEoscSubjects(_subjects: any): any[] { let eoscSubjectsFound = []; diff --git a/landingPages/landing-utils/showIdentifiers.component.ts b/landingPages/landing-utils/showIdentifiers.component.ts index 11a15f14..cf1d3ca1 100644 --- a/landingPages/landing-utils/showIdentifiers.component.ts +++ b/landingPages/landing-utils/showIdentifiers.component.ts @@ -10,6 +10,7 @@ import { } from '@angular/core'; import {EnvProperties} from "../../utils/properties/env-properties"; import {properties} from "../../../../environments/environment"; +import {ParsingFunctions} from "./parsingFunctions.class"; @Component({ selector: 'showIdentifiers', @@ -26,8 +27,7 @@ import {properties} from "../../../../environments/environment"; {{key}}: - {{item}} @@ -69,7 +69,7 @@ export class ShowIdentifiersComponent implements AfterViewInit { properties: EnvProperties = properties; @ViewChildren("content", { read: ElementRef }) types: QueryList; @ViewChild('identifiersModal') identifiersModal; - + public parsingFunctions: ParsingFunctions = new ParsingFunctions(); constructor(private cdr: ChangeDetectorRef) { } @@ -118,7 +118,7 @@ export class ShowIdentifiersComponent implements AfterViewInit { if(value.includes("http://") || value.includes("https://")) { return ""; } - if(key == "doi") { + if(key == "doi" || key == "Digital Object Identifier") { return properties.doiURL; } else if(key == "pmc") { return properties.pmcURL; diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index c6fab328..12bf1539 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -74,13 +74,14 @@ export class ResultLandingService { error: "Http failure response for " + finalUrl + ": 404 Not Found" }); } + //TODO make sure to pass the correct part return res['results'][0]; } else { return res; } })) - .pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res])) - .pipe(map(res => [ + // .pipe(map(res => [res['meta']['status'], res['result']['metadata']['oaf:entity'], res])) + /*.pipe(map(res => [ res[1]['oaf:result'], // 0 res[1]['oaf:result']['title'], // 1 res[1]['oaf:result']['rels']['rel'], // 2 @@ -99,7 +100,7 @@ export class ResultLandingService { ? res[1]['extraInfo']['references']['reference'] : null, // 13 res[0], // 14 res[2], // 15 - ])) + ]))*/ .pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties))); } @@ -128,330 +129,335 @@ export class ResultLandingService { parseResultLandingInfo(data: any, subjectsVocabulary: any, properties: EnvProperties): any { this.resultLandingInfo = new ResultLandingInfo(); - // res - 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; + try { - // res['result']['metadata']['oaf:entity']['oaf:result'] - if (data[0] != null) { - let date: string = (data[0].dateofacceptance ? data[0].dateofacceptance : '') + ''; // transform to string in case it is an integer + + // res + this.resultLandingInfo.record = data; + this.resultLandingInfo.objIdentifier = data["header"]["id"]; + //TODO relcan ? + this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result"); + this.resultLandingInfo.resultType = data['header']['recordType']; + let date: string = (data['result']['publicationdate'] ? data['result']['publicationdate'] : '') + ''; // transform to string in case it is an integer this.resultLandingInfo.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date; - this.resultLandingInfo.dateofacceptance = data[0].dateofacceptance ? Dates.getDate(data[0].dateofacceptance) : null; - this.resultLandingInfo.publisher = data[0].publisher; - this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data[0] && data[0].description ? data[0].description : []); - this.resultLandingInfo.embargoEndDate = data[0].embargoenddate ? Dates.getDate(data[0].embargoenddate) : null; + this.resultLandingInfo.dateofacceptance = data['result']['publicationdate'] ? Dates.getDate(data['result']['publicationdate']) : null; + this.resultLandingInfo.publisher = data['result']['publisher']; + this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data['result']['description'] ? data['result']['description'] : []); + this.resultLandingInfo.embargoEndDate = data['result']['embargoenddate'] ? Dates.getDate(data['result']['embargoenddate']) : null; - if(data[0].hasOwnProperty("publiclyfunded") && data[0].publiclyfunded) { - this.resultLandingInfo.publiclyFunded = data[0].publiclyfunded; + + if (data['result'].hasOwnProperty("publiclyFunded") && data['result'].publiclyFunded) { + this.resultLandingInfo.publiclyFunded = data['result'].publiclyFunded; } - if((data[0].hasOwnProperty("isgreen") && data[0].isgreen) - || (data[0].hasOwnProperty("openaccesscolor") && data[0].openaccesscolor) - || (data[0].hasOwnProperty("isindiamondjournal") && data[0].isindiamondjournal)) { + //TODO check duplicates - are we going to keep one? + if ((data['result'].hasOwnProperty("isGreen") && data['result'].isGreen) + || (data['result'].hasOwnProperty("openAccessColor") && data['result'].openAccessColor) + || (data['result'].hasOwnProperty("isInDiamondJournal") && data['result'].isInDiamondJournal)) { this.resultLandingInfo.oaRoutes = { - "green": data[0].isgreen, - "oaColor": data[0].openaccesscolor, - "isInDiamondJournal":data[0].isindiamondjournal + "green": data['result'].isGreen, + "oaColor": data['result'].openAccessColor, + "isInDiamondJournal": data['result'].isInDiamondJournal }; } - } - if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) { - this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname; - } - // res['result']['metadata']['oaf:entity']['oaf:result']['title'] - if (data[1] != null) { - if (Array.isArray(data[1])) { - for (let i = 0; i < data[1].length; i++) { - if (data[1][i] && data[1][i].content) { - if (!this.resultLandingInfo.title || data[1][i].classid == "main title") { - this.resultLandingInfo.title = StringUtils.HTMLToString(String(data[1][i].content)); - } - if (!this.resultLandingInfo.subtitle && data[1][i].classid === 'subtitle') { - this.resultLandingInfo.subtitle = StringUtils.HTMLToString(String(data[1][i].content)); - } - // if(data[1][i].classid == "main title") { - // break; - // } - } - } - if (this.resultLandingInfo.title === this.resultLandingInfo.subtitle) { - this.resultLandingInfo.subtitle = ""; - } - if (!this.resultLandingInfo.title) { - this.resultLandingInfo.title = ""; - } - // this.resultLandingInfo.title = (data[1][0] && data[1][0].content) ? String(data[1][0].content) : ""; - } else { - this.resultLandingInfo.title = (data[1] && data[1].content) ? StringUtils.HTMLToString(String(data[1].content)) : ""; +//TODO continue from here + if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) { + this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname; } - } - - // res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel'] - if (data[2] != null) { - let relation; - let length = Array.isArray(data[2]) ? data[2].length : 1; - - for (let i = 0; i < length; i++) { - relation = Array.isArray(data[2]) ? data[2][i] : data[2]; - if (relation.hasOwnProperty("to")) { - if (relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") { - this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation); - } - if (relation['to'].scheme && relation['to'].scheme == "dnet:result_result_relations") { - let relationName: string = relation.to.class; - if (!this.resultLandingInfo.relatedClassFilters.has(relationName)) { - this.resultLandingInfo.relatedClassFilters.add(relationName); - } - - let provenanceAction: string = relation.provenanceaction; - - this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName); - } else if (relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") { - this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation); - } else if (relation['to'].scheme && relation['to'].scheme == "dnet:result_datasource_relations" && - (relation['datasourcetype']?.classname!== "service" || properties.adminToolsPortalType == "eosc")) { - let relationName: string = relation.to.class; - if (!this.resultLandingInfo.relatedServicesClassFilters.has(relationName)) { - this.resultLandingInfo.relatedServicesClassFilters.add(relationName); - } - - let provenanceAction: string = relation.provenanceaction; - - // this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName); - if (this.resultLandingInfo.relatedServices == undefined) { - this.resultLandingInfo.relatedServices = []; - } - this.resultLandingInfo.relatedServices = this.parsingFunctions.parseDatasources(this.resultLandingInfo.relatedServices, relation, provenanceAction, relationName); - } - } - } - } - - // res['result']['metadata']['oaf:entity']['oaf:result']['children'] - if (data[3] != null) { - if (data[3].hasOwnProperty("result")) { - this.resultLandingInfo.deletedByInferenceIds = []; - let length = Array.isArray(data[3]['result']) ? data[3]['result'].length : 1; - - for (let i = 0; i < length; i++) { - let result = Array.isArray(data[3]['result']) ? data[3]['result'][i] : data[3]['result']; - this.resultLandingInfo.deletedByInferenceIds.push(result.objidentifier); - } - this.resultLandingInfo.children = data[3]['result']; - - } - - if (data[3].hasOwnProperty("instance")) { - this.resultLandingInfo.hostedBy_collectedFrom = new Array(); - - - this.resultLandingInfo.types = new Array(); - let types = new Set(); - - let counter = 0; - let instance; - - let length = Array.isArray(data[3]['instance']) ? data[3]['instance'].length : 1; - - for (let i = 0; i < length; i++) { - instance = Array.isArray(data[3]['instance']) ? data[3]['instance'][i] : data[3]['instance']; - - this.parsingFunctions.parseTypes(this.resultLandingInfo.types, types, instance); - - if (instance.hasOwnProperty("webresource")) { - let url; - if (!Array.isArray(instance['webresource'])) { - url = instance['webresource'].url; - } else { - url = instance['webresource'][0].url; - } - if (url.includes('&')) { - url = url.replace(/&/gmu, '&'); - } - - /**********************************************************/ - if (instance.hasOwnProperty("hostedby")) { - this.parsingFunctions.parseHostedBy_collectedFrom(this.resultLandingInfo.hostedBy_collectedFrom, instance, url, this.resultLandingInfo.accessMode); - } - /**********************************************************/ - } - } - - /* Order Download from via openness*/ - this.resultLandingInfo.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom); - } - - if (data[3].hasOwnProperty("externalreference")) { - let externalResults: Map> = this.parseBioentitiesAndSoftware(data[3]); - this.resultLandingInfo.bioentities = externalResults; - } - } - - // res['result']['metadata']['oaf:entity']['oaf:result']['pid'] - if (data[4] != null) { - this.resultLandingInfo.identifiers = this.parsingFunctions.parseIdentifiers(data[4]); - } - - // res['result']['metadata']['oaf:entity']['oaf:result']['journal'] - if (data[5] != null) { - this.resultLandingInfo.journal = { - "journal": "", - "issn": "", - "lissn": "", - "eissn": "", - "issue": "", - "volume": "", - "start_page": "", - "end_page": "" - } - - this.resultLandingInfo.journal['journal'] = data[5].content; - this.resultLandingInfo.journal['issn'] = data[5].issn; - this.resultLandingInfo.journal['lissn'] = data[5].lissn; - this.resultLandingInfo.journal['eissn'] = data[5].eissn; - this.resultLandingInfo.journal['issue'] = data[5].iss; - this.resultLandingInfo.journal['volume'] = data[5].vol; - this.resultLandingInfo.journal['start_page'] = data[5].sp; - this.resultLandingInfo.journal['end_page'] = data[5].ep; - } - - // res['result']['metadata']['oaf:entity']['oaf:result']['language'] - if (data[6] != null) { - this.resultLandingInfo.languages = this.parsingFunctions.parseLanguages(data[6]); - // let languagesAndCodes: string[][] = this.parsingFunctions.parseLanguages(data[6]); - // this.resultLandingInfo.languages = languagesAndCodes[0]; - // this.resultLandingInfo.languageCodes = languagesAndCodes[1]; - } - - // res['result']['metadata']['oaf:entity']['oaf:result']['country'] - 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[8] != null) { - let subjectResults: [string[], Map, Map, string[], string[]] = this.parsingFunctions.parseAllSubjects(data[8], subjectsVocabulary); - this.resultLandingInfo.subjects = subjectResults[0]; - this.resultLandingInfo.otherSubjects = subjectResults[1]; - this.resultLandingInfo.classifiedSubjects = subjectResults[2]; - - if (subjectResults[3]) { - let searchFieldsHelper: SearchFields = new SearchFields(); - subjectResults[3].forEach(element => { - // hide L3 & L4 FoS - let add = true; - if(element) { - let id = element.split(" ")[0]; - if(id.length > 4 && properties.environment != "development") { - add = false; - } - } - if(add) { - this.resultLandingInfo.fos.push( - { - id: element, - label: searchFieldsHelper.getFosParameter() == "foslabel" ? element.replace(/^\d+/, '').trim() : element + // res['result']['metadata']['oaf:entity']['oaf:result']['title'] + if (data[1] != null) { + if (Array.isArray(data[1])) { + for (let i = 0; i < data[1].length; i++) { + if (data[1][i] && data[1][i].content) { + if (!this.resultLandingInfo.title || data[1][i].classid == "main title") { + this.resultLandingInfo.title = StringUtils.HTMLToString(String(data[1][i].content)); } - ); + if (!this.resultLandingInfo.subtitle && data[1][i].classid === 'subtitle') { + this.resultLandingInfo.subtitle = StringUtils.HTMLToString(String(data[1][i].content)); + } + // if(data[1][i].classid == "main title") { + // break; + // } + } } - }); - } - if (this.resultLandingInfo.fos) { - this.resultLandingInfo.fos.sort((a, b) => a.id.localeCompare(b.id)); - } - if(properties.dashboard != "irish") { - this.resultLandingInfo.sdg = subjectResults[4]; - if (this.resultLandingInfo.sdg) { - this.resultLandingInfo.sdg.sort((a, b) => { - return HelperFunctions.sortSDGs(a, b); - }) + if (this.resultLandingInfo.title === this.resultLandingInfo.subtitle) { + this.resultLandingInfo.subtitle = ""; + } + if (!this.resultLandingInfo.title) { + this.resultLandingInfo.title = ""; + } + // this.resultLandingInfo.title = (data[1][0] && data[1][0].content) ? String(data[1][0].content) : ""; + } else { + this.resultLandingInfo.title = (data[1] && data[1].content) ? StringUtils.HTMLToString(String(data[1].content)) : ""; } } - // if(!this.resultLandingInfo.eoscSubjects) { - // this.resultLandingInfo.eoscSubjects = subjectResults[5]; - // } - } + // res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel'] + if (data[2] != null) { + let relation; + let length = Array.isArray(data[2]) ? data[2].length : 1; - this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( + for (let i = 0; i < length; i++) { + relation = Array.isArray(data[2]) ? data[2][i] : data[2]; + if (relation.hasOwnProperty("to")) { + if (relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") { + this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation); + } + if (relation['to'].scheme && relation['to'].scheme == "dnet:result_result_relations") { + let relationName: string = relation.to.class; + if (!this.resultLandingInfo.relatedClassFilters.has(relationName)) { + this.resultLandingInfo.relatedClassFilters.add(relationName); + } + + let provenanceAction: string = relation.provenanceaction; + + this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName); + } else if (relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") { + this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation); + } else if (relation['to'].scheme && relation['to'].scheme == "dnet:result_datasource_relations" && + (relation['datasourcetype']?.classname !== "service" || properties.adminToolsPortalType == "eosc")) { + let relationName: string = relation.to.class; + if (!this.resultLandingInfo.relatedServicesClassFilters.has(relationName)) { + this.resultLandingInfo.relatedServicesClassFilters.add(relationName); + } + + let provenanceAction: string = relation.provenanceaction; + + // this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName); + if (this.resultLandingInfo.relatedServices == undefined) { + this.resultLandingInfo.relatedServices = []; + } + this.resultLandingInfo.relatedServices = this.parsingFunctions.parseDatasources(this.resultLandingInfo.relatedServices, relation, provenanceAction, relationName); + } + } + } + } + + // res['result']['metadata']['oaf:entity']['oaf:result']['children'] + if (data[3] != null) { + if (data[3].hasOwnProperty("result")) { + this.resultLandingInfo.deletedByInferenceIds = []; + let length = Array.isArray(data[3]['result']) ? data[3]['result'].length : 1; + + for (let i = 0; i < length; i++) { + let result = Array.isArray(data[3]['result']) ? data[3]['result'][i] : data[3]['result']; + this.resultLandingInfo.deletedByInferenceIds.push(result.objidentifier); + } + this.resultLandingInfo.children = data[3]['result']; + + } + + if (data[3].hasOwnProperty("instance")) { + this.resultLandingInfo.hostedBy_collectedFrom = new Array(); + + + this.resultLandingInfo.types = new Array(); + let types = new Set(); + + let counter = 0; + let instance; + + let length = Array.isArray(data[3]['instance']) ? data[3]['instance'].length : 1; + + for (let i = 0; i < length; i++) { + instance = Array.isArray(data[3]['instance']) ? data[3]['instance'][i] : data[3]['instance']; + + this.parsingFunctions.parseTypes(this.resultLandingInfo.types, types, instance); + + if (instance.hasOwnProperty("webresource")) { + let url; + if (!Array.isArray(instance['webresource'])) { + url = instance['webresource'].url; + } else { + url = instance['webresource'][0].url; + } + if (url.includes('&')) { + url = url.replace(/&/gmu, '&'); + } + + /**********************************************************/ + if (instance.hasOwnProperty("hostedby")) { + this.parsingFunctions.parseHostedBy_collectedFrom(this.resultLandingInfo.hostedBy_collectedFrom, instance, url, this.resultLandingInfo.accessMode); + } + /**********************************************************/ + } + } + + /* Order Download from via openness*/ + this.resultLandingInfo.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom); + } + + if (data[3].hasOwnProperty("externalreference")) { + let externalResults: Map> = this.parseBioentitiesAndSoftware(data[3]); + this.resultLandingInfo.bioentities = externalResults; + } + } + + // res['result']['metadata']['oaf:entity']['oaf:result']['pid'] + if (data[4] != null) { + this.resultLandingInfo.identifiers = this.parsingFunctions.parseIdentifiers(data[4]); + } + + // res['result']['metadata']['oaf:entity']['oaf:result']['journal'] + if (data[5] != null) { + this.resultLandingInfo.journal = { + "journal": "", + "issn": "", + "lissn": "", + "eissn": "", + "issue": "", + "volume": "", + "start_page": "", + "end_page": "" + } + + this.resultLandingInfo.journal['journal'] = data[5].content; + this.resultLandingInfo.journal['issn'] = data[5].issn; + this.resultLandingInfo.journal['lissn'] = data[5].lissn; + this.resultLandingInfo.journal['eissn'] = data[5].eissn; + this.resultLandingInfo.journal['issue'] = data[5].iss; + this.resultLandingInfo.journal['volume'] = data[5].vol; + this.resultLandingInfo.journal['start_page'] = data[5].sp; + this.resultLandingInfo.journal['end_page'] = data[5].ep; + } + + // res['result']['metadata']['oaf:entity']['oaf:result']['language'] + if (data[6] != null) { + this.resultLandingInfo.languages = this.parsingFunctions.parseLanguages(data[6]); + // let languagesAndCodes: string[][] = this.parsingFunctions.parseLanguages(data[6]); + // this.resultLandingInfo.languages = languagesAndCodes[0]; + // this.resultLandingInfo.languageCodes = languagesAndCodes[1]; + } + + // res['result']['metadata']['oaf:entity']['oaf:result']['country'] + 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[8] != null) { + let subjectResults: [string[], Map, Map, string[], string[]] = this.parsingFunctions.parseAllSubjects(data[8], subjectsVocabulary); + this.resultLandingInfo.subjects = subjectResults[0]; + this.resultLandingInfo.otherSubjects = subjectResults[1]; + this.resultLandingInfo.classifiedSubjects = subjectResults[2]; + + if (subjectResults[3]) { + let searchFieldsHelper: SearchFields = new SearchFields(); + subjectResults[3].forEach(element => { + // hide L3 & L4 FoS + let add = true; + if (element) { + let id = element.split(" ")[0]; + if (id.length > 4 && properties.environment != "development") { + add = false; + } + } + if (add) { + this.resultLandingInfo.fos.push( + { + id: element, + label: searchFieldsHelper.getFosParameter() == "foslabel" ? element.replace(/^\d+/, '').trim() : element + } + ); + } + }); + } + if (this.resultLandingInfo.fos) { + this.resultLandingInfo.fos.sort((a, b) => a.id.localeCompare(b.id)); + } + if (properties.dashboard != "irish") { + this.resultLandingInfo.sdg = subjectResults[4]; + if (this.resultLandingInfo.sdg) { + this.resultLandingInfo.sdg.sort((a, b) => { + return HelperFunctions.sortSDGs(a, b); + }) + } + } + + // if(!this.resultLandingInfo.eoscSubjects) { + // this.resultLandingInfo.eoscSubjects = subjectResults[5]; + // } + } + + this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( this.resultLandingInfo.hostedBy_collectedFrom, this.resultLandingInfo.publisher, this.resultLandingInfo.journal?.journal, this.resultLandingInfo.identifiers); - // res['result']['metadata']['oaf:entity']['oaf:result']['programmingLanguage'] - if (data[12] != null) { - this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[12]); - } - - // res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference'] - if (data[13] != null) { - this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]); - } - - // res['result']['metadata']['oaf:entity']['oaf:result']['context'] - if (data[9] != null) { - this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[9]); - } - - // res['result']['header']['dri:status'] - 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[10] != null) { - if (this.resultLandingInfo.authors == undefined) { - this.resultLandingInfo.authors = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>(); + // res['result']['metadata']['oaf:entity']['oaf:result']['programmingLanguage'] + if (data[12] != null) { + this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[12]); } - let authors = data[10]; - let length = Array.isArray(authors) ? authors.length : 1; + // res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference'] + if (data[13] != null) { + this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]); + } - for (let i = 0; i < length; i++) { - let author = Array.isArray(authors) ? authors[i] : authors; - if (author) { - if (author.orcid) { - author.orcid = author.orcid.toUpperCase(); - } - if (author.orcid_pending) { - author.orcid_pending = author.orcid_pending.toUpperCase(); - } + // res['result']['metadata']['oaf:entity']['oaf:result']['context'] + if (data[9] != null) { + this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[9]); + } - if(this.resultLandingInfo['authors'][author.rank] && this.resultLandingInfo['authors'][author.rank].fullName == author.content) { - if(!author.orcid && this.resultLandingInfo['authors'][author.rank].orcid) { - author.orcid = this.resultLandingInfo['authors'][author.rank].orcid; - } else if(!author.orcid_pending && this.resultLandingInfo['authors'][author.rank].orcid_pending) { - author.orcid_pending = this.resultLandingInfo['authors'][author.rank].orcid_pending; - } - } + // res['result']['header']['dri:status'] + if (data[14] != null && data[14] == "under curation") { + this.resultLandingInfo.underCurationMessage = true; + } else { + this.resultLandingInfo.underCurationMessage = false; + } - this.resultLandingInfo['authors'][author.rank] = { - "fullName": author.content, - "orcid": author.orcid, - "orcid_pending": author.orcid_pending - }; + // res['result']['metadata']['oaf:entity']['oaf:result']['creator'] + if (data[10] != null) { + if (this.resultLandingInfo.authors == undefined) { + this.resultLandingInfo.authors = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>(); } + + let authors = data[10]; + let length = Array.isArray(authors) ? authors.length : 1; + + for (let i = 0; i < length; i++) { + let author = Array.isArray(authors) ? authors[i] : authors; + if (author) { + if (author.orcid) { + author.orcid = author.orcid.toUpperCase(); + } + if (author.orcid_pending) { + author.orcid_pending = author.orcid_pending.toUpperCase(); + } + + if (this.resultLandingInfo['authors'][author.rank] && this.resultLandingInfo['authors'][author.rank].fullName == author.content) { + if (!author.orcid && this.resultLandingInfo['authors'][author.rank].orcid) { + author.orcid = this.resultLandingInfo['authors'][author.rank].orcid; + } else if (!author.orcid_pending && this.resultLandingInfo['authors'][author.rank].orcid_pending) { + author.orcid_pending = this.resultLandingInfo['authors'][author.rank].orcid_pending; + } + } + + this.resultLandingInfo['authors'][author.rank] = { + "fullName": author.content, + "orcid": author.orcid, + "orcid_pending": author.orcid_pending + }; + } + } + this.resultLandingInfo.authors = this.resultLandingInfo.authors.filter(function (item) { + return (item != undefined && item.fullName != undefined); + }); } - this.resultLandingInfo.authors = this.resultLandingInfo.authors.filter(function (item) { - return (item != undefined && item.fullName != undefined); - }); + + // res['result']['metadata']['oaf:entity']['oaf:result']['measure'] + if (data[0]?.measure) { + this.resultLandingInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure); + } + + this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults); + }catch (e){ + } - - // res['result']['metadata']['oaf:entity']['oaf:result']['measure'] - if (data[0]?.measure) { - this.resultLandingInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure); - } - - this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults); - return this.resultLandingInfo; } diff --git a/services/searchResearchResults.service.ts b/services/searchResearchResults.service.ts index 098a01f5..12972e3f 100644 --- a/services/searchResearchResults.service.ts +++ b/services/searchResearchResults.service.ts @@ -234,14 +234,16 @@ export class SearchResearchResultsService { /////////////////////////// Athena Code /////////////////////////// if (resData['pid']) { if (!Array.isArray(resData['pid'])) { - if (resData['pid'].type && resData['pid'].type == 'doi') { + //TODO change to "doi" + if (resData['pid'].type && resData['pid'].type == 'Digital Object Identifier') { if (resData['pid'].value != '' && resData['pid'].value != null) { result.DOIs.push((resData['pid'].value + "").replace("https://doi.org/", "")); } } } else { for (let i = 0; i < resData['pid'].length; i++) { - if (resData['pid'][i].type == 'doi') { + //TODO change to "doi" + if (resData['pid'][i].type == 'Digital Object Identifier') { if (resData['pid'][i].value != '' && resData['pid'][i].value != null && resData['pid'][i].value) { result.DOIs.push((resData['pid'][i].value + "").replace("https://doi.org/", "")); } @@ -307,7 +309,6 @@ export class SearchResearchResultsService { result['id'] = canId; } result['relcanId'] = result['id']; - if (resData['links']) { let relLength = Array.isArray(resData['links']) ? resData['links'].length : 1; @@ -379,27 +380,28 @@ export class SearchResearchResultsService { if (resData['result'].embargoenddate && resData['result'].embargoenddate != '') { result.embargoEndDate = Dates.getDate(resData['result'].embargoenddate); } -// TODO continue from here - if (!Array.isArray(resData.publisher)) { - result.publisher = resData.publisher; + + if (!Array.isArray(resData['result'].publisher)) { + result.publisher = resData['result'].publisher; } else { - for (let i = 0; i < resData.publisher.length; i++) { + for (let i = 0; i < resData.publisher['result'].length; i++) { if (result.publisher != undefined) { - result.publisher += ', ' + resData['publisher'][i]; + result.publisher += ', ' + resData['result']['publisher'][i]; } else { - result.publisher = resData['publisher'][i]; + result.publisher = resData['result']['publisher'][i]; } } } + //todo DOUBLEcheck with connect if (resData['context'] != null) { result.enermapsId = ParsingFunctions.getEnermapsConceptId(this.parsingFunctions.parseContexts(resData['context'])); } - if (resData.dateofacceptance && resData.dateofacceptance != null) { - let date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // transform to string in case it is an integer + if (resData['result'].publicationdate && resData['result'].publicationdate != null) { + let date: string = (resData['result'].publicationdate ? resData['result'].publicationdate : '') + ''; // transform to string in case it is an integer result.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date; - result.dateofacceptance = resData.dateofacceptance ? Dates.getDate(resData.dateofacceptance) : null; + result.dateofacceptance = resData['result'].publicationdate ? Dates.getDate(resData['result'].publicationdate) : null; } - if (resData.journal && resData.journal != null) { + if (resData['result'].journal && resData['result'].journal != null) { result.journal = { "journal": "", "issn": "", @@ -410,14 +412,14 @@ export class SearchResearchResultsService { "start_page": "", "end_page": "" } - result.journal['journal'] = resData.journal.content; - result.journal['issn'] = resData.journal.issn; - result.journal['lissn'] = resData.journal.lissn; - result.journal['eissn'] = resData.journal.eissn; - result.journal['issue'] = resData.journal.iss; - result.journal['volume'] = resData.journal.vol; - result.journal['start_page'] = resData.journal.sp; - result.journal['end_page'] = resData.journal.ep; + result.journal['journal'] = resData['result'].journal.name; + result.journal['issn'] = resData['result'].journal.issnPrinted; + result.journal['lissn'] = resData['result'].journal.issnLinking; + result.journal['eissn'] = resData['result'].journal.issnOnline; + result.journal['issue'] = resData['result'].journal.iss; + result.journal['volume'] = resData['result'].journal.vol; + result.journal['start_page'] = resData['result'].journal.sp; + result.journal['end_page'] = resData['result'].journal.ep; } result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( @@ -425,16 +427,17 @@ export class SearchResearchResultsService { result['journal'] ? result['journal'].journal : null, result.identifiers); - if (resData.hasOwnProperty("publiclyfunded") && resData.publiclyfunded) { - result.publiclyFunded = resData.publiclyfunded; + if (resData['result'].hasOwnProperty("publiclyFunded") && resData['result'].publiclyFunded) { + result.publiclyFunded = resData['result'].publiclyFunded; } - if ((resData.hasOwnProperty("isgreen") && resData.isgreen) - || (resData.hasOwnProperty("openaccesscolor") && resData.openaccesscolor) - || (resData.hasOwnProperty("isindiamondjournal") && resData.isindiamondjournal)) { + //TODO check duplicates - are we going to keep one? + if ((resData['result'].hasOwnProperty("isGreen") && resData['result'].isGreen) + || (resData['result'].hasOwnProperty("openAccessColor") && resData['result'].openAccessColor) + || (resData['result'].hasOwnProperty("isInDiamondJournal") && resData['result'].isInDiamondJournal)) { result.oaRoutes = { - "green": resData.isgreen, - "oaColor": resData.openaccesscolor, - "isInDiamondJournal": resData.isindiamondjournal + "green": resData['result'].isGreen, + "oaColor": resData['result'].openAccessColor, + "isInDiamondJournal": resData['result'].isInDiamondJournal }; } }catch (e){