[new-search-json| WIP ] start parsing for search research results
This commit is contained in:
parent
82e8551129
commit
89dcbb7c8f
|
@ -282,8 +282,8 @@ export class ParsingFunctions {
|
|||
let length = Array.isArray(instance['hostedby']) ? instance['hostedby'].length : 1;
|
||||
for (let i = 0; i < length; i++) {
|
||||
let hostedBy = Array.isArray(instance['hostedby']) ? instance['hostedby'][i] : instance['hostedby'];
|
||||
if (hostedBy.name && hostedBy.name != "other resources" && hostedBy.name != "Unknown Repository") {
|
||||
downloadNames.add(String(hostedBy.name));
|
||||
if (hostedBy.dsName && hostedBy.dsName != "other resources" && hostedBy.dsName != "Unknown Repository") {
|
||||
downloadNames.add(String(hostedBy.dsName));
|
||||
}
|
||||
}
|
||||
available.downloadNames = Array.from(downloadNames);
|
||||
|
@ -297,8 +297,8 @@ export class ParsingFunctions {
|
|||
let length = Array.isArray(instance['collectedfrom']) ? instance['collectedfrom'].length : 1;
|
||||
for (let i = 0; i < length; i++) {
|
||||
let collectedFrom = Array.isArray(instance['collectedfrom']) ? instance['collectedfrom'][i] : instance['collectedfrom'];
|
||||
if (collectedFrom.name && collectedFrom.id) {
|
||||
available.collectedNamesAndIds.set(String(collectedFrom.name), collectedFrom.id);
|
||||
if (collectedFrom.dsName && collectedFrom.dsId) {
|
||||
available.collectedNamesAndIds.set(String(collectedFrom.dsName), collectedFrom.dsId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -308,8 +308,8 @@ export class ParsingFunctions {
|
|||
let length = Array.isArray(instance['instancetype']) ? instance['instancetype'].length : 1;
|
||||
for (let i = 0; i < length; i++) {
|
||||
let instanceType = Array.isArray(instance['instancetype']) ? instance['instancetype'][i] : instance['instancetype'];
|
||||
if (instanceType.classname && instanceType.classname.toLowerCase() !== "unknown") {
|
||||
types.add(instanceType.classname);
|
||||
if (instanceType && instanceType.toLowerCase() !== "unknown") {
|
||||
types.add(instanceType);
|
||||
}
|
||||
}
|
||||
available.types = Array.from(types);
|
||||
|
@ -337,9 +337,9 @@ export class ParsingFunctions {
|
|||
let accessRight = Array.isArray(instance['accessright']) ? instance['accessright'][i] : instance['accessright'];
|
||||
|
||||
if (this.changeBestAccessMode(available.accessRight, accessRight)) {
|
||||
available.accessRight = accessRight.classname;
|
||||
available.accessRight = accessRight.value;
|
||||
if (this.changeBestAccessMode(globalAccessRight, accessRight)) {
|
||||
globalAccessRight = accessRight.classname;
|
||||
globalAccessRight = accessRight.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ export class ParsingFunctions {
|
|||
available.fulltext = instance['fulltext'];
|
||||
}
|
||||
|
||||
if(instance.hasOwnProperty("refereed") && instance.refereed.classname == "peerReviewed") {
|
||||
if(instance.hasOwnProperty("refereed") && instance.refereed == "peerReviewed") {
|
||||
available.peerReviewed = true;
|
||||
}
|
||||
|
||||
|
@ -594,24 +594,24 @@ export class ParsingFunctions {
|
|||
parseIdentifiers(pid: any): Map<string, string[]> {
|
||||
let identifiers = new Map<string, string[]>();
|
||||
|
||||
if (pid.hasOwnProperty("classid") && pid['classid'] != "") {
|
||||
if (pid.classid == "doi" || pid.classid == "pmc" || pid.classid == "handle" || pid.classid == "pmid" || pid.classid == "re3data"
|
||||
|| pid.classid == "swhid"
|
||||
|| pid.classid == "ROR" || pid.classid == "ISNI" || pid.classid == "Wikidata" || pid.classid == "FundRef") {
|
||||
if (!identifiers.has(pid.classid)) {
|
||||
identifiers.set(pid.classid, new Array<string>());
|
||||
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 (!identifiers.has(pid.type)) {
|
||||
identifiers.set(pid.type, new Array<string>());
|
||||
}
|
||||
identifiers.get(pid.classid).push(pid.content + "");
|
||||
identifiers.get(pid.type).push(pid.value + "");
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < pid.length; i++) {
|
||||
if (pid[i].classid == "doi" || pid[i].classid == "pmc" || pid[i].classid == "handle" || pid[i].classid == "pmid" || pid[i].classid == "re3data"
|
||||
|| pid[i].classid == "swhid"
|
||||
|| pid[i].classid == "ROR" || pid[i].classid == "ISNI" || pid[i].classid == "Wikidata" || pid[i].classid == "FundRef") {
|
||||
if (!identifiers.has(pid[i].classid)) {
|
||||
identifiers.set(pid[i].classid, new Array<string>());
|
||||
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 (!identifiers.has(pid[i].type)) {
|
||||
identifiers.set(pid[i].type, new Array<string>());
|
||||
}
|
||||
identifiers.get(pid[i].classid).push(pid[i].content + "");
|
||||
identifiers.get(pid[i].type).push(pid[i].value + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -839,10 +839,10 @@ export class ParsingFunctions {
|
|||
}
|
||||
|
||||
parseTypes(types: string[], uniqueTypes: Set<string>, instance: any) {
|
||||
if (instance && instance.hasOwnProperty("instancetype") && instance['instancetype'].classname) {
|
||||
if (!uniqueTypes.has(instance['instancetype'].classname)) {
|
||||
types.push(instance['instancetype'].classname);
|
||||
uniqueTypes.add(instance['instancetype'].classname);
|
||||
if (instance && instance.hasOwnProperty("instancetype")) {
|
||||
if (!uniqueTypes.has(instance['instancetype'])) {
|
||||
types.push(instance['instancetype']);
|
||||
uniqueTypes.add(instance['instancetype']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,262 +190,263 @@ export class SearchResearchResultsService {
|
|||
let length = Array.isArray(data) ? data.length : 1;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
|
||||
|
||||
let resData = Array.isArray(data) ? data[i]: data;
|
||||
var result: SearchResult = new SearchResult();
|
||||
if (resData['resulttype']) {
|
||||
result.entityType = resData['resulttype']['classname'];
|
||||
} else {
|
||||
result.entityType = resultType;
|
||||
}
|
||||
|
||||
result['title'] = {"name": '', "accessMode": ''};
|
||||
|
||||
if (Array.isArray(resData['title'])) {
|
||||
for (let i = 0; i < resData['title'].length; i++) {
|
||||
if (resData['title'][i] && resData['title'][i].content) {
|
||||
if (!result.title.name || resData['title'][i].classid == "main title") {
|
||||
result['title'].name = StringUtils.HTMLToString(String(resData['title'][i].content));
|
||||
}
|
||||
if (resData['title'][i].classid == "main title") {
|
||||
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['title'] && resData['title'].content) ? StringUtils.HTMLToString(String(resData['title'].content)) : "";
|
||||
}
|
||||
|
||||
if (resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classname")) {
|
||||
result['title'].accessMode = resData['bestaccessright'].classname;
|
||||
}
|
||||
|
||||
result.types = new Array<string>();
|
||||
let types = new Set<string>();
|
||||
|
||||
let instance;
|
||||
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
|
||||
result.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
|
||||
for (let i = 0; i < length; i++) {
|
||||
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
|
||||
this.parsingFunctions.parseTypes(result.types, types, instance);
|
||||
if(instance?.hasOwnProperty("hostedby")) {
|
||||
if(instance.hasOwnProperty("webresource")) {
|
||||
let url = Array.isArray(instance['webresource'])?instance['webresource'][0].url:instance['webresource'].url;
|
||||
if(url.includes('&')) {
|
||||
url = url.replace(/&/gmu, '&');
|
||||
}
|
||||
if(instance.hasOwnProperty("hostedby")) {
|
||||
this.parsingFunctions.parseHostedBy_collectedFrom(result.hostedBy_collectedFrom, instance, url, result.title.accessMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
result.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom);
|
||||
|
||||
// Measure
|
||||
result.measure = this.parsingFunctions.parseMeasures(resData['measure']);
|
||||
/////////////////////////// Athena Code ///////////////////////////
|
||||
if (resData['pid']) {
|
||||
if (!Array.isArray(resData['pid'])) {
|
||||
if (resData['pid'].classid && resData['pid'].classid == 'doi') {
|
||||
if (resData['pid'].content != '' && resData['pid'].content != null) {
|
||||
result.DOIs.push((resData['pid'].content + "").replace("https://doi.org/", ""));
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (resData.result['resulttype']) {
|
||||
result.entityType = resData.result['resulttype'];
|
||||
} else {
|
||||
for (let i = 0; i < resData['pid'].length; i++) {
|
||||
if (resData['pid'][i].classid == 'doi') {
|
||||
if (resData['pid'][i].content != '' && resData['pid'][i].content != null && resData['pid'][i].content) {
|
||||
result.DOIs.push((resData['pid'][i].content + "").replace("https://doi.org/", ""));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']);
|
||||
}
|
||||
/////////////////////////// Athena Code ///////////////////////////
|
||||
if (resData['programmingLanguage'] && resData['programmingLanguage'] != null) {
|
||||
result.programmingLanguages = new Array<string>();
|
||||
|
||||
if (!Array.isArray(resData['programmingLanguage'])) {
|
||||
if (resData['programmingLanguage'].classname != "Undetermined" && resData['programmingLanguage'].classname) {
|
||||
result.programmingLanguages.push(resData['programmingLanguage'].classname);
|
||||
if (!result.title.name) {
|
||||
result['title'].name = "";
|
||||
}
|
||||
// result['title'].name = (resData['title'][0] && resData['title'][0].content) ? String(resData['title'][0].content) : "";
|
||||
} else {
|
||||
for (let i = 0; i < resData['programmingLanguage'].length; i++) {
|
||||
if (resData['programmingLanguage'][i].classname != "Undetermined" && resData['programmingLanguage'][i].classname) {
|
||||
result.programmingLanguages.push(resData['programmingLanguage'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resData['language'] && resData['language'] != null) {
|
||||
result.languages = new Array<string>();
|
||||
|
||||
if (!Array.isArray(resData['language'])) {
|
||||
if (resData['language'].classname != "Undetermined" && resData['language'].classname) {
|
||||
result.languages.push(resData['language'].classname);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < resData['language'].length; i++) {
|
||||
if (resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
|
||||
result.languages.push(resData['language'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resData['country'] && resData['country'] != null) {
|
||||
result.countriesForResults = new Array<string>();
|
||||
|
||||
if (!Array.isArray(resData['country'])) {
|
||||
if (resData['country'].classname != "Undetermined" && resData['country'].classname) {
|
||||
result.countriesForResults.push(resData['country'].classname);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < resData['country'].length; i++) {
|
||||
if (resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
|
||||
result.countriesForResults.push(resData['country'][i].classname);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
|
||||
result['objId'] = result['id'];
|
||||
let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "result");
|
||||
if (canId) {
|
||||
result['id'] = canId;
|
||||
}
|
||||
result['relcanId'] = result['id'];
|
||||
|
||||
if (resData['rels'].hasOwnProperty("rel")) {
|
||||
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
|
||||
|
||||
for (let j = 0; j < relLength; j++) {
|
||||
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
|
||||
|
||||
if (relation.hasOwnProperty("to")) {
|
||||
if (relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") {
|
||||
result['projects'] = this.parseProjects(result['projects'], relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resData.hasOwnProperty("creator") && resData['creator'] != null) {
|
||||
if (result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>();
|
||||
result['title'].name = (resData.result['maintitle']) ? StringUtils.HTMLToString(resData.result['maintitle']) : "";
|
||||
}
|
||||
|
||||
let authors = resData['creator'];
|
||||
let length = Array.isArray(authors) ? authors.length : 1;
|
||||
if (resData.result['bestaccessright'] && resData.result['bestaccessright']['label']) {
|
||||
result['title'].accessMode = resData.result['bestaccessright']['label'];
|
||||
}
|
||||
|
||||
result.types = new Array<string>();
|
||||
let types = new Set<string>();
|
||||
|
||||
let instance;
|
||||
let length = Array.isArray(resData.result['instance']) ? resData.result['instance'].length : 1;
|
||||
result.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
|
||||
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(result['authors'][author.rank] && result['authors'][author.rank].fullName == author.content) {
|
||||
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;
|
||||
instance = Array.isArray(resData.result['instance']) ? resData.result['instance'][i] : resData.result['instance'];
|
||||
this.parsingFunctions.parseTypes(result.types, types, instance);
|
||||
if (instance?.hasOwnProperty("hostedby")) {
|
||||
if (instance.hasOwnProperty("url")) {
|
||||
let url = Array.isArray(instance['url']) ? instance['url'][0] : instance['url'];
|
||||
if (url.includes('&')) {
|
||||
url = url.replace(/&/gmu, '&');
|
||||
}
|
||||
if (instance.hasOwnProperty("hostedby")) {
|
||||
this.parsingFunctions.parseHostedBy_collectedFrom(result.hostedBy_collectedFrom, instance, url, result.title.accessMode);
|
||||
}
|
||||
}
|
||||
|
||||
result['authors'][author.rank] = {
|
||||
"fullName": author.content,
|
||||
"orcid": author.orcid,
|
||||
"orcid_pending": author.orcid_pending
|
||||
};
|
||||
}
|
||||
}
|
||||
result.authors = result.authors.filter(function (item) {
|
||||
return (item != undefined && item.fullName != undefined);
|
||||
});
|
||||
}
|
||||
|
||||
var date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // 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);
|
||||
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 (!Array.isArray(resData.publisher)) {
|
||||
result.publisher = resData.publisher;
|
||||
} else {
|
||||
for (let i = 0; i < resData.publisher.length; i++) {
|
||||
if (result.publisher != undefined) {
|
||||
result.publisher += ', ' + resData['publisher'][i];
|
||||
result.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom);
|
||||
//TODO measures when available
|
||||
// Measure
|
||||
result.measure = this.parsingFunctions.parseMeasures(resData['measure']);
|
||||
/////////////////////////// Athena Code ///////////////////////////
|
||||
if (resData['pid']) {
|
||||
if (!Array.isArray(resData['pid'])) {
|
||||
if (resData['pid'].type && resData['pid'].type == 'doi') {
|
||||
if (resData['pid'].value != '' && resData['pid'].value != null) {
|
||||
result.DOIs.push((resData['pid'].value + "").replace("https://doi.org/", ""));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.publisher = resData['publisher'][i];
|
||||
for (let i = 0; i < resData['pid'].length; i++) {
|
||||
if (resData['pid'][i].type == 'doi') {
|
||||
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.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']);
|
||||
}
|
||||
/////////////////////////// Athena Code ///////////////////////////
|
||||
if (resData.result['programmingLanguage'] && resData.result['programmingLanguage'] != null) {
|
||||
result.programmingLanguages = new Array<string>();
|
||||
|
||||
if (!Array.isArray(resData.result['programmingLanguage'])) {
|
||||
if (resData.result['programmingLanguage'] != "Undetermined" && resData.result['programmingLanguage']) {
|
||||
result.programmingLanguages.push(resData.result['programmingLanguage']);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < resData.result['programmingLanguage'].length; i++) {
|
||||
if (resData.result['programmingLanguage'][i] != "Undetermined" && resData.result['programmingLanguage'][i]) {
|
||||
result.programmingLanguages.push(resData.result['programmingLanguage'][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
result.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
||||
result.dateofacceptance = resData.dateofacceptance ? Dates.getDate(resData.dateofacceptance) : null;
|
||||
}
|
||||
if (resData.journal && resData.journal != null) {
|
||||
result.journal = {
|
||||
"journal": "",
|
||||
"issn": "",
|
||||
"lissn": "",
|
||||
"eissn": "",
|
||||
"issue": "",
|
||||
"volume": "",
|
||||
"start_page": "",
|
||||
"end_page": ""
|
||||
|
||||
if (resData['language'] && resData['language'] != null) {
|
||||
result.languages = new Array<string>();
|
||||
|
||||
if (!Array.isArray(resData['language'])) {
|
||||
if (resData['language'].label != "Undetermined" && resData['language'].label) {
|
||||
result.languages.push(resData['language'].label);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < resData['language'].length; i++) {
|
||||
if (resData['language'][i].label != "Undetermined" && resData['language'][i].label) {
|
||||
result.languages.push(resData['language'][i].label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
|
||||
result.hostedBy_collectedFrom, result.publisher,
|
||||
result['journal']?result['journal'].journal:null, result.identifiers);
|
||||
if (resData.result['country'] && resData.result['country'] != null) {
|
||||
result.countriesForResults = new Array<string>();
|
||||
|
||||
if (!Array.isArray(resData.result['country'])) {
|
||||
if (resData.result['country'].label != "Undetermined" && resData.result['country'].label) {
|
||||
result.countriesForResults.push(resData.result['country'].label);
|
||||
}
|
||||
} else {
|
||||
for (let i = 0; i < resData.result['country'].length; i++) {
|
||||
if (resData.result['country'][i].label != "Undetermined" && resData.result['country'][i].label) {
|
||||
result.countriesForResults.push(resData.result['country'][i].label);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result['id'] = resData['header']['id'];
|
||||
result['objId'] = result['id'];
|
||||
//TODO canID
|
||||
let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "result");
|
||||
if (canId) {
|
||||
result['id'] = canId;
|
||||
}
|
||||
result['relcanId'] = result['id'];
|
||||
|
||||
if (resData['links']) {
|
||||
let relLength = Array.isArray(resData['links']) ? resData['links'].length : 1;
|
||||
|
||||
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") {
|
||||
result['projects'] = this.parseProjects(result['projects'], relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resData.hasOwnProperty("creator") && resData['creator'] != null) {
|
||||
if (result['authors'] == undefined) {
|
||||
result['authors'] = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>();
|
||||
}
|
||||
|
||||
let authors = resData['creator'];
|
||||
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 (result['authors'][author.rank] && result['authors'][author.rank].fullName == author.content) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
result['authors'][author.rank] = {
|
||||
"fullName": author.content,
|
||||
"orcid": author.orcid,
|
||||
"orcid_pending": author.orcid_pending
|
||||
};
|
||||
}
|
||||
}
|
||||
result.authors = result.authors.filter(function (item) {
|
||||
return (item != undefined && item.fullName != undefined);
|
||||
});
|
||||
}
|
||||
|
||||
var date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // 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);
|
||||
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 (!Array.isArray(resData.publisher)) {
|
||||
result.publisher = resData.publisher;
|
||||
} else {
|
||||
for (let i = 0; i < resData.publisher.length; i++) {
|
||||
if (result.publisher != undefined) {
|
||||
result.publisher += ', ' + resData['publisher'][i];
|
||||
} else {
|
||||
result.publisher = resData['publisher'][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
result.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
||||
result.dateofacceptance = resData.dateofacceptance ? Dates.getDate(resData.dateofacceptance) : null;
|
||||
}
|
||||
if (resData.journal && resData.journal != null) {
|
||||
result.journal = {
|
||||
"journal": "",
|
||||
"issn": "",
|
||||
"lissn": "",
|
||||
"eissn": "",
|
||||
"issue": "",
|
||||
"volume": "",
|
||||
"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.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
|
||||
result.hostedBy_collectedFrom, result.publisher,
|
||||
result['journal'] ? result['journal'].journal : null, result.identifiers);
|
||||
|
||||
|
||||
if(resData.hasOwnProperty("publiclyfunded") && resData.publiclyfunded) {
|
||||
result.publiclyFunded = resData.publiclyfunded;
|
||||
}
|
||||
if((resData.hasOwnProperty("isgreen") && resData.isgreen)
|
||||
|| (resData.hasOwnProperty("openaccesscolor") && resData.openaccesscolor)
|
||||
|| (resData.hasOwnProperty("isindiamondjournal") && resData.isindiamondjournal)) {
|
||||
result.oaRoutes = {
|
||||
"green": resData.isgreen,
|
||||
"oaColor": resData.openaccesscolor,
|
||||
"isInDiamondJournal":resData.isindiamondjournal
|
||||
};
|
||||
if (resData.hasOwnProperty("publiclyfunded") && resData.publiclyfunded) {
|
||||
result.publiclyFunded = resData.publiclyfunded;
|
||||
}
|
||||
if ((resData.hasOwnProperty("isgreen") && resData.isgreen)
|
||||
|| (resData.hasOwnProperty("openaccesscolor") && resData.openaccesscolor)
|
||||
|| (resData.hasOwnProperty("isindiamondjournal") && resData.isindiamondjournal)) {
|
||||
result.oaRoutes = {
|
||||
"green": resData.isgreen,
|
||||
"oaColor": resData.openaccesscolor,
|
||||
"isInDiamondJournal": resData.isindiamondjournal
|
||||
};
|
||||
}
|
||||
}catch (e){
|
||||
console.error(e)
|
||||
}
|
||||
|
||||
results.push(result);
|
||||
|
|
Loading…
Reference in New Issue