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";
|
2019-09-05 10:49:33 +02:00
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class ResultLandingService {
|
|
|
|
|
|
|
|
constructor(private http: HttpClient ) {
|
|
|
|
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";
|
2021-03-11 14:27:30 +01:00
|
|
|
url += "?pid="+encodeURIComponent(identifier.id) + "&pidtype=" + identifier.class + "&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
|
|
|
|
2022-06-09 15:45:39 +02:00
|
|
|
getResultLandingInfo (id: string, identifier: Identifier, type: string, provenanceActionVocabulary: any, 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)
|
|
|
|
.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;
|
|
|
|
}
|
|
|
|
}))
|
2019-09-05 10:49:33 +02: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']['subject'], // 7
|
|
|
|
res[1]['oaf:result']['context'], // 8
|
|
|
|
res[1]['oaf:result']['creator'], // 9
|
|
|
|
res[1]['oaf:result']['country'] , // 10
|
|
|
|
res[1]['oaf:result']['programmingLanguage'], // 11 - software
|
|
|
|
//res[1]['oaf:result']['resulttype'],
|
2022-05-03 10:52:07 +02:00
|
|
|
(res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['references'] !== undefined)
|
|
|
|
? res[1]['extraInfo']['references']['reference'] : null, // 12
|
2019-09-05 10:49:33 +02:00
|
|
|
res[0], // 13
|
2022-06-09 15:45:39 +02:00
|
|
|
res[2], // 14
|
|
|
|
(res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['citations'] !== undefined)
|
|
|
|
? res[1]['extraInfo']['citations']['citation'] : null, // 15
|
2019-09-05 10:49:33 +02:00
|
|
|
]))
|
2022-06-09 15:45:39 +02:00
|
|
|
.pipe(map(res => this.parseResultLandingInfo(res, provenanceActionVocabulary, 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
|
|
|
|
|
|
|
private handleError (error: HttpErrorResponse) {
|
|
|
|
// 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);
|
|
|
|
return throwError(error || 'Server error');
|
|
|
|
}
|
|
|
|
|
2022-06-09 15:45:39 +02:00
|
|
|
parseResultLandingInfo (data: any, provenanceActionVocabulary: any, subjectsVocabulary: any, properties: EnvProperties): any {
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo = new ResultLandingInfo();
|
|
|
|
|
|
|
|
// res
|
|
|
|
this.resultLandingInfo.record = data[14];
|
2021-03-08 15:42:26 +01:00
|
|
|
this.resultLandingInfo.objIdentifier = data[14]["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
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo.date = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
2020-07-30 11:31:15 +02:00
|
|
|
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;
|
2022-02-14 16:04:09 +01:00
|
|
|
this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data[0] && data[0].description?data[0].description:[]);
|
2020-07-30 11:31:15 +02:00
|
|
|
this.resultLandingInfo.embargoEndDate = data[0].embargoenddate?Dates.getDate(data[0].embargoenddate):null;
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2020-02-07 14:05:07 +01:00
|
|
|
if(data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) {
|
|
|
|
this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname;
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['title']
|
|
|
|
if(data[1] != null) {
|
|
|
|
if(Array.isArray(data[1])) {
|
2021-02-10 10:33:36 +01:00
|
|
|
for(let i=0; i<data[1].length; i++) {
|
|
|
|
if(data[1][i] && data[1][i].content) {
|
2021-02-20 10:20:05 +01:00
|
|
|
if(!this.resultLandingInfo.title || data[1][i].classid == "main title") {
|
|
|
|
this.resultLandingInfo.title = String(data[1][i].content);
|
|
|
|
}
|
2022-03-15 22:31:10 +01:00
|
|
|
if(!this.resultLandingInfo.subtitle && data[1][i].classid === 'subtitle') {
|
|
|
|
this.resultLandingInfo.subtitle = 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
|
|
|
}
|
|
|
|
}
|
2022-03-15 22:31:10 +01:00
|
|
|
if(this.resultLandingInfo.title === this.resultLandingInfo.subtitle) {
|
|
|
|
this.resultLandingInfo.subtitle = "";
|
|
|
|
}
|
2021-02-20 10:20:05 +01:00
|
|
|
if(!this.resultLandingInfo.title) {
|
|
|
|
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 {
|
2020-02-24 14:19:16 +01:00
|
|
|
this.resultLandingInfo.title = (data[1] && data[1].content) ? String(data[1].content) : "";
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel']
|
|
|
|
if(data[2] != null) {
|
|
|
|
let relation;
|
|
|
|
let length = Array.isArray(data[2]) ? data[2].length : 1;
|
|
|
|
|
|
|
|
for(let i=0; i<length; i++) {
|
|
|
|
relation = Array.isArray(data[2]) ? data[2][i] : data[2];
|
|
|
|
if(relation.hasOwnProperty("to")) {
|
2021-09-27 11:19:24 +02:00
|
|
|
if(relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") {
|
2019-10-09 15:28:23 +02:00
|
|
|
this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation, provenanceActionVocabulary);
|
2022-01-07 11:16:23 +01:00
|
|
|
}
|
|
|
|
if(relation['to'].scheme && relation['to'].scheme == "dnet:result_result_relations") {
|
|
|
|
let relationName = relation.to.class;
|
|
|
|
if(!this.resultLandingInfo.relatedClassFilters.has(relationName)) {
|
|
|
|
this.resultLandingInfo.relatedClassFilters.add(relationName);
|
|
|
|
}
|
|
|
|
|
2019-10-09 15:28:23 +02:00
|
|
|
let provenanceAction: string = "";
|
|
|
|
if(provenanceActionVocabulary != null && relation.provenanceaction in provenanceActionVocabulary) {
|
|
|
|
provenanceAction = provenanceActionVocabulary[relation.provenanceaction];
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
2022-01-07 11:16:23 +01:00
|
|
|
this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction);
|
2022-03-15 22:31:10 +01:00
|
|
|
} else if(relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") {
|
|
|
|
this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation);
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
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
|
|
|
}
|
|
|
|
if(url.includes('&')) {
|
|
|
|
let regExp = /&/gmu;
|
|
|
|
let newUrl = url.replace(regExp, '&');
|
|
|
|
url = newUrl;
|
2019-09-05 10:49:33 +02: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*/
|
|
|
|
this.resultLandingInfo.hostedBy_collectedFrom.sort((a, b) => {
|
2022-01-07 11:01:22 +01:00
|
|
|
let firstAccessRight: string = (a.accessRight ? a.accessRight.toLowerCase() : null);
|
|
|
|
let secondAccessRight: string = (b.accessRight ? b.accessRight.toLowerCase() : null);
|
|
|
|
|
|
|
|
if (firstAccessRight === secondAccessRight) {
|
2020-03-16 14:09:46 +01:00
|
|
|
return 0;
|
2022-01-07 11:01:22 +01:00
|
|
|
} else {
|
|
|
|
if (firstAccessRight === 'open access') {
|
|
|
|
return -1;
|
|
|
|
} else if (secondAccessRight === 'open access') {
|
|
|
|
return 1;
|
|
|
|
} else if (firstAccessRight === "open source") {
|
|
|
|
return -1;
|
|
|
|
} else if (secondAccessRight === "open source") {
|
|
|
|
return 1;
|
|
|
|
} else if (firstAccessRight === "embargo") {
|
|
|
|
return -1;
|
|
|
|
} else if (secondAccessRight === "embargo") {
|
|
|
|
return 1;
|
|
|
|
} else if (firstAccessRight === "restricted") {
|
|
|
|
return -1;
|
|
|
|
} else if (secondAccessRight === "restricted") {
|
|
|
|
return 1;
|
|
|
|
} else if (firstAccessRight === "closed access") {
|
|
|
|
return -1;
|
|
|
|
} else if (secondAccessRight === "closed access") {
|
|
|
|
return 1;
|
|
|
|
} else if (firstAccessRight === "not available") {
|
|
|
|
return -1;
|
|
|
|
} else if (secondAccessRight === "not available") {
|
|
|
|
return 1;
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
2022-01-07 11:01:22 +01:00
|
|
|
return 0;
|
2020-03-16 14:09:46 +01:00
|
|
|
});
|
2019-09-05 10:49:33 +02: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']
|
|
|
|
if(data[4] != null) {
|
|
|
|
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']
|
|
|
|
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]);
|
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']
|
|
|
|
if(data[10] != null) {
|
|
|
|
this.resultLandingInfo.countries = this.parsingFunctions.parseCountries(data[10]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['subject']
|
|
|
|
if(data[7] != null) {
|
2022-06-09 15:45:39 +02:00
|
|
|
let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>, string[], string[], any[]] = this.parsingFunctions.parseAllSubjects(data[7], subjectsVocabulary);
|
2019-09-05 10:49:33 +02:00
|
|
|
this.resultLandingInfo.subjects = subjectResults[0];
|
|
|
|
this.resultLandingInfo.otherSubjects = subjectResults[1];
|
|
|
|
this.resultLandingInfo.classifiedSubjects = subjectResults[2];
|
2022-03-15 22:31:10 +01:00
|
|
|
this.resultLandingInfo.fos = subjectResults[3];
|
|
|
|
if(this.resultLandingInfo.fos) {
|
|
|
|
this.resultLandingInfo.fos.sort((a, b) => a.localeCompare(b))
|
|
|
|
}
|
|
|
|
this.resultLandingInfo.sdg = subjectResults[4];
|
|
|
|
if(this.resultLandingInfo.sdg) {
|
|
|
|
this.resultLandingInfo.sdg.sort((a, b) => {
|
|
|
|
return HelperFunctions.sortSDGs(a, b);
|
|
|
|
})
|
|
|
|
}
|
2021-09-23 16:49:41 +02:00
|
|
|
|
2022-05-12 13:05:54 +02:00
|
|
|
this.resultLandingInfo.eoscSubjects = subjectResults[5];
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
|
|
|
|
this.resultLandingInfo.hostedBy_collectedFrom, this.resultLandingInfo.publisher,
|
|
|
|
this.resultLandingInfo.journal, this.resultLandingInfo.identifiers);
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['programmingLanguage']
|
|
|
|
if(data[11] != null) {
|
|
|
|
this.resultLandingInfo.programmingLanguages = this.parsingFunctions.parseProgrammingLanguages(data[11]);
|
|
|
|
}
|
|
|
|
|
2022-06-09 15:45:39 +02:00
|
|
|
// res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference']
|
2019-09-05 10:49:33 +02:00
|
|
|
if(data[12] != null) {
|
|
|
|
this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[12]);
|
|
|
|
}
|
|
|
|
|
2022-06-09 15:45:39 +02:00
|
|
|
// #7509 - OLD: res['result']['metadata']['oaf:entity']['extraInfo']['citations']['citation']
|
|
|
|
if(data[12] == null && data[15] != null) {
|
|
|
|
this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[15]);
|
|
|
|
}
|
|
|
|
|
2019-09-05 10:49:33 +02:00
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['context']
|
|
|
|
if(data[8] != null) {
|
|
|
|
this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[8]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['header']['dri:status']
|
|
|
|
if(data[13] != null && data[13] == "under curation") {
|
|
|
|
this.resultLandingInfo.underCurationMessage = true;
|
|
|
|
} else {
|
|
|
|
this.resultLandingInfo.underCurationMessage = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// res['result']['metadata']['oaf:entity']['oaf:result']['creator']
|
|
|
|
if(data[9] != null) {
|
|
|
|
if(this.resultLandingInfo.authors == undefined) {
|
2021-02-20 10:20:05 +01:00
|
|
|
this.resultLandingInfo.authors = new Array<{"fullName": string, "orcid": string, "orcid_pending": string}>();
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
let authors = data[9];
|
|
|
|
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) {
|
2021-03-11 13:16:13 +01:00
|
|
|
if(author.orcid) {
|
|
|
|
author.orcid = author.orcid.toUpperCase();
|
|
|
|
}
|
|
|
|
if(author.orcid_pending) {
|
|
|
|
author.orcid_pending = author.orcid_pending.toUpperCase();
|
|
|
|
}
|
2021-02-20 10:20:05 +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
|
|
|
|
|
|
|
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[] {
|
2019-09-05 10:49:33 +02:00
|
|
|
if(organizations == undefined) {
|
2020-03-16 14:09:46 +01:00
|
|
|
organizations = []
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
let organization: { "name": string, "shortname": string,
|
|
|
|
"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;
|
|
|
|
if(relation.country) {
|
|
|
|
organization.country = relation.country.classname;
|
|
|
|
}
|
|
|
|
if(relation.trust) {
|
|
|
|
organization.trust = Math.round(relation.trust*100);
|
|
|
|
}
|
|
|
|
|
|
|
|
organizations.push(organization);
|
|
|
|
return organizations;
|
|
|
|
}
|
|
|
|
|
2020-01-17 15:15:23 +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;
|
|
|
|
for(let i=0; i<length; i++) {
|
|
|
|
externalreference = Array.isArray(children['externalreference']) ? children['externalreference'][i] : children['externalreference'];
|
|
|
|
|
|
|
|
if(externalreference.hasOwnProperty("qualifier")) {
|
|
|
|
if(externalreference['qualifier'].classid == "accessionNumber") {
|
|
|
|
|
|
|
|
if(bioentities == undefined) {
|
|
|
|
bioentities = new Map<string, Map<string, string>>();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!bioentities.has(externalreference.sitename)) {
|
|
|
|
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) {
|
2021-10-06 15:23:57 +02:00
|
|
|
let url = properties.enermapsURL+"/api/db/metadata?shared_id=eq."+id;
|
2021-05-19 11:36:09 +02:00
|
|
|
return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
|
|
|
|
// return this.http.get(url)
|
|
|
|
.pipe(map(res => this.parseEnermapsDetails(res)));
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
for(let key of keys) {
|
|
|
|
if(key != "shared_id" && key && metadata[key]) {
|
2021-08-23 16:55:30 +02:00
|
|
|
entries.push([key+"", metadata[key]+""]);
|
2021-05-19 11:36:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return entries;
|
|
|
|
}
|
2019-09-05 10:49:33 +02:00
|
|
|
}
|