[new-search-json | WIP ] continue parsing research results

This commit is contained in:
argirok 2024-10-08 15:28:30 +03:00
parent 89dcbb7c8f
commit 187444bb09
1 changed files with 35 additions and 43 deletions

View File

@ -200,22 +200,7 @@ export class SearchResearchResultsService {
result.entityType = resultType;
}
result['title'] = {"name": '', "accessMode": ''};
//TODO needs to check for Array?
if (Array.isArray(resData.result['maintitle'])) {
for (let i = 0; i < resData.result['maintitle'].length; i++) {
if (resData.result['maintitle'][i]) {
result['title'].name = StringUtils.HTMLToString(resData.result['maintitle'][i]);
break;
}
}
if (!result.title.name) {
result['title'].name = "";
}
// result['title'].name = (resData['title'][0] && resData['title'][0].content) ? String(resData['title'][0].content) : "";
} else {
result['title'].name = (resData.result['maintitle']) ? StringUtils.HTMLToString(resData.result['maintitle']) : "";
}
result['title'].name = (resData.result['maintitle']) ? StringUtils.HTMLToString(resData.result['maintitle']) : "";
if (resData.result['bestaccessright'] && resData.result['bestaccessright']['label']) {
result['title'].accessMode = resData.result['bestaccessright']['label'];
@ -328,45 +313,53 @@ export class SearchResearchResultsService {
for (let j = 0; j < relLength; j++) {
let relation = Array.isArray(resData['links']) ? resData['links'][j] : resData['links'];
// TODO continue from here
if (relation.hasOwnProperty("to")) {
if (relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") {
// if (relation.hasOwnProperty("to")) {
if (relation['header']['relationClass'] && relation['header']['relationClass'].toLowerCase() == "isproducedby") {
result['projects'] = this.parseProjects(result['projects'], relation);
}
}
// }
}
}
if (resData.hasOwnProperty("creator") && resData['creator'] != null) {
if (resData['result'].hasOwnProperty("author") && resData['result']['author'] != null) {
if (result['authors'] == undefined) {
result['authors'] = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>();
}
let authors = resData['creator'];
let authors = resData['result']['author'];
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();
let pids = author.pid?author.pid:[];
for(let pid of pids) {
if (pid.type == 'orcid') {
author.orcid = pid.value.toUpperCase();
break;
}
}
if (author.orcid_pending) {
author.orcid_pending = author.orcid_pending.toUpperCase();
}
if (result['authors'][author.rank] && result['authors'][author.rank].fullName == author.content) {
//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 */
if (result['authors'][author.rank] && result['authors'][author.rank].fullName == author.fullName) {
if (!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) {
author.orcid_pending = result['authors'][author.rank].orcid_pending;
//TODO as soon as it is included
// } else if (!author.orcid_pending && result['authors'][author.rank].orcid_pending) {
// author.orcid_pending = result['authors'][author.rank].orcid_pending;
}
}
result['authors'][author.rank] = {
"fullName": author.content,
"orcid": author.orcid,
"orcid_pending": author.orcid_pending
"fullName": author.fullname,
"orcid": author.orcid? author.orcid: "",
"orcid_pending": ""/* TODO as soon as it is included author.orcid_pending*/
};
}
}
@ -375,19 +368,18 @@ export class SearchResearchResultsService {
});
}
var date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // transform to string in case it is an integer
var date: string = (resData['result'].publicationdate ? resData['result'].publicationdate : '') + ''; // transform to string in case it is an integer
result.year = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
let abstracts = this.parsingFunctions.parseDescription(resData.description, true);
let abstracts = this.parsingFunctions.parseDescription(resData['result'].description, true);
result.description = abstracts;
// if (result.description && result.description.length > this.sizeOfDescription) {
// result.description = result.description.substring(0, this.sizeOfDescription) + "...";
// }
if (resData.embargoenddate && resData.embargoenddate != '') {
result.embargoEndDate = Dates.getDate(resData.embargoenddate);
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;
} else {
@ -479,10 +471,10 @@ export class SearchResearchResultsService {
"code": ""
};
if (relation.title != 'unidentified') {
projects[countProjects]['id'] = relation['to'].content;
if (relation.projectTitle != 'unidentified') {
projects[countProjects]['id'] = relation['header']['identifier'];
projects[countProjects]['acronym'] = relation.acronym;
projects[countProjects]['title'] = relation.title;
projects[countProjects]['title'] = relation.projectTitle;
projects[countProjects]['code'] = relation.code;
} else {
projects[countProjects]['id'] = "";