2019-09-05 10:49:33 +02:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {HttpClient, HttpErrorResponse} from "@angular/common/http";
|
|
|
|
import {throwError} from 'rxjs';
|
|
|
|
import {ResultLandingInfo} from '../../utils/entities/resultLandingInfo';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {ParsingFunctions} from '../landing-utils/parsingFunctions.class';
|
2020-11-11 15:43:13 +01:00
|
|
|
import {map} from "rxjs/operators";
|
2020-07-01 14:11:57 +02:00
|
|
|
import {HostedByCollectedFrom, Organization} from "../../utils/result-preview/result-preview";
|
2021-07-26 12:05:36 +02:00
|
|
|
import {Dates, Identifier, StringUtils} from "../../utils/string-utils.class";
|
2021-01-13 12:58:06 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2022-03-15 22:31:10 +01:00
|
|
|
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
2024-01-08 14:36:27 +01:00
|
|
|
import {SearchFields} from "../../utils/properties/searchFields";
|
2019-09-05 10:49:33 +02:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ResultLandingService {
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
constructor(private http: HttpClient) {
|
2019-09-05 10:49:33 +02:00
|
|
|
this.parsingFunctions = new ParsingFunctions();
|
|
|
|
}
|
|
|
|
|
|
|
|
public parsingFunctions: ParsingFunctions;
|
|
|
|
resultLandingInfo: ResultLandingInfo;
|
|
|
|
|
2021-01-13 12:58:06 +01:00
|
|
|
private buildResultLandingInfoUrl(id: string, identifier: Identifier, type: string): string {
|
|
|
|
if (id) {
|
|
|
|
let url = properties.searchAPIURLLAst;
|
|
|
|
if (type === 'publication') {
|
|
|
|
url += 'publications/';
|
|
|
|
} else if (type === 'dataset') {
|
|
|
|
url += 'datasets/';
|
|
|
|
} else if (type === 'software') {
|
|
|
|
url += 'software/';
|
2021-02-20 10:20:05 +01:00
|
|
|
} else if (type === 'orp' || type === 'other') {
|
2021-01-13 12:58:06 +01:00
|
|
|
url += 'other/';
|
|
|
|
} else if (type === 'result') {
|
|
|
|
url += 'results/';
|
|
|
|
}
|
|
|
|
url += id + '?format=json';
|
|
|
|
return url;
|
|
|
|
} else if (identifier) {
|
|
|
|
// pid = "10.3389/fphys.2014.00466";
|
|
|
|
let url = properties.searchAPIURLLAst + "resources2";
|
2023-10-30 09:53:19 +01:00
|
|
|
url += "?query=(pid exact \"" + encodeURIComponent(identifier.id) + "\")&type=";
|
2021-01-13 12:58:06 +01:00
|
|
|
if (type === 'publication') {
|
|
|
|
url += 'publications';
|
|
|
|
} else if (type === 'dataset') {
|
|
|
|
url += 'datasets';
|
|
|
|
} else if (type === 'software') {
|
|
|
|
url += 'software';
|
|
|
|
} else if (type === 'orp') {
|
|
|
|
url += 'other';
|
|
|
|
} else if (type === 'result') {
|
|
|
|
url += 'results';
|
|
|
|
}
|
|
|
|
url += "&format=json";
|
|
|
|
return url;
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
2021-01-13 12:58:06 +01:00
|
|
|
}
|
2019-09-05 10:49:33 +02:00
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
getResultLandingInfo(id: string, identifier: Identifier, type: string,
|
|
|
|
subjectsVocabulary: any,
|
|
|
|
properties: EnvProperties): any {
|
2021-01-13 12:58:06 +01:00
|
|
|
let url: string = this.buildResultLandingInfoUrl(id, identifier, type);
|
|
|
|
|
|
|
|
let finalUrl: string = (properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url;
|
|
|
|
return this.http.get(finalUrl)
|
2023-02-16 15:33:40 +01:00
|
|
|
.pipe(map(res => {
|
|
|
|
if (!id && identifier) {
|
|
|
|
if (!res['results'] || res['results'].length == 0) {
|
|
|
|
throw new HttpErrorResponse({
|
|
|
|
status: 404,
|
|
|
|
statusText: "Not found",
|
|
|
|
url: finalUrl,
|
|
|
|
error: "Http failure response for " + finalUrl + ": 404 Not Found"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return res['results'][0];
|
|
|
|
} else {
|
|
|
|
return res;
|
2021-01-13 12:58:06 +01:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
}))
|
|
|
|
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res]))
|
|
|
|
.pipe(map(res => [
|
|
|
|
res[1]['oaf:result'], // 0
|
|
|
|
res[1]['oaf:result']['title'], // 1
|
|
|
|
res[1]['oaf:result']['rels']['rel'], // 2
|
|
|
|
res[1]['oaf:result']['children'], // 3
|
|
|
|
res[1]['oaf:result']['pid'], // 4
|
|
|
|
res[1]['oaf:result']['journal'], // 5
|
|
|
|
res[1]['oaf:result']['language'], // 6
|
|
|
|
res[1]['oaf:result']['eoscifguidelines'], // 7
|
|
|
|
res[1]['oaf:result']['subject'], // 8
|
|
|
|
res[1]['oaf:result']['context'], // 9
|
|
|
|
res[1]['oaf:result']['creator'], // 10
|
|
|
|
res[1]['oaf:result']['country'], // 11
|
|
|
|
res[1]['oaf:result']['programmingLanguage'], // 12 - software
|
|
|
|
//res[1]['oaf:result']['resulttype'],
|
|
|
|
(res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['references'] !== undefined)
|
|
|
|
? res[1]['extraInfo']['references']['reference'] : null, // 13
|
|
|
|
res[0], // 14
|
|
|
|
res[2], // 15
|
|
|
|
]))
|
|
|
|
.pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties)));
|
2019-10-09 15:28:23 +02:00
|
|
|
}
|
|
|
|
|
2020-07-13 00:10:43 +02:00
|
|
|
// getProvenanceActionVocabulary (properties: EnvProperties): any {
|
|
|
|
// let url = properties.vocabulariesAPI+"dnet:provenanceActions.json";
|
|
|
|
//
|
|
|
|
// return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
|
|
|
// .pipe(map(res => res['terms']))
|
|
|
|
// .pipe(map(res => this.parseProvenanceActionVocabulary(res, properties)));
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// parseProvenanceActionVocabulary(terms: any, properties: EnvProperties) {
|
|
|
|
// var provenanceActionVocabulary: {} = {};
|
|
|
|
// for(let term of terms) {
|
|
|
|
// provenanceActionVocabulary[term.code] = term.englishName;
|
|
|
|
// }
|
|
|
|
// return provenanceActionVocabulary;
|
|
|
|
// }
|
2019-09-05 10:49:33 +02:00
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
private handleError(error: HttpErrorResponse) {
|
2019-09-05 10:49:33 +02:00
|
|
|
// in a real world app, we may send the error to some remote logging infrastructure
|
|
|
|
// instead of just logging it to the console
|
|
|
|
console.log(error);
|
2023-02-16 15:33:40 +01:00
|
|
|
return throwError(error || 'Server error');
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
parseResultLandingInfo(data: any, subjectsVocabulary: any, properties: EnvProperties): any {
|
|
|
|
this.resultLandingInfo = new ResultLandingInfo();
|
2019-09-05 10:49:33 +02:00
|
|
|
// res
|
2022-08-30 10:35:42 +02:00
|
|
|
this.resultLandingInfo.record = data[15];
|
|
|
|
this.resultLandingInfo.objIdentifier = data[15]["result"]["header"]["dri:objIdentifier"];
|
2020-08-19 13:01:22 +02:00
|
|
|
this.resultLandingInfo.relcanId = ParsingFunctions.parseRelCanonicalId(this.resultLandingInfo.record, "result");
|
2020-03-04 15:29:50 +01:00
|
|
|
this.resultLandingInfo.resultType = data[0].resulttype.classid;
|
2019-09-05 10:49:33 +02:00
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']
|
|
|
|
if (data[0] != null) {
|
2020-07-13 00:10:43 +02:00
|
|
|
let date: string = (data[0].dateofacceptance ? data[0].dateofacceptance : '') + ''; // transform to string in case it is an integer
|
2023-02-16 15:33:40 +01:00
|
|
|
this.resultLandingInfo.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
|
|
|
this.resultLandingInfo.dateofacceptance = data[0].dateofacceptance ? Dates.getDate(data[0].dateofacceptance) : null;
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo.publisher = data[0].publisher;
|
2023-02-16 15:33:40 +01:00
|
|
|
this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data[0] && data[0].description ? data[0].description : []);
|
|
|
|
this.resultLandingInfo.embargoEndDate = data[0].embargoenddate ? Dates.getDate(data[0].embargoenddate) : null;
|
2023-12-20 22:55:00 +01:00
|
|
|
|
|
|
|
if(data[0].hasOwnProperty("publiclyfunded") && data[0].publiclyfunded) {
|
|
|
|
this.resultLandingInfo.publiclyFunded = data[0].publiclyfunded;
|
|
|
|
}
|
|
|
|
if((data[0].hasOwnProperty("isgreen") && data[0].isgreen)
|
|
|
|
|| (data[0].hasOwnProperty("openaccesscolor") && data[0].openaccesscolor)
|
|
|
|
|| (data[0].hasOwnProperty("isindiamondjournal") && data[0].isindiamondjournal)) {
|
|
|
|
this.resultLandingInfo.oaRoutes = {
|
|
|
|
"green": data[0].isgreen,
|
|
|
|
"oaColor": data[0].openaccesscolor,
|
|
|
|
"isInDiamondJournal":data[0].isindiamondjournal
|
|
|
|
};
|
|
|
|
}
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) {
|
2020-02-07 14:05:07 +01:00
|
|
|
this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname;
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['title']
|
2023-02-16 15:33:40 +01:00
|
|
|
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") {
|
2022-11-28 18:22:01 +01:00
|
|
|
this.resultLandingInfo.title = StringUtils.HTMLToString(String(data[1][i].content));
|
2021-02-20 10:20:05 +01:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (!this.resultLandingInfo.subtitle && data[1][i].classid === 'subtitle') {
|
2022-11-28 18:22:01 +01:00
|
|
|
this.resultLandingInfo.subtitle = StringUtils.HTMLToString(String(data[1][i].content));
|
2021-02-10 10:33:36 +01:00
|
|
|
}
|
2022-03-15 22:31:10 +01:00
|
|
|
// if(data[1][i].classid == "main title") {
|
|
|
|
// break;
|
|
|
|
// }
|
2021-02-10 10:33:36 +01:00
|
|
|
}
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.resultLandingInfo.title === this.resultLandingInfo.subtitle) {
|
2022-03-15 22:31:10 +01:00
|
|
|
this.resultLandingInfo.subtitle = "";
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (!this.resultLandingInfo.title) {
|
2021-02-20 10:20:05 +01:00
|
|
|
this.resultLandingInfo.title = "";
|
|
|
|
}
|
2021-02-10 10:33:36 +01:00
|
|
|
// this.resultLandingInfo.title = (data[1][0] && data[1][0].content) ? String(data[1][0].content) : "";
|
2019-09-05 10:49:33 +02:00
|
|
|
} else {
|
2022-11-28 18:22:01 +01:00
|
|
|
this.resultLandingInfo.title = (data[1] && data[1].content) ? StringUtils.HTMLToString(String(data[1].content)) : "";
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[2] != null) {
|
2019-09-05 10:49:33 +02:00
|
|
|
let relation;
|
|
|
|
let length = Array.isArray(data[2]) ? data[2].length : 1;
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
for (let i = 0; i < length; i++) {
|
2019-09-05 10:49:33 +02:00
|
|
|
relation = Array.isArray(data[2]) ? data[2][i] : data[2];
|
2023-02-16 15:33:40 +01:00
|
|
|
if (relation.hasOwnProperty("to")) {
|
|
|
|
if (relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") {
|
2022-09-06 15:28:51 +02:00
|
|
|
this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation);
|
2022-01-07 11:16:23 +01:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (relation['to'].scheme && relation['to'].scheme == "dnet:result_result_relations") {
|
2022-08-03 17:21:14 +02:00
|
|
|
let relationName: string = relation.to.class;
|
2023-02-16 15:33:40 +01:00
|
|
|
if (!this.resultLandingInfo.relatedClassFilters.has(relationName)) {
|
2022-01-07 11:16:23 +01:00
|
|
|
this.resultLandingInfo.relatedClassFilters.add(relationName);
|
|
|
|
}
|
|
|
|
|
2022-09-06 15:28:51 +02:00
|
|
|
let provenanceAction: string = relation.provenanceaction;
|
2019-09-05 10:49:33 +02:00
|
|
|
|
2022-08-03 17:21:14 +02:00
|
|
|
this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName);
|
2023-02-16 15:33:40 +01:00
|
|
|
} else if (relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") {
|
2022-03-15 22:31:10 +01:00
|
|
|
this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation);
|
2024-07-01 22:35:47 +02:00
|
|
|
} else if (relation['to'].scheme && relation['to'].scheme == "dnet:result_datasource_relations") {
|
|
|
|
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);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['children']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[3] != null) {
|
|
|
|
if (data[3].hasOwnProperty("result")) {
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo.deletedByInferenceIds = [];
|
|
|
|
let length = Array.isArray(data[3]['result']) ? data[3]['result'].length : 1;
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
for (let i = 0; i < length; i++) {
|
2019-09-05 10:49:33 +02:00
|
|
|
let result = Array.isArray(data[3]['result']) ? data[3]['result'][i] : data[3]['result'];
|
|
|
|
this.resultLandingInfo.deletedByInferenceIds.push(result.objidentifier);
|
|
|
|
}
|
2024-07-01 23:25:35 +02:00
|
|
|
this.resultLandingInfo.children = data[3]['result'];
|
2019-09-05 10:49:33 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[3].hasOwnProperty("instance")) {
|
2020-07-01 14:11:57 +02:00
|
|
|
this.resultLandingInfo.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
|
2019-09-05 10:49:33 +02:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
for (let i = 0; i < length; i++) {
|
2019-09-05 10:49:33 +02:00
|
|
|
instance = Array.isArray(data[3]['instance']) ? data[3]['instance'][i] : data[3]['instance'];
|
|
|
|
|
|
|
|
this.parsingFunctions.parseTypes(this.resultLandingInfo.types, types, instance);
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
if (instance.hasOwnProperty("webresource")) {
|
2019-09-05 10:49:33 +02:00
|
|
|
let url;
|
2023-02-16 15:33:40 +01:00
|
|
|
if (!Array.isArray(instance['webresource'])) {
|
2019-09-05 10:49:33 +02:00
|
|
|
url = instance['webresource'].url;
|
2021-10-25 11:40:55 +02:00
|
|
|
} else {
|
2019-09-05 10:49:33 +02:00
|
|
|
url = instance['webresource'][0].url;
|
2022-01-07 11:01:22 +01:00
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (url.includes('&')) {
|
|
|
|
url = url.replace(/&/gmu, '&');
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************/
|
2023-02-16 15:33:40 +01:00
|
|
|
if (instance.hasOwnProperty("hostedby")) {
|
2022-01-07 11:01:22 +01:00
|
|
|
this.parsingFunctions.parseHostedBy_collectedFrom(this.resultLandingInfo.hostedBy_collectedFrom, instance, url, this.resultLandingInfo.accessMode);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
/**********************************************************/
|
|
|
|
}
|
|
|
|
}
|
2022-01-07 11:01:22 +01:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
/* Order Download from via openness*/
|
2023-02-16 15:33:40 +01:00
|
|
|
this.resultLandingInfo.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[3].hasOwnProperty("externalreference")) {
|
2020-01-17 15:15:23 +01:00
|
|
|
let externalResults: Map<string, Map<string, string>> = this.parseBioentitiesAndSoftware(data[3]);
|
|
|
|
this.resultLandingInfo.bioentities = externalResults;
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['pid']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[4] != null) {
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo.identifiers = this.parsingFunctions.parseIdentifiers(data[4]);
|
|
|
|
}
|
2021-02-15 14:19:33 +01:00
|
|
|
|
2019-09-05 10:49:33 +02:00
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['journal']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[5] != null) {
|
|
|
|
this.resultLandingInfo.journal = {
|
|
|
|
"journal": "",
|
|
|
|
"issn": "",
|
|
|
|
"lissn": "",
|
|
|
|
"eissn": "",
|
|
|
|
"issue": "",
|
|
|
|
"volume": "",
|
|
|
|
"start_page": "",
|
|
|
|
"end_page": ""
|
|
|
|
}
|
2019-09-05 10:49:33 +02:00
|
|
|
|
|
|
|
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']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[6] != null) {
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo.languages = this.parsingFunctions.parseLanguages(data[6]);
|
2021-01-13 12:58:06 +01:00
|
|
|
// let languagesAndCodes: string[][] = this.parsingFunctions.parseLanguages(data[6]);
|
|
|
|
// this.resultLandingInfo.languages = languagesAndCodes[0];
|
|
|
|
// this.resultLandingInfo.languageCodes = languagesAndCodes[1];
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['country']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[11] != null) {
|
2022-08-30 10:35:42 +02:00
|
|
|
this.resultLandingInfo.countries = this.parsingFunctions.parseCountries(data[11]);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2022-08-30 10:35:42 +02:00
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['eoscifguidelines']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[7] != null) {
|
2022-08-30 10:35:42 +02:00
|
|
|
this.resultLandingInfo.eoscSubjects = this.parsingFunctions.parseEoscSubjects(data[7]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['subject']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[8] != null) {
|
2022-09-30 13:51:00 +02:00
|
|
|
let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>, string[], string[]] = this.parsingFunctions.parseAllSubjects(data[8], subjectsVocabulary);
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo.subjects = subjectResults[0];
|
|
|
|
this.resultLandingInfo.otherSubjects = subjectResults[1];
|
|
|
|
this.resultLandingInfo.classifiedSubjects = subjectResults[2];
|
2024-01-08 14:36:27 +01:00
|
|
|
|
2023-05-02 11:47:49 +02:00
|
|
|
if (subjectResults[3]) {
|
2024-01-08 14:36:27 +01:00
|
|
|
let searchFieldsHelper: SearchFields = new SearchFields();
|
2023-05-02 11:47:49 +02:00
|
|
|
subjectResults[3].forEach(element => {
|
2024-08-01 13:06:12 +02:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2023-05-02 11:47:49 +02:00
|
|
|
});
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (this.resultLandingInfo.fos) {
|
2023-04-25 12:02:33 +02:00
|
|
|
this.resultLandingInfo.fos.sort((a, b) => a.id.localeCompare(b.id));
|
2022-03-15 22:31:10 +01:00
|
|
|
}
|
2024-01-09 10:33:46 +01:00
|
|
|
if(properties.dashboard != "irish") {
|
2023-12-20 22:19:34 +01:00
|
|
|
this.resultLandingInfo.sdg = subjectResults[4];
|
|
|
|
if (this.resultLandingInfo.sdg) {
|
|
|
|
this.resultLandingInfo.sdg.sort((a, b) => {
|
|
|
|
return HelperFunctions.sortSDGs(a, b);
|
|
|
|
})
|
|
|
|
}
|
2022-03-15 22:31:10 +01:00
|
|
|
}
|
2021-09-23 16:49:41 +02:00
|
|
|
|
2022-09-30 13:51:00 +02:00
|
|
|
// if(!this.resultLandingInfo.eoscSubjects) {
|
|
|
|
// this.resultLandingInfo.eoscSubjects = subjectResults[5];
|
|
|
|
// }
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
|
2023-02-16 15:33:40 +01:00
|
|
|
this.resultLandingInfo.hostedBy_collectedFrom, this.resultLandingInfo.publisher,
|
2023-02-17 18:40:05 +01:00
|
|
|
this.resultLandingInfo.journal?.journal, this.resultLandingInfo.identifiers);
|
2019-09-05 10:49:33 +02:00
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['programmingLanguage']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[12] != null) {
|
2022-08-30 10:35:42 +02:00
|
|
|
this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[12]);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2022-06-09 15:45:39 +02:00
|
|
|
// res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[13] != null) {
|
2022-08-30 10:35:42 +02:00
|
|
|
this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['context']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[9] != null) {
|
2022-08-30 10:35:42 +02:00
|
|
|
this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[9]);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['header']['dri:status']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[14] != null && data[14] == "under curation") {
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo.underCurationMessage = true;
|
|
|
|
} else {
|
|
|
|
this.resultLandingInfo.underCurationMessage = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['creator']
|
2023-02-16 15:33:40 +01:00
|
|
|
if (data[10] != null) {
|
|
|
|
if (this.resultLandingInfo.authors == undefined) {
|
|
|
|
this.resultLandingInfo.authors = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>();
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2022-08-30 10:35:42 +02:00
|
|
|
let authors = data[10];
|
2019-09-05 10:49:33 +02:00
|
|
|
let length = Array.isArray(authors) ? authors.length : 1;
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
for (let i = 0; i < length; i++) {
|
2019-09-05 10:49:33 +02:00
|
|
|
let author = Array.isArray(authors) ? authors[i] : authors;
|
2023-02-16 15:33:40 +01:00
|
|
|
if (author) {
|
|
|
|
if (author.orcid) {
|
2021-03-11 13:16:13 +01:00
|
|
|
author.orcid = author.orcid.toUpperCase();
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (author.orcid_pending) {
|
2021-03-11 13:16:13 +01:00
|
|
|
author.orcid_pending = author.orcid_pending.toUpperCase();
|
|
|
|
}
|
2024-01-24 16:03:15 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
this.resultLandingInfo['authors'][author.rank] = {
|
|
|
|
"fullName": author.content,
|
|
|
|
"orcid": author.orcid,
|
|
|
|
"orcid_pending": author.orcid_pending
|
|
|
|
};
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
this.resultLandingInfo.authors = this.resultLandingInfo.authors.filter(function (item) {
|
|
|
|
return (item != undefined && item.fullName != undefined);
|
|
|
|
});
|
|
|
|
}
|
2022-01-07 11:16:23 +01:00
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['measure']
|
|
|
|
if (data[0]?.measure) {
|
|
|
|
this.resultLandingInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure);
|
|
|
|
}
|
2023-01-13 07:32:16 +01:00
|
|
|
|
2022-01-07 11:16:23 +01:00
|
|
|
this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults);
|
2019-09-05 10:49:33 +02:00
|
|
|
|
|
|
|
return this.resultLandingInfo;
|
|
|
|
}
|
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
parseRelatedOrganizations(organizations: Organization[], relation: any): Organization[] {
|
2023-02-16 15:33:40 +01:00
|
|
|
if (organizations == undefined) {
|
2020-03-16 14:09:46 +01:00
|
|
|
organizations = []
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
let organization: {
|
|
|
|
"name": string, "shortname": string,
|
2019-09-05 10:49:33 +02:00
|
|
|
"id": string, "websiteUrl": string,
|
|
|
|
"country": string, "trust": number
|
|
|
|
} = {
|
2020-03-16 14:09:46 +01:00
|
|
|
name: "", shortname: "",
|
|
|
|
id: "", websiteUrl: "",
|
|
|
|
country: "", trust: null
|
2019-09-05 10:49:33 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
organization.id = relation['to'].content;
|
|
|
|
organization.name = relation.legalname;
|
|
|
|
organization.shortname = relation.legalshortname;
|
|
|
|
organization.websiteUrl = relation.websiteurl;
|
2023-02-16 15:33:40 +01:00
|
|
|
if (relation.country) {
|
2019-09-05 10:49:33 +02:00
|
|
|
organization.country = relation.country.classname;
|
|
|
|
}
|
2023-02-16 15:33:40 +01:00
|
|
|
if (relation.trust) {
|
|
|
|
organization.trust = Math.round(relation.trust * 100);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
organizations.push(organization);
|
|
|
|
return organizations;
|
|
|
|
}
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
parseBioentitiesAndSoftware(children: any): Map<string, Map<string, string>> {
|
2019-09-05 10:49:33 +02:00
|
|
|
let bioentities: Map<string, Map<string, string>>;
|
|
|
|
|
|
|
|
let length = Array.isArray(children['externalreference']) ? children['externalreference'].length : 1;
|
|
|
|
|
|
|
|
let externalreference;
|
2023-02-16 15:33:40 +01:00
|
|
|
for (let i = 0; i < length; i++) {
|
2019-09-05 10:49:33 +02:00
|
|
|
externalreference = Array.isArray(children['externalreference']) ? children['externalreference'][i] : children['externalreference'];
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
if (externalreference.hasOwnProperty("qualifier")) {
|
|
|
|
if (externalreference['qualifier'].classid == "accessionNumber") {
|
2019-09-05 10:49:33 +02:00
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
if (bioentities == undefined) {
|
2019-09-05 10:49:33 +02:00
|
|
|
bioentities = new Map<string, Map<string, string>>();
|
|
|
|
}
|
|
|
|
|
2023-02-16 15:33:40 +01:00
|
|
|
if (!bioentities.has(externalreference.sitename)) {
|
2019-09-05 10:49:33 +02:00
|
|
|
bioentities.set(externalreference.sitename, new Map<string, string>());
|
|
|
|
}
|
|
|
|
bioentities.get(externalreference.sitename).set(externalreference.refidentifier, externalreference.url);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-17 15:15:23 +01:00
|
|
|
return bioentities;
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2021-05-19 11:36:09 +02:00
|
|
|
getEnermapsDetails(id: string) {
|
2023-02-16 15:33:40 +01:00
|
|
|
let url = properties.enermapsURL + "/api/db/metadata?shared_id=eq." + id;
|
|
|
|
return this.http.get((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
|
|
|
|
// return this.http.get(url)
|
|
|
|
.pipe(map(res => this.parseEnermapsDetails(res)));
|
2021-05-19 11:36:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
parseEnermapsDetails(response: any) {
|
|
|
|
let details = Array.isArray(response) ? response[0] : response;
|
|
|
|
let metadata = (details && details.metadata) ? details.metadata : null;
|
|
|
|
|
|
|
|
let entries = [];
|
|
|
|
let keys = metadata ? Object.keys(metadata) : null;
|
2023-02-16 15:33:40 +01:00
|
|
|
for (let key of keys) {
|
|
|
|
if (key != "shared_id" && key && metadata[key]) {
|
|
|
|
entries.push([key + "", metadata[key] + ""]);
|
2021-05-19 11:36:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return entries;
|
|
|
|
}
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|