[new-search-json | WIP | CHANGED]: Updated parsing according to new json schema.

1. open-aire-jsonld-converter.service.ts: On method "getLicense()", added statically schema: "dnet:access_modes" for bestaccessright.
2. searchResearchResults.service.ts: [BUG] Removed "/" after search service url (duplicate /) | Updated parsing of "measures" field | Updated parsing of "pid" field | Added parsing of orcid_pending.
3. searchProjects.service.ts: Updated parsing of "measures" field.
4. searchOrganizations.service.ts: Updated parsing of project links (relations).
5. searchDataproviders.service.ts: Updated parsing of "measures" field.
6. resultLanding.service.ts: Added parsing of orcid_pending | Added parsing of "externalreference" field and updated method "parseBioentitiesAndSoftware()" | Updated parsing of "measures" field | Added parsing of resultService links (relation).
7. project.service.ts: Updated parsing of "measures" field.
8. dataProvider.service.ts: Updated parsing of "measures" field | Updated parsing of "contentpolicies" field.
9. parsingFunctions.class.ts: Use identifierTypes array with ids/codes | Updated parsing of "accessRight" field | Updated parsing in method "parseDatasources()" | Updated parsing of "pid" field in method "parseIdentifiers()" | Updated parsing of "measures" field in method "parseMeasures()".
This commit is contained in:
Konstantina Galouni 2024-10-23 18:57:15 +03:00
parent 945a8b1c90
commit 6b0c581920
10 changed files with 126 additions and 166 deletions

View File

@ -200,7 +200,7 @@ export class DataProviderService {
// TODO: Add check for array // TODO: Add check for array
if(datasource.contentpolicies) { if(datasource.contentpolicies) {
this.dataProviderInfo.contentpolicy = datasource.contentpolicies.label; this.dataProviderInfo.contentpolicy = datasource.contentpolicies[0].label;
} }
if(datasource['datasourcetype']) { if(datasource['datasourcetype']) {
@ -352,10 +352,9 @@ export class DataProviderService {
} }
} }
// TODO: Missing from json if (data?.measure) {
// if (data[0]?.measure) { this.dataProviderInfo.measure = this.parsingFunctions.parseMeasures(data.measure);
// this.dataProviderInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure); }
// }
return this.dataProviderInfo; return this.dataProviderInfo;
} }

View File

@ -28,10 +28,10 @@ export class ParsingFunctions {
public open = 'open_access'; public open = 'open_access';
public closed = 'closed_access'; public closed = 'closed_access';
public unknown = 'unknown_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 //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", // public identifierTypes = ["Digital Object Identifier", "pmc", "Handle", "PubMed ID", "re3data", "swhid",
"ROR", "International Standard Name Identifier", "Wikidata", "FundRef"]; // "ROR", "International Standard Name Identifier", "Wikidata", "FundRef"];
private instanceWithDoiExists: boolean = false; private instanceWithDoiExists: boolean = false;
constructor() { constructor() {
@ -339,11 +339,10 @@ export class ParsingFunctions {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let accessRight = Array.isArray(instance['accessright']) ? instance['accessright'][i] : instance['accessright']; 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)) { if (this.changeBestAccessMode(available.accessRight, accessRight)) {
available.accessRight = accessRight.value; available.accessRight = accessRight.label;
if (this.changeBestAccessMode(globalAccessRight, accessRight)) { if (this.changeBestAccessMode(globalAccessRight, accessRight)) {
globalAccessRight = accessRight.value; globalAccessRight = accessRight.label;
} }
} }
} }
@ -549,7 +548,7 @@ export class ParsingFunctions {
openaireCompatibility: "" openaireCompatibility: ""
}; };
datasource['id'] = relation['to'].content; datasource['id'] = relation['header'].relatedIdentifier;
if(relation["officialname"]) if(relation["officialname"])
datasource.name = relation.officialname; datasource.name = relation.officialname;
else { else {
@ -557,10 +556,10 @@ export class ParsingFunctions {
} }
let percentageName: string; let percentageName: string;
if (relation.trust) { if (relation['header'].trust) {
percentageName = "trust"; percentageName = "trust";
} else if (relation.similarity) { // } else if (relation.similarity) {
percentageName = "similarity"; // percentageName = "similarity";
} }
if (percentageName) { if (percentageName) {
datasource['percentage'] = Math.round(relation[percentageName] * 100); datasource['percentage'] = Math.round(relation[percentageName] * 100);
@ -568,13 +567,13 @@ export class ParsingFunctions {
} }
// type // type
if(relation.hasOwnProperty('datasourcetype') && relation['datasourcetype'].hasOwnProperty("classname")) { if(relation['datasourcetype'] && relation['datasourcetype']["code"]) {
datasource.class = relation['datasourcetype'].classname; datasource.class = relation['datasourcetype'].code;
} }
// compatibility // compatibility
if(relation.hasOwnProperty("openairecompatibility")) { if(relation["openairecompatibility"]) {
datasource.openaireCompatibility = relation['openairecompatibility'].classname; datasource.openaireCompatibility = relation['openairecompatibility'].label;
} }
if(datasource.class !== "service" || properties.adminToolsPortalType == "eosc") { if(datasource.class !== "service" || properties.adminToolsPortalType == "eosc") {
@ -599,20 +598,20 @@ export class ParsingFunctions {
parseIdentifiers(pid: any): Map<string, string[]> { parseIdentifiers(pid: any): Map<string, string[]> {
let identifiers = new Map<string, string[]>(); let identifiers = new Map<string, string[]>();
if (pid.hasOwnProperty("type") && pid['type'] != "") { if (pid.hasOwnProperty("typeCode") && pid['typeCode'] != "") {
if (this.identifierTypes.indexOf(pid.type) !=-1) { if (this.identifierTypes.indexOf(pid.typeCode) !=-1) {
if (!identifiers.has(pid.type)) { if (!identifiers.has(pid.typeCode)) {
identifiers.set(pid.type, new Array<string>()); identifiers.set(pid.typeCode, new Array<string>());
} }
identifiers.get(pid.type).push(pid.value + ""); identifiers.get(pid.typeCode).push(pid.value + "");
} }
} else { } else {
for (let i = 0; i < pid.length; i++) { for (let i = 0; i < pid.length; i++) {
if (this.identifierTypes.indexOf(pid[i].type) !=-1) { if (this.identifierTypes.indexOf(pid[i].typeCode) !=-1) {
if (!identifiers.has(pid[i].type)) { if (!identifiers.has(pid[i].typeCode)) {
identifiers.set(pid[i].type, new Array<string>()); identifiers.set(pid[i].typeCode, new Array<string>());
} }
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"]; // setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
// eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; // eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"];
// } else { // } else {
// TODO: typeLabel now is just type
if (!classifiedSubjects.has(subject.typeLabel)) { if (!classifiedSubjects.has(subject.typeLabel)) {
classifiedSubjects.set(subject.typeLabel, new Array<string>()); classifiedSubjects.set(subject.typeLabel, new Array<string>());
} }
@ -976,83 +974,71 @@ export class ParsingFunctions {
let downloads: number = 0; let downloads: number = 0;
elements.forEach(element => { elements.forEach(element => {
if (element.id == 'views') { if (element.id == 'views') {
views += element.count; let viewsNum = parseInt(element.unit.label);
let datasourceId = element.datasource; views += viewsNum;
let datasourceId = element.unit.code;
if(datasourceId) { if(datasourceId) {
if(datasourcePosition.has(element.datasource)) { if(datasourcePosition.has(datasourceId)) {
countsPerDatasource[datasourcePosition.get(element.datasource)].views = element.count; countsPerDatasource[datasourcePosition.get(datasourceId)].views = viewsNum;
} else { } else {
datasourcePosition.set(element.datasource, countsPerDatasource.length); datasourcePosition.set(datasourceId, countsPerDatasource.length);
countsPerDatasource.push({"datasourceId": element.datasource.split("||")[0], "datasourceName": element.datasource.split("||")[1], "views": element.count, "downloads": 0}) countsPerDatasource.push({"datasourceId": datasourceId.split("||")[0], "datasourceName": datasourceId.split("||")[1], "views": viewsNum, "downloads": 0})
} }
} }
// measure.views = element.count; // measure.views = element.count;
} }
if (element.id == 'downloads') { if (element.id == 'downloads') {
downloads += element.count; let downloadsNum = parseInt(element.unit.label);
let datasourceId = element.datasource; downloads += downloadsNum;
let datasourceId = element.unit.code;
if(datasourceId) { if(datasourceId) {
if(datasourcePosition.has(element.datasource)) { if(datasourcePosition.has(datasourceId)) {
countsPerDatasource[datasourcePosition.get(element.datasource)].downloads = element.count; countsPerDatasource[datasourcePosition.get(datasourceId)].downloads = downloadsNum;
} else { } else {
datasourcePosition.set(element.datasource, countsPerDatasource.length); datasourcePosition.set(datasourceId, countsPerDatasource.length);
countsPerDatasource.push({"datasourceId": element.datasource.split("||")[0], "datasourceName": element.datasource.split("||")[1], "views": 0, "downloads": element.count}) countsPerDatasource.push({"datasourceId": datasourceId.split("||")[0], "datasourceName": datasourceId.split("||")[1], "views": 0, "downloads": downloadsNum})
} }
} }
// measure.downloads = element.count; // measure.downloads = element.count;
} }
if (element.id == 'influence_alt' || element.id == 'citation_count') { if (element.id == 'influence_alt' || element.id == 'citation_count') {
bip.push({name: 'citations', icon: 'cite', value: element.score, order: 2}); for(let unit of element.unit) {
// measure.citations = element.score; if(unit.code == "score") {
bip.push({name: 'citations', icon: 'cite', value: parseInt(element.unit.label), order: 2});
} }
if (element.id == 'popularity') { }
let metric: Metric = {name: 'popularity', icon: 'fire', value: null, order: 3}; }
if (element.class == 'C1') { if (element.id == 'popularity' || element.id == 'influence' || element.id == 'impulse') {
metric.value = 'Top 0.01%'; let value = "";
} else if (element.class == 'C2') { for(let unit of element.unit) {
metric.value = 'Top 0.1%'; if (unit.code == "class") {
} else if (element.class == 'C3') { if (unit.label == 'C1') {
metric.value = 'Top 1%'; value = 'Top 0.01%';
} else if (element.class == 'C4') { } else if (unit.label == 'C2') {
metric.value = 'Top 10%'; value = 'Top 0.1%';
} else if (unit.label == 'C3') {
value = 'Top 1%';
} else if (unit.label == 'C4') {
value = 'Top 10%';
} else { } else {
metric.value = 'Average'; value = 'Average';
} }
// measure.popularity = metric.value; }
}
if (element.id == 'popularity') {
let metric: Metric = {name: 'popularity', icon: 'fire', value: value, order: 3};
bip.push(metric); bip.push(metric);
} }
if (element.id == 'influence') { if (element.id == 'influence') {
let metric: Metric = {name: 'influence', icon: 'landmark', value: null, order: 4}; let metric: Metric = {name: 'influence', icon: 'landmark', value: value, 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';
}
// measure.influence = metric.value;
bip.push(metric); bip.push(metric);
} }
if (element.id == 'impulse') { if (element.id == 'impulse') {
let metric: Metric = {name: 'impulse', icon: 'rocket', value: null, order: 5}; let metric: Metric = {name: 'impulse', icon: 'rocket', value: value, 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';
}
// measure.impulse = metric.value;
bip.push(metric); bip.push(metric);
} }
}
}); });
if(views > 0) { if(views > 0) {

View File

@ -207,10 +207,9 @@ export class ProjectService {
} }
} }
// TODO: Missing from json if (data.measures) {
// if (data[0]?.measure) { this.projectInfo.measure = this.parsingFunctions.parseMeasures(data.measures);
// this.projectInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure); }
// }
return this.projectInfo; return this.projectInfo;

View File

@ -157,7 +157,7 @@ export class ResultLandingService {
if (result.publiclyFunded) { if (result.publiclyFunded) {
this.resultLandingInfo.publiclyFunded = result.publiclyFunded; this.resultLandingInfo.publiclyFunded = result.publiclyFunded;
} }
//TODO check duplicates - are we going to keep one?
if (result["isGreen"] || result["openAccessColor"] || result["isInDiamondJournal"]) { if (result["isGreen"] || result["openAccessColor"] || result["isInDiamondJournal"]) {
this.resultLandingInfo.oaRoutes = { this.resultLandingInfo.oaRoutes = {
"green": result.isGreen, "green": result.isGreen,
@ -311,20 +311,16 @@ export class ResultLandingService {
let author = Array.isArray(authors) ? authors[i] : authors; let author = Array.isArray(authors) ? authors[i] : authors;
if (author) { if (author) {
parsedAuthor.fullName = author.fullname; parsedAuthor.fullName = author.fullname;
// TODO: pid.type has "Open Researcher and Contributor ID" value now
let pids = author.pid?author.pid:[]; let pids = author.pid?author.pid:[];
for(let pid of pids) { for(let pid of pids) {
if (pid.type == 'orcid') { if (pid.typeCode == 'orcid') {
parsedAuthor.orcid = pid.value.toUpperCase(); parsedAuthor.orcid = pid.value.toUpperCase();
break; 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 (this.resultLandingInfo['authors'][author.rank] && this.resultLandingInfo['authors'][author.rank].fullName == author.fullname) {
if (!parsedAuthor.orcid && this.resultLandingInfo['authors'][author.rank].orcid) { if (!parsedAuthor.orcid && this.resultLandingInfo['authors'][author.rank].orcid) {
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? // TODO: example?
// if (data[3].hasOwnProperty("externalreference")) { if (result["externalreference"]) {
// let externalResults: Map<string, Map<string, string>> = this.parseBioentitiesAndSoftware(data[3]); let externalResults: Map<string, Map<string, string>> = this.parseBioentitiesAndSoftware(result["externalreference"]);
// this.resultLandingInfo.bioentities = externalResults; this.resultLandingInfo.bioentities = externalResults;
// } }
} }
if(data["pid"]) { if(data["pid"]) {
@ -375,30 +371,23 @@ export class ResultLandingService {
} }
let provenanceAction: string = relation.provenanceaction; let provenanceAction: string = relation.provenanceaction;
// TODO NOW!!! do not add merges here!
this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName); this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName);
} else if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "hasauthorinstitution") { } else if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "hasauthorinstitution") {
this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation); this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation);
} 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);
} }
// 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'].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) { if(!this.resultLandingInfo.deletedByInferenceIds) {
this.resultLandingInfo.deletedByInferenceIds = []; this.resultLandingInfo.deletedByInferenceIds = [];
} }
@ -417,6 +406,10 @@ export class ResultLandingService {
this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data['context']); 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.parsingFunctions.addPublisherToHostedBy_collectedFrom(
this.resultLandingInfo.hostedBy_collectedFrom, this.resultLandingInfo.publisher, this.resultLandingInfo.hostedBy_collectedFrom, this.resultLandingInfo.publisher,
this.resultLandingInfo.journal?.journal, this.resultLandingInfo.identifiers); this.resultLandingInfo.journal?.journal, this.resultLandingInfo.identifiers);
@ -434,11 +427,6 @@ export class ResultLandingService {
// } else { // } else {
// this.resultLandingInfo.underCurationMessage = false; // 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; return this.resultLandingInfo;
} }
@ -476,14 +464,14 @@ export class ResultLandingService {
parseBioentitiesAndSoftware(children: any): Map<string, Map<string, string>> { parseBioentitiesAndSoftware(children: any): Map<string, Map<string, string>> {
let bioentities: Map<string, Map<string, string>>; let bioentities: Map<string, Map<string, string>>;
let length = Array.isArray(children['externalreference']) ? children['externalreference'].length : 1; let length = Array.isArray(children) ? children.length : 1;
let externalreference; let externalreference;
for (let i = 0; i < length; i++) { 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"]) {
if (externalreference['qualifier'].classid == "accessionNumber") { if (externalreference['qualifier'].code == "accessionNumber") {
if (bioentities == undefined) { if (bioentities == undefined) {
bioentities = new Map<string, Map<string, string>>(); bioentities = new Map<string, Map<string, string>>();

View File

@ -95,6 +95,7 @@ export class OrganizationService {
for(let i=0; i<relLength; i++) { for(let i=0; i<relLength; i++) {
let relation = Array.isArray(links) ? links[i] : links; let relation = Array.isArray(links) ? links[i] : links;
if (relation["header"]) { if (relation["header"]) {
// TODO: Check if merges or isMergedIn
if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "merges" && relation['header'].relatedRecordType == "organization") { if (relation['header'].relationClass && relation['header'].relationClass.toLowerCase() == "merges" && relation['header'].relatedRecordType == "organization") {
if(!this.organizationInfo.deletedByInferenceIds) { if(!this.organizationInfo.deletedByInferenceIds) {
this.organizationInfo.deletedByInferenceIds = []; this.organizationInfo.deletedByInferenceIds = [];

View File

@ -132,7 +132,6 @@ export class SearchDataprovidersService {
result['type'] = this.getDataproviderType(resData); result['type'] = this.getDataproviderType(resData);
if (resData['eosctype']) { if (resData['eosctype']) {
// TODO: Check if field is available, .label is correct?
result.entityType = resData['eosctype'].label == "Service" ? "service" : "dataprovider"; result.entityType = resData['eosctype'].label == "Service" ? "service" : "dataprovider";
} }
@ -170,9 +169,8 @@ export class SearchDataprovidersService {
result['subjects'] = this.getDataproviderSubjects(resData); result['subjects'] = this.getDataproviderSubjects(resData);
// TODO: example?
// Measure // Measure
//result.measure = this.parsingFunctions.parseMeasures(resData['measure']); result.measure = this.parsingFunctions.parseMeasures(resData['measures']);
} }
if(resBody["links"]) { if(resBody["links"]) {
@ -181,7 +179,6 @@ export class SearchDataprovidersService {
result['countries'] = res[0]; result['countries'] = res[0];
} }
// TODO: now pid.type & pid.value, but Claudio said that pid.type would be replaced by pid.typeCode and pid.typeLabel
if(resBody['pid']) { if(resBody['pid']) {
result.identifiers = this.parsingFunctions.parseIdentifiers(resBody['pid']); result.identifiers = this.parsingFunctions.parseIdentifiers(resBody['pid']);
} }

View File

@ -155,11 +155,12 @@ export class SearchOrganizationsService {
"code": "" "code": ""
} }
if(relation.title != 'unidentified') { // TODO: Missing projectTitle and sometimes no acronym either.
if(relation.projectTitle != 'unidentified') {
result['projects'][countProjects]['id'] = result['projects'][countProjects]['id'] =
/*OpenaireProperties.getsearchLinkToProject() + */relation['header'].relatedIdentifier; /*OpenaireProperties.getsearchLinkToProject() + */relation['header'].relatedIdentifier;
result['projects'][countProjects]['acronym'] = relation.acronym; result['projects'][countProjects]['acronym'] = relation.acronym;
result['projects'][countProjects]['title'] = relation.title; // TODO: Could not find any examples with this field result['projects'][countProjects]['title'] = relation.projectTitle;
result['projects'][countProjects]['code'] = relation.code; result['projects'][countProjects]['code'] = relation.code;
} else { } else {
result['projects'][countProjects]['id'] = ""; result['projects'][countProjects]['id'] = "";
@ -185,7 +186,6 @@ export class SearchOrganizationsService {
} }
} }
// TODO: now pid.type & pid.value, but Claudio said that pid.type would be replaced by pid.typeCode and pid.typeLabel
if(result['pid']) { if(result['pid']) {
result.identifiers = this.parsingFunctions.parseIdentifiers(result['pid']); result.identifiers = this.parsingFunctions.parseIdentifiers(result['pid']);
} }

View File

@ -221,7 +221,7 @@ export class SearchProjectsService {
result.endYear = resData.enddate.split('-')[0]; result.endYear = resData.enddate.split('-')[0];
} }
// Measure // Measure
result.measure = this.parsingFunctions.parseMeasures(resData['measure']); result.measure = this.parsingFunctions.parseMeasures(resData['measures']);
} }
if (resBody["links"]) { if (resBody["links"]) {

View File

@ -149,7 +149,7 @@ export class SearchResearchResultsService {
//let url = link+"/resources2?format=json&query="+params+" sortBy resultdateofacceptance/sort.descending&type="+this.getEntityQueryName(resultType,true); //let url = link+"/resources2?format=json&query="+params+" sortBy resultdateofacceptance/sort.descending&type="+this.getEntityQueryName(resultType,true);
let url = link + "/" + this.getEntityQueryName(resultType, true); let url = link + this.getEntityQueryName(resultType, true);
url += "?format=json"; url += "?format=json";
url += "&fq=" + params; url += "&fq=" + params;
url += "&sortBy=resultdateofacceptance,descending"; url += "&sortBy=resultdateofacceptance,descending";
@ -227,22 +227,19 @@ export class SearchResearchResultsService {
} }
} }
result.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom); result.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom);
//TODO measures when available
// Measure // Measure
result.measure = this.parsingFunctions.parseMeasures(resData['measure']); result.measure = this.parsingFunctions.parseMeasures(resData['measures']);
/////////////////////////// Athena Code /////////////////////////// /////////////////////////// Athena Code ///////////////////////////
if (resData['pid']) { if (resData['pid']) {
if (!Array.isArray(resData['pid'])) { if (!Array.isArray(resData['pid'])) {
//TODO change to "doi" if (resData['pid'].typeCode && resData['pid'].typeCode == 'doi') {
if (resData['pid'].type && resData['pid'].type == 'Digital Object Identifier') {
if (resData['pid'].value != '' && resData['pid'].value != null) { if (resData['pid'].value != '' && resData['pid'].value != null) {
result.DOIs.push((resData['pid'].value + "").replace("https://doi.org/", "")); result.DOIs.push((resData['pid'].value + "").replace("https://doi.org/", ""));
} }
} }
} else { } else {
for (let i = 0; i < resData['pid'].length; i++) { for (let i = 0; i < resData['pid'].length; i++) {
//TODO change to "doi" if (resData['pid'][i].typeCode == 'doi') {
if (resData['pid'][i].type == 'Digital Object Identifier') {
if (resData['pid'][i].value != '' && resData['pid'][i].value != null && resData['pid'][i].value) { 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/", "")); result.DOIs.push((resData['pid'][i].value + "").replace("https://doi.org/", ""));
} }
@ -334,23 +331,19 @@ export class SearchResearchResultsService {
if (author) { if (author) {
let pids = author.pid?author.pid:[]; let pids = author.pid?author.pid:[];
for(let pid of pids) { for(let pid of pids) {
if (pid.type == 'orcid') { if (pid.typeCode == 'orcid') {
author.orcid = pid.value.toUpperCase(); author.orcid = pid.value.toUpperCase();
break; break;
} else if (pid.typeCode == "orcid_pending") {
author.orcid_pending = pid.value.toUpperCase();
} }
} }
//TODO as soon as it is included
/* if (author.orcid_pending) {
author.orcid_pending = author.orcid_pending.toUpperCase();
}*/
/* The same author with the same rank if it */ /* The same author with the same rank if it */
if (result['authors'][author.rank] && result['authors'][author.rank].fullName == author.fullName) { if (result['authors'][author.rank] && result['authors'][author.rank].fullName == author.fullName) {
if (!author.orcid && result['authors'][author.rank].orcid) { if (!author.orcid && result['authors'][author.rank].orcid) {
author.orcid = result['authors'][author.rank].orcid; author.orcid = result['authors'][author.rank].orcid;
} else if (!author.orcid_pending && result['authors'][author.rank].orcid_pending) {
//TODO as soon as it is included author.orcid_pending = result['authors'][author.rank].orcid_pending;
// } else if (!author.orcid_pending && result['authors'][author.rank].orcid_pending) {
// author.orcid_pending = result['authors'][author.rank].orcid_pending;
} }
} }
@ -358,7 +351,7 @@ export class SearchResearchResultsService {
result['authors'][author.rank] = { result['authors'][author.rank] = {
"fullName": author.fullname, "fullName": author.fullname,
"orcid": author.orcid? author.orcid: "", "orcid": author.orcid? author.orcid: "",
"orcid_pending": ""/* TODO as soon as it is included author.orcid_pending*/ "orcid_pending": author.orcid_pending ? author.orcid_pending : ""
}; };
} }
} }
@ -428,7 +421,6 @@ export class SearchResearchResultsService {
if (resData['result'].publiclyFunded) { if (resData['result'].publiclyFunded) {
result.publiclyFunded = resData['result'].publiclyFunded; result.publiclyFunded = resData['result'].publiclyFunded;
} }
//TODO check duplicates - are we going to keep one?
if (resData['result'].isGreen if (resData['result'].isGreen
|| resData['result'].openAccessColor || resData['result'].openAccessColor
|| resData['result'].isInDiamondJournal) { || resData['result'].isInDiamondJournal) {
@ -614,7 +606,7 @@ export class SearchResearchResultsService {
.pipe(map(res => res['meta']['total'])); .pipe(map(res => res['meta']['total']));
} }
fetchByDOIs(DOIs:string[],query:string): any { 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}) 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")])); .pipe(map(res => [res['meta'].total, this.parseResults("result", res['results'], properties), RefineResultsUtils.parse(res['refineResults'], null, "publication")]));
} }

View File

@ -259,13 +259,14 @@ convertDatasource(datasource: any, URL, otherUrl): Organization {
if (!item) return null; if (!item) return null;
if (!_.has(item, "code")) return null; if (!_.has(item, "code")) return null;
if (!_.has(item, "label")) return null; if (!_.has(item, "label")) return null;
if (!_.has(item, "schemeid")) return null; // if (!_.has(item, "schemeid")) return null;
return [{ return [{
title: [_.get(item, "label")], title: [_.get(item, "label")],
identifier: [{ identifier: [{
id: _.get(item, "code"), 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[] { private getSameAs(result: any): String[] {
const relations = _.get(result, "links", null); const relations = _.get(result, "links", null);
if (!relations) return null; if (!relations) return null;
const array = new Array<String>(); const array = new Array<String>();
console.log("relations");
if(Array.isArray(relations) ) { if(Array.isArray(relations) ) {
for (let i = 0; i < relations.length; i++) { for (let i = 0; i < relations.length; i++) {
@ -342,7 +341,6 @@ console.log("relations");
return array; return array;
} }
// TODO: Update parsing - classid missing?
private getKeyword(result: any, classification:'FOS'|'SDG' |null = null): String[] { private getKeyword(result: any, classification:'FOS'|'SDG' |null = null): String[] {
const subjects = _.get(result, "result.subject", null); const subjects = _.get(result, "result.subject", null);
if (!subjects) return null; if (!subjects) return null;