[new-search-json | WIP ] continue parsing research results, start parsing result landing

This commit is contained in:
argirok 2024-10-09 09:54:41 +03:00
parent 187444bb09
commit f675fba83b
4 changed files with 350 additions and 342 deletions

View File

@ -28,7 +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"];
//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; private instanceWithDoiExists: boolean = false;
constructor() { constructor() {
@ -595,9 +598,7 @@ export class ParsingFunctions {
let identifiers = new Map<string, string[]>(); let identifiers = new Map<string, string[]>();
if (pid.hasOwnProperty("type") && pid['type'] != "") { if (pid.hasOwnProperty("type") && pid['type'] != "") {
if (pid.type == "doi" || pid.type == "pmc" || pid.type == "handle" || pid.type == "pmid" || pid.type == "re3data" if (this.identifierTypes.indexOf(pid.type) !=-1) {
|| pid.type == "swhid"
|| pid.type == "ROR" || pid.type == "ISNI" || pid.type == "Wikidata" || pid.type == "FundRef") {
if (!identifiers.has(pid.type)) { if (!identifiers.has(pid.type)) {
identifiers.set(pid.type, new Array<string>()); identifiers.set(pid.type, new Array<string>());
} }
@ -605,9 +606,7 @@ export class ParsingFunctions {
} }
} else { } else {
for (let i = 0; i < pid.length; i++) { 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" if (this.identifierTypes.indexOf(pid[i].type) !=-1) {
|| 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)) { if (!identifiers.has(pid[i].type)) {
identifiers.set(pid[i].type, new Array<string>()); identifiers.set(pid[i].type, new Array<string>());
} }
@ -617,7 +616,7 @@ export class ParsingFunctions {
} }
return identifiers; return identifiers;
} }
// publication & dataset landing : for subjects and otherSubjects and classifiedSubjects // publication & dataset landing : for subjects and otherSubjects and classifiedSubjects
parseEoscSubjects(_subjects: any): any[] { parseEoscSubjects(_subjects: any): any[] {
let eoscSubjectsFound = []; let eoscSubjectsFound = [];

View File

@ -10,6 +10,7 @@ import {
} from '@angular/core'; } from '@angular/core';
import {EnvProperties} from "../../utils/properties/env-properties"; import {EnvProperties} from "../../utils/properties/env-properties";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {ParsingFunctions} from "./parsingFunctions.class";
@Component({ @Component({
selector: 'showIdentifiers', selector: 'showIdentifiers',
@ -26,8 +27,7 @@ import {properties} from "../../../../environments/environment";
<span class="uk-text-meta uk-text-small" [class.uk-text-uppercase]="key != 're3data'">{{key}}: </span> <span class="uk-text-meta uk-text-small" [class.uk-text-uppercase]="key != 're3data'">{{key}}: </span>
<span [class.uk-margin-small-left]="modal"> <span [class.uk-margin-small-left]="modal">
<ng-container *ngFor="let item of identifiers.get(key) let j=index"> <ng-container *ngFor="let item of identifiers.get(key) let j=index">
<a *ngIf="key == 'doi' || key == 'pmc' || key == 'pmid' || key == 'handle' || key == 're3data' || key == 'swhid' <a *ngIf="parsingFunctions.identifierTypes.indexOf(key) != -1"
|| key == 'ROR' || key == 'ISNI' || key == 'Wikidata' || key == 'FundRef'"
[href]="getUrl(key, item) + item" target="_blank" class="uk-display-inline-block custom-external"> [href]="getUrl(key, item) + item" target="_blank" class="uk-display-inline-block custom-external">
{{item}} {{item}}
</a> </a>
@ -69,7 +69,7 @@ export class ShowIdentifiersComponent implements AfterViewInit {
properties: EnvProperties = properties; properties: EnvProperties = properties;
@ViewChildren("content", { read: ElementRef }) types: QueryList<ElementRef>; @ViewChildren("content", { read: ElementRef }) types: QueryList<ElementRef>;
@ViewChild('identifiersModal') identifiersModal; @ViewChild('identifiersModal') identifiersModal;
public parsingFunctions: ParsingFunctions = new ParsingFunctions();
constructor(private cdr: ChangeDetectorRef) { constructor(private cdr: ChangeDetectorRef) {
} }
@ -118,7 +118,7 @@ export class ShowIdentifiersComponent implements AfterViewInit {
if(value.includes("http://") || value.includes("https://")) { if(value.includes("http://") || value.includes("https://")) {
return ""; return "";
} }
if(key == "doi") { if(key == "doi" || key == "Digital Object Identifier") {
return properties.doiURL; return properties.doiURL;
} else if(key == "pmc") { } else if(key == "pmc") {
return properties.pmcURL; return properties.pmcURL;

View File

@ -74,13 +74,14 @@ export class ResultLandingService {
error: "Http failure response for " + finalUrl + ": 404 Not Found" error: "Http failure response for " + finalUrl + ": 404 Not Found"
}); });
} }
//TODO make sure to pass the correct part
return res['results'][0]; return res['results'][0];
} else { } else {
return res; return res;
} }
})) }))
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res])) // .pipe(map(res => [res['meta']['status'], res['result']['metadata']['oaf:entity'], res]))
.pipe(map(res => [ /*.pipe(map(res => [
res[1]['oaf:result'], // 0 res[1]['oaf:result'], // 0
res[1]['oaf:result']['title'], // 1 res[1]['oaf:result']['title'], // 1
res[1]['oaf:result']['rels']['rel'], // 2 res[1]['oaf:result']['rels']['rel'], // 2
@ -99,7 +100,7 @@ export class ResultLandingService {
? res[1]['extraInfo']['references']['reference'] : null, // 13 ? res[1]['extraInfo']['references']['reference'] : null, // 13
res[0], // 14 res[0], // 14
res[2], // 15 res[2], // 15
])) ]))*/
.pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties))); .pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties)));
} }
@ -128,330 +129,335 @@ export class ResultLandingService {
parseResultLandingInfo(data: any, subjectsVocabulary: any, properties: EnvProperties): any { parseResultLandingInfo(data: any, subjectsVocabulary: any, properties: EnvProperties): any {
this.resultLandingInfo = new ResultLandingInfo(); this.resultLandingInfo = new ResultLandingInfo();
// res try {
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;
// res['result']['metadata']['oaf:entity']['oaf:result']
if (data[0] != null) { // res
let date: string = (data[0].dateofacceptance ? data[0].dateofacceptance : '') + ''; // transform to string in case it is an integer 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.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
this.resultLandingInfo.dateofacceptance = data[0].dateofacceptance ? Dates.getDate(data[0].dateofacceptance) : null; this.resultLandingInfo.dateofacceptance = data['result']['publicationdate'] ? Dates.getDate(data['result']['publicationdate']) : null;
this.resultLandingInfo.publisher = data[0].publisher; this.resultLandingInfo.publisher = data['result']['publisher'];
this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data[0] && data[0].description ? data[0].description : []); this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data['result']['description'] ? data['result']['description'] : []);
this.resultLandingInfo.embargoEndDate = data[0].embargoenddate ? Dates.getDate(data[0].embargoenddate) : null; 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) //TODO check duplicates - are we going to keep one?
|| (data[0].hasOwnProperty("openaccesscolor") && data[0].openaccesscolor) if ((data['result'].hasOwnProperty("isGreen") && data['result'].isGreen)
|| (data[0].hasOwnProperty("isindiamondjournal") && data[0].isindiamondjournal)) { || (data['result'].hasOwnProperty("openAccessColor") && data['result'].openAccessColor)
|| (data['result'].hasOwnProperty("isInDiamondJournal") && data['result'].isInDiamondJournal)) {
this.resultLandingInfo.oaRoutes = { this.resultLandingInfo.oaRoutes = {
"green": data[0].isgreen, "green": data['result'].isGreen,
"oaColor": data[0].openaccesscolor, "oaColor": data['result'].openAccessColor,
"isInDiamondJournal":data[0].isindiamondjournal "isInDiamondJournal": data['result'].isInDiamondJournal
}; };
} }
}
if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) { //TODO continue from here
this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname; 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)) : "";
} }
} // res['result']['metadata']['oaf:entity']['oaf:result']['title']
if (data[1] != null) {
// res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel'] if (Array.isArray(data[1])) {
if (data[2] != null) { for (let i = 0; i < data[1].length; i++) {
let relation; if (data[1][i] && data[1][i].content) {
let length = Array.isArray(data[2]) ? data[2].length : 1; if (!this.resultLandingInfo.title || data[1][i].classid == "main title") {
this.resultLandingInfo.title = StringUtils.HTMLToString(String(data[1][i].content));
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<HostedByCollectedFrom>();
this.resultLandingInfo.types = new Array<string>();
let types = new Set<string>();
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('&amp;')) {
url = url.replace(/&amp;/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<string, Map<string, string>> = 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<string, string[]>, Map<string, string[]>, 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.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.fos) { }
this.resultLandingInfo.fos.sort((a, b) => a.id.localeCompare(b.id)); if (!this.resultLandingInfo.title) {
} this.resultLandingInfo.title = "";
if(properties.dashboard != "irish") { }
this.resultLandingInfo.sdg = subjectResults[4]; // this.resultLandingInfo.title = (data[1][0] && data[1][0].content) ? String(data[1][0].content) : "";
if (this.resultLandingInfo.sdg) { } else {
this.resultLandingInfo.sdg.sort((a, b) => { this.resultLandingInfo.title = (data[1] && data[1].content) ? StringUtils.HTMLToString(String(data[1].content)) : "";
return HelperFunctions.sortSDGs(a, b);
})
} }
} }
// if(!this.resultLandingInfo.eoscSubjects) { // res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel']
// this.resultLandingInfo.eoscSubjects = subjectResults[5]; 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<HostedByCollectedFrom>();
this.resultLandingInfo.types = new Array<string>();
let types = new Set<string>();
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('&amp;')) {
url = url.replace(/&amp;/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<string, Map<string, string>> = 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<string, string[]>, Map<string, string[]>, 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.hostedBy_collectedFrom, this.resultLandingInfo.publisher,
this.resultLandingInfo.journal?.journal, this.resultLandingInfo.identifiers); this.resultLandingInfo.journal?.journal, this.resultLandingInfo.identifiers);
// res['result']['metadata']['oaf:entity']['oaf:result']['programmingLanguage'] // res['result']['metadata']['oaf:entity']['oaf:result']['programmingLanguage']
if (data[12] != null) { if (data[12] != null) {
this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[12]); 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 }>();
} }
let authors = data[10]; // res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference']
let length = Array.isArray(authors) ? authors.length : 1; if (data[13] != null) {
this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]);
}
for (let i = 0; i < length; i++) { // res['result']['metadata']['oaf:entity']['oaf:result']['context']
let author = Array.isArray(authors) ? authors[i] : authors; if (data[9] != null) {
if (author) { this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[9]);
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) { // res['result']['header']['dri:status']
if(!author.orcid && this.resultLandingInfo['authors'][author.rank].orcid) { if (data[14] != null && data[14] == "under curation") {
author.orcid = this.resultLandingInfo['authors'][author.rank].orcid; this.resultLandingInfo.underCurationMessage = true;
} else if(!author.orcid_pending && this.resultLandingInfo['authors'][author.rank].orcid_pending) { } else {
author.orcid_pending = this.resultLandingInfo['authors'][author.rank].orcid_pending; this.resultLandingInfo.underCurationMessage = false;
} }
}
this.resultLandingInfo['authors'][author.rank] = { // res['result']['metadata']['oaf:entity']['oaf:result']['creator']
"fullName": author.content, if (data[10] != null) {
"orcid": author.orcid, if (this.resultLandingInfo.authors == undefined) {
"orcid_pending": author.orcid_pending 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; return this.resultLandingInfo;
} }

View File

@ -234,14 +234,16 @@ export class SearchResearchResultsService {
/////////////////////////// Athena Code /////////////////////////// /////////////////////////// Athena Code ///////////////////////////
if (resData['pid']) { if (resData['pid']) {
if (!Array.isArray(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) { 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++) {
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) { 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/", ""));
} }
@ -307,7 +309,6 @@ export class SearchResearchResultsService {
result['id'] = canId; result['id'] = canId;
} }
result['relcanId'] = result['id']; result['relcanId'] = result['id'];
if (resData['links']) { if (resData['links']) {
let relLength = Array.isArray(resData['links']) ? resData['links'].length : 1; let relLength = Array.isArray(resData['links']) ? resData['links'].length : 1;
@ -379,27 +380,28 @@ export class SearchResearchResultsService {
if (resData['result'].embargoenddate && resData['result'].embargoenddate != '') { if (resData['result'].embargoenddate && resData['result'].embargoenddate != '') {
result.embargoEndDate = Dates.getDate(resData['result'].embargoenddate); result.embargoEndDate = Dates.getDate(resData['result'].embargoenddate);
} }
// TODO continue from here
if (!Array.isArray(resData.publisher)) { if (!Array.isArray(resData['result'].publisher)) {
result.publisher = resData.publisher; result.publisher = resData['result'].publisher;
} else { } else {
for (let i = 0; i < resData.publisher.length; i++) { for (let i = 0; i < resData.publisher['result'].length; i++) {
if (result.publisher != undefined) { if (result.publisher != undefined) {
result.publisher += ', ' + resData['publisher'][i]; result.publisher += ', ' + resData['result']['publisher'][i];
} else { } else {
result.publisher = resData['publisher'][i]; result.publisher = resData['result']['publisher'][i];
} }
} }
} }
//todo DOUBLEcheck with connect
if (resData['context'] != null) { if (resData['context'] != null) {
result.enermapsId = ParsingFunctions.getEnermapsConceptId(this.parsingFunctions.parseContexts(resData['context'])); result.enermapsId = ParsingFunctions.getEnermapsConceptId(this.parsingFunctions.parseContexts(resData['context']));
} }
if (resData.dateofacceptance && resData.dateofacceptance != null) { if (resData['result'].publicationdate && resData['result'].publicationdate != null) {
let date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // transform to string in case it is an integer 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.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 = { result.journal = {
"journal": "", "journal": "",
"issn": "", "issn": "",
@ -410,14 +412,14 @@ export class SearchResearchResultsService {
"start_page": "", "start_page": "",
"end_page": "" "end_page": ""
} }
result.journal['journal'] = resData.journal.content; result.journal['journal'] = resData['result'].journal.name;
result.journal['issn'] = resData.journal.issn; result.journal['issn'] = resData['result'].journal.issnPrinted;
result.journal['lissn'] = resData.journal.lissn; result.journal['lissn'] = resData['result'].journal.issnLinking;
result.journal['eissn'] = resData.journal.eissn; result.journal['eissn'] = resData['result'].journal.issnOnline;
result.journal['issue'] = resData.journal.iss; result.journal['issue'] = resData['result'].journal.iss;
result.journal['volume'] = resData.journal.vol; result.journal['volume'] = resData['result'].journal.vol;
result.journal['start_page'] = resData.journal.sp; result.journal['start_page'] = resData['result'].journal.sp;
result.journal['end_page'] = resData.journal.ep; result.journal['end_page'] = resData['result'].journal.ep;
} }
result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
@ -425,16 +427,17 @@ export class SearchResearchResultsService {
result['journal'] ? result['journal'].journal : null, result.identifiers); result['journal'] ? result['journal'].journal : null, result.identifiers);
if (resData.hasOwnProperty("publiclyfunded") && resData.publiclyfunded) { if (resData['result'].hasOwnProperty("publiclyFunded") && resData['result'].publiclyFunded) {
result.publiclyFunded = resData.publiclyfunded; result.publiclyFunded = resData['result'].publiclyFunded;
} }
if ((resData.hasOwnProperty("isgreen") && resData.isgreen) //TODO check duplicates - are we going to keep one?
|| (resData.hasOwnProperty("openaccesscolor") && resData.openaccesscolor) if ((resData['result'].hasOwnProperty("isGreen") && resData['result'].isGreen)
|| (resData.hasOwnProperty("isindiamondjournal") && resData.isindiamondjournal)) { || (resData['result'].hasOwnProperty("openAccessColor") && resData['result'].openAccessColor)
|| (resData['result'].hasOwnProperty("isInDiamondJournal") && resData['result'].isInDiamondJournal)) {
result.oaRoutes = { result.oaRoutes = {
"green": resData.isgreen, "green": resData['result'].isGreen,
"oaColor": resData.openaccesscolor, "oaColor": resData['result'].openAccessColor,
"isInDiamondJournal": resData.isindiamondjournal "isInDiamondJournal": resData['result'].isInDiamondJournal
}; };
} }
}catch (e){ }catch (e){