Add measures and hosteby collected from in search result objects

This commit is contained in:
Konstantinos Triantafyllou 2023-02-16 16:33:40 +02:00
parent 1093027ca1
commit 0a1e0fbd8a
10 changed files with 852 additions and 785 deletions

View File

@ -1,5 +1,5 @@
import {HostedByCollectedFrom, Journal, Project, RelationResult} from "../../utils/result-preview/result-preview"; import {HostedByCollectedFrom, Journal, Project, RelationResult} from "../../utils/result-preview/result-preview";
import {Context, Reference} from "../../utils/entities/resultLandingInfo"; import {Context, Measure, Reference} from "../../utils/entities/resultLandingInfo";
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {StringUtils} from "../../utils/string-utils.class"; import {StringUtils} from "../../utils/string-utils.class";
@ -8,18 +8,34 @@ import {StringUtils} from "../../utils/string-utils.class";
providedIn: 'root' providedIn: 'root'
}) })
export class ParsingFunctions { export class ParsingFunctions {
public eoscSubjects = [ public eoscSubjects = [
{label: 'EOSC::Jupyter Notebook', link: 'https://' + (properties.environment != 'production'?'beta.':'') + 'marketplace.eosc-portal.eu/services?tag=EOSC%3A%3AJupyter+Notebook', value: 'Jupyter Notebook'}, {
{label: 'EOSC::RO-crate', link: 'https://' + (properties.environment != 'production'?'beta.':'') + 'marketplace.eosc-portal.eu/datasources/eosc.psnc.6f0470e3bb9203ec3a7553f3a72a7a1f?q=ROHub', value: 'RO-crate'}, label: 'EOSC::Jupyter Notebook',
{label: 'EOSC::Galaxy Workflow', link: 'https://' + (properties.environment != 'production'?'beta.':'') + 'marketplace.eosc-portal.eu/services?tag=EOSC%3A%3AGalaxy+Workflow', value: 'Galaxy Workflow'}, link: 'https://' + (properties.environment != 'production' ? 'beta.' : '') + 'marketplace.eosc-portal.eu/services?tag=EOSC%3A%3AJupyter+Notebook',
{label: 'EOSC::Twitter Data', link: 'https://' + (properties.environment != 'production'?'beta.':'') + 'marketplace.eosc-portal.eu/services?tag=EOSC%3A%3ATwitter+Data', value: 'Twitter Data'} value: 'Jupyter Notebook'
] },
{
label: 'EOSC::RO-crate',
link: 'https://' + (properties.environment != 'production' ? 'beta.' : '') + 'marketplace.eosc-portal.eu/datasources/eosc.psnc.6f0470e3bb9203ec3a7553f3a72a7a1f?q=ROHub',
value: 'RO-crate'
},
{
label: 'EOSC::Galaxy Workflow',
link: 'https://' + (properties.environment != 'production' ? 'beta.' : '') + 'marketplace.eosc-portal.eu/services?tag=EOSC%3A%3AGalaxy+Workflow',
value: 'Galaxy Workflow'
},
{
label: 'EOSC::Twitter Data',
link: 'https://' + (properties.environment != 'production' ? 'beta.' : '') + 'marketplace.eosc-portal.eu/services?tag=EOSC%3A%3ATwitter+Data',
value: 'Twitter Data'
}
]
public notebookInSubjects: boolean = false; public notebookInSubjects: boolean = false;
private notebookKeyword: string = "eosc jupyter notebook"; private notebookKeyword: string = "eosc jupyter notebook";
private notebook_label: string = "EOSC"; private notebook_label: string = "EOSC";
private notebook_value: string = "EOSC Jupyter Notebook"; private notebook_value: string = "EOSC Jupyter Notebook";
public open = 'open_access'; public open = 'open_access';
public closed = 'closed_access'; public closed = 'closed_access';
public unknown = 'question_mark'; public unknown = 'question_mark';
@ -28,30 +44,30 @@ export class ParsingFunctions {
constructor() { constructor() {
} }
public ngOnDestroy() { public ngOnDestroy() {
} }
public parseFundingByProjects(fundedByProjects: Project[], relation: any): Project[] { public parseFundingByProjects(fundedByProjects: Project[], relation: any): Project[] {
if (fundedByProjects == undefined) { if (fundedByProjects == undefined) {
fundedByProjects = []; fundedByProjects = [];
} }
let fundedByProject: Project = { let fundedByProject: Project = {
"id": "", "acronym": "", "title": "", "id": "", "acronym": "", "title": "",
"funderShortname": "", "funderName": "", "funderShortname": "", "funderName": "",
"funding": "", "code": "", "provenanceAction": "", "validated": false "funding": "", "code": "", "provenanceAction": "", "validated": false
}; };
if (relation.title != 'unidentified') { if (relation.title != 'unidentified') {
fundedByProject['id'] = relation['to'].content; fundedByProject['id'] = relation['to'].content;
fundedByProject['acronym'] = relation.acronym; fundedByProject['acronym'] = relation.acronym;
fundedByProject['title'] = relation.title; fundedByProject['title'] = relation.title;
fundedByProject['code'] = relation.code; fundedByProject['code'] = relation.code;
if(relation.validated && relation.validated.date) { if (relation.validated && relation.validated.date) {
fundedByProject['validated'] = true; fundedByProject['validated'] = true;
} }
fundedByProject['provenanceAction'] = relation.provenanceaction; fundedByProject['provenanceAction'] = relation.provenanceaction;
} else { } else {
fundedByProject['id'] = ""; fundedByProject['id'] = "";
fundedByProject['acronym'] = ""; fundedByProject['acronym'] = "";
@ -59,11 +75,11 @@ export class ParsingFunctions {
fundedByProject['code'] = ""; fundedByProject['code'] = "";
fundedByProject['provenanceAction'] = ""; fundedByProject['provenanceAction'] = "";
} }
if (relation.hasOwnProperty("funding")) { if (relation.hasOwnProperty("funding")) {
let funding: { "funderName": string, "funderShortname": string, "stream": string }; let funding: { "funderName": string, "funderShortname": string, "stream": string };
funding = this.parseFundingTrees(relation.funding); funding = this.parseFundingTrees(relation.funding);
if (funding.funderName) { if (funding.funderName) {
fundedByProject['funderName'] = funding.funderName; fundedByProject['funderName'] = funding.funderName;
} }
@ -77,7 +93,7 @@ export class ParsingFunctions {
fundedByProjects.push(fundedByProject); fundedByProjects.push(fundedByProject);
return fundedByProjects; return fundedByProjects;
} }
// publication & research data : for fundedByProjects | project landing : for funding // publication & research data : for fundedByProjects | project landing : for funding
public parseFundingTrees(fundingTree: any): { "funderName": string, "funderShortname": string, "stream": string } { public parseFundingTrees(fundingTree: any): { "funderName": string, "funderShortname": string, "stream": string } {
let funding: { "funderName": string, "funderShortname": string, "stream": string } = { let funding: { "funderName": string, "funderShortname": string, "stream": string } = {
@ -86,64 +102,64 @@ export class ParsingFunctions {
"stream": "" "stream": ""
}; };
let length = Array.isArray(fundingTree) ? fundingTree.length : 1; let length = Array.isArray(fundingTree) ? fundingTree.length : 1;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let fundingData = Array.isArray(fundingTree) ? fundingTree[i] : fundingTree; let fundingData = Array.isArray(fundingTree) ? fundingTree[i] : fundingTree;
if (fundingData.hasOwnProperty("funder")) { if (fundingData.hasOwnProperty("funder")) {
funding.funderShortname = fundingData['funder'].shortname; funding.funderShortname = fundingData['funder'].shortname;
funding.funderName = fundingData['funder'].name; funding.funderName = fundingData['funder'].name;
} }
funding.stream = this.addFundingLevel0(fundingData, funding.stream); funding.stream = this.addFundingLevel0(fundingData, funding.stream);
funding.stream = this.addFundingLevel1(fundingData, funding.stream); funding.stream = this.addFundingLevel1(fundingData, funding.stream);
funding.stream = this.addFundingLevel2(fundingData, funding.stream); funding.stream = this.addFundingLevel2(fundingData, funding.stream);
} }
return funding; return funding;
} }
addFundingLevel0(parent: string, fundingStream: string): string { addFundingLevel0(parent: string, fundingStream: string): string {
if (parent.hasOwnProperty("funding_level_0")) { if (parent.hasOwnProperty("funding_level_0")) {
let level0 = parent['funding_level_0']; let level0 = parent['funding_level_0'];
fundingStream += (fundingStream) ? " ; " : ""; fundingStream += (fundingStream) ? " ; " : "";
fundingStream += level0.name; fundingStream += level0.name;
} }
return fundingStream; return fundingStream;
} }
addFundingLevel1(parent: string, fundingStream: string): string { addFundingLevel1(parent: string, fundingStream: string): string {
if (parent.hasOwnProperty("funding_level_1")) { if (parent.hasOwnProperty("funding_level_1")) {
let level1 = parent['funding_level_1']; let level1 = parent['funding_level_1'];
// For projects' parsing // For projects' parsing
if (level1.hasOwnProperty("parent")) { if (level1.hasOwnProperty("parent")) {
fundingStream = this.addFundingLevel0(level1.parent, fundingStream); fundingStream = this.addFundingLevel0(level1.parent, fundingStream);
} }
fundingStream += (fundingStream) ? " | " : ""; fundingStream += (fundingStream) ? " | " : "";
fundingStream += level1.name; fundingStream += level1.name;
} }
return fundingStream; return fundingStream;
} }
addFundingLevel2(parent: string, fundingStream: string): string { addFundingLevel2(parent: string, fundingStream: string): string {
if (parent.hasOwnProperty("funding_level_2")) { if (parent.hasOwnProperty("funding_level_2")) {
let level2 = parent['funding_level_2']; let level2 = parent['funding_level_2'];
// For projects' parsing // For projects' parsing
if (level2.hasOwnProperty("parent")) { if (level2.hasOwnProperty("parent")) {
fundingStream = this.addFundingLevel1(level2.parent, fundingStream); fundingStream = this.addFundingLevel1(level2.parent, fundingStream);
} }
fundingStream += (fundingStream) ? " | " : ""; fundingStream += (fundingStream) ? " | " : "";
fundingStream += level2.name; fundingStream += level2.name;
} }
return fundingStream; return fundingStream;
} }
// publication & dataset landing : for collectedFrom // publication & dataset landing : for collectedFrom
parseCollectedFrom(collectedFrom: { "name": string, "id": string }[], parseCollectedFrom(collectedFrom: { "name": string, "id": string }[],
_collectedFrom: any) { _collectedFrom: any) {
@ -152,10 +168,10 @@ export class ParsingFunctions {
collectedFrom[length]['name'] = _collectedFrom.name; collectedFrom[length]['name'] = _collectedFrom.name;
collectedFrom[length]['id'] = _collectedFrom.id; collectedFrom[length]['id'] = _collectedFrom.id;
} }
// publication & dataset landing : for downloadFrom // publication & dataset landing : for downloadFrom
addPublisherToHostedBy_collectedFrom(hostedBy_collectedFrom: HostedByCollectedFrom[], addPublisherToHostedBy_collectedFrom(hostedBy_collectedFrom: HostedByCollectedFrom[],
publisher: string, journal: Journal, publisher: string, journal: string,
identifiers: Map<string, string[]>/*, title: { "name": string, "url": string, "accessMode": string}*/) { identifiers: Map<string, string[]>/*, title: { "name": string, "url": string, "accessMode": string}*/) {
if (!this.instanceWithDoiExists && publisher && identifiers != null && identifiers.has('doi')) { if (!this.instanceWithDoiExists && publisher && identifiers != null && identifiers.has('doi')) {
if (hostedBy_collectedFrom == null) { if (hostedBy_collectedFrom == null) {
@ -171,13 +187,13 @@ export class ParsingFunctions {
accessRightIcon: "" accessRightIcon: ""
}; };
if (journal && journal.journal) { if (journal) {
available.downloadNames.push(publisher + "/ " + journal['journal']); available.downloadNames.push(publisher + "/ " + journal['journal']);
} else { } else {
available.downloadNames.push(publisher); available.downloadNames.push(publisher);
} }
available.downloadUrl = properties.doiURL + identifiers.get("doi")[0];; available.downloadUrl = properties.doiURL + identifiers.get("doi")[0];
available.accessRightIcon = this.unknown; available.accessRightIcon = this.unknown;
/* /*
if(title != undefined && title['url'] == "") { if(title != undefined && title['url'] == "") {
@ -188,16 +204,16 @@ export class ParsingFunctions {
} }
return hostedBy_collectedFrom; return hostedBy_collectedFrom;
} }
// publication & dataset landing : for downloadFrom // publication & dataset landing : for downloadFrom
parseDownloadFrom(downloadFrom: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, url: string) { parseDownloadFrom(downloadFrom: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, url: string) {
let key: string = instance['hostedby'].name; let key: string = instance['hostedby'].name;
if (key) { if (key) {
this.addUrlAndAccessMode(downloadFrom, instance, key, url); this.addUrlAndAccessMode(downloadFrom, instance, key, url);
} }
} }
// publication & dataset landing : for publishedIn // publication & dataset landing : for publishedIn
parsePublishedIn(publishedIn: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, result: any, url: string, counter: number): number { parsePublishedIn(publishedIn: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, result: any, url: string, counter: number): number {
if (result != null && result.hasOwnProperty("source")) { if (result != null && result.hasOwnProperty("source")) {
@ -210,7 +226,7 @@ export class ParsingFunctions {
} else { } else {
key = result['source']; key = result['source'];
} }
if (key) { if (key) {
this.addUrlAndAccessMode(publishedIn, instance, key, url); this.addUrlAndAccessMode(publishedIn, instance, key, url);
counter++; counter++;
@ -218,30 +234,30 @@ export class ParsingFunctions {
} }
return counter; return counter;
} }
// publication & dataset landing : for downloadFrom and publishedIn // publication & dataset landing : for downloadFrom and publishedIn
addUrlAndAccessMode(mapStructure: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, key: string, url: string) { addUrlAndAccessMode(mapStructure: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, key: string, url: string) {
if (!mapStructure.has(key)) { if (!mapStructure.has(key)) {
mapStructure.set(key, {"url": null, "accessMode": null, "bestAccessMode": null}); mapStructure.set(key, {"url": null, "accessMode": null, "bestAccessMode": null});
} }
if (mapStructure.get(key)['url'] == null) { if (mapStructure.get(key)['url'] == null) {
mapStructure.get(key)['url'] = new Array<string>(); mapStructure.get(key)['url'] = new Array<string>();
} }
if (url) { if (url) {
mapStructure.get(key)['url'].push(url); mapStructure.get(key)['url'].push(url);
} }
if (mapStructure.get(key)['accessMode'] == null) { if (mapStructure.get(key)['accessMode'] == null) {
mapStructure.get(key)['accessMode'] = new Array<string>(); mapStructure.get(key)['accessMode'] = new Array<string>();
} }
if (instance.hasOwnProperty("accessright")) { if (instance.hasOwnProperty("accessright")) {
if (url) { if (url) {
mapStructure.get(key)['accessMode'].push(instance['accessright'].classname); mapStructure.get(key)['accessMode'].push(instance['accessright'].classname);
} }
if (this.changeBestAccessMode(mapStructure.get(key)['bestAccessMode'], instance['accessright'])) { if (this.changeBestAccessMode(mapStructure.get(key)['bestAccessMode'], instance['accessright'])) {
mapStructure.get(key)['bestAccessMode'] = instance['accessright'].classname; mapStructure.get(key)['bestAccessMode'] = instance['accessright'].classname;
} }
@ -252,7 +268,7 @@ export class ParsingFunctions {
parseHostedBy_collectedFrom(hostedBy_collectedFrom: HostedByCollectedFrom[], parseHostedBy_collectedFrom(hostedBy_collectedFrom: HostedByCollectedFrom[],
instance: any, url: string, globalAccessRight: string) { instance: any, url: string, globalAccessRight: string) {
if(!url) { if (!url) {
return; return;
} }
@ -287,7 +303,7 @@ export class ParsingFunctions {
let length = Array.isArray(instance['collectedfrom']) ? instance['collectedfrom'].length : 1; let length = Array.isArray(instance['collectedfrom']) ? instance['collectedfrom'].length : 1;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let collectedFrom = Array.isArray(instance['collectedfrom']) ? instance['collectedfrom'][i] : instance['collectedfrom']; let collectedFrom = Array.isArray(instance['collectedfrom']) ? instance['collectedfrom'][i] : instance['collectedfrom'];
if(collectedFrom.name && collectedFrom.id) { if (collectedFrom.name && collectedFrom.id) {
available.collectedNamesAndIds.set(String(collectedFrom.name), collectedFrom.id); available.collectedNamesAndIds.set(String(collectedFrom.name), collectedFrom.id);
} }
} }
@ -298,7 +314,7 @@ export class ParsingFunctions {
let length = Array.isArray(instance['instancetype']) ? instance['instancetype'].length : 1; let length = Array.isArray(instance['instancetype']) ? instance['instancetype'].length : 1;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let instanceType = Array.isArray(instance['instancetype']) ? instance['instancetype'][i] : instance['instancetype']; let instanceType = Array.isArray(instance['instancetype']) ? instance['instancetype'][i] : instance['instancetype'];
if(instanceType.classname && instanceType.classname.toLowerCase() !== "unknown") { if (instanceType.classname && instanceType.classname.toLowerCase() !== "unknown") {
types.add(instanceType.classname); types.add(instanceType.classname);
} }
} }
@ -317,7 +333,7 @@ export class ParsingFunctions {
} }
available['downloadUrl'] = url; available['downloadUrl'] = url;
if(url.includes("doi.org/")) { if (url.includes("doi.org/")) {
this.instanceWithDoiExists = true; this.instanceWithDoiExists = true;
} }
@ -348,20 +364,56 @@ export class ParsingFunctions {
available.accessRightIcon = this.unknown; available.accessRightIcon = this.unknown;
} }
if(instance.hasOwnProperty("license")) { if (instance.hasOwnProperty("license")) {
available.license = Array.isArray(instance['license']) ? instance['license'][0] : instance['license']; available.license = Array.isArray(instance['license']) ? instance['license'][0] : instance['license'];
} }
hostedBy_collectedFrom.push(available); hostedBy_collectedFrom.push(available);
} }
compareHostedByCollectedFrom(a: HostedByCollectedFrom, b: HostedByCollectedFrom) {
let firstAccessRight: string = (a.accessRight ? a.accessRight.toLowerCase() : null);
let secondAccessRight: string = (b.accessRight ? b.accessRight.toLowerCase() : null);
if (firstAccessRight === secondAccessRight) {
return 0;
} 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;
}
}
return 0;
}
// publication & dataset landing : for downloadFrom and publishedIn // publication & dataset landing : for downloadFrom and publishedIn
changeBestAccessMode(currentAccessMode: string, accessMode: any): boolean { changeBestAccessMode(currentAccessMode: string, accessMode: any): boolean {
if (!accessMode) { if (!accessMode) {
return false; return false;
} }
accessMode = accessMode.classid; accessMode = accessMode.classid;
switch (currentAccessMode) { switch (currentAccessMode) {
case null: case null:
if (accessMode != "UNKNOWN") { if (accessMode != "UNKNOWN") {
@ -370,22 +422,22 @@ export class ParsingFunctions {
return false; return false;
case "CLOSED": case "CLOSED":
if (accessMode == "OPEN" || if (accessMode == "OPEN" ||
accessMode == "OPEN SOURCE" || accessMode == "OPEN SOURCE" ||
accessMode == "EMBARGO" || accessMode == "EMBARGO" ||
accessMode == "RESTRICTED") { accessMode == "RESTRICTED") {
return true; return true;
} }
return false; return false;
case "RESTRICTED": case "RESTRICTED":
if (accessMode == "OPEN" || if (accessMode == "OPEN" ||
accessMode == "OPEN SOURCE" || accessMode == "OPEN SOURCE" ||
accessMode == "EMBARGO") { accessMode == "EMBARGO") {
return true; return true;
} }
return false; return false;
case "EMBARGO": case "EMBARGO":
if (accessMode == "OPEN" || if (accessMode == "OPEN" ||
accessMode == "OPEN SOURCE") { accessMode == "OPEN SOURCE") {
return true; return true;
} }
return false; return false;
@ -397,7 +449,7 @@ export class ParsingFunctions {
} }
return false; return false;
} }
// publication & dataset & software & orp landing : for relatedResearchResults // publication & dataset & software & orp landing : for relatedResearchResults
parseResults(researchResults: RelationResult[], relation, provenanceAction: string, relationName: string): RelationResult[] { parseResults(researchResults: RelationResult[], relation, provenanceAction: string, relationName: string): RelationResult[] {
if (researchResults == undefined) { if (researchResults == undefined) {
@ -417,7 +469,7 @@ export class ParsingFunctions {
// researchResult.relationName = relation.to.class; // researchResult.relationName = relation.to.class;
if(relation['resulttype']) { if (relation['resulttype']) {
if (relation['resulttype'].classname == "publication") { if (relation['resulttype'].classname == "publication") {
researchResult['class'] = "publication"; researchResult['class'] = "publication";
} else if (relation['resulttype'].classname == "dataset") { } else if (relation['resulttype'].classname == "dataset") {
@ -429,10 +481,10 @@ export class ParsingFunctions {
} }
} }
researchResult['id'] = relation['to'].content; researchResult['id'] = relation['to'].content;
if(Array.isArray(relation['title'])) { if (Array.isArray(relation['title'])) {
for(let i=0; i<relation['title'].length; i++) { for (let i = 0; i < relation['title'].length; i++) {
if(relation['title'][i] && relation['title'][i].content) { if (relation['title'][i] && relation['title'][i].content) {
if(!researchResult['name'] || relation['title'][i].classid == "main title") { if (!researchResult['name'] || relation['title'][i].classid == "main title") {
researchResult['name'] = String(relation['title'][i].content); researchResult['name'] = String(relation['title'][i].content);
} }
} }
@ -440,7 +492,7 @@ export class ParsingFunctions {
} else { } else {
researchResult['name'] = (relation['title'] && relation['title'].content) ? String(relation['title'].content) : ""; researchResult['name'] = (relation['title'] && relation['title'].content) ? String(relation['title'].content) : "";
} }
if(!researchResult['name']) { if (!researchResult['name']) {
researchResult['name'] = "[no title available]"; researchResult['name'] = "[no title available]";
} }
if (relation.hasOwnProperty("dateofacceptance")) { if (relation.hasOwnProperty("dateofacceptance")) {
@ -449,12 +501,12 @@ export class ParsingFunctions {
} }
//researchResult['date'] = relation.dateofacceptance.substring(0,4);; //researchResult['date'] = relation.dateofacceptance.substring(0,4);;
let percentageName: string; let percentageName: string;
if(relation.trust) { if (relation.trust) {
percentageName = "trust"; percentageName = "trust";
} else if(relation.similarity) { } else if (relation.similarity) {
percentageName = "similarity"; percentageName = "similarity";
} }
if(percentageName) { if (percentageName) {
researchResult['percentage'] = Math.round(relation[percentageName] * 100); researchResult['percentage'] = Math.round(relation[percentageName] * 100);
researchResult['percentageName'] = percentageName; researchResult['percentageName'] = percentageName;
} }
@ -470,17 +522,17 @@ export class ParsingFunctions {
} }
return results; return results;
} }
// publication & dataset landing : for identifiers // publication & dataset landing : for identifiers
parseIdentifiers(pid: any): Map<string, string[]> { parseIdentifiers(pid: any): Map<string, string[]> {
let identifiers = new Map<string, string[]>(); let identifiers = new Map<string, string[]>();
if (pid.hasOwnProperty("classid") && pid['classid'] != "") { if (pid.hasOwnProperty("classid") && pid['classid'] != "") {
if (pid.classid == "doi" || pid.classid == "pmc" || pid.classid == "handle" || pid.classid == "pmid" || pid.classid == "re3data") { if (pid.classid == "doi" || pid.classid == "pmc" || pid.classid == "handle" || pid.classid == "pmid" || pid.classid == "re3data") {
if (!identifiers.has(pid.classid)) { if (!identifiers.has(pid.classid)) {
identifiers.set(pid.classid, new Array<string>()); identifiers.set(pid.classid, new Array<string>());
} }
identifiers.get(pid.classid).push(pid.content+""); identifiers.get(pid.classid).push(pid.content + "");
} }
} else { } else {
for (let i = 0; i < pid.length; i++) { for (let i = 0; i < pid.length; i++) {
@ -488,7 +540,7 @@ export class ParsingFunctions {
if (!identifiers.has(pid[i].classid)) { if (!identifiers.has(pid[i].classid)) {
identifiers.set(pid[i].classid, new Array<string>()); identifiers.set(pid[i].classid, new Array<string>());
} }
identifiers.get(pid[i].classid).push(pid[i].content+""); identifiers.get(pid[i].classid).push(pid[i].content + "");
} }
} }
} }
@ -505,10 +557,10 @@ export class ParsingFunctions {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
subject = Array.isArray(_subjects) ? _subjects[i] : _subjects; subject = Array.isArray(_subjects) ? _subjects[i] : _subjects;
let content: string = subject.code+""; let content: string = subject.code + "";
let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content); let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content);
let found: boolean = checkAndAddEoscSubjectResp["found"]; let found: boolean = checkAndAddEoscSubjectResp["found"];
if(found) { if (found) {
setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"]; setOfEoscSubjects = checkAndAddEoscSubjectResp["setOfEoscSubject"];
eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"]; eoscSubjectsFound = checkAndAddEoscSubjectResp["eoscSubjectsFound"];
} }
@ -518,7 +570,7 @@ export class ParsingFunctions {
} }
// publication & dataset landing : for subjects and otherSubjects and classifiedSubjects // publication & dataset landing : for subjects and otherSubjects and classifiedSubjects
parseAllSubjects(_subjects: any, vocabulary: any): [string[], Map<string, string[]>, Map<string, string[]>, string[], string[], ] { parseAllSubjects(_subjects: any, vocabulary: any): [string[], Map<string, string[]>, Map<string, string[]>, string[], string[],] {
// let eoscSubjectsFound = []; // let eoscSubjectsFound = [];
let subjects: string[]; let subjects: string[];
let otherSubjects: Map<string, string[]>; let otherSubjects: Map<string, string[]>;
@ -535,7 +587,7 @@ export class ParsingFunctions {
subject = Array.isArray(_subjects) ? _subjects[i] : _subjects; subject = Array.isArray(_subjects) ? _subjects[i] : _subjects;
if (subject.classid != "") { if (subject.classid != "") {
if (subject.classid == "keyword") { if (subject.classid == "keyword") {
let content: string = subject.content+""; let content: string = subject.content + "";
// let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content); // let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content);
// let found: boolean = checkAndAddEoscSubjectResp["found"]; // let found: boolean = checkAndAddEoscSubjectResp["found"];
// if(found) { // if(found) {
@ -549,22 +601,22 @@ export class ParsingFunctions {
// } // }
} else if (!vocabulary || vocabulary[subject.classid] || subject.classid === "SDG" || subject.classid === "FOS") { } else if (!vocabulary || vocabulary[subject.classid] || subject.classid === "SDG" || subject.classid === "FOS") {
// if (subject.inferred && subject.inferred == true) { // if (subject.inferred && subject.inferred == true) {
if(subject.classid === "SDG") { if (subject.classid === "SDG") {
if (sdg == undefined) { if (sdg == undefined) {
sdg = new Array<string>(); sdg = new Array<string>();
} }
sdg.push(subject.content+""); sdg.push(subject.content + "");
} else if(subject.classid === "FOS") { } else if (subject.classid === "FOS") {
if (fos == undefined) { if (fos == undefined) {
fos = new Array<string>(); fos = new Array<string>();
} }
fos.push(subject.content+""); fos.push(subject.content + "");
} else { } else {
if (classifiedSubjects == undefined) { if (classifiedSubjects == undefined) {
classifiedSubjects = new Map<string, string[]>(); classifiedSubjects = new Map<string, string[]>();
} }
let content: string = subject.content+""; let content: string = subject.content + "";
// let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content); // let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content);
// let found: boolean = checkAndAddEoscSubjectResp["found"]; // let found: boolean = checkAndAddEoscSubjectResp["found"];
// if(found) { // if(found) {
@ -578,7 +630,7 @@ export class ParsingFunctions {
// } // }
} }
} else { } else {
let content: string = subject.content+""; let content: string = subject.content + "";
// let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content); // let checkAndAddEoscSubjectResp = this.checkAndAddEoscSubject(setOfEoscSubjects, eoscSubjectsFound, subject, content);
// let found: boolean = checkAndAddEoscSubjectResp["found"]; // let found: boolean = checkAndAddEoscSubjectResp["found"];
// if(found) { // if(found) {
@ -600,7 +652,7 @@ export class ParsingFunctions {
checkAndAddEoscSubject(setOfEoscSubjects: Set<string>, eoscSubjectsFound, subject, content) { checkAndAddEoscSubject(setOfEoscSubjects: Set<string>, eoscSubjectsFound, subject, content) {
let found: boolean = false; let found: boolean = false;
if(!setOfEoscSubjects.has(content)) { if (!setOfEoscSubjects.has(content)) {
// looping through our declared array // looping through our declared array
this.eoscSubjects.forEach(item => { this.eoscSubjects.forEach(item => {
if (content && content == item.label) { if (content && content == item.label) {
@ -612,7 +664,7 @@ export class ParsingFunctions {
} }
return {"found": found, "setOfEoscSubject": setOfEoscSubjects, "eoscSubjectsFound": eoscSubjectsFound}; return {"found": found, "setOfEoscSubject": setOfEoscSubjects, "eoscSubjectsFound": eoscSubjectsFound};
} }
parseContexts(_contexts: any): Context[] { parseContexts(_contexts: any): Context[] {
let contexts = new Array<Context>(); let contexts = new Array<Context>();
@ -623,7 +675,7 @@ export class ParsingFunctions {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let numOfCategories: number = 0; // count categories with label let numOfCategories: number = 0; // count categories with label
context = Array.isArray(_contexts) ? _contexts[i] : _contexts; context = Array.isArray(_contexts) ? _contexts[i] : _contexts;
if (context.label && context.hasOwnProperty("type") && (context['type'] == "community" || context['type'] == "ri")) { if (context.label && context.hasOwnProperty("type") && (context['type'] == "community" || context['type'] == "ri")) {
if (context.hasOwnProperty("category")) { if (context.hasOwnProperty("category")) {
let category; let category;
@ -639,7 +691,7 @@ export class ParsingFunctions {
// initalize if there is concept label or this is the last concept of the category and there were no concepts // initalize if there is concept label or this is the last concept of the category and there were no concepts
// otherwise we could have multiple entries for the same category but without concepts // otherwise we could have multiple entries for the same category but without concepts
if(categoryConcept.label || (numOfConcepts == 0 && j == (length1 - 1))) { if (categoryConcept.label || (numOfConcepts == 0 && j == (length1 - 1))) {
contexts[position] = { contexts[position] = {
"labelContext": "", "idContext": "", "labelContext": "", "idContext": "",
"labelCategory": "", "idCategory": "", "labelCategory": "", "idCategory": "",
@ -656,10 +708,12 @@ export class ParsingFunctions {
numOfConcepts++; numOfConcepts++;
} }
} }
} else if(category.label || (numOfCategories == 0 && z == (length2 - 1))) { } else if (category.label || (numOfCategories == 0 && z == (length2 - 1))) {
contexts[position] = {"labelContext": "", "idContext": "", contexts[position] = {
"labelCategory": "", "idCategory": "", "labelContext": "", "idContext": "",
"labelConcept": "", "idConcept": ""}; "labelCategory": "", "idCategory": "",
"labelConcept": "", "idConcept": ""
};
contexts[position]['labelContext'] = context.label; contexts[position]['labelContext'] = context.label;
contexts[position]['idContext'] = context.id; contexts[position]['idContext'] = context.id;
contexts[position]['labelCategory'] = category.label ? category.label : null; contexts[position]['labelCategory'] = category.label ? category.label : null;
@ -671,9 +725,11 @@ export class ParsingFunctions {
} }
} }
} else { } else {
contexts[position] = {"labelContext": "", "idContext": "", contexts[position] = {
"labelCategory": "", "idCategory": "", "labelContext": "", "idContext": "",
"labelConcept": "", "idConcept": ""}; "labelCategory": "", "idCategory": "",
"labelConcept": "", "idConcept": ""
};
contexts[position]['labelContext'] = context.label; contexts[position]['labelContext'] = context.label;
contexts[position]['idContext'] = context.id; contexts[position]['idContext'] = context.id;
contexts[position]['labelCategory'] = null; contexts[position]['labelCategory'] = null;
@ -687,11 +743,15 @@ export class ParsingFunctions {
} }
return contexts; return contexts;
} }
public static getEnermapsConceptId(contexts: any): string{
let enermapsconcepts = contexts.filter(c=> {return c.idCategory == "enermaps::selection" && c.idConcept}); public static getEnermapsConceptId(contexts: any): string {
return enermapsconcepts && enermapsconcepts.length > 0?enermapsconcepts[0].idConcept.split("enermaps::selection::")[1]:null; let enermapsconcepts = contexts.filter(c => {
return c.idCategory == "enermaps::selection" && c.idConcept
});
return enermapsconcepts && enermapsconcepts.length > 0 ? enermapsconcepts[0].idConcept.split("enermaps::selection::")[1] : null;
// return "hotmaps_heat_tot_curr_density" // return "hotmaps_heat_tot_curr_density"
} }
parseTypes(types: string[], uniqueTypes: Set<string>, instance: any) { parseTypes(types: string[], uniqueTypes: Set<string>, instance: any) {
if (instance && instance.hasOwnProperty("instancetype") && instance['instancetype'].classname) { if (instance && instance.hasOwnProperty("instancetype") && instance['instancetype'].classname) {
if (!uniqueTypes.has(instance['instancetype'].classname)) { if (!uniqueTypes.has(instance['instancetype'].classname)) {
@ -700,7 +760,7 @@ export class ParsingFunctions {
} }
} }
} }
parseLanguages(_languages: any) { parseLanguages(_languages: any) {
var languages = new Array<string>(); var languages = new Array<string>();
@ -717,10 +777,10 @@ export class ParsingFunctions {
} }
return languages; return languages;
} }
parseCountries(_countries: any) { parseCountries(_countries: any) {
var countries = new Array<string>(); var countries = new Array<string>();
if (!Array.isArray(_countries)) { if (!Array.isArray(_countries)) {
if (_countries.classname != "Undetermined" && _countries.classname) { if (_countries.classname != "Undetermined" && _countries.classname) {
countries.push(_countries.classname); countries.push(_countries.classname);
@ -734,10 +794,10 @@ export class ParsingFunctions {
} }
return countries; return countries;
} }
parseProgrammingLanguages(_pLanguages) { parseProgrammingLanguages(_pLanguages) {
var pLanguages = new Array<string>(); var pLanguages = new Array<string>();
if (!Array.isArray(_pLanguages)) { if (!Array.isArray(_pLanguages)) {
if (_pLanguages.classname != "Undetermined" && _pLanguages.classname) { if (_pLanguages.classname != "Undetermined" && _pLanguages.classname) {
pLanguages.push(_pLanguages.classname); pLanguages.push(_pLanguages.classname);
@ -751,16 +811,16 @@ export class ParsingFunctions {
} }
return pLanguages; return pLanguages;
} }
parseReferences(citations: any): Reference[] { parseReferences(citations: any): Reference[] {
let references: Reference[] = []; let references: Reference[] = [];
citations = Array.isArray(citations) ? citations : [citations]; citations = Array.isArray(citations) ? citations : [citations];
citations.forEach(citation => { citations.forEach(citation => {
let reference: Reference = {name: null, ids: []}; let reference: Reference = {name: null, ids: []};
if(citation.rawText) { if (citation.rawText) {
reference.name = citation.rawText; reference.name = citation.rawText;
} }
if(citation.id) { if (citation.id) {
let ids: any[] = Array.isArray(citation.id) ? citation.id : [citation.id]; let ids: any[] = Array.isArray(citation.id) ? citation.id : [citation.id];
ids.forEach(id => { ids.forEach(id => {
reference.ids.push({ reference.ids.push({
@ -774,35 +834,117 @@ export class ParsingFunctions {
}); });
return references; return references;
} }
static parseRelCanonicalId(record, type){
try{ static parseRelCanonicalId(record, type) {
if(record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"] && record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"][type]){ try {
for(let child of record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"][type]){ if (record["result"]["metadata"]["oaf:entity"][("oaf:" + type)]["children"] && record["result"]["metadata"]["oaf:entity"][("oaf:" + type)]["children"][type]) {
for (let child of record["result"]["metadata"]["oaf:entity"][("oaf:" + type)]["children"][type]) {
return child["objidentifier"]; return child["objidentifier"];
} }
} }
}catch(e){ } catch (e) {
// console.error(e); // console.error(e);
} }
return record["result"]["header"]["dri:objIdentifier"]; return record["result"]["header"]["dri:objIdentifier"];
} }
parseDescription(description, stripHTML: boolean = false):string { parseDescription(description, stripHTML: boolean = false): string {
let abstracts = []; let abstracts = [];
if(!Array.isArray(description)) { if (!Array.isArray(description)) {
abstracts = [description ? String(description) : ""]; abstracts = [description ? String(description) : ""];
} else { } else {
abstracts = description.map( x => String(x)); abstracts = description.map(x => String(x));
} }
try{ try {
abstracts = abstracts.map( x => StringUtils.HTMLToString(x)); abstracts = abstracts.map(x => StringUtils.HTMLToString(x));
} catch (e) {} } catch (e) {
abstracts = abstracts.sort((a,b) => b.length - a.length); }
if(stripHTML) { abstracts = abstracts.sort((a, b) => b.length - a.length);
return abstracts.join(' '); if (stripHTML) {
} else { return abstracts.join(' ');
return abstracts.length > 0 ? ('<p>' + abstracts.join('</p> <p>') + '</p>') : abstracts.join(' '); } else {
} return abstracts.length > 0 ? ('<p>' + abstracts.join('</p> <p>') + '</p>') : abstracts.join(' ');
}
}
parseMeasures(measures: any[]): Measure {
if (measures.length) {
let parsed: Measure = {
"downloads": null,
"views": null,
"popularity": null,
"influence": null,
"citations": null,
"impulse": null
};
measures.forEach(measure => {
if (measure.id == 'downloads') {
// parsed.downloads = measure.count == 0 ? ' - ' : measure.count;
parsed.downloads = measure.count;
}
if (measure.id == 'views') {
// parsed.views = measure.count == 0 ? ' - ' : measure.count;
parsed.views = measure.count;
}
if (measure.id == 'influence') {
if (measure.class == 'C1') {
parsed.influence = 'Top 0.01%';
} else if (measure.class == 'C2') {
parsed.influence = 'Top 0.1%';
} else if (measure.class == 'C3') {
parsed.influence = 'Top 1%';
} else if (measure.class == 'C4') {
parsed.influence = 'Top 10%';
} else if (measure.class == 'A') {
parsed.influence = 'Exceptional';
} else if (measure.class == 'B') {
parsed.influence = 'Substantial';
} else {
parsed.influence = 'Average';
}
}
if (measure.id == 'popularity') {
if (measure.class == 'C1') {
parsed.popularity = 'Top 0.01%';
} else if (measure.class == 'C2') {
parsed.popularity = 'Top 0.1%';
} else if (measure.class == 'C3') {
parsed.popularity = 'Top 1%';
} else if (measure.class == 'C4') {
parsed.popularity = 'Top 10%';
} else if (measure.class == 'A') {
parsed.popularity = 'Exceptional';
} else if (measure.class == 'B') {
parsed.popularity = 'Substantial';
} else {
parsed.popularity = 'Average';
}
}
if (measure.id == 'influence_alt') {
// parsed['citations'] = measure.score == 0 ? ' - ' : measure.score;
parsed.citations = measure.score;
}
if (measure.id == 'impulse') {
if (measure.class == 'C1') {
parsed.impulse = 'Top 0.01%';
} else if (measure.class == 'C2') {
parsed.impulse = 'Top 0.1%';
} else if (measure.class == 'C3') {
parsed.impulse = 'Top 1%';
} else if (measure.class == 'C4') {
parsed.impulse = 'Top 10%';
} else if (measure.class == 'A') {
parsed.impulse = 'Exceptional';
} else if (measure.class == 'B') {
parsed.impulse = 'Substantial';
} else {
parsed.impulse = 'Average';
}
}
});
return parsed;
}
return null;
} }
} }

View File

@ -13,7 +13,7 @@ import {HelperFunctions} from "../../utils/HelperFunctions.class";
@Injectable() @Injectable()
export class ResultLandingService { export class ResultLandingService {
constructor(private http: HttpClient ) { constructor(private http: HttpClient) {
this.parsingFunctions = new ParsingFunctions(); this.parsingFunctions = new ParsingFunctions();
} }
@ -39,7 +39,7 @@ export class ResultLandingService {
} else if (identifier) { } else if (identifier) {
// pid = "10.3389/fphys.2014.00466"; // pid = "10.3389/fphys.2014.00466";
let url = properties.searchAPIURLLAst + "resources2"; let url = properties.searchAPIURLLAst + "resources2";
url += "?pid="+encodeURIComponent(identifier.id) + "&pidtype=" + identifier.class + "&type="; url += "?pid=" + encodeURIComponent(identifier.id) + "&pidtype=" + identifier.class + "&type=";
if (type === 'publication') { if (type === 'publication') {
url += 'publications'; url += 'publications';
} else if (type === 'dataset') { } else if (type === 'dataset') {
@ -56,50 +56,50 @@ export class ResultLandingService {
} }
} }
getResultLandingInfo (id: string, identifier: Identifier, type: string, getResultLandingInfo(id: string, identifier: Identifier, type: string,
subjectsVocabulary: any, subjectsVocabulary: any,
properties: EnvProperties): any { properties: EnvProperties): any {
let url: string = this.buildResultLandingInfoUrl(id, identifier, type); let url: string = this.buildResultLandingInfoUrl(id, identifier, type);
let finalUrl: string = (properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url; let finalUrl: string = (properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url;
return this.http.get(finalUrl) return this.http.get(finalUrl)
.pipe(map(res => { .pipe(map(res => {
if(!id && identifier) { if (!id && identifier) {
if(!res['results'] || res['results'].length == 0) { if (!res['results'] || res['results'].length == 0) {
throw new HttpErrorResponse({ throw new HttpErrorResponse({
status: 404, status: 404,
statusText: "Not found", statusText: "Not found",
url: finalUrl, url: finalUrl,
error: "Http failure response for "+finalUrl+": 404 Not Found" error: "Http failure response for " + finalUrl + ": 404 Not Found"
}); });
}
return res['results'][0];
} else {
return res;
} }
return res['results'][0]; }))
} else { .pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res]))
return res; .pipe(map(res => [
} res[1]['oaf:result'], // 0
})) res[1]['oaf:result']['title'], // 1
.pipe(map(res => [res['result']['header']['dri:status'], res['result']['metadata']['oaf:entity'], res])) res[1]['oaf:result']['rels']['rel'], // 2
.pipe(map(res => [ res[1]['oaf:result']['children'], // 3
res[1]['oaf:result'], // 0 res[1]['oaf:result']['pid'], // 4
res[1]['oaf:result']['title'], // 1 res[1]['oaf:result']['journal'], // 5
res[1]['oaf:result']['rels']['rel'], // 2 res[1]['oaf:result']['language'], // 6
res[1]['oaf:result']['children'], // 3 res[1]['oaf:result']['eoscifguidelines'], // 7
res[1]['oaf:result']['pid'], // 4 res[1]['oaf:result']['subject'], // 8
res[1]['oaf:result']['journal'], // 5 res[1]['oaf:result']['context'], // 9
res[1]['oaf:result']['language'], // 6 res[1]['oaf:result']['creator'], // 10
res[1]['oaf:result']['eoscifguidelines'], // 7 res[1]['oaf:result']['country'], // 11
res[1]['oaf:result']['subject'], // 8 res[1]['oaf:result']['programmingLanguage'], // 12 - software
res[1]['oaf:result']['context'], // 9 //res[1]['oaf:result']['resulttype'],
res[1]['oaf:result']['creator'], // 10 (res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['references'] !== undefined)
res[1]['oaf:result']['country'] , // 11 ? res[1]['extraInfo']['references']['reference'] : null, // 13
res[1]['oaf:result']['programmingLanguage'], // 12 - software res[0], // 14
//res[1]['oaf:result']['resulttype'], res[2], // 15
(res[1]['extraInfo'] !== undefined && res[1]['extraInfo']['references'] !== undefined) ]))
? res[1]['extraInfo']['references']['reference'] : null, // 13 .pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties)));
res[0], // 14
res[2], // 15
]))
.pipe(map(res => this.parseResultLandingInfo(res, subjectsVocabulary, properties)));
} }
// getProvenanceActionVocabulary (properties: EnvProperties): any { // getProvenanceActionVocabulary (properties: EnvProperties): any {
@ -118,15 +118,15 @@ export class ResultLandingService {
// return provenanceActionVocabulary; // return provenanceActionVocabulary;
// } // }
private handleError (error: HttpErrorResponse) { private handleError(error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.log(error); console.log(error);
return throwError(error || 'Server error'); return throwError(error || 'Server error');
} }
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 // res
this.resultLandingInfo.record = data[15]; this.resultLandingInfo.record = data[15];
this.resultLandingInfo.objIdentifier = data[15]["result"]["header"]["dri:objIdentifier"]; this.resultLandingInfo.objIdentifier = data[15]["result"]["header"]["dri:objIdentifier"];
@ -136,25 +136,25 @@ export class ResultLandingService {
// res['result']['metadata']['oaf:entity']['oaf:result'] // res['result']['metadata']['oaf:entity']['oaf:result']
if (data[0] != null) { if (data[0] != null) {
let date: string = (data[0].dateofacceptance ? data[0].dateofacceptance : '') + ''; // transform to string in case it is an integer let date: string = (data[0].dateofacceptance ? data[0].dateofacceptance : '') + ''; // 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[0].dateofacceptance ? Dates.getDate(data[0].dateofacceptance) : null;
this.resultLandingInfo.publisher = data[0].publisher; this.resultLandingInfo.publisher = data[0].publisher;
this.resultLandingInfo.description = this.parsingFunctions.parseDescription(data[0] && data[0].description?data[0].description:[]); 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; this.resultLandingInfo.embargoEndDate = data[0].embargoenddate ? Dates.getDate(data[0].embargoenddate) : null;
} }
if(data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) { if (data[0]['bestaccessright'] && data[0]['bestaccessright'].hasOwnProperty("classname")) {
this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname; this.resultLandingInfo.accessMode = data[0]['bestaccessright'].classname;
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['title'] // res['result']['metadata']['oaf:entity']['oaf:result']['title']
if(data[1] != null) { if (data[1] != null) {
if(Array.isArray(data[1])) { if (Array.isArray(data[1])) {
for(let i=0; i<data[1].length; i++) { for (let i = 0; i < data[1].length; i++) {
if(data[1][i] && data[1][i].content) { if (data[1][i] && data[1][i].content) {
if(!this.resultLandingInfo.title || data[1][i].classid == "main title") { if (!this.resultLandingInfo.title || data[1][i].classid == "main title") {
this.resultLandingInfo.title = StringUtils.HTMLToString(String(data[1][i].content)); this.resultLandingInfo.title = StringUtils.HTMLToString(String(data[1][i].content));
} }
if(!this.resultLandingInfo.subtitle && data[1][i].classid === 'subtitle') { if (!this.resultLandingInfo.subtitle && data[1][i].classid === 'subtitle') {
this.resultLandingInfo.subtitle = StringUtils.HTMLToString(String(data[1][i].content)); this.resultLandingInfo.subtitle = StringUtils.HTMLToString(String(data[1][i].content));
} }
// if(data[1][i].classid == "main title") { // if(data[1][i].classid == "main title") {
@ -162,10 +162,10 @@ export class ResultLandingService {
// } // }
} }
} }
if(this.resultLandingInfo.title === this.resultLandingInfo.subtitle) { if (this.resultLandingInfo.title === this.resultLandingInfo.subtitle) {
this.resultLandingInfo.subtitle = ""; this.resultLandingInfo.subtitle = "";
} }
if(!this.resultLandingInfo.title) { if (!this.resultLandingInfo.title) {
this.resultLandingInfo.title = ""; this.resultLandingInfo.title = "";
} }
// this.resultLandingInfo.title = (data[1][0] && data[1][0].content) ? String(data[1][0].content) : ""; // this.resultLandingInfo.title = (data[1][0] && data[1][0].content) ? String(data[1][0].content) : "";
@ -175,26 +175,26 @@ export class ResultLandingService {
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel'] // res['result']['metadata']['oaf:entity']['oaf:result']['rels']['rel']
if(data[2] != null) { if (data[2] != null) {
let relation; let relation;
let length = Array.isArray(data[2]) ? data[2].length : 1; let length = Array.isArray(data[2]) ? data[2].length : 1;
for(let i=0; i<length; i++) { for (let i = 0; i < length; i++) {
relation = Array.isArray(data[2]) ? data[2][i] : data[2]; relation = Array.isArray(data[2]) ? data[2][i] : data[2];
if(relation.hasOwnProperty("to")) { if (relation.hasOwnProperty("to")) {
if(relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") { if (relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") {
this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation); this.resultLandingInfo.fundedByProjects = this.parsingFunctions.parseFundingByProjects(this.resultLandingInfo.fundedByProjects, relation);
} }
if(relation['to'].scheme && relation['to'].scheme == "dnet:result_result_relations") { if (relation['to'].scheme && relation['to'].scheme == "dnet:result_result_relations") {
let relationName: string = relation.to.class; let relationName: string = relation.to.class;
if(!this.resultLandingInfo.relatedClassFilters.has(relationName)) { if (!this.resultLandingInfo.relatedClassFilters.has(relationName)) {
this.resultLandingInfo.relatedClassFilters.add(relationName); this.resultLandingInfo.relatedClassFilters.add(relationName);
} }
let provenanceAction: string = relation.provenanceaction; let provenanceAction: string = relation.provenanceaction;
this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName); this.resultLandingInfo.relatedResults = this.parsingFunctions.parseResults(this.resultLandingInfo.relatedResults, relation, provenanceAction, relationName);
} else if(relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") { } else if (relation['to'].class && relation['to'].class.toLowerCase() == "hasauthorinstitution") {
this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation); this.resultLandingInfo.organizations = this.parseRelatedOrganizations(this.resultLandingInfo.organizations, relation);
} }
} }
@ -202,19 +202,19 @@ export class ResultLandingService {
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['children'] // res['result']['metadata']['oaf:entity']['oaf:result']['children']
if(data[3] != null) { if (data[3] != null) {
if(data[3].hasOwnProperty("result")) { if (data[3].hasOwnProperty("result")) {
this.resultLandingInfo.deletedByInferenceIds = []; this.resultLandingInfo.deletedByInferenceIds = [];
let length = Array.isArray(data[3]['result']) ? data[3]['result'].length : 1; let length = Array.isArray(data[3]['result']) ? data[3]['result'].length : 1;
for(let i=0; i<length; i++) { for (let i = 0; i < length; i++) {
let result = Array.isArray(data[3]['result']) ? data[3]['result'][i] : data[3]['result']; let result = Array.isArray(data[3]['result']) ? data[3]['result'][i] : data[3]['result'];
this.resultLandingInfo.deletedByInferenceIds.push(result.objidentifier); this.resultLandingInfo.deletedByInferenceIds.push(result.objidentifier);
} }
} }
if(data[3].hasOwnProperty("instance")) { if (data[3].hasOwnProperty("instance")) {
this.resultLandingInfo.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>(); this.resultLandingInfo.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
@ -226,26 +226,24 @@ export class ResultLandingService {
let length = Array.isArray(data[3]['instance']) ? data[3]['instance'].length : 1; let length = Array.isArray(data[3]['instance']) ? data[3]['instance'].length : 1;
for(let i=0; i<length; i++) { for (let i = 0; i < length; i++) {
instance = Array.isArray(data[3]['instance']) ? data[3]['instance'][i] : data[3]['instance']; instance = Array.isArray(data[3]['instance']) ? data[3]['instance'][i] : data[3]['instance'];
this.parsingFunctions.parseTypes(this.resultLandingInfo.types, types, instance); this.parsingFunctions.parseTypes(this.resultLandingInfo.types, types, instance);
if(instance.hasOwnProperty("webresource")) { if (instance.hasOwnProperty("webresource")) {
let url; let url;
if(!Array.isArray(instance['webresource'])) { if (!Array.isArray(instance['webresource'])) {
url = instance['webresource'].url; url = instance['webresource'].url;
} else { } else {
url = instance['webresource'][0].url; url = instance['webresource'][0].url;
} }
if(url.includes('&amp;')) { if (url.includes('&amp;')) {
let regExp = /&amp;/gmu; url = url.replace(/&amp;/gmu, '&');
let newUrl = url.replace(regExp, '&');
url = newUrl;
} }
/**********************************************************/ /**********************************************************/
if(instance.hasOwnProperty("hostedby")) { if (instance.hasOwnProperty("hostedby")) {
this.parsingFunctions.parseHostedBy_collectedFrom(this.resultLandingInfo.hostedBy_collectedFrom, instance, url, this.resultLandingInfo.accessMode); this.parsingFunctions.parseHostedBy_collectedFrom(this.resultLandingInfo.hostedBy_collectedFrom, instance, url, this.resultLandingInfo.accessMode);
} }
/**********************************************************/ /**********************************************************/
@ -253,57 +251,32 @@ export class ResultLandingService {
} }
/* Order Download from via openness*/ /* Order Download from via openness*/
this.resultLandingInfo.hostedBy_collectedFrom.sort((a, b) => { this.resultLandingInfo.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom);
let firstAccessRight: string = (a.accessRight ? a.accessRight.toLowerCase() : null);
let secondAccessRight: string = (b.accessRight ? b.accessRight.toLowerCase() : null);
if (firstAccessRight === secondAccessRight) {
return 0;
} 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;
}
}
return 0;
});
} }
if(data[3].hasOwnProperty("externalreference")) { if (data[3].hasOwnProperty("externalreference")) {
let externalResults: Map<string, Map<string, string>> = this.parseBioentitiesAndSoftware(data[3]); let externalResults: Map<string, Map<string, string>> = this.parseBioentitiesAndSoftware(data[3]);
this.resultLandingInfo.bioentities = externalResults; this.resultLandingInfo.bioentities = externalResults;
} }
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['pid'] // res['result']['metadata']['oaf:entity']['oaf:result']['pid']
if(data[4] != null) { if (data[4] != null) {
this.resultLandingInfo.identifiers = this.parsingFunctions.parseIdentifiers(data[4]); this.resultLandingInfo.identifiers = this.parsingFunctions.parseIdentifiers(data[4]);
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['journal'] // res['result']['metadata']['oaf:entity']['oaf:result']['journal']
if(data[5] != null) { if (data[5] != null) {
this.resultLandingInfo.journal = {"journal": "", "issn": "", "lissn": "", "eissn": "", "issue": "", "volume": "", "start_page": "", "end_page": ""} this.resultLandingInfo.journal = {
"journal": "",
"issn": "",
"lissn": "",
"eissn": "",
"issue": "",
"volume": "",
"start_page": "",
"end_page": ""
}
this.resultLandingInfo.journal['journal'] = data[5].content; this.resultLandingInfo.journal['journal'] = data[5].content;
this.resultLandingInfo.journal['issn'] = data[5].issn; this.resultLandingInfo.journal['issn'] = data[5].issn;
@ -316,7 +289,7 @@ export class ResultLandingService {
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['language'] // res['result']['metadata']['oaf:entity']['oaf:result']['language']
if(data[6] != null) { if (data[6] != null) {
this.resultLandingInfo.languages = this.parsingFunctions.parseLanguages(data[6]); this.resultLandingInfo.languages = this.parsingFunctions.parseLanguages(data[6]);
// let languagesAndCodes: string[][] = this.parsingFunctions.parseLanguages(data[6]); // let languagesAndCodes: string[][] = this.parsingFunctions.parseLanguages(data[6]);
// this.resultLandingInfo.languages = languagesAndCodes[0]; // this.resultLandingInfo.languages = languagesAndCodes[0];
@ -324,27 +297,27 @@ export class ResultLandingService {
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['country'] // res['result']['metadata']['oaf:entity']['oaf:result']['country']
if(data[11] != null) { if (data[11] != null) {
this.resultLandingInfo.countries = this.parsingFunctions.parseCountries(data[11]); this.resultLandingInfo.countries = this.parsingFunctions.parseCountries(data[11]);
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['eoscifguidelines'] // res['result']['metadata']['oaf:entity']['oaf:result']['eoscifguidelines']
if(data[7] != null) { if (data[7] != null) {
this.resultLandingInfo.eoscSubjects = this.parsingFunctions.parseEoscSubjects(data[7]); this.resultLandingInfo.eoscSubjects = this.parsingFunctions.parseEoscSubjects(data[7]);
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['subject'] // res['result']['metadata']['oaf:entity']['oaf:result']['subject']
if(data[8] != null) { if (data[8] != null) {
let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>, string[], string[]] = this.parsingFunctions.parseAllSubjects(data[8], subjectsVocabulary); let subjectResults: [string[], Map<string, string[]>, Map<string, string[]>, string[], string[]] = this.parsingFunctions.parseAllSubjects(data[8], subjectsVocabulary);
this.resultLandingInfo.subjects = subjectResults[0]; this.resultLandingInfo.subjects = subjectResults[0];
this.resultLandingInfo.otherSubjects = subjectResults[1]; this.resultLandingInfo.otherSubjects = subjectResults[1];
this.resultLandingInfo.classifiedSubjects = subjectResults[2]; this.resultLandingInfo.classifiedSubjects = subjectResults[2];
this.resultLandingInfo.fos = subjectResults[3]; this.resultLandingInfo.fos = subjectResults[3];
if(this.resultLandingInfo.fos) { if (this.resultLandingInfo.fos) {
this.resultLandingInfo.fos.sort((a, b) => a.localeCompare(b)) this.resultLandingInfo.fos.sort((a, b) => a.localeCompare(b))
} }
this.resultLandingInfo.sdg = subjectResults[4]; this.resultLandingInfo.sdg = subjectResults[4];
if(this.resultLandingInfo.sdg) { if (this.resultLandingInfo.sdg) {
this.resultLandingInfo.sdg.sort((a, b) => { this.resultLandingInfo.sdg.sort((a, b) => {
return HelperFunctions.sortSDGs(a, b); return HelperFunctions.sortSDGs(a, b);
}) })
@ -356,50 +329,54 @@ export class ResultLandingService {
} }
this.resultLandingInfo.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom( 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, 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'] // res['result']['metadata']['oaf:entity']['extraInfo']['references']['reference']
if(data[13] != null) { if (data[13] != null) {
this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]); this.resultLandingInfo.references = this.parsingFunctions.parseReferences(data[13]);
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['context'] // res['result']['metadata']['oaf:entity']['oaf:result']['context']
if(data[9] != null) { if (data[9] != null) {
this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[9]); this.resultLandingInfo.contexts = this.parsingFunctions.parseContexts(data[9]);
} }
// res['result']['header']['dri:status'] // res['result']['header']['dri:status']
if(data[14] != null && data[14] == "under curation") { if (data[14] != null && data[14] == "under curation") {
this.resultLandingInfo.underCurationMessage = true; this.resultLandingInfo.underCurationMessage = true;
} else { } else {
this.resultLandingInfo.underCurationMessage = false; this.resultLandingInfo.underCurationMessage = false;
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['creator'] // res['result']['metadata']['oaf:entity']['oaf:result']['creator']
if(data[10] != null) { if (data[10] != null) {
if(this.resultLandingInfo.authors == undefined) { if (this.resultLandingInfo.authors == undefined) {
this.resultLandingInfo.authors = new Array<{"fullName": string, "orcid": string, "orcid_pending": string}>(); this.resultLandingInfo.authors = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>();
} }
let authors = data[10]; let authors = data[10];
let length = Array.isArray(authors) ? authors.length : 1; let length = Array.isArray(authors) ? authors.length : 1;
for(let i=0; i<length; i++) { for (let i = 0; i < length; i++) {
let author = Array.isArray(authors) ? authors[i] : authors; let author = Array.isArray(authors) ? authors[i] : authors;
if(author) { if (author) {
if(author.orcid) { if (author.orcid) {
author.orcid = author.orcid.toUpperCase(); author.orcid = author.orcid.toUpperCase();
} }
if(author.orcid_pending) { if (author.orcid_pending) {
author.orcid_pending = author.orcid_pending.toUpperCase(); author.orcid_pending = author.orcid_pending.toUpperCase();
} }
this.resultLandingInfo['authors'][author.rank] = {"fullName": author.content, "orcid": author.orcid, "orcid_pending": author.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) { this.resultLandingInfo.authors = this.resultLandingInfo.authors.filter(function (item) {
@ -407,77 +384,10 @@ export class ResultLandingService {
}); });
} }
// res['result']['metadata']['oaf:entity']['oaf:result']['measure'] // res['result']['metadata']['oaf:entity']['oaf:result']['measure']
if (data[0] != null) { if (data[0]?.measure) {
if (data[0].measure?.length) { this.resultLandingInfo.measure = this.parsingFunctions.parseMeasures(data[0].measure);
this.resultLandingInfo.measure = {"downloads": null, "views": null, "popularity": null, "influence": null, "citations": null, "impulse": null}; }
for (let i = 0; i < data[0].measure.length; i++) {
if (data[0].measure[i].id == 'downloads') {
// this.resultLandingInfo.measure['downloads'] = data[0].measure[i].count == 0 ? ' - ' : data[0].measure[i].count;
this.resultLandingInfo.measure['downloads'] = data[0].measure[i].count;
}
if (data[0].measure[i].id == 'views') {
// this.resultLandingInfo.measure['views'] = data[0].measure[i].count == 0 ? ' - ' : data[0].measure[i].count;
this.resultLandingInfo.measure['views'] = data[0].measure[i].count;
}
if (data[0].measure[i].id == 'influence') {
if (data[0].measure[i].class == 'C1') {
this.resultLandingInfo.measure['influence'] = 'Top 0.01%';
} else if (data[0].measure[i].class == 'C2') {
this.resultLandingInfo.measure['influence'] = 'Top 0.1%';
} else if (data[0].measure[i].class == 'C3') {
this.resultLandingInfo.measure['influence'] = 'Top 1%';
} else if (data[0].measure[i].class == 'C4') {
this.resultLandingInfo.measure['influence'] = 'Top 10%';
} else if (data[0].measure[i].class == 'A') {
this.resultLandingInfo.measure['influence'] = 'Exceptional';
} else if (data[0].measure[i].class == 'B') {
this.resultLandingInfo.measure['influence'] = 'Substantial';
} else {
this.resultLandingInfo.measure['influence'] = 'Average';
}
}
if (data[0].measure[i].id == 'popularity') {
if (data[0].measure[i].class == 'C1') {
this.resultLandingInfo.measure['popularity'] = 'Top 0.01%';
} else if (data[0].measure[i].class == 'C2') {
this.resultLandingInfo.measure['popularity'] = 'Top 0.1%';
} else if (data[0].measure[i].class == 'C3') {
this.resultLandingInfo.measure['popularity'] = 'Top 1%';
} else if (data[0].measure[i].class == 'C4') {
this.resultLandingInfo.measure['popularity'] = 'Top 10%';
} else if (data[0].measure[i].class == 'A') {
this.resultLandingInfo.measure['popularity'] = 'Exceptional';
} else if (data[0].measure[i].class == 'B') {
this.resultLandingInfo.measure['popularity'] = 'Substantial';
} else {
this.resultLandingInfo.measure['popularity'] = 'Average';
}
}
if (data[0].measure[i].id == 'influence_alt') {
// this.resultLandingInfo.measure['citations'] = data[0].measure[i].score == 0 ? ' - ' : data[0].measure[i].score;
this.resultLandingInfo.measure['citations'] = data[0].measure[i].score;
}
if (data[0].measure[i].id == 'impulse') {
if (data[0].measure[i].class == 'C1') {
this.resultLandingInfo.measure['impulse'] = 'Top 0.01%';
} else if (data[0].measure[i].class == 'C2') {
this.resultLandingInfo.measure['impulse'] = 'Top 0.1%';
} else if (data[0].measure[i].class == 'C3') {
this.resultLandingInfo.measure['impulse'] = 'Top 1%';
} else if (data[0].measure[i].class == 'C4') {
this.resultLandingInfo.measure['impulse'] = 'Top 10%';
} else if (data[0].measure[i].class == 'A') {
this.resultLandingInfo.measure['impulse'] = 'Exceptional';
} else if (data[0].measure[i].class == 'B') {
this.resultLandingInfo.measure['impulse'] = 'Substantial';
} else {
this.resultLandingInfo.measure['impulse'] = 'Average';
}
}
}
}
}
this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults); this.resultLandingInfo.relatedResults = this.parsingFunctions.sortByPercentage(this.resultLandingInfo.relatedResults);
@ -485,11 +395,12 @@ export class ResultLandingService {
} }
parseRelatedOrganizations(organizations: Organization[], relation: any): Organization[] { parseRelatedOrganizations(organizations: Organization[], relation: any): Organization[] {
if(organizations == undefined) { if (organizations == undefined) {
organizations = [] organizations = []
} }
let organization: { "name": string, "shortname": string, let organization: {
"name": string, "shortname": string,
"id": string, "websiteUrl": string, "id": string, "websiteUrl": string,
"country": string, "trust": number "country": string, "trust": number
} = { } = {
@ -502,34 +413,34 @@ export class ResultLandingService {
organization.name = relation.legalname; organization.name = relation.legalname;
organization.shortname = relation.legalshortname; organization.shortname = relation.legalshortname;
organization.websiteUrl = relation.websiteurl; organization.websiteUrl = relation.websiteurl;
if(relation.country) { if (relation.country) {
organization.country = relation.country.classname; organization.country = relation.country.classname;
} }
if(relation.trust) { if (relation.trust) {
organization.trust = Math.round(relation.trust*100); organization.trust = Math.round(relation.trust * 100);
} }
organizations.push(organization); organizations.push(organization);
return organizations; return organizations;
} }
parseBioentitiesAndSoftware(children: any) : Map<string, Map<string, string>> { parseBioentitiesAndSoftware(children: any): Map<string, Map<string, string>> {
let bioentities: Map<string, Map<string, string>>; let bioentities: Map<string, Map<string, string>>;
let length = Array.isArray(children['externalreference']) ? children['externalreference'].length : 1; let length = Array.isArray(children['externalreference']) ? children['externalreference'].length : 1;
let externalreference; let externalreference;
for(let i=0; i<length; i++) { for (let i = 0; i < length; i++) {
externalreference = Array.isArray(children['externalreference']) ? children['externalreference'][i] : children['externalreference']; externalreference = Array.isArray(children['externalreference']) ? children['externalreference'][i] : children['externalreference'];
if(externalreference.hasOwnProperty("qualifier")) { if (externalreference.hasOwnProperty("qualifier")) {
if(externalreference['qualifier'].classid == "accessionNumber") { if (externalreference['qualifier'].classid == "accessionNumber") {
if(bioentities == undefined) { if (bioentities == undefined) {
bioentities = new Map<string, Map<string, string>>(); bioentities = new Map<string, Map<string, string>>();
} }
if(!bioentities.has(externalreference.sitename)) { if (!bioentities.has(externalreference.sitename)) {
bioentities.set(externalreference.sitename, new Map<string, string>()); bioentities.set(externalreference.sitename, new Map<string, string>());
} }
bioentities.get(externalreference.sitename).set(externalreference.refidentifier, externalreference.url); bioentities.get(externalreference.sitename).set(externalreference.refidentifier, externalreference.url);
@ -542,10 +453,10 @@ export class ResultLandingService {
} }
getEnermapsDetails(id: string) { getEnermapsDetails(id: string) {
let url = properties.enermapsURL+"/api/db/metadata?shared_id=eq."+id; 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((properties.useLongCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
// return this.http.get(url) // return this.http.get(url)
.pipe(map(res => this.parseEnermapsDetails(res))); .pipe(map(res => this.parseEnermapsDetails(res)));
} }
parseEnermapsDetails(response: any) { parseEnermapsDetails(response: any) {
@ -554,9 +465,9 @@ export class ResultLandingService {
let entries = []; let entries = [];
let keys = metadata ? Object.keys(metadata) : null; let keys = metadata ? Object.keys(metadata) : null;
for(let key of keys) { for (let key of keys) {
if(key != "shared_id" && key && metadata[key]) { if (key != "shared_id" && key && metadata[key]) {
entries.push([key+"", metadata[key]+""]); entries.push([key + "", metadata[key] + ""]);
} }
} }
return entries; return entries;

View File

@ -1,9 +1,9 @@
<ul class="uk-list uk-list-xlarge uk-margin" [ngClass]="custom_class"> <ul class="uk-list uk-list-xlarge uk-margin" [ngClass]="custom_class">
<errorMessages [status]="[status]" [type]="'results'"></errorMessages> <errorMessages [status]="[status]" [type]="'results'"></errorMessages>
<li *ngFor="let result of previewResults"> <li *ngFor="let result of previewResults" [class.uk-border-bottom]="!isMobile">
<result-preview [properties]="properties" [showOrganizations]="showOrganizations" <result-preview [properties]="properties" [showOrganizations]="showOrganizations"
[showSubjects]="showSubjects" [result]="result" [showEnermaps]="showEnermaps" [showSubjects]="showSubjects" [result]="result" [showEnermaps]="showEnermaps"
[isCard]="true"> [isCard]="isMobile" [isMobile]="isMobile">
</result-preview> </result-preview>
</li> </li>
</ul> </ul>

View File

@ -2,18 +2,19 @@ import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core'
import {SearchResult} from '../../utils/entities/searchResult'; import {SearchResult} from '../../utils/entities/searchResult';
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {ResultPreview} from "../../utils/result-preview/result-preview"; import {ResultPreview} from "../../utils/result-preview/result-preview";
import {HttpClient} from "@angular/common/http";
import {OrcidService} from "../../orcid/orcid.service"; import {OrcidService} from "../../orcid/orcid.service";
import {Session} from "../../login/utils/helper.class"; import {Session} from "../../login/utils/helper.class";
import {properties} from "../../../../environments/environment"; import {properties} from "../../../../environments/environment";
import {LayoutService} from "../../dashboard/sharedComponents/sidebar/layout.service";
import {Subscription} from "rxjs";
@Component({ @Component({
selector: 'search-result', selector: 'search-result',
templateUrl: 'searchResult.component.html' templateUrl: 'searchResult.component.html'
}) })
export class SearchResultComponent implements OnInit, OnChanges { export class SearchResultComponent implements OnInit, OnChanges {
@Input() results: SearchResult[]; @Input() results: SearchResult[];
previewResults:ResultPreview[]; previewResults: ResultPreview[];
@Input() status: number; @Input() status: number;
@Input() type: string; @Input() type: string;
@Input() showLoading: boolean = false; @Input() showLoading: boolean = false;
@ -22,62 +23,73 @@ export class SearchResultComponent implements OnInit, OnChanges {
@Input() custom_class: string = ""; @Input() custom_class: string = "";
@Input() properties: EnvProperties; @Input() properties: EnvProperties;
@Input() showEnermaps: boolean; @Input() showEnermaps: boolean;
public isMobile: boolean = false;
private subscriptions: any[] = [];
constructor( private http: HttpClient/*ATHENA CODE*/ constructor(private orcidService: OrcidService,
, private orcidService: OrcidService) { private layoutService: LayoutService) {
} }
ngOnInit() {} ngOnInit() {
sub; this.subscriptions.push(this.layoutService.isMobile.subscribe(isMobile => {
this.isMobile = isMobile;
}));
console.log(this.results);
}
ngOnDestroy() { ngOnDestroy() {
if(this.sub){ this.subscriptions.forEach(subscription => {
this.sub.unsubscribe(); if(subscription instanceof Subscription) {
} subscription.unsubscribe();
} }
initialize(){ })
this.previewResults = [];
for(let result of this.results){
this.previewResults.push(this.getResultPreview(result));
}
if((properties.adminToolsPortalType == "explore" || properties.adminToolsPortalType == "community" || properties.adminToolsPortalType == "aggregator")
&& Session.isLoggedIn() && this.results && this.results.length > 0
&& (this.type == "result" || this.type == "publication" || this.type == "dataset" || this.type == "software" || this.type == "other")
) {
this.orcidService.getPutCodes(this.previewResults.map(
previewResult => {
if(previewResult.identifiers) {
let pidsArray: string[] = [];
for(let key of Array.from(previewResult.identifiers.keys())) {
pidsArray = pidsArray.concat(previewResult.identifiers.get(key));
}
return pidsArray;//.join();
}
})).subscribe(
putCodes => {
for (let i = 0; i < this.previewResults.length; i++) {
if(this.previewResults[i].identifiers) {
this.previewResults[i].orcidPutCodes = putCodes[i];
// console.debug(i, this.previewResults[i].orcidPutCodes);
}
}
}, error => {
}
);
}
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
if (changes.results) { if (changes.results) {
this.initialize(); this.initialize();
} }
} }
public getResultPreview(result: SearchResult): ResultPreview {
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type); initialize() {
this.previewResults = [];
for (let result of this.results) {
this.previewResults.push(this.getResultPreview(result));
}
if ((properties.adminToolsPortalType == "explore" || properties.adminToolsPortalType == "community" || properties.adminToolsPortalType == "aggregator")
&& Session.isLoggedIn() && this.results && this.results.length > 0
&& (this.type == "result" || this.type == "publication" || this.type == "dataset" || this.type == "software" || this.type == "other")
) {
this.subscriptions.push(this.orcidService.getPutCodes(this.previewResults.map(
previewResult => {
if (previewResult.identifiers) {
let pidsArray: string[] = [];
for (let key of Array.from(previewResult.identifiers.keys())) {
pidsArray = pidsArray.concat(previewResult.identifiers.get(key));
}
return pidsArray;//.join();
}
})).subscribe(
putCodes => {
for (let i = 0; i < this.previewResults.length; i++) {
if (this.previewResults[i].identifiers) {
this.previewResults[i].orcidPutCodes = putCodes[i];
// console.debug(i, this.previewResults[i].orcidPutCodes);
}
}
}, error => {
}
));
}
} }
public getResultPreview(result: SearchResult): ResultPreview {
return ResultPreview.searchResultConvert(result, (result.entityType) ? result.entityType : this.type);
}
public quote(params: string): string { public quote(params: string): string {
return '"' + params + '"'; return '"' + params + '"';
} }

View File

@ -7,20 +7,20 @@ import {ParsingFunctions} from '../landingPages/landing-utils/parsingFunctions.c
import {EnvProperties} from '../utils/properties/env-properties'; import {EnvProperties} from '../utils/properties/env-properties';
import {map} from "rxjs/operators"; import {map} from "rxjs/operators";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {HostedByCollectedFrom} from "../utils/result-preview/result-preview";
@Injectable() @Injectable()
export class SearchResearchResultsService { export class SearchResearchResultsService {
private sizeOfDescription: number = 270;
public parsingFunctions: ParsingFunctions = new ParsingFunctions(); public parsingFunctions: ParsingFunctions = new ParsingFunctions();
constructor(private http: HttpClient=null) { constructor(private http: HttpClient = null) {
} }
search(resultType: string, params: string, refineParams: string, page: number, size: number, sortBy: string, refineFields: string[], properties: EnvProperties): any { search(resultType: string, params: string, refineParams: string, page: number, size: number, sortBy: string, refineFields: string[], properties: EnvProperties): any {
let link = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true); let link = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true);
let url = link + "?"; let url = link + "?";
if (params != null && params != '') { if (params != null && params != '') {
url += params; url += params;
@ -32,21 +32,21 @@ export class SearchResearchResultsService {
url += "&sortBy=" + sortBy; url += "&sortBy=" + sortBy;
} }
url += "&page=" + (page - 1) + "&size=" + size + "&format=json"; url += "&page=" + (page - 1) + "&size=" + size + "&format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")]));
} }
searchById(resultType: string, id: string, properties: EnvProperties): any { searchById(resultType: string, id: string, properties: EnvProperties): any {
let url = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true) + "/" + id + "?format=json"; let url = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true) + "/" + id + "?format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => this.parseResults(resultType, res, properties))); .pipe(map(res => this.parseResults(resultType, res, properties)));
} }
searchAggregators(resultType: string, id: string, params: string, refineParams: string, page: number, size: number, properties: EnvProperties): any { searchAggregators(resultType: string, id: string, params: string, refineParams: string, page: number, size: number, properties: EnvProperties): any {
let link = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true); let link = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true);
let url = link + "?" + "&format=json"; let url = link + "?" + "&format=json";
if (params != null && params != '') { if (params != null && params != '') {
url += params; url += params;
@ -55,33 +55,33 @@ export class SearchResearchResultsService {
url += refineParams; url += refineParams;
} }
url += "&page=" + (page - 1) + "&size=" + size; url += "&page=" + (page - 1) + "&size=" + size;
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => this.parseRefineResults(id, res['refineResults']))); .pipe(map(res => this.parseRefineResults(id, res['refineResults'])));
} }
searchByListOfDOI(resultType: string, DOIs: string[], refineParams: string, page: number, size: number, refineFields: string[], properties: EnvProperties): any { searchByListOfDOI(resultType: string, DOIs: string[], refineParams: string, page: number, size: number, refineFields: string[], properties: EnvProperties): any {
let link = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true); let link = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true);
let url = link + "?" + "&format=json&"; let url = link + "?" + "&format=json&";
var doisParams = ""; var doisParams = "";
for (var i = 0; i < DOIs.length; i++) { for (var i = 0; i < DOIs.length; i++) {
doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + DOIs[i] + '"'; doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + DOIs[i] + '"';
} }
if (doisParams.length > 0) { if (doisParams.length > 0) {
url += "&" + doisParams; url += "&" + doisParams;
} }
if (refineParams != null && refineParams != '') { if (refineParams != null && refineParams != '') {
url += refineParams; url += refineParams;
} }
url += "&page=" + (page - 1) + "&size=" + size; url += "&page=" + (page - 1) + "&size=" + size;
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")]));
} }
advancedSearch(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any { advancedSearch(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any {
let url = properties.searchResourcesAPIURL; let url = properties.searchResourcesAPIURL;
var basicQuery = "(oaftype exact result) and (resulttypeid exact " + this.getEntityQueryName(resultType, false) + ") "; var basicQuery = "(oaftype exact result) and (resulttypeid exact " + this.getEntityQueryName(resultType, false) + ") ";
@ -101,14 +101,14 @@ export class SearchResearchResultsService {
if (refineQuery) { if (refineQuery) {
url += "&" + refineQuery; url += "&" + refineQuery;
} }
url += "&page=" + (page - 1) + "&size=" + size; url += "&page=" + (page - 1) + "&size=" + size;
url += "&format=json"; url += "&format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")]));
} }
advancedSearchResults(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any { advancedSearchResults(resultType: string, params: string, page: number, size: number, sortBy: string, properties: EnvProperties, refineParams: string = null, refineFields: string[] = null, refineQuery: string = null): any {
let url = properties.searchAPIURLLAst + "resources2/?format=json"; let url = properties.searchAPIURLLAst + "resources2/?format=json";
if (params != null && params != '') { if (params != null && params != '') {
@ -124,30 +124,30 @@ export class SearchResearchResultsService {
if (refineQuery) { if (refineQuery) {
url += "&" + refineQuery; url += "&" + refineQuery;
} }
url += "&page=" + (page - 1) + "&size=" + size; url += "&page=" + (page - 1) + "&size=" + size;
// url += "&format=json"; // url += "&format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")])); .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties), RefineResultsUtils.parse(res['refineResults'], refineFields, "publication")]));
} }
searchResultForEntity(resultType: string, params: string, page: number, size: number, properties: EnvProperties): any { searchResultForEntity(resultType: string, params: string, page: number, size: number, properties: EnvProperties): any {
let link = properties.searchAPIURLLAst; let link = properties.searchAPIURLLAst;
//let url = link+params+"/"+this.getEntityQueryName(resultType,true)+ "?format=json"; //let url = link+params+"/"+this.getEntityQueryName(resultType,true)+ "?format=json";
//url += "&page="+(page-1)+"&size="+size; //url += "&page="+(page-1)+"&size="+size;
//url += "&sortBy=resultdateofacceptance,descending"; //url += "&sortBy=resultdateofacceptance,descending";
//let url = link+"/resources2?format=json&query="+params+" sortBy resultdateofacceptance/sort.descending&type="+this.getEntityQueryName(resultType,true); //let url = link+"/resources2?format=json&query="+params+" sortBy resultdateofacceptance/sort.descending&type="+this.getEntityQueryName(resultType,true);
let url = link + "/" + this.getEntityQueryName(resultType, true); let url = link + "/" + this.getEntityQueryName(resultType, true);
url += "?format=json"; url += "?format=json";
url += "&fq=" + params; url += "&fq=" + params;
url += "&sortBy=resultdateofacceptance,descending"; url += "&sortBy=resultdateofacceptance,descending";
url += "&page=" + (page - 1) + "&size=" + size; url += "&page=" + (page - 1) + "&size=" + size;
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)]));
} }
//???? why different from above? //???? why different from above?
@ -157,9 +157,9 @@ export class SearchResearchResultsService {
url += "&sortBy=resultdateofacceptance,descending"; url += "&sortBy=resultdateofacceptance,descending";
url += "&page=" + (page - 1) + "&size=" + size + "&format=json"; url += "&page=" + (page - 1) + "&size=" + size + "&format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)]));
} }
searchForMyOrcidLinks(resultType: string, orcidQuery: string, typeQuery: string, page: number, size: number): any { searchForMyOrcidLinks(resultType: string, orcidQuery: string, typeQuery: string, page: number, size: number): any {
let url = properties.searchAPIURLLAst + "resources2/?format=json"; let url = properties.searchAPIURLLAst + "resources2/?format=json";
if (orcidQuery != null && orcidQuery != '') { if (orcidQuery != null && orcidQuery != '') {
@ -167,14 +167,14 @@ export class SearchResearchResultsService {
} }
url += typeQuery; url += typeQuery;
url += "&page=" + (page - 1) + "&size=" + size; url += "&page=" + (page - 1) + "&size=" + size;
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)])); .pipe(map(res => [res['meta'].total, this.parseResults(resultType, res['results'], properties)]));
} }
parseResults(resultType: string, data: any, properties: EnvProperties): SearchResult[] { parseResults(resultType: string, data: any, properties: EnvProperties): SearchResult[] {
let results: SearchResult[] = []; let results: SearchResult[] = [];
if(data == null) { if (data == null) {
return results; return results;
} }
@ -182,135 +182,16 @@ export class SearchResearchResultsService {
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result']; let resData = Array.isArray(data) ? data[i]['result']['metadata']['oaf:entity']['oaf:result'] : data['result']['metadata']['oaf:entity']['oaf:result'];
var result: SearchResult = new SearchResult(); var result: SearchResult = new SearchResult();
if (resData['resulttype']) { if (resData['resulttype']) {
result.entityType = resData['resulttype']['classname']; result.entityType = resData['resulttype']['classname'];
} else { } else {
result.entityType = resultType; result.entityType = resultType;
} }
result.types = new Array<string>();
let types = new Set<string>();
let instance;
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
for (let i = 0; i < length; i++) {
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
this.parsingFunctions.parseTypes(result.types, types, instance);
}
// Measure
result.measure = new Array<string>();
if (resData['measure'] && Array.isArray(resData['measure'])) {
for (let i = 0; i < resData['measure'].length; i++) {
if (resData['measure'][i].id == 'influence') {
result.measure[1] = resData['measure'][i].class;
if (resData['measure'][i].class == 'C1') {
result.measure[3] = 'Top 0.01% in';
} else if (resData['measure'][i].class == 'C2') {
result.measure[3] = 'Top 0.1% in';
} else if (resData['measure'][i].class == 'C3') {
result.measure[3] = 'Top 1% in';
} else if (resData['measure'][i].class == 'C4') {
result.measure[3] = 'Top 10% in';
} else if (resData['measure'][i].class == 'A') {
result.measure[3] = 'Exceptional';
} else if (resData['measure'][i].class == 'B') {
result.measure[3] = 'Substantial';
} else {
result.measure[3] = 'Average';
}
}
if (resData['measure'][i].id == 'popularity') {
result.measure[0] = resData['measure'][i].class;
if (resData['measure'][i].class == 'C1') {
result.measure[2] = 'Top 0.01% in';
} else if (resData['measure'][i].class == 'C2') {
result.measure[2] = 'Top 0.1% in';
} else if (resData['measure'][i].class == 'C3') {
result.measure[2] = 'Top 1% in';
} else if (resData['measure'][i].class == 'C4') {
result.measure[2] = 'Top 10% in';
} else if (resData['measure'][i].class == 'A') {
result.measure[2] = 'Exceptional';
} else if (resData['measure'][i].class == 'B') {
result.measure[2] = 'Substantial';
} else {
result.measure[2] = 'Average';
}
}
}
}
/////////////////////////// Athena Code ///////////////////////////
if (resData['pid']) {
if (!Array.isArray(resData['pid'])) {
if (resData['pid'].classid && resData['pid'].classid == 'doi') {
if (resData['pid'].content != '' && resData['pid'].content != null) {
result.DOIs.push((resData['pid'].content+"").replace("https://doi.org/", ""));
}
}
} else {
for (let i = 0; i < resData['pid'].length; i++) {
if (resData['pid'][i].classid == 'doi') {
if (resData['pid'][i].content != '' && resData['pid'][i].content != null && resData['pid'][i].content) {
result.DOIs.push((resData['pid'][i].content+"").replace("https://doi.org/", ""));
}
}
}
}
result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']);
}
/////////////////////////// Athena Code ///////////////////////////
if (resData['programmingLanguage'] && resData['programmingLanguage'] != null) {
result.programmingLanguages = new Array<string>();
if (!Array.isArray(resData['programmingLanguage'])) {
if (resData['programmingLanguage'].classname != "Undetermined" && resData['programmingLanguage'].classname) {
result.programmingLanguages.push(resData['programmingLanguage'].classname);
}
} else {
for (let i = 0; i < resData['programmingLanguage'].length; i++) {
if (resData['programmingLanguage'][i].classname != "Undetermined" && resData['programmingLanguage'][i].classname) {
result.programmingLanguages.push(resData['programmingLanguage'][i].classname);
}
}
}
}
if (resData['language'] && resData['language'] != null) {
result.languages = new Array<string>();
if (!Array.isArray(resData['language'])) {
if (resData['language'].classname != "Undetermined" && resData['language'].classname) {
result.languages.push(resData['language'].classname);
}
} else {
for (let i = 0; i < resData['language'].length; i++) {
if (resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
result.languages.push(resData['language'][i].classname);
}
}
}
}
if (resData['country'] && resData['country'] != null) {
result.countriesForResults = new Array<string>();
if (!Array.isArray(resData['country'])) {
if (resData['country'].classname != "Undetermined" && resData['country'].classname) {
result.countriesForResults.push(resData['country'].classname);
}
} else {
for (let i = 0; i < resData['country'].length; i++) {
if (resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
result.countriesForResults.push(resData['country'][i].classname);
}
}
}
}
result['title'] = {"name": '', "accessMode": ''}; result['title'] = {"name": '', "accessMode": ''};
if (Array.isArray(resData['title'])) { if (Array.isArray(resData['title'])) {
for (let i = 0; i < resData['title'].length; i++) { for (let i = 0; i < resData['title'].length; i++) {
if (resData['title'][i] && resData['title'][i].content) { if (resData['title'][i] && resData['title'][i].content) {
@ -329,7 +210,107 @@ export class SearchResearchResultsService {
} else { } else {
result['title'].name = (resData['title'] && resData['title'].content) ? StringUtils.HTMLToString(String(resData['title'].content)) : ""; result['title'].name = (resData['title'] && resData['title'].content) ? StringUtils.HTMLToString(String(resData['title'].content)) : "";
} }
if (resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classname")) {
result['title'].accessMode = resData['bestaccessright'].classname;
}
result.types = new Array<string>();
let types = new Set<string>();
let instance;
let length = Array.isArray(resData['children']['instance']) ? resData['children']['instance'].length : 1;
for (let i = 0; i < length; i++) {
instance = Array.isArray(resData['children']['instance']) ? resData['children']['instance'][i] : resData['children']['instance'];
this.parsingFunctions.parseTypes(result.types, types, instance);
if(instance?.hasOwnProperty("hostedby")) {
result.hostedBy_collectedFrom = new Array<HostedByCollectedFrom>();
if(instance.hasOwnProperty("webresource")) {
let url = Array.isArray(instance['webresource'])?instance['webresource'][0].url:instance['webresource'].url;
if(url.includes('&amp;')) {
url = url.replace(/&amp;/gmu, '&');
}
if(instance.hasOwnProperty("hostedby")) {
this.parsingFunctions.parseHostedBy_collectedFrom(result.hostedBy_collectedFrom, instance, url, result.title.accessMode);
}
result.hostedBy_collectedFrom.sort(this.parsingFunctions.compareHostedByCollectedFrom);
}
}
let journal = resData['journal']?resData['journal'].content:null;
result.hostedBy_collectedFrom = this.parsingFunctions.addPublisherToHostedBy_collectedFrom(
result.hostedBy_collectedFrom, result.publisher,
journal, result.identifiers);
}
// Measure
result.measure = this.parsingFunctions.parseMeasures(resData['measure']);
/////////////////////////// Athena Code ///////////////////////////
if (resData['pid']) {
if (!Array.isArray(resData['pid'])) {
if (resData['pid'].classid && resData['pid'].classid == 'doi') {
if (resData['pid'].content != '' && resData['pid'].content != null) {
result.DOIs.push((resData['pid'].content + "").replace("https://doi.org/", ""));
}
}
} else {
for (let i = 0; i < resData['pid'].length; i++) {
if (resData['pid'][i].classid == 'doi') {
if (resData['pid'][i].content != '' && resData['pid'][i].content != null && resData['pid'][i].content) {
result.DOIs.push((resData['pid'][i].content + "").replace("https://doi.org/", ""));
}
}
}
}
result.identifiers = this.parsingFunctions.parseIdentifiers(resData['pid']);
}
/////////////////////////// Athena Code ///////////////////////////
if (resData['programmingLanguage'] && resData['programmingLanguage'] != null) {
result.programmingLanguages = new Array<string>();
if (!Array.isArray(resData['programmingLanguage'])) {
if (resData['programmingLanguage'].classname != "Undetermined" && resData['programmingLanguage'].classname) {
result.programmingLanguages.push(resData['programmingLanguage'].classname);
}
} else {
for (let i = 0; i < resData['programmingLanguage'].length; i++) {
if (resData['programmingLanguage'][i].classname != "Undetermined" && resData['programmingLanguage'][i].classname) {
result.programmingLanguages.push(resData['programmingLanguage'][i].classname);
}
}
}
}
if (resData['language'] && resData['language'] != null) {
result.languages = new Array<string>();
if (!Array.isArray(resData['language'])) {
if (resData['language'].classname != "Undetermined" && resData['language'].classname) {
result.languages.push(resData['language'].classname);
}
} else {
for (let i = 0; i < resData['language'].length; i++) {
if (resData['language'][i].classname != "Undetermined" && resData['language'][i].classname) {
result.languages.push(resData['language'][i].classname);
}
}
}
}
if (resData['country'] && resData['country'] != null) {
result.countriesForResults = new Array<string>();
if (!Array.isArray(resData['country'])) {
if (resData['country'].classname != "Undetermined" && resData['country'].classname) {
result.countriesForResults.push(resData['country'].classname);
}
} else {
for (let i = 0; i < resData['country'].length; i++) {
if (resData['country'][i].classname != "Undetermined" && resData['country'][i].classname) {
result.countriesForResults.push(resData['country'][i].classname);
}
}
}
}
result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier']; result['id'] = Array.isArray(data) ? data[i]['result']['header']['dri:objIdentifier'] : data['result']['header']['dri:objIdentifier'];
result['objId'] = result['id']; result['objId'] = result['id'];
let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "result"); let canId = ParsingFunctions.parseRelCanonicalId(Array.isArray(data) ? data[i] : data, "result");
@ -337,16 +318,13 @@ export class SearchResearchResultsService {
result['id'] = canId; result['id'] = canId;
} }
result['relcanId'] = result['id']; result['relcanId'] = result['id'];
if (resData['bestaccessright'] && resData['bestaccessright'].hasOwnProperty("classname")) {
result['title'].accessMode = resData['bestaccessright'].classname;
}
if (resData['rels'].hasOwnProperty("rel")) { if (resData['rels'].hasOwnProperty("rel")) {
let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1; let relLength = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'].length : 1;
for (let j = 0; j < relLength; j++) { for (let j = 0; j < relLength; j++) {
let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel']; let relation = Array.isArray(resData['rels']['rel']) ? resData['rels']['rel'][j] : resData['rels']['rel'];
if (relation.hasOwnProperty("to")) { if (relation.hasOwnProperty("to")) {
if (relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") { if (relation['to'].class && relation['to'].class.toLowerCase() == "isproducedby") {
result['projects'] = this.parseProjects(result['projects'], relation); result['projects'] = this.parseProjects(result['projects'], relation);
@ -354,22 +332,22 @@ export class SearchResearchResultsService {
} }
} }
} }
if (resData.hasOwnProperty("creator") && resData['creator'] != null) { if (resData.hasOwnProperty("creator") && resData['creator'] != null) {
if (result['authors'] == undefined) { if (result['authors'] == undefined) {
result['authors'] = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>(); result['authors'] = new Array<{ "fullName": string, "orcid": string, "orcid_pending": string }>();
} }
let authors = resData['creator']; let authors = resData['creator'];
let length = Array.isArray(authors) ? authors.length : 1; let length = Array.isArray(authors) ? authors.length : 1;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let author = Array.isArray(authors) ? authors[i] : authors; let author = Array.isArray(authors) ? authors[i] : authors;
if (author) { if (author) {
if(author.orcid) { if (author.orcid) {
author.orcid = author.orcid.toUpperCase(); author.orcid = author.orcid.toUpperCase();
} }
if(author.orcid_pending) { if (author.orcid_pending) {
author.orcid_pending = author.orcid_pending.toUpperCase(); author.orcid_pending = author.orcid_pending.toUpperCase();
} }
result['authors'][author.rank] = { result['authors'][author.rank] = {
@ -383,20 +361,20 @@ export class SearchResearchResultsService {
return (item != undefined && item.fullName != undefined); return (item != undefined && item.fullName != undefined);
}); });
} }
var date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // transform to string in case it is an integer var date: string = (resData.dateofacceptance ? resData.dateofacceptance : '') + ''; // transform to string in case it is an integer
result.year = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date; result.year = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
let abstracts = this.parsingFunctions.parseDescription(resData.description, true); let abstracts = this.parsingFunctions.parseDescription(resData.description, true);
result.description = abstracts; result.description = abstracts;
// if (result.description && result.description.length > this.sizeOfDescription) { // if (result.description && result.description.length > this.sizeOfDescription) {
// result.description = result.description.substring(0, this.sizeOfDescription) + "..."; // result.description = result.description.substring(0, this.sizeOfDescription) + "...";
// } // }
if (resData.embargoenddate && resData.embargoenddate != '') { if (resData.embargoenddate && resData.embargoenddate != '') {
result.embargoEndDate = Dates.getDate(resData.embargoenddate); result.embargoEndDate = Dates.getDate(resData.embargoenddate);
} }
if (!Array.isArray(resData.publisher)) { if (!Array.isArray(resData.publisher)) {
result.publisher = resData.publisher; result.publisher = resData.publisher;
} else { } else {
@ -408,14 +386,14 @@ export class SearchResearchResultsService {
} }
} }
} }
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']));
} }
results.push(result); results.push(result);
} }
return results; return results;
} }
parseProjects(projects: { parseProjects(projects: {
"id": string, "acronym": string, "title": string, "id": string, "acronym": string, "title": string,
"funderShortname": string, "funderName": string, "funderShortname": string, "funderName": string,
@ -432,15 +410,15 @@ export class SearchResearchResultsService {
"code": string "code": string
}>(); }>();
} }
let countProjects = projects.length; let countProjects = projects.length;
projects[countProjects] = { projects[countProjects] = {
"id": "", "acronym": "", "title": "", "id": "", "acronym": "", "title": "",
"funderShortname": "", "funderName": "", "funderShortname": "", "funderName": "",
"code": "" "code": ""
}; };
if (relation.title != 'unidentified') { if (relation.title != 'unidentified') {
projects[countProjects]['id'] = relation['to'].content; projects[countProjects]['id'] = relation['to'].content;
projects[countProjects]['acronym'] = relation.acronym; projects[countProjects]['acronym'] = relation.acronym;
@ -452,36 +430,36 @@ export class SearchResearchResultsService {
projects[countProjects]['title'] = ""; projects[countProjects]['title'] = "";
projects[countProjects]['code'] = ""; projects[countProjects]['code'] = "";
} }
if (relation.hasOwnProperty("funding")) { if (relation.hasOwnProperty("funding")) {
let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1; let fundingLength = Array.isArray(relation['funding']) ? relation['funding'].length : 1;
for (let z = 0; z < fundingLength; z++) { for (let z = 0; z < fundingLength; z++) {
let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding']; let fundingData = Array.isArray(relation['funding']) ? relation['funding'][z] : relation['funding'];
if (fundingData.hasOwnProperty("funder")) { if (fundingData.hasOwnProperty("funder")) {
projects[countProjects]['funderShortname'] = fundingData['funder'].shortname; projects[countProjects]['funderShortname'] = fundingData['funder'].shortname;
projects[countProjects]['funderName'] = fundingData['funder'].name; projects[countProjects]['funderName'] = fundingData['funder'].name;
} }
} }
} }
return projects; return projects;
} }
parseRefineResults(id: string, data: any): any { parseRefineResults(id: string, data: any): any {
var results: any = []; var results: any = [];
if (data.hasOwnProperty("resulthostingdatasource")) { if (data.hasOwnProperty("resulthostingdatasource")) {
let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1; let length = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'].length : 1;
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource']; let datasource = Array.isArray(data['resulthostingdatasource']) ? data['resulthostingdatasource'][i] : data['resulthostingdatasource'];
let result: { "name": string, "id": string, "count": number } = {"name": "", "id": "", "count": 0}; let result: { "name": string, "id": string, "count": number } = {"name": "", "id": "", "count": 0};
result['name'] = datasource.name; result['name'] = datasource.name;
result['id'] = datasource.id.split("||")[0]; result['id'] = datasource.id.split("||")[0];
result['count'] = datasource.count; result['count'] = datasource.count;
if (result['id'] != id && result['name'] != "Unknown Repository") { if (result['id'] != id && result['name'] != "Unknown Repository") {
results.push(result); results.push(result);
} }
@ -489,19 +467,19 @@ export class SearchResearchResultsService {
} }
return results; return results;
} }
private numOfResults(url: string, properties: EnvProperties): any { private numOfResults(url: string, properties: EnvProperties): any {
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => res['total'])); .pipe(map(res => res['total']));
} }
numOfEntityResults(resultType: string, id: string, entity: string, properties: EnvProperties): any { numOfEntityResults(resultType: string, id: string, entity: string, properties: EnvProperties): any {
var parameters: string = ""; var parameters: string = "";
parameters = this.getEntityQueryName(entity, true) + "/" + id + "/" + this.getEntityQueryName(resultType, true) + "/count"; parameters = this.getEntityQueryName(entity, true) + "/" + id + "/" + this.getEntityQueryName(resultType, true) + "/count";
let url = properties.searchAPIURLLAst + parameters + "?format=json"; let url = properties.searchAPIURLLAst + parameters + "?format=json";
return this.numOfResults(url, properties); return this.numOfResults(url, properties);
} }
numOfResearchOutcomes(params: string, properties: EnvProperties, refineParams: string = null): any { numOfResearchOutcomes(params: string, properties: EnvProperties, refineParams: string = null): any {
let url = properties.searchAPIURLLAst + "resources2/?format=json&size=0&type=results"; let url = properties.searchAPIURLLAst + "resources2/?format=json&size=0&type=results";
if (params.length > 0) { if (params.length > 0) {
@ -518,20 +496,20 @@ export class SearchResearchResultsService {
// } // }
url += "&query=" + params; url += "&query=" + params;
} }
if (refineParams != null && refineParams != '') { if (refineParams != null && refineParams != '') {
url += refineParams; url += refineParams;
} }
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => res['meta']['total'])); .pipe(map(res => res['meta']['total']));
} }
numOfSearchResults(resultType: string, params: string, properties: EnvProperties, refineParams: string = null): any { numOfSearchResults(resultType: string, params: string, properties: EnvProperties, refineParams: string = null): any {
let url = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true) + "/count?format=json"; let url = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true) + "/count?format=json";
if (params.length > 0) { if (params.length > 0) {
var DOIs: string[] = DOI.getDOIsFromString(params); var DOIs: string[] = DOI.getDOIsFromString(params);
var doisParams = ""; var doisParams = "";
for (var i = 0; i < DOIs.length; i++) { for (var i = 0; i < DOIs.length; i++) {
doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + DOIs[i] + '"'; doisParams += (doisParams.length > 0 ? "&" : "") + 'doi="' + DOIs[i] + '"';
} }
@ -541,30 +519,30 @@ export class SearchResearchResultsService {
url += "&q=" + StringUtils.URIEncode(params); url += "&q=" + StringUtils.URIEncode(params);
} }
} }
if (refineParams != null && refineParams != '') { if (refineParams != null && refineParams != '') {
url += refineParams; url += refineParams;
} }
return this.numOfResults(url, properties); return this.numOfResults(url, properties);
} }
numOfSearchResultsLinkedToPub(resultType: string, properties: EnvProperties): any { numOfSearchResultsLinkedToPub(resultType: string, properties: EnvProperties): any {
let url = properties.searchAPIURLLAst + "resources?query=" + encodeURIComponent("( (oaftype exact result) and (resulttypeid exact " + resultType + ") and (relresulttype=publication) )") + "&page=0&size=0&format=json"; let url = properties.searchAPIURLLAst + "resources?query=" + encodeURIComponent("( (oaftype exact result) and (resulttypeid exact " + resultType + ") and (relresulttype=publication) )") + "&page=0&size=0&format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => res['meta']['total'])); .pipe(map(res => res['meta']['total']));
} }
countTotalResults(resultType: string, properties: EnvProperties, refineParams: string = null): any { countTotalResults(resultType: string, properties: EnvProperties, refineParams: string = null): any {
let url = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true) + "/count?format=json" + refineParams; let url = properties.searchAPIURLLAst + this.getEntityQueryName(resultType, true) + "/count?format=json" + refineParams;
return this.numOfResults(url, properties); return this.numOfResults(url, properties);
} }
/* /*
private quote(word: any): string { private quote(word: any): string {
return '"'+word+'"'; return '"'+word+'"';
} }
*/ */
private getEntityQueryName(entityType: string, plural: boolean) { private getEntityQueryName(entityType: string, plural: boolean) {
if (entityType == "publication" || entityType == "dataset" || entityType == "organization" || entityType == "datasource" || entityType == "project") { if (entityType == "publication" || entityType == "dataset" || entityType == "organization" || entityType == "datasource" || entityType == "project") {
if (plural) { if (plural) {
@ -578,8 +556,8 @@ export class SearchResearchResultsService {
} }
public countCollectedResultsWithFundingInfo(datasourceId: string) { public countCollectedResultsWithFundingInfo(datasourceId: string) {
let url = properties.searchAPIURLLAst + "resources?query=" + encodeURIComponent("(oaftype=result and collectedfromdatasourceid exact \""+datasourceId+"\" and relprojectid=*)") + "&page=0&size=0&format=json"; let url = properties.searchAPIURLLAst + "resources?query=" + encodeURIComponent("(oaftype=result and collectedfromdatasourceid exact \"" + datasourceId + "\" and relprojectid=*)") + "&page=0&size=0&format=json";
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => res['meta']['total'])); .pipe(map(res => res['meta']['total']));
} }
} }

View File

@ -1,36 +1,37 @@
import {Author, Organization, Project, ResultTitle} from "../result-preview/result-preview"; import {Author, HostedByCollectedFrom, Organization, Project, ResultTitle} from "../result-preview/result-preview";
import {Measure} from "./resultLandingInfo";
export class SearchResult { export class SearchResult {
title: ResultTitle; title: ResultTitle;
id: string; id: string;
relcanId: string; relcanId: string;
objId: string; objId: string;
DOIs: string[]=[]; DOIs: string[] = [];
identifiers: Map<string, string[]>; identifiers: Map<string, string[]>;
measure: Array<string>; measure: Measure;
//publications & datasets & orp & software & projects & dataproviders: //publications & datasets & orp & software & projects & dataproviders:
description: string; description: string;
//publications & datasets & orp & software & organizations: //publications & datasets & orp & software & organizations:
projects: Project[]; projects: Project[];
//datasets & orp & publications & software //datasets & orp & publications & software
year: string; year: string;
embargoEndDate: Date | string; embargoEndDate: Date | string;
authors: Author[]; authors: Author[];
countriesForResults: string[]; countriesForResults: string[];
languages: string[]; languages: string[];
//datasets & orp & software: //datasets & orp & software:
publisher: string; publisher: string;
//software //software
programmingLanguages: string[]; programmingLanguages: string[];
//dataproviders & projects: //dataproviders & projects:
organizations: Organization[]; organizations: Organization[];
//projects: //projects:
acronym: string; acronym: string;
code: string; code: string;
@ -43,10 +44,10 @@ export class SearchResult {
endYear: number; endYear: number;
openAccessMandatePublications: boolean; openAccessMandatePublications: boolean;
openAccessMandateDatasets: boolean; openAccessMandateDatasets: boolean;
hostedBy_collectedFrom: HostedByCollectedFrom[];
//organizations: //organizations:
country: string; country: string;
//dataproviders: //dataproviders:
englishname: string; englishname: string;
type: string; type: string;
@ -56,11 +57,12 @@ export class SearchResult {
compatibilityUNKNOWN: boolean; compatibilityUNKNOWN: boolean;
countries: string[]; countries: string[];
subjects: string[]; subjects: string[];
entityType: string; entityType: string;
types: string[]; types: string[];
enermapsId:string; enermapsId: string;
constructor() { constructor() {
} }
} }

View File

@ -1,20 +1,22 @@
<div *ngIf="result" [ngClass]="{'uk-card uk-card-default': isCard}"> <div *ngIf="result" [ngClass]="{'uk-card uk-card-default': isCard}">
<div [ngClass]="{'uk-card-body': isCard}"> <div [ngClass]="{'uk-card-body': isCard}">
<div class="uk-grid uk-flex uk-flex-middle"> <div class="uk-grid uk-flex uk-flex-middle">
<div *ngIf="properties.enermapsURL && showEnermaps && result.enermapsId" class=" uk-inline uk-width-auto uk-text-center uk-visible-toggle"> <div *ngIf="properties.enermapsURL && showEnermaps && result.enermapsId"
<img class="uk-width-medium" [src]="properties.enermapsURL +'/images/datasets/' + result.enermapsId + '.png'" class=" uk-inline uk-width-auto uk-text-center uk-visible-toggle">
alt="Enermaps tool preview" loading="lazy"> <img class="uk-width-medium" [src]="properties.enermapsURL +'/images/datasets/' + result.enermapsId + '.png'"
<div class="uk-overlay uk-margin-medium-left uk-overlay-default uk-position-bottom uk-hidden-hover uk-padding-small"> alt="Enermaps tool preview" loading="lazy">
<div
class="uk-overlay uk-margin-medium-left uk-overlay-default uk-position-bottom uk-hidden-hover uk-padding-small">
<p>Visit <a <p>Visit <a
class="custom-external uk-margin-right uk-margin-small-top" class="custom-external uk-margin-right uk-margin-small-top"
[href]="properties.enermapsURL + '/?shared_id=' + result.enermapsId" target="_blank" > [href]="properties.enermapsURL + '/?shared_id=' + result.enermapsId" target="_blank">
Enermaps tool Enermaps tool
</a></p> </a></p>
</div> </div>
</div> </div>
<div class="uk-width-expand"> <div class="uk-width-expand">
<!-- 1st section (small title, mail title and deposit link) --> <!-- 1st section (title, subtitle and deposit link) -->
<div class="section1 uk-margin-bottom"> <div class="uk-margin-bottom">
<!-- Deposit searchPage URL --> <!-- Deposit searchPage URL -->
<!-- <span class="uk-width-expand uk-flex-right"> <!-- <span class="uk-width-expand uk-flex-right">
<a *ngIf="result.websiteURL && promoteWebsiteURL" href="{{result.websiteURL}}" target="_blank" type="submit" <a *ngIf="result.websiteURL && promoteWebsiteURL" href="{{result.websiteURL}}" target="_blank" type="submit"
@ -22,23 +24,11 @@
<span><span>Visit repository to deposit</span><span uk-icon="arrow-right"></span></span> <span><span>Visit repository to deposit</span><span uk-icon="arrow-right"></span></span>
</a> </a>
</span> --> </span> -->
<!-- Small subtitle above title -->
<div class="uk-text-small uk-margin-xsmall-bottom">
<span *ngIf="type" class="uk-text-capitalize type">{{type}}</span>
<span *ngIf="type && beforeTitle.length > 0"> . </span>
<span *ngIf="beforeTitle.length > 0" class="uk-text-capitalize">
{{beforeTitle.join(' . ')}}
</span>
<span *ngIf="result.embargoEndDate && result.embargoEndDate != ''">
<span
*ngIf="beforeTitle.length > 0"> . </span> Embargo End Date: {{result.embargoEndDate | date: 'dd MMM yyyy'}}
</span>
</div>
<!-- Title --> <!-- Title -->
<div> <div>
<h2 class="uk-margin-remove uk-text-break uk-inline-block uk-h6"> <h2 class="uk-margin-remove uk-text-break uk-inline-block uk-h6">
<a *ngIf="!externalUrl && result.id" (click)="onClick()" [queryParams]="createParam()" <a *ngIf="!externalUrl && result.id" (click)="onClick()" [queryParams]="createParam()"
[routerLink]="url" class="uk-link uk-link-heading uk-width-expand"> [routerLink]="url" class="uk-link uk-text-decoration-none uk-width-expand">
<div *ngIf="(result.title) || result.acronym"> <div *ngIf="(result.title) || result.acronym">
<span *ngIf="result.acronym"> <span *ngIf="result.acronym">
{{result.acronym}} {{result.acronym}}
@ -51,8 +41,9 @@
[no title available] [no title available]
</div> </div>
</a> </a>
<a *ngIf="externalUrl && result.id" (click)="onClick()" <a *ngIf="externalUrl && result.id" (click)="onClick()"
target="_blank" [href]="externalUrl+result.id" class="custom-external uk-link uk-link-heading uk-width-expand"> target="_blank" [href]="externalUrl+result.id"
class="custom-external uk-link uk-text-decoration-none uk-width-expand">
<span *ngIf="(result.title) || result.acronym"> <span *ngIf="(result.title) || result.acronym">
<span *ngIf="result.acronym"> <span *ngIf="result.acronym">
{{result.acronym}} {{result.acronym}}
@ -65,8 +56,7 @@
[no title available] [no title available]
</span> </span>
</a> </a>
<div *ngIf="!result.id" class="uk-width-expand">
<div *ngIf="!result.id" class="uk-width-expand">
<div *ngIf="(result.title) || result.acronym"> <div *ngIf="(result.title) || result.acronym">
<span *ngIf="result.acronym"> <span *ngIf="result.acronym">
{{result.acronym}} {{result.acronym}}
@ -82,9 +72,21 @@
<!-- <hr class="uk-margin-remove-bottom" *ngIf="result.websiteURL && promoteWebsiteURL"> --> <!-- <hr class="uk-margin-remove-bottom" *ngIf="result.websiteURL && promoteWebsiteURL"> -->
</h2> </h2>
</div> </div>
<!-- Small subtitle above title -->
<div class="uk-text-small uk-margin-xsmall-bottom">
<span *ngIf="type" class="uk-text-capitalize type">{{type}}</span>
<span *ngIf="type && beforeTitle.length > 0"> . </span>
<span *ngIf="beforeTitle.length > 0" class="uk-text-capitalize">
{{beforeTitle.join(' . ')}}
</span>
<span *ngIf="result.embargoEndDate && result.embargoEndDate != ''">
<span
*ngIf="beforeTitle.length > 0"> . </span> Embargo End Date: {{result.embargoEndDate | date: 'dd MMM yyyy'}}
</span>
</div>
</div> </div>
<!-- 2nd section (labels only) --> <!-- 2nd section (labels only) -->
<div class="section2 uk-margin-bottom"> <div class="uk-margin-bottom">
<!-- Labels --> <!-- Labels -->
<div> <div>
<span <span
@ -93,7 +95,7 @@
title="Access Mode"> title="Access Mode">
{{result.accessMode}} {{result.accessMode}}
</span>{{' '}} </span>{{' '}}
<span <span
*ngIf="result.openAccessMandatePublications && (!result.openAccessMandateDatasets)" *ngIf="result.openAccessMandatePublications && (!result.openAccessMandateDatasets)"
class="uk-label uk-label-success uk-text-truncate" class="uk-label uk-label-success uk-text-truncate"
title="Open Access mandate for {{openaireEntities.PUBLICATIONS}}"> title="Open Access mandate for {{openaireEntities.PUBLICATIONS}}">
@ -101,7 +103,8 @@
</span>{{' '}} </span>{{' '}}
<span <span
*ngIf="result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets && (result.openAccessMandatePublications == undefined || !result.openAccessMandatePublications)" *ngIf="result.openAccessMandateDatasets != undefined && result.openAccessMandateDatasets && (result.openAccessMandatePublications == undefined || !result.openAccessMandatePublications)"
class="uk-label uk-label-success uk-text-truncate " title="Open Access mandate for {{openaireEntities.DATASETS}}"> class="uk-label uk-label-success uk-text-truncate "
title="Open Access mandate for {{openaireEntities.DATASETS}}">
Open Access mandate for {{openaireEntities.DATASETS}} Open Access mandate for {{openaireEntities.DATASETS}}
</span>{{' '}} </span>{{' '}}
<span <span
@ -118,25 +121,25 @@
</span>{{' '}} </span>{{' '}}
</span> </span>
<span *ngIf="result.programmingLanguages && result.programmingLanguages.length > 0"> <span *ngIf="result.programmingLanguages && result.programmingLanguages.length > 0">
<span <span
*ngFor="let programmingLanguage of result.programmingLanguages" *ngFor="let programmingLanguage of result.programmingLanguages"
class="uk-label" title="Programming Language"> class="uk-label" title="Programming Language">
{{programmingLanguage}} {{programmingLanguage}}
</span>{{" "}} </span>{{" "}}
</span> </span>
<!-- <span --> <!-- <span -->
<!-- *ngIf="result.sc39" class="uk-label" title="Special Clause 39">--> <!-- *ngIf="result.sc39" class="uk-label" title="Special Clause 39">-->
<!-- Special Clause 39--> <!-- Special Clause 39-->
<!-- </span>{{' '}}--> <!-- </span>{{' '}}-->
<span <span
*ngIf="result.compatibility && result.compatibility != '' && result.compatibility.toLowerCase() != 'not yet registered'" *ngIf="result.compatibility && result.compatibility != '' && result.compatibility.toLowerCase() != 'not yet registered'"
class="uk-label" title="Compatibility"> class="uk-label" title="Compatibility">
{{result.compatibility}} {{result.compatibility}}
</span>{{' '}} </span>{{' '}}
<span <span
*ngIf="result.compatibility != undefined && result.compatibility != '' && result.compatibility.toLowerCase() == 'not yet registered' *ngIf="result.compatibility != undefined && result.compatibility != '' && result.compatibility.toLowerCase() == 'not yet registered'
&& result.resultType != 'service'" && result.resultType != 'service'"
class="uk-label" [class.uk-label-danger]="deposit" title="OpenAIRE Compatibility"> class="uk-label" [class.uk-label-danger]="deposit" title="OpenAIRE Compatibility">
{{result.compatibility}} <span *ngIf="properties.adminToolsPortalType == 'eosc'">in OpenAIRE</span> {{result.compatibility}} <span *ngIf="properties.adminToolsPortalType == 'eosc'">in OpenAIRE</span>
</span>{{' '}} </span>{{' '}}
</div> </div>
@ -151,7 +154,7 @@
</span> </span>
<span *ngIf="result.code" [class.uk-margin-left]="result.funderShortname"> <span *ngIf="result.code" [class.uk-margin-left]="result.funderShortname">
<span class="uk-text-meta">{{openaireEntities.PROJECT}} Code: </span> <span class="uk-text-meta">{{openaireEntities.PROJECT}} Code: </span>
{{result.code}} {{result.code}}
</span> </span>
<!-- Currently not parsed --> <!-- Currently not parsed -->
<!-- <span *ngIf="result.callIdentifier" [class.uk-margin-left]="(result.funderShortname || result.code)">--> <!-- <span *ngIf="result.callIdentifier" [class.uk-margin-left]="(result.funderShortname || result.code)">-->
@ -176,7 +179,7 @@
<div *ngIf="result.authors" class="uk-flex uk-margin-small-bottom"> <div *ngIf="result.authors" class="uk-flex uk-margin-small-bottom">
<span class="uk-text-meta">Authors:&nbsp;</span> <span class="uk-text-meta">Authors:&nbsp;</span>
<showAuthors [authors]="result.authors" [authorsLimit]=10 [modal]="modal" <showAuthors [authors]="result.authors" [authorsLimit]=10 [modal]="modal"
[showAll]=false></showAuthors> [showAll]=false></showAuthors>
</div> </div>
<!-- Identifiers --> <!-- Identifiers -->
<div *ngIf="result.identifiers && result.identifiers.size > 0" class="uk-margin-small-bottom"> <div *ngIf="result.identifiers && result.identifiers.size > 0" class="uk-margin-small-bottom">
@ -189,7 +192,7 @@
</div> </div>
<!-- Countries --> <!-- Countries -->
<div *ngIf="result.countries && result.countries.length > 0" <div *ngIf="result.countries && result.countries.length > 0"
class="uk-margin-small-bottom"> class="uk-margin-small-bottom">
<span class="uk-text-meta">{{(result.countries.length == 1) ? 'Country' : 'Countries'}}: </span> <span class="uk-text-meta">{{(result.countries.length == 1) ? 'Country' : 'Countries'}}: </span>
<span *ngFor="let country of result.countries.slice(0,10) let i = index"> <span *ngFor="let country of result.countries.slice(0,10) let i = index">
{{country}}{{(i < (result.countries.slice(0, 10).length - 1)) ? ", " : ""}} {{country}}{{(i < (result.countries.slice(0, 10).length - 1)) ? ", " : ""}}
@ -205,7 +208,7 @@
</span> </span>
<span *ngIf="project.acronym || project.title"> <span *ngIf="project.acronym || project.title">
| {{ project.acronym ? project.acronym : (project.title.length > 25 ? | {{ project.acronym ? project.acronym : (project.title.length > 25 ?
project.title.substring(0, 25) + '...' : project.title)}} project.title.substring(0, 25) + '...' : project.title)}}
</span> </span>
<span *ngIf="project.code"> ({{project.code}})</span> <span *ngIf="project.code"> ({{project.code}})</span>
<span *ngIf="i < result.projects.length-1">,</span> <span *ngIf="i < result.projects.length-1">,</span>
@ -214,7 +217,7 @@
</div> </div>
<!-- Organizations --> <!-- Organizations -->
<div *ngIf="showOrganizations && result.organizations && result.organizations.length > 0" <div *ngIf="showOrganizations && result.organizations && result.organizations.length > 0"
class="uk-margin-small-bottom"> class="uk-margin-small-bottom">
<span class="uk-text-meta">Partners: </span> <span class="uk-text-meta">Partners: </span>
<span *ngFor="let organization of result.organizations.slice(0,10) let i=index"> <span *ngFor="let organization of result.organizations.slice(0,10) let i=index">
<span>{{organization.name}}</span> <span>{{organization.name}}</span>
@ -223,7 +226,8 @@
<span *ngIf="result.organizations.length > 10">...</span> <span *ngIf="result.organizations.length > 10">...</span>
</div> </div>
<!-- Website URL --> <!-- Website URL -->
<div *ngIf="result.websiteURL && result.websiteURL != '' && !promoteWebsiteURL" class="uk-margin-small-bottom"> <div *ngIf="result.websiteURL && result.websiteURL != '' && !promoteWebsiteURL"
class="uk-margin-small-bottom">
<span class="uk-text-meta">Website URL: </span> <span class="uk-text-meta">Website URL: </span>
<span> <span>
<a href="{{result.websiteURL}}" target="_blank" class="custom-external"> <a href="{{result.websiteURL}}" target="_blank" class="custom-external">
@ -242,7 +246,7 @@
</div> </div>
<!-- Subjects --> <!-- Subjects -->
<div *ngIf="showSubjects && result.subjects && result.subjects.length > 0" <div *ngIf="showSubjects && result.subjects && result.subjects.length > 0"
class="uk-margin-small-bottom"> class="uk-margin-small-bottom">
<span class="uk-text-meta">Subject: </span> <span class="uk-text-meta">Subject: </span>
<span *ngFor="let subject of result.subjects.slice(0,10) let i = index"> <span *ngFor="let subject of result.subjects.slice(0,10) let i = index">
<span>{{subject}}</span> <span>{{subject}}</span>
@ -252,18 +256,19 @@
</div> </div>
<!-- Download from--> <!-- Download from-->
<div *ngIf="result.hostedBy_collectedFrom && result.hostedBy_collectedFrom.length > 0" <div *ngIf="result.hostedBy_collectedFrom && result.hostedBy_collectedFrom.length > 0"
class="uk-margin-small-bottom"> class="uk-margin-small-bottom">
<div *ngFor="let from of result.hostedBy_collectedFrom" <div *ngFor="let from of result.hostedBy_collectedFrom"
[title]="from.accessRight ? from.accessRight : 'Not available'" [title]="from.accessRight ? from.accessRight : 'Not available'"
class="uk-flex uk-flex-middle"> class="uk-flex uk-flex-middle">
<span [class]="'uk-margin-small-right ' + (from.accessRightIcon == 'lock_open' ? 'uk-text-success' : 'uk-text-meta')"> <span
[class]="'uk-margin-small-right ' + (from.accessRightIcon == 'lock_open' ? 'uk-text-success' : 'uk-text-meta')">
<icon [name]="from.accessRightIcon" flex="true" type="outlined"></icon> <icon [name]="from.accessRightIcon" flex="true" type="outlined"></icon>
</span> </span>
<span class="uk-width-expand"> <span class="uk-width-expand">
<span class="uk-margin-right uk-display-inline-block"> <span class="uk-margin-right uk-display-inline-block">
<span class="uk-text-meta">Download from: </span> <span class="uk-text-meta">Download from: </span>
<a *ngIf="from.downloadUrl" <a *ngIf="from.downloadUrl"
[href]="from.downloadUrl" target="_blank" class="title"> [href]="from.downloadUrl" target="_blank" class="title">
<span class="custom-external">{{from.downloadNames.join("; ")}}</span> <span class="custom-external">{{from.downloadNames.join("; ")}}</span>
</a> </a>
<span *ngIf="!from.downloadUrl || from.downloadUrl.length === 0" class="title"> <span *ngIf="!from.downloadUrl || from.downloadUrl.length === 0" class="title">
@ -272,9 +277,11 @@
</span> </span>
<span class="provider uk-display-inline-block"> <span class="provider uk-display-inline-block">
<span class="uk-text-meta">Provider: </span> <span class="uk-text-meta">Provider: </span>
<a *ngFor="let collectedName of from.collectedNamesAndIds.keys(); let i=index" [routerLink]="dataProviderUrl" <a *ngFor="let collectedName of from.collectedNamesAndIds.keys(); let i=index"
[queryParams]="{datasourceId: from.collectedNamesAndIds.get(collectedName)}" (click)="onClick();"> [routerLink]="dataProviderUrl"
{{collectedName}}<ng-container *ngIf="(i !== (from.collectedNamesAndIds.size - 1))">; </ng-container> [queryParams]="{datasourceId: from.collectedNamesAndIds.get(collectedName)}" (click)="onClick();">
{{collectedName}}
<ng-container *ngIf="(i !== (from.collectedNamesAndIds.size - 1))">; </ng-container>
</a> </a>
</span> </span>
</span> </span>
@ -292,7 +299,7 @@
<div> <div>
<span class="uk-width-expand uk-flex-right"> <span class="uk-width-expand uk-flex-right">
<a *ngIf="result.websiteURL && promoteWebsiteURL" href="{{result.websiteURL}}" target="_blank" type="submit" <a *ngIf="result.websiteURL && promoteWebsiteURL" href="{{result.websiteURL}}" target="_blank" type="submit"
class="uk-float-right uk-margin-small-left uk-display-inline-block uk-text-uppercase uk-button uk-button-text"> class="uk-float-right uk-margin-small-left uk-display-inline-block uk-text-uppercase uk-button uk-button-text">
<span class="uk-flex uk-flex-middle"> <span class="uk-flex uk-flex-middle">
<icon name="file_upload" type="outlined" [flex]="true" class="uk-margin-small-right"></icon> <icon name="file_upload" type="outlined" [flex]="true" class="uk-margin-small-right"></icon>
<span>Go to repository</span> <span>Go to repository</span>
@ -304,33 +311,33 @@
</div> </div>
</div> </div>
<!--&& loggedIn (card footer)--> <!--&& loggedIn (card footer)-->
<div *ngIf="result.measure?.length || <div *ngIf="result.measure ||((properties.adminToolsPortalType == 'explore' || properties.adminToolsPortalType == 'community' || properties.adminToolsPortalType == 'aggregator')
((properties.adminToolsPortalType == 'explore' || properties.adminToolsPortalType == 'community' || properties.adminToolsPortalType == 'aggregator') && && ((showOrcid && result.identifiers && result.identifiers.size > 0 && isResultType) || result.orcidCreationDates?.length > 0))"
((showOrcid && result.identifiers && result.identifiers.size > 0 && isResultType) || result.orcidCreationDates?.length > 0))" class="uk-text-small"
class="uk-text-small" [ngClass]="{'uk-card-footer': isCard}">
[ngClass]="{'uk-card-footer': isCard}"> <!-- Impact Factors-->
<!-- Impact Factors--> <span class="uk-flex uk-flex-top uk-flex-wrap" style="grid-gap: 10px;">
<span class="uk-flex uk-flex-top uk-flex-wrap" style="grid-gap: 10px;">
<ng-container *ngIf="result.measure?.length"> <ng-container *ngIf="result.measure?.length">
<!--Popularity --> <!--Popularity -->
<a title="Popularity" class="popularity-{{result.measure[0]}} uk-margin-right uk-flex uk-flex-middle uk-width-auto@s uk-width-1-1"> <a title="Popularity"
class="popularity-{{result.measure[0]}} uk-margin-right uk-flex uk-flex-middle uk-width-auto@s uk-width-1-1">
<svg xmlns="http://www.w3.org/2000/svg" width="10.749" height="14.33" viewBox="0 0 10.749 14.33"><defs><!--<style>.a{fill:#d51717;}</style>--></defs><path <svg xmlns="http://www.w3.org/2000/svg" width="10.749" height="14.33" viewBox="0 0 10.749 14.33"><defs><!--<style>.a{fill:#d51717;}</style>--></defs><path
class="a" class="a"
d="M10.382.67a14.44,14.44,0,0,1,.5,3.225A2.331,2.331,0,0,1,8.589,6.4,2.445,2.445,0,0,1,6.15,3.895l.02-.242A9.25,9.25,0,0,0,4,9.625a5.375,5.375,0,0,0,10.749,0A11.5,11.5,0,0,0,10.382.67ZM9.18,12.985a2.134,2.134,0,0,1-2.163-2.11A2.1,2.1,0,0,1,8.9,8.779a5.181,5.181,0,0,0,3.1-1.733,9.374,9.374,0,0,1,.4,2.714A3.226,3.226,0,0,1,9.18,12.985Z" d="M10.382.67a14.44,14.44,0,0,1,.5,3.225A2.331,2.331,0,0,1,8.589,6.4,2.445,2.445,0,0,1,6.15,3.895l.02-.242A9.25,9.25,0,0,0,4,9.625a5.375,5.375,0,0,0,10.749,0A11.5,11.5,0,0,0,10.382.67ZM9.18,12.985a2.134,2.134,0,0,1-2.163-2.11A2.1,2.1,0,0,1,8.9,8.779a5.181,5.181,0,0,0,3.1-1.733,9.374,9.374,0,0,1,.4,2.714A3.226,3.226,0,0,1,9.18,12.985Z"
transform="translate(-4 -0.67)"/> transform="translate(-4 -0.67)"/>
</svg> </svg>
<span class="uk-margin-small-left"> <span class="uk-margin-small-left">
{{" " + result.measure[2] + " popularity" }} {{" " + result.measure[2] + " popularity" }}
</span> </span>
</a> </a>
<div class="default-dropdown uk-margin-remove-top uk-padding-small" <div class="default-dropdown uk-margin-remove-top uk-padding-small"
uk-dropdown="pos: bottom-left; mode:click" style="min-width: 70px !important;"> uk-dropdown="pos: bottom-left; mode:click" style="min-width: 70px !important;">
<span class="uk-flex uk-flex-middle"> <span class="uk-flex uk-flex-middle">
<span class="popularity-{{result.measure[0]}}"> <span class="popularity-{{result.measure[0]}}">
<svg xmlns="http://www.w3.org/2000/svg" width="20.234" height="26.974" <svg xmlns="http://www.w3.org/2000/svg" width="20.234" height="26.974"
viewBox="0 0 20.234 26.974"><defs> </defs><path class="a" viewBox="0 0 20.234 26.974"><defs> </defs><path class="a"
d="M16.014.67a27.181,27.181,0,0,1,.936,6.07c0,2.605-1.707,4.717-4.312,4.717A4.6,4.6,0,0,1,8.047,6.74l.038-.455A17.411,17.411,0,0,0,4,17.527a10.117,10.117,0,0,0,20.234,0A21.643,21.643,0,0,0,16.014.67ZM13.75,23.85A4.016,4.016,0,0,1,9.678,19.88c0-2.049,1.328-3.49,3.554-3.946a9.753,9.753,0,0,0,5.843-3.263,17.645,17.645,0,0,1,.746,5.109,6.072,6.072,0,0,1-6.07,6.07Z" d="M16.014.67a27.181,27.181,0,0,1,.936,6.07c0,2.605-1.707,4.717-4.312,4.717A4.6,4.6,0,0,1,8.047,6.74l.038-.455A17.411,17.411,0,0,0,4,17.527a10.117,10.117,0,0,0,20.234,0A21.643,21.643,0,0,0,16.014.67ZM13.75,23.85A4.016,4.016,0,0,1,9.678,19.88c0-2.049,1.328-3.49,3.554-3.946a9.753,9.753,0,0,0,5.843-3.263,17.645,17.645,0,0,1,.746,5.109,6.072,6.072,0,0,1-6.07,6.07Z"
transform="translate(-4 -0.67)"/> transform="translate(-4 -0.67)"/>
</svg> </svg>
</span> </span>
<span class="uk-margin-small-left"> <span class="uk-margin-small-left">
@ -344,32 +351,34 @@
Popularity: Citation-based measure reflecting the current impact. Popularity: Citation-based measure reflecting the current impact.
</div> </div>
<div> <div>
<a title="Link to Bip!Finder" class="uk-float-right" target="_blank" href="https://bip.imis.athena-innovation.gr/site/details?id={{result.objId}}"> <a title="Link to Bip!Finder" class="uk-float-right" target="_blank"
href="https://bip.imis.athena-innovation.gr/site/details?id={{result.objId}}">
View more details View more details
</a> </a>
</div> </div>
</div> </div>
<!--Influence --> <!--Influence -->
<a title="Influence" class="influence-{{result.measure[1]}} uk-margin-right uk-flex uk-flex-middle uk-width-auto@s uk-width-1-1"> <a title="Influence"
class="influence-{{result.measure[1]}} uk-margin-right uk-flex uk-flex-middle uk-width-auto@s uk-width-1-1">
<svg xmlns="http://www.w3.org/2000/svg" width="12.667" height="14" viewBox="0 0 12.667 14"> <svg xmlns="http://www.w3.org/2000/svg" width="12.667" height="14" viewBox="0 0 12.667 14">
<defs><!--<style>.a{fill:#e1920a;}</style>--></defs> <defs><!--<style>.a{fill:#e1920a;}</style>--></defs>
<path class="a" <path class="a"
d="M3.333,7v4.667h2V7Zm4,0v4.667h2V7ZM2,15H14.667V13H2Zm9.333-8v4.667h2V7Zm-3-6L2,4.333V5.667H14.667V4.333Z" d="M3.333,7v4.667h2V7Zm4,0v4.667h2V7ZM2,15H14.667V13H2Zm9.333-8v4.667h2V7Zm-3-6L2,4.333V5.667H14.667V4.333Z"
transform="translate(-2 -1)"/> transform="translate(-2 -1)"/>
</svg> </svg>
<span class="uk-margin-small-left"> <span class="uk-margin-small-left">
{{" " + result.measure[3] + " influence" }} {{" " + result.measure[3] + " influence" }}
</span> </span>
</a> </a>
<div class="default-dropdown uk-margin-remove-top uk-padding-small" <div class="default-dropdown uk-margin-remove-top uk-padding-small"
uk-dropdown="pos: bottom-left; mode:click" style="min-width: 70px !important;"> uk-dropdown="pos: bottom-left; mode:click" style="min-width: 70px !important;">
<span class="uk-flex uk-flex-middle"> <span class="uk-flex uk-flex-middle">
<span class="influence-{{result.measure[1]}}"> <span class="influence-{{result.measure[1]}}">
<svg xmlns="http://www.w3.org/2000/svg" width="24.299" height="26.857" viewBox="0 0 24.299 26.857"><defs><style>.a { <svg xmlns="http://www.w3.org/2000/svg" width="24.299" height="26.857" viewBox="0 0 24.299 26.857"><defs><style>.a {
fill: #464646; fill: #464646;
}</style></defs><path class="a" }</style></defs><path class="a"
d="M4.558,12.51v8.952H8.394V12.51Zm7.673,0v8.952h3.837V12.51ZM2,27.857H26.3V24.02H2ZM19.9,12.51v8.952h3.837V12.51ZM14.149,1,2,7.394V9.952H26.3V7.394Z" d="M4.558,12.51v8.952H8.394V12.51Zm7.673,0v8.952h3.837V12.51ZM2,27.857H26.3V24.02H2ZM19.9,12.51v8.952h3.837V12.51ZM14.149,1,2,7.394V9.952H26.3V7.394Z"
transform="translate(-2 -1)"/> transform="translate(-2 -1)"/>
</svg> </svg>
</span> </span>
<span class=" uk-margin-small-left"> <span class=" uk-margin-small-left">
@ -383,25 +392,27 @@
Influence: Citation-based measure reflecting the total impact. Influence: Citation-based measure reflecting the total impact.
</div> </div>
<div> <div>
<a title="Link to Bip!Finder" class=" uk-float-right" target="_blank" href="https://bip.imis.athena-innovation.gr/site/details?id={{result.objId}}"> <a title="Link to Bip!Finder" class=" uk-float-right" target="_blank"
href="https://bip.imis.athena-innovation.gr/site/details?id={{result.objId}}">
View more details View more details
</a> </a>
</div> </div>
</div> </div>
</ng-container> </ng-container>
<!-- && loggedIn --> <!-- && loggedIn -->
<!-- TODO: change colors/opacity and disabled attr for ORCID buttons --> <!-- TODO: change colors/opacity and disabled attr for ORCID buttons -->
<span *ngIf="(properties.adminToolsPortalType == 'explore' || properties.adminToolsPortalType == 'community' || properties.adminToolsPortalType == 'aggregator') <span *ngIf="(properties.adminToolsPortalType == 'explore' || properties.adminToolsPortalType == 'community' || properties.adminToolsPortalType == 'aggregator')
&& showOrcid && result.identifiers && result.identifiers.size > 0 && isResultType" && showOrcid && result.identifiers && result.identifiers.size > 0 && isResultType"
class="uk-margin-auto-left"> class="uk-margin-auto-left">
<orcid-work *ngIf="showOrcid && result.identifiers && result.identifiers.size > 0" <orcid-work *ngIf="showOrcid && result.identifiers && result.identifiers.size > 0"
[resultId]="result.relcanId" [resultTitle]="result.title" [resultId]="result.relcanId" [resultTitle]="result.title"
[type]="result.resultType" [pageType]="'search'" [type]="result.resultType" [pageType]="'search'"
[putCodes]="result.orcidPutCodes" [givenPutCode]="true" [identifiers]="result.identifiers"> [putCodes]="result.orcidPutCodes" [givenPutCode]="true" [identifiers]="result.identifiers">
</orcid-work> </orcid-work>
</span> </span>
<span *ngIf="(properties.adminToolsPortalType == 'explore' || properties.adminToolsPortalType == 'community') && result.orcidCreationDates?.length > 0" <span
class="uk-width-expand uk-text-right"> *ngIf="(properties.adminToolsPortalType == 'explore' || properties.adminToolsPortalType == 'community') && result.orcidCreationDates?.length > 0"
class="uk-width-expand uk-text-right">
<span *ngIf="result.orcidCreationDates?.length > 0" class="uk-display-inline-block"> <span *ngIf="result.orcidCreationDates?.length > 0" class="uk-display-inline-block">
<span class="uk-text-meta"> <span class="uk-text-meta">
Added in ORCID: Added in ORCID:
@ -415,5 +426,5 @@
</span> </span>
</span> </span>
</span> </span>
</div>
</div> </div>
</div>

View File

@ -1,10 +1,17 @@
// Impact Factors // Impact Factors
.popularity-A svg .a, .popularity-C1 svg .a, .popularity-C2 svg .a, .influence-A svg .a, .influence-C1 svg .a, .influence-C2 svg .a { .popularity-A, .popularity-C1, .popularity-C2, .influence-A, .influence-C1, .influence-C2 {
fill:#d51717; & svg a {
fill: #d51717;
}
} }
.popularity-B svg .a, .popularity-C3 svg .a, .popularity-C4 svg .a, .influence-B svg .a, .influence-C3 svg .a, .influence-C4 svg .a {
fill: #e1920a; .popularity-B, .popularity-C3, .popularity-C4, .influence-B, .influence-C3, .influence-C4 {
& svg a {
fill: #e1920a;
}
} }
.popularity-C svg .a, .popularity-C5 svg .a, .influence-C svg .a, .influence-C5 svg .a {
fill: #444; .popularity-C, .popularity-C5, .influence-C, .influence-C5 {
} & svg a {
fill: #444;
}}

View File

@ -12,7 +12,7 @@ import {HelperFunctions} from "../HelperFunctions.class";
@Component({ @Component({
selector: 'result-preview', selector: 'result-preview',
templateUrl: 'result-preview.component.html', templateUrl: 'result-preview.component.html',
styleUrls: ['result-preview.component.less'] styleUrls: ['result-preview.component.less']
}) })
export class ResultPreviewComponent implements OnInit, OnChanges { export class ResultPreviewComponent implements OnInit, OnChanges {
@Input() result: ResultPreview; @Input() result: ResultPreview;
@ -23,7 +23,8 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
@Input() modal: AlertModal = null; @Input() modal: AlertModal = null;
@Input() promoteWebsiteURL: boolean = false; @Input() promoteWebsiteURL: boolean = false;
@Input() hasLink: boolean = true; @Input() hasLink: boolean = true;
@Input() isCard: boolean = false; @Input() isCard: boolean = false;
@Input() isMobile: boolean = false;
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
public urlParam: string; public urlParam: string;
public url: string; public url: string;
@ -34,11 +35,11 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
@Input() showOrcid: boolean = true; @Input() showOrcid: boolean = true;
@Input() showEnermaps: boolean = false; @Input() showEnermaps: boolean = false;
@Input() deposit: boolean = false; @Input() deposit: boolean = false;
@Input() provenanceActionVocabulary = null; @Input() provenanceActionVocabulary = null;
@Input() relationsVocabulary = null; @Input() relationsVocabulary = null;
ngOnInit(): void { ngOnInit(): void {
if(this.hasLink) { if (this.hasLink) {
if (this.result.resultType === "publication") { if (this.result.resultType === "publication") {
this.urlParam = "articleId"; this.urlParam = "articleId";
this.url = properties.searchLinkToPublication.split('?')[0]; this.url = properties.searchLinkToPublication.split('?')[0];
@ -52,9 +53,9 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
this.urlParam = "orpId"; this.urlParam = "orpId";
this.url = properties.searchLinkToOrp.split('?')[0]; this.url = properties.searchLinkToOrp.split('?')[0];
} else if (this.result.resultType == "project") { } else if (this.result.resultType == "project") {
if(this.result.id) { if (this.result.id) {
this.urlParam = "projectId"; this.urlParam = "projectId";
}else if(this.result.code && this.result.funderShortname){ } else if (this.result.code && this.result.funderShortname) {
this.result.id = this.result.code; this.result.id = this.result.code;
this.urlParam = "grantId"; this.urlParam = "grantId";
} }
@ -63,7 +64,7 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
this.urlParam = "organizationId"; this.urlParam = "organizationId";
this.url = properties.searchLinkToOrganization.split('?')[0]; this.url = properties.searchLinkToOrganization.split('?')[0];
} else if (this.result.resultType == "dataprovider") { } else if (this.result.resultType == "dataprovider") {
if(this.result.compatibilityUNKNOWN && properties.adminToolsPortalType == "eosc") { if (this.result.compatibilityUNKNOWN && properties.adminToolsPortalType == "eosc") {
this.urlParam = "serviceId"; this.urlParam = "serviceId";
this.url = properties.searchLinkToService.split('?')[0]; this.url = properties.searchLinkToService.split('?')[0];
} else { } else {
@ -80,100 +81,102 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
this.checkPID(); this.checkPID();
} }
this.initBeforeTitle(); this.initBeforeTitle();
if(this.result.languages) { if (this.result.languages) {
this.result.languages = this.removeUnknown(this.result.languages); this.result.languages = this.removeUnknown(this.result.languages);
} }
if(this.result.countries) { if (this.result.countries) {
this.result.countries = this.removeUnknown(this.result.countries); this.result.countries = this.removeUnknown(this.result.countries);
} }
} }
ngOnChanges(changes: SimpleChanges) { ngOnChanges(changes: SimpleChanges) {
if(changes.result && this.hasLink) { if (changes.result && this.hasLink) {
this.checkPID(); this.checkPID();
} }
} }
checkPID() { checkPID() {
// if result has a pid use it as parameter instead of openaireId // if result has a pid use it as parameter instead of openaireId
let pid:Identifier =this.getPID(); let pid: Identifier = this.getPID();
if(pid){ if (pid) {
this.urlParam = "pid"; this.urlParam = "pid";
this.result.id = pid.id; this.result.id = pid.id;
} }
} }
getPID() { getPID() {
return Identifier.getPIDFromIdentifiers(this.result.identifiers); return Identifier.getPIDFromIdentifiers(this.result.identifiers);
} }
public initBeforeTitle() { public initBeforeTitle() {
if(this.result.resultType && this.result.resultType !== 'dataprovider') { if (this.result.resultType && this.result.resultType !== 'dataprovider') {
this.type = this.getTypeName(this.result.resultType); this.type = this.getTypeName(this.result.resultType);
} }
if(this.result.types) { if (this.result.types) {
this.removeUnknown(this.removeDuplicates(this.result.types)).forEach(type => { this.removeUnknown(this.removeDuplicates(this.result.types)).forEach(type => {
this.beforeTitle.push(type); this.beforeTitle.push(type);
}); });
} }
if(this.result.year) { if (this.result.year) {
this.beforeTitle.push(this.result.year.toString()); this.beforeTitle.push(this.result.year.toString());
} }
if(this.result.startYear && this.result.endYear) { if (this.result.startYear && this.result.endYear) {
this.beforeTitle.push(this.result.startYear.toString() + ' - ' + this.result.endYear.toString()); this.beforeTitle.push(this.result.startYear.toString() + ' - ' + this.result.endYear.toString());
} }
if(this.result.provenanceAction) { if (this.result.provenanceAction) {
let value = HelperFunctions.getVocabularyLabel(this.result.provenanceAction, this.provenanceActionVocabulary, false); let value = HelperFunctions.getVocabularyLabel(this.result.provenanceAction, this.provenanceActionVocabulary, false);
if(value) { if (value) {
this.beforeTitle.push(value); this.beforeTitle.push(value);
} }
} }
if(this.result.relationName) { if (this.result.relationName) {
this.beforeTitle.push(HelperFunctions.getVocabularyLabel(this.result.relationName, this.relationsVocabulary)); this.beforeTitle.push(HelperFunctions.getVocabularyLabel(this.result.relationName, this.relationsVocabulary));
} }
// if(this.result.percentage) { // if(this.result.percentage) {
// this.beforeTitle.push((this.result.relation ? this.result.relation+": " : "") + this.result.percentage.toString() + "%"); // this.beforeTitle.push((this.result.relation ? this.result.relation+": " : "") + this.result.percentage.toString() + "%");
// } // }
} }
public getTypeName(type: string): string { public getTypeName(type: string): string {
return StringUtils.getEntityName(type, false); return StringUtils.getEntityName(type, false);
} }
public removeUnknown(array: string[]): string[] { public removeUnknown(array: string[]): string[] {
return array.filter(value => value.toLowerCase() !== 'unknown'); return array.filter(value => value.toLowerCase() !== 'unknown');
} }
public removeDuplicates(array: string[]): string[] { public removeDuplicates(array: string[]): string[] {
return array.filter(value => value.toLowerCase() !== this.result.resultType); return array.filter(value => value.toLowerCase() !== this.result.resultType);
} }
public accessClass(accessMode: string): string { public accessClass(accessMode: string): string {
if(accessMode.toLowerCase().indexOf('open') !== -1) { if (accessMode.toLowerCase().indexOf('open') !== -1) {
return 'success'; return 'success';
} else if(accessMode.toLowerCase() === 'not available') { } else if (accessMode.toLowerCase() === 'not available') {
return 'disabled'; // unknown return 'disabled'; // unknown
} else { } else {
return 'disabled'; // closed return 'disabled'; // closed
} }
} }
public onClick() { public onClick() {
if(this.modal) { if (this.modal) {
this.modal.cancel(); this.modal.cancel();
} }
} }
createParam(){
if(this.urlParam == "grantId" ){ createParam() {
return this.routerHelper.createQueryParams([this.urlParam,"funder"],[this.result.id,this.result.funderShortname]) if (this.urlParam == "grantId") {
return this.routerHelper.createQueryParams([this.urlParam, "funder"], [this.result.id, this.result.funderShortname])
} }
return this.routerHelper.createQueryParam(this.urlParam,this.result.id) return this.routerHelper.createQueryParam(this.urlParam, this.result.id)
} }
public get isResultType() { public get isResultType() {
return this.result.resultType == "publication" || this.result.resultType == "dataset" || return this.result.resultType == "publication" || this.result.resultType == "dataset" ||
this.result.resultType == "software" || this.result.resultType == "other" || this.result.resultType == "result"; this.result.resultType == "software" || this.result.resultType == "other" || this.result.resultType == "result";
} }
} }

View File

@ -1,5 +1,5 @@
import {SearchResult} from "../entities/searchResult"; import {SearchResult} from "../entities/searchResult";
import {ResultLandingInfo} from "../entities/resultLandingInfo"; import {Measure, ResultLandingInfo} from "../entities/resultLandingInfo";
import {OrganizationInfo} from "../entities/organizationInfo"; import {OrganizationInfo} from "../entities/organizationInfo";
export interface HostedByCollectedFrom { export interface HostedByCollectedFrom {
@ -81,12 +81,12 @@ export class ResultPreview {
countries: string[]; countries: string[];
//Impact factor //Impact factor
DOI:string; DOI: string;
measure: Array<string>; measure: Measure;
//publications & datasets & orp & software & organizations: //publications & datasets & orp & software & organizations:
projects: Project[]; projects: Project[];
//datasets & orp & publications & software //datasets & orp & publications & software
description: string; description: string;
year: string; year: string;
@ -101,13 +101,13 @@ export class ResultPreview {
//datasets & orp & software: //datasets & orp & software:
publisher: string; publisher: string;
//software //software
programmingLanguages: string[]; programmingLanguages: string[];
//dataproviders & projects: //dataproviders & projects:
organizations: Organization[]; organizations: Organization[];
//projects: //projects:
acronym: string; acronym: string;
code: string; code: string;
@ -120,10 +120,10 @@ export class ResultPreview {
endYear: number; endYear: number;
openAccessMandatePublications: boolean; openAccessMandatePublications: boolean;
openAccessMandateDatasets: boolean; openAccessMandateDatasets: boolean;
//organizations: //organizations:
country: string; country: string;
//dataproviders: //dataproviders:
englishname: string; englishname: string;
websiteURL: string; websiteURL: string;
@ -131,10 +131,10 @@ export class ResultPreview {
compatibility: string; compatibility: string;
compatibilityUNKNOWN: boolean; compatibilityUNKNOWN: boolean;
subjects: string[]; subjects: string[];
resultType: string; resultType: string;
types: string[]; types: string[];
// Relation result // Relation result
relationName: string; relationName: string;
relation: string; relation: string;
@ -142,7 +142,8 @@ export class ResultPreview {
provenanceAction: string; provenanceAction: string;
//enermaps id - image //enermaps id - image
enermapsId:string; enermapsId: string;
public static searchResultConvert(result: SearchResult, type: string): ResultPreview { public static searchResultConvert(result: SearchResult, type: string): ResultPreview {
let resultPreview: ResultPreview = new ResultPreview(); let resultPreview: ResultPreview = new ResultPreview();
resultPreview.id = result.id; resultPreview.id = result.id;
@ -151,9 +152,9 @@ export class ResultPreview {
resultPreview.title = result.title.name; resultPreview.title = result.title.name;
resultPreview.accessMode = result.title.accessMode; resultPreview.accessMode = result.title.accessMode;
// resultPreview.sc39 = result.title.sc39; // resultPreview.sc39 = result.title.sc39;
if(result.countriesForResults) { if (result.countriesForResults) {
resultPreview.countries = result.countriesForResults; resultPreview.countries = result.countriesForResults;
} else if(result.country) { } else if (result.country) {
resultPreview.countries = [result.country]; resultPreview.countries = [result.country];
} else { } else {
resultPreview.countries = result.countries; resultPreview.countries = result.countries;
@ -179,7 +180,7 @@ export class ResultPreview {
resultPreview.openAccessMandatePublications = result.openAccessMandatePublications; resultPreview.openAccessMandatePublications = result.openAccessMandatePublications;
resultPreview.openAccessMandateDatasets = result.openAccessMandateDatasets; resultPreview.openAccessMandateDatasets = result.openAccessMandateDatasets;
resultPreview.englishname = result.englishname; resultPreview.englishname = result.englishname;
if(result.type) { if (result.type) {
resultPreview.types = [result.type]; resultPreview.types = [result.type];
} else { } else {
resultPreview.types = result.types; resultPreview.types = result.types;
@ -197,18 +198,18 @@ export class ResultPreview {
// } // }
resultPreview.identifiers = result.identifiers; resultPreview.identifiers = result.identifiers;
resultPreview.enermapsId = result.enermapsId; resultPreview.enermapsId = result.enermapsId;
resultPreview.measure = result.measure; resultPreview.measure = result.measure;
return resultPreview; return resultPreview;
} }
public static resultLandingInfoConvert(result: ResultLandingInfo, type: string): ResultPreview { public static resultLandingInfoConvert(result: ResultLandingInfo, type: string): ResultPreview {
let resultPreview: ResultPreview = new ResultPreview(); let resultPreview: ResultPreview = new ResultPreview();
resultPreview.title = result.title; resultPreview.title = result.title;
resultPreview.accessMode = result.accessMode; resultPreview.accessMode = result.accessMode;
resultPreview.countries = result.countries; resultPreview.countries = result.countries;
resultPreview.projects = result.fundedByProjects; resultPreview.projects = result.fundedByProjects;
resultPreview.description = result.description;//.length > 0 ? result.description[0] : ""; resultPreview.description = result.description;//.length > 0 ? result.description[0] : "";
if(result.dateofacceptance) { if (result.dateofacceptance) {
resultPreview.year = new Date(result.dateofacceptance).getFullYear().toString(); resultPreview.year = new Date(result.dateofacceptance).getFullYear().toString();
} }
resultPreview.embargoEndDate = result.embargoEndDate; resultPreview.embargoEndDate = result.embargoEndDate;
@ -224,13 +225,13 @@ export class ResultPreview {
resultPreview.hostedBy_collectedFrom = result.hostedBy_collectedFrom; resultPreview.hostedBy_collectedFrom = result.hostedBy_collectedFrom;
return resultPreview; return resultPreview;
} }
public static relationResultConvert(result: RelationResult): ResultPreview { public static relationResultConvert(result: RelationResult): ResultPreview {
let resultPreview: ResultPreview = new ResultPreview(); let resultPreview: ResultPreview = new ResultPreview();
resultPreview.id = result.id; resultPreview.id = result.id;
resultPreview.title = result.name; resultPreview.title = result.name;
resultPreview.resultType = result.class; resultPreview.resultType = result.class;
if(result.date) { if (result.date) {
resultPreview.year = result.date.toString(); resultPreview.year = result.date.toString();
} }
resultPreview.relationName = result.relationName; resultPreview.relationName = result.relationName;
@ -239,19 +240,19 @@ export class ResultPreview {
resultPreview.provenanceAction = result.provenanceAction; resultPreview.provenanceAction = result.provenanceAction;
return resultPreview; return resultPreview;
} }
public static organizationConvert(result: Organization, relation: string = 'trust'): ResultPreview { public static organizationConvert(result: Organization, relation: string = 'trust'): ResultPreview {
let resultPreview: ResultPreview = new ResultPreview(); let resultPreview: ResultPreview = new ResultPreview();
resultPreview.id = result.id; resultPreview.id = result.id;
if(result.name) { if (result.name) {
resultPreview.title = result.name; resultPreview.title = result.name;
if(result.shortname) { if (result.shortname) {
resultPreview.title += ' (' + result.shortname + ')'; resultPreview.title += ' (' + result.shortname + ')';
} }
} else if(result.shortname) { } else if (result.shortname) {
resultPreview.title = result.shortname; resultPreview.title = result.shortname;
} }
if(result.country) { if (result.country) {
resultPreview.countries = [result.country]; resultPreview.countries = [result.country];
} }
resultPreview.relation = relation; resultPreview.relation = relation;
@ -260,25 +261,25 @@ export class ResultPreview {
resultPreview.resultType = 'organization'; resultPreview.resultType = 'organization';
return resultPreview; return resultPreview;
} }
public static organizationInfoConvert(result: OrganizationInfo): ResultPreview { public static organizationInfoConvert(result: OrganizationInfo): ResultPreview {
let resultPreview: ResultPreview = new ResultPreview(); let resultPreview: ResultPreview = new ResultPreview();
if(result.title && result.title.name) { if (result.title && result.title.name) {
resultPreview.title = result.title.name; resultPreview.title = result.title.name;
if(result.name) { if (result.name) {
resultPreview.title += ' (' + result.name + ')'; resultPreview.title += ' (' + result.name + ')';
} }
} else if(result.name) { } else if (result.name) {
resultPreview.title = result.name; resultPreview.title = result.name;
} }
if(result.country) { if (result.country) {
resultPreview.countries = [result.country]; resultPreview.countries = [result.country];
} }
if(result.title && result.title.url) { if (result.title && result.title.url) {
resultPreview.websiteURL = result.title.url; resultPreview.websiteURL = result.title.url;
} }
resultPreview.resultType = 'organization'; resultPreview.resultType = 'organization';
return resultPreview; return resultPreview;
} }
} }