diff --git a/landingPages/dataProvider/dataProvider.service.ts b/landingPages/dataProvider/dataProvider.service.ts index 99835dfb..a9615b67 100644 --- a/landingPages/dataProvider/dataProvider.service.ts +++ b/landingPages/dataProvider/dataProvider.service.ts @@ -200,7 +200,7 @@ export class DataProviderService { // TODO: Add check for array if(datasource.contentpolicies) { - this.dataProviderInfo.contentpolicy = datasource.contentpolicies.label; + this.dataProviderInfo.contentpolicy = datasource.contentpolicies[0].label; } if(datasource['datasourcetype']) { @@ -352,10 +352,9 @@ export class DataProviderService { } } - // TODO: Missing from json - // if (data[0]?.measure) { - // this.dataProviderInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure); - // } + if (data?.measure) { + this.dataProviderInfo.measure = this.parsingFunctions.parseMeasures(data.measure); + } return this.dataProviderInfo; } diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index 8cc8c435..7fd591b1 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -28,10 +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"]; + 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"]; + // public identifierTypes = ["Digital Object Identifier", "pmc", "Handle", "PubMed ID", "re3data", "swhid", + // "ROR", "International Standard Name Identifier", "Wikidata", "FundRef"]; private instanceWithDoiExists: boolean = false; constructor() { @@ -252,7 +252,7 @@ export class ParsingFunctions { if (url) { mapStructure.get(key)['accessMode'].push(instance['accessright'].label); } - + if (this.changeBestAccessMode(mapStructure.get(key)['bestAccessMode'], instance['accessright'])) { mapStructure.get(key)['bestAccessMode'] = instance['accessright'].label; } @@ -339,11 +339,10 @@ export class ParsingFunctions { for (let i = 0; i < length; i++) { let accessRight = Array.isArray(instance['accessright']) ? instance['accessright'][i] : instance['accessright']; - //TODO: should be accessRight.label in the new version if (this.changeBestAccessMode(available.accessRight, accessRight)) { - available.accessRight = accessRight.value; + available.accessRight = accessRight.label; if (this.changeBestAccessMode(globalAccessRight, accessRight)) { - globalAccessRight = accessRight.value; + globalAccessRight = accessRight.label; } } } @@ -549,7 +548,7 @@ export class ParsingFunctions { openaireCompatibility: "" }; - datasource['id'] = relation['to'].content; + datasource['id'] = relation['header'].relatedIdentifier; if(relation["officialname"]) datasource.name = relation.officialname; else { @@ -557,10 +556,10 @@ export class ParsingFunctions { } let percentageName: string; - if (relation.trust) { + if (relation['header'].trust) { percentageName = "trust"; - } else if (relation.similarity) { - percentageName = "similarity"; + // } else if (relation.similarity) { + // percentageName = "similarity"; } if (percentageName) { datasource['percentage'] = Math.round(relation[percentageName] * 100); @@ -568,13 +567,13 @@ export class ParsingFunctions { } // type - if(relation.hasOwnProperty('datasourcetype') && relation['datasourcetype'].hasOwnProperty("classname")) { - datasource.class = relation['datasourcetype'].classname; + if(relation['datasourcetype'] && relation['datasourcetype']["code"]) { + datasource.class = relation['datasourcetype'].code; } // compatibility - if(relation.hasOwnProperty("openairecompatibility")) { - datasource.openaireCompatibility = relation['openairecompatibility'].classname; + if(relation["openairecompatibility"]) { + datasource.openaireCompatibility = relation['openairecompatibility'].label; } if(datasource.class !== "service" || properties.adminToolsPortalType == "eosc") { @@ -599,20 +598,20 @@ export class ParsingFunctions { parseIdentifiers(pid: any): Map { let identifiers = new Map(); - if (pid.hasOwnProperty("type") && pid['type'] != "") { - if (this.identifierTypes.indexOf(pid.type) !=-1) { - if (!identifiers.has(pid.type)) { - identifiers.set(pid.type, new Array()); + if (pid.hasOwnProperty("typeCode") && pid['typeCode'] != "") { + if (this.identifierTypes.indexOf(pid.typeCode) !=-1) { + if (!identifiers.has(pid.typeCode)) { + identifiers.set(pid.typeCode, new Array()); } - identifiers.get(pid.type).push(pid.value + ""); + identifiers.get(pid.typeCode).push(pid.value + ""); } } else { for (let i = 0; i < pid.length; i++) { - if (this.identifierTypes.indexOf(pid[i].type) !=-1) { - if (!identifiers.has(pid[i].type)) { - identifiers.set(pid[i].type, new Array()); + if (this.identifierTypes.indexOf(pid[i].typeCode) !=-1) { + if (!identifiers.has(pid[i].typeCode)) { + identifiers.set(pid[i].typeCode, new Array()); } - identifiers.get(pid[i].type).push(pid[i].value + ""); + identifiers.get(pid[i].typeCode).push(pid[i].value + ""); } } } @@ -695,7 +694,6 @@ export class ParsingFunctions { // setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; // eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; // } else { - // TODO: typeLabel now is just type if (!classifiedSubjects.has(subject.typeLabel)) { classifiedSubjects.set(subject.typeLabel, new Array()); } @@ -976,82 +974,70 @@ export class ParsingFunctions { let downloads: number = 0; elements.forEach(element => { if (element.id == 'views') { - views += element.count; - let datasourceId = element.datasource; + let viewsNum = parseInt(element.unit.label); + views += viewsNum; + let datasourceId = element.unit.code; if(datasourceId) { - if(datasourcePosition.has(element.datasource)) { - countsPerDatasource[datasourcePosition.get(element.datasource)].views = element.count; + if(datasourcePosition.has(datasourceId)) { + countsPerDatasource[datasourcePosition.get(datasourceId)].views = viewsNum; } else { - datasourcePosition.set(element.datasource, countsPerDatasource.length); - countsPerDatasource.push({"datasourceId": element.datasource.split("||")[0], "datasourceName": element.datasource.split("||")[1], "views": element.count, "downloads": 0}) + datasourcePosition.set(datasourceId, countsPerDatasource.length); + countsPerDatasource.push({"datasourceId": datasourceId.split("||")[0], "datasourceName": datasourceId.split("||")[1], "views": viewsNum, "downloads": 0}) } } // measure.views = element.count; } if (element.id == 'downloads') { - downloads += element.count; - let datasourceId = element.datasource; + let downloadsNum = parseInt(element.unit.label); + downloads += downloadsNum; + let datasourceId = element.unit.code; if(datasourceId) { - if(datasourcePosition.has(element.datasource)) { - countsPerDatasource[datasourcePosition.get(element.datasource)].downloads = element.count; + if(datasourcePosition.has(datasourceId)) { + countsPerDatasource[datasourcePosition.get(datasourceId)].downloads = downloadsNum; } else { - datasourcePosition.set(element.datasource, countsPerDatasource.length); - countsPerDatasource.push({"datasourceId": element.datasource.split("||")[0], "datasourceName": element.datasource.split("||")[1], "views": 0, "downloads": element.count}) + datasourcePosition.set(datasourceId, countsPerDatasource.length); + countsPerDatasource.push({"datasourceId": datasourceId.split("||")[0], "datasourceName": datasourceId.split("||")[1], "views": 0, "downloads": downloadsNum}) } } // measure.downloads = element.count; } if (element.id == 'influence_alt' || element.id == 'citation_count') { - bip.push({name: 'citations', icon: 'cite', value: element.score, order: 2}); - // measure.citations = element.score; - } - if (element.id == 'popularity') { - let metric: Metric = {name: 'popularity', icon: 'fire', value: null, order: 3}; - if (element.class == 'C1') { - metric.value = 'Top 0.01%'; - } else if (element.class == 'C2') { - metric.value = 'Top 0.1%'; - } else if (element.class == 'C3') { - metric.value = 'Top 1%'; - } else if (element.class == 'C4') { - metric.value = 'Top 10%'; - } else { - metric.value = 'Average'; + for(let unit of element.unit) { + if(unit.code == "score") { + bip.push({name: 'citations', icon: 'cite', value: parseInt(element.unit.label), order: 2}); + } } - // measure.popularity = metric.value; - bip.push(metric); } - if (element.id == 'influence') { - let metric: Metric = {name: 'influence', icon: 'landmark', value: null, order: 4}; - if (element.class == 'C1') { - metric.value = 'Top 0.01%'; - } else if (element.class == 'C2') { - metric.value = 'Top 0.1%'; - } else if (element.class == 'C3') { - metric.value = 'Top 1%'; - } else if (element.class == 'C4') { - metric.value = 'Top 10%'; - } else { - metric.value = 'Average'; + if (element.id == 'popularity' || element.id == 'influence' || element.id == 'impulse') { + let value = ""; + for(let unit of element.unit) { + if (unit.code == "class") { + if (unit.label == 'C1') { + value = 'Top 0.01%'; + } else if (unit.label == 'C2') { + value = 'Top 0.1%'; + } else if (unit.label == 'C3') { + value = 'Top 1%'; + } else if (unit.label == 'C4') { + value = 'Top 10%'; + } else { + value = 'Average'; + } + } } - // measure.influence = metric.value; - bip.push(metric); - } - if (element.id == 'impulse') { - let metric: Metric = {name: 'impulse', icon: 'rocket', value: null, order: 5}; - if (element.class == 'C1') { - metric.value = 'Top 0.01%'; - } else if (element.class == 'C2') { - metric.value = 'Top 0.1%'; - } else if (element.class == 'C3') { - metric.value = 'Top 1%'; - } else if (element.class == 'C4') { - metric.value = 'Top 10%'; - } else { - metric.value = 'Average'; + + if (element.id == 'popularity') { + let metric: Metric = {name: 'popularity', icon: 'fire', value: value, order: 3}; + bip.push(metric); + } + if (element.id == 'influence') { + let metric: Metric = {name: 'influence', icon: 'landmark', value: value, order: 4}; + bip.push(metric); + } + if (element.id == 'impulse') { + let metric: Metric = {name: 'impulse', icon: 'rocket', value: value, order: 5}; + bip.push(metric); } - // measure.impulse = metric.value; - bip.push(metric); } }); diff --git a/landingPages/project/project.service.ts b/landingPages/project/project.service.ts index fa5c77fb..29dc368d 100644 --- a/landingPages/project/project.service.ts +++ b/landingPages/project/project.service.ts @@ -207,10 +207,9 @@ export class ProjectService { } } - // TODO: Missing from json - // if (data[0]?.measure) { - // this.projectInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure); - // } + if (data.measures) { + this.projectInfo.measure = this.parsingFunctions.parseMeasures(data.measures); + } return this.projectInfo; diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index 7d724d41..7b0175d8 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -157,7 +157,7 @@ export class ResultLandingService { if (result.publiclyFunded) { this.resultLandingInfo.publiclyFunded = result.publiclyFunded; } - //TODO check duplicates - are we going to keep one? + if (result["isGreen"] || result["openAccessColor"] || result["isInDiamondJournal"]) { this.resultLandingInfo.oaRoutes = { "green": result.isGreen, @@ -311,20 +311,16 @@ export class ResultLandingService { let author = Array.isArray(authors) ? authors[i] : authors; if (author) { parsedAuthor.fullName = author.fullname; - // TODO: pid.type has "Open Researcher and Contributor ID" value now let pids = author.pid?author.pid:[]; for(let pid of pids) { - if (pid.type == 'orcid') { + if (pid.typeCode == 'orcid') { parsedAuthor.orcid = pid.value.toUpperCase(); break; + } else if (pid.typeCode == "orcid_pending") { + parsedAuthor.orcid_pending = pid.value.toUpperCase(); } } - // TODO: missing from json - // if (author.pid && author.pid.type == "orcid_pending") { - // author.orcid_pending = author.orcid_pending.toUpperCase(); - // } - if (this.resultLandingInfo['authors'][author.rank] && this.resultLandingInfo['authors'][author.rank].fullName == author.fullname) { if (!parsedAuthor.orcid && this.resultLandingInfo['authors'][author.rank].orcid) { parsedAuthor.orcid = this.resultLandingInfo['authors'][author.rank].orcid; @@ -345,11 +341,11 @@ export class ResultLandingService { }); } - // TODO: Missing from response? - // if (data[3].hasOwnProperty("externalreference")) { - // let externalResults: Map> = this.parseBioentitiesAndSoftware(data[3]); - // this.resultLandingInfo.bioentities = externalResults; - // } + // TODO: example? + if (result["externalreference"]) { + let externalResults: Map> = this.parseBioentitiesAndSoftware(result["externalreference"]); + this.resultLandingInfo.bioentities = externalResults; + } } if(data["pid"]) { @@ -375,30 +371,23 @@ export class ResultLandingService { } let provenanceAction: string = relation.provenanceaction; - // TODO NOW!!! do not add merges here! this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName); } else if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "hasauthorinstitution") { this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation); - } - // TODO: No examples - mapping xml to json for datasourcetype? - // else if (relation['header'].relationType == "dnet:result_datasource_relations" && - // (relation['datasourcetype']?.classname !== "service" || properties.adminToolsPortalType == "eosc")) { - // let relationName: string = relation.header.relationClass; - // if (!this.resultLandingInfo.relatedServicesClassFilters.has(relationName)) { - // this.resultLandingInfo.relatedServicesClassFilters.add(relationName); - // } - // - // let provenanceAction: string = relation.header.relationProvenance; - // - // // this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName); - // if (this.resultLandingInfo.relatedServices == undefined) { - // this.resultLandingInfo.relatedServices = []; - // } - //check - // this.resultLandingInfo.relatedServices = this.parsingFunctions.parseDatasources(this.resultLandingInfo.relatedServices, relation, provenanceAction, relationName); - // } + } else if (relation['header'].relationType == "resultService" && + (relation['datasourcetype']?.code !== "service" || properties.adminToolsPortalType == "eosc")) { + let relationName: string = relation.header.relationClass; + if (!this.resultLandingInfo.relatedServicesClassFilters.has(relationName)) { + this.resultLandingInfo.relatedServicesClassFilters.add(relationName); + } - else if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "merges" && relation['header'].relationType == "resultResult") { + let provenanceAction: string = relation.header.relationProvenance; + + if (this.resultLandingInfo.relatedServices == undefined) { + this.resultLandingInfo.relatedServices = []; + } + this.resultLandingInfo.relatedServices = this.parsingFunctions.parseDatasources(this.resultLandingInfo.relatedServices, relation, provenanceAction, relationName); + } else if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "merges" && relation['header'].relationType == "resultResult") { if(!this.resultLandingInfo.deletedByInferenceIds) { this.resultLandingInfo.deletedByInferenceIds = []; } @@ -417,6 +406,10 @@ export class ResultLandingService { this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data['context']); } + if (data.measures) { + this.resultLandingInfo.measure = this.parsingFunctions.parseMeasures(data.measures); + } + this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( this.resultLandingInfo.hostedBy_collectedFrom, this.resultLandingInfo.publisher, this.resultLandingInfo.journal?.journal, this.resultLandingInfo.identifiers); @@ -434,11 +427,6 @@ export class ResultLandingService { // } else { // this.resultLandingInfo.underCurationMessage = false; // } - // - // // res['result']['metadata']['oaf:entity']['oaf:result']['measure'] - // if (data[0]?.measure) { - // this.resultLandingInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure); - // } return this.resultLandingInfo; } @@ -476,14 +464,14 @@ export class ResultLandingService { parseBioentitiesAndSoftware(children: any): Map> { let bioentities: Map>; - let length = Array.isArray(children['externalreference']) ? children['externalreference'].length : 1; + let length = Array.isArray(children) ? children.length : 1; let externalreference; for (let i = 0; i < length; i++) { - externalreference = Array.isArray(children['externalreference']) ? children['externalreference'][i] : children['externalreference']; + externalreference = Array.isArray(children) ? children[i] : children; - if (externalreference.hasOwnProperty("qualifier")) { - if (externalreference['qualifier'].classid == "accessionNumber") { + if (externalreference["qualifier"]) { + if (externalreference['qualifier'].code == "accessionNumber") { if (bioentities == undefined) { bioentities = new Map>(); diff --git a/services/organization.service.ts b/services/organization.service.ts index 7d48db1f..866c69c5 100644 --- a/services/organization.service.ts +++ b/services/organization.service.ts @@ -95,6 +95,7 @@ export class OrganizationService { for(let i=0; i res['meta']['total'])); } fetchByDOIs(DOIs:string[],query:string): any { - let url = properties.searchAPIURLLAst + "/researchProducts/byDoi?type=publications" + (query?query:""); + let url = properties.searchAPIURLLAst + "researchProducts/byDoi?type=publications" + (query?query:""); return this.http.post(url, {doiArray: DOIs}) .pipe(map(res => [res['meta'].total, this.parseResults("result", res['results'], properties), RefineResultsUtils.parse(res['refineResults'], null, "publication")])); } diff --git a/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts b/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts index f309246b..71504bc4 100644 --- a/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts +++ b/sharedComponents/schema2jsonld/service/open-aire-jsonld-converter.service.ts @@ -259,13 +259,14 @@ convertDatasource(datasource: any, URL, otherUrl): Organization { if (!item) return null; if (!_.has(item, "code")) return null; if (!_.has(item, "label")) return null; - if (!_.has(item, "schemeid")) return null; + // if (!_.has(item, "schemeid")) return null; return [{ title: [_.get(item, "label")], identifier: [{ id: _.get(item, "code"), - schema: _.get(item, "schemeid") + schema: "dnet:access_modes" + // schema: _.get(item, "schemeid") }] }]; } @@ -298,12 +299,10 @@ convertDatasource(datasource: any, URL, otherUrl): Organization { }; } - // TODO: Update parsing - check if parsing is ok private getSameAs(result: any): String[] { const relations = _.get(result, "links", null); if (!relations) return null; const array = new Array(); -console.log("relations"); if(Array.isArray(relations) ) { for (let i = 0; i < relations.length; i++) { @@ -342,7 +341,6 @@ console.log("relations"); return array; } - // TODO: Update parsing - classid missing? private getKeyword(result: any, classification:'FOS'|'SDG' |null = null): String[] { const subjects = _.get(result, "result.subject", null); if (!subjects) return null;