2020-03-12 14:49:10 +01:00
|
|
|
import {SearchResult} from "../entities/searchResult";
|
|
|
|
import {ResultLandingInfo} from "../entities/resultLandingInfo";
|
|
|
|
import {OrganizationInfo} from "../entities/organizationInfo";
|
|
|
|
|
|
|
|
export interface HostedByCollectedFrom {
|
2022-01-07 11:01:22 +01:00
|
|
|
downloadNames: string[];
|
|
|
|
downloadUrl: string;
|
|
|
|
collectedNamesAndIds: Map<string, string>;
|
|
|
|
accessRight: string;
|
|
|
|
types: string[];
|
|
|
|
years: string[];
|
|
|
|
accessRightIcon: string;
|
2020-03-12 14:49:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Journal {
|
|
|
|
journal?: string;
|
|
|
|
issn?: string;
|
|
|
|
lissn: string;
|
|
|
|
eissn?: string;
|
|
|
|
issue?: string;
|
|
|
|
volume?: string;
|
|
|
|
start_page?: string;
|
|
|
|
end_page?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface RelationResult {
|
|
|
|
name: string;
|
|
|
|
id: string;
|
|
|
|
date: string;
|
|
|
|
percentage: number;
|
2022-01-07 11:16:23 +01:00
|
|
|
percentageName?: string;
|
2020-03-12 14:49:10 +01:00
|
|
|
class: string
|
|
|
|
provenanceAction?: string;
|
2022-01-07 11:16:23 +01:00
|
|
|
relationName?: string;
|
2020-03-12 14:49:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface Project {
|
|
|
|
id: string;
|
|
|
|
acronym: string;
|
|
|
|
title: string;
|
|
|
|
funderShortname: string;
|
|
|
|
funderName: string;
|
|
|
|
funding?: string;
|
|
|
|
code: string;
|
2021-05-13 17:48:01 +02:00
|
|
|
validated?: boolean;
|
2020-03-12 14:49:10 +01:00
|
|
|
budget?: string;
|
|
|
|
contribution?: string;
|
|
|
|
currency?: string;
|
|
|
|
provenanceAction?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Author {
|
|
|
|
fullName: string;
|
|
|
|
orcid: string;
|
2021-02-20 10:20:05 +01:00
|
|
|
orcid_pending: string;
|
2020-03-12 14:49:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export interface ResultTitle {
|
|
|
|
name: string;
|
|
|
|
accessMode: string;
|
|
|
|
sc39: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Organization {
|
|
|
|
id: string;
|
|
|
|
name: string;
|
|
|
|
shortname?: string;
|
|
|
|
websiteUrl?: string;
|
|
|
|
country?: string;
|
|
|
|
trust?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class ResultPreview {
|
2021-02-20 10:22:25 +01:00
|
|
|
relcanId: string;
|
2020-03-12 14:49:10 +01:00
|
|
|
id: string;
|
|
|
|
title: string;
|
|
|
|
accessMode: string;
|
|
|
|
sc39: string;
|
|
|
|
countries: string[];
|
2020-04-06 16:49:38 +02:00
|
|
|
|
|
|
|
//Impact factor
|
|
|
|
DOI:string;
|
2020-05-25 14:24:48 +02:00
|
|
|
pop_inf;
|
2020-03-12 14:49:10 +01:00
|
|
|
//publications & datasets & orp & software & organizations:
|
|
|
|
projects: Project[];
|
|
|
|
|
|
|
|
//datasets & orp & publications & software
|
|
|
|
description: string;
|
|
|
|
year: string;
|
|
|
|
embargoEndDate: Date | string;
|
|
|
|
authors: Author[];
|
|
|
|
languages: string[];
|
|
|
|
identifiers: Map<string, string[]>; //key is the classname
|
|
|
|
hostedBy_collectedFrom: HostedByCollectedFrom[];
|
2021-01-13 19:30:25 +01:00
|
|
|
orcidPutCodes: string[];
|
2021-02-10 10:05:37 +01:00
|
|
|
orcidUpdateDates: string [];
|
|
|
|
orcidCreationDates: string [];
|
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
//datasets & orp & software:
|
|
|
|
publisher: string;
|
|
|
|
|
|
|
|
//software
|
|
|
|
programmingLanguages: string[];
|
|
|
|
|
|
|
|
//dataproviders & projects:
|
|
|
|
organizations: Organization[];
|
|
|
|
|
|
|
|
//projects:
|
|
|
|
acronym: string;
|
|
|
|
code: string;
|
2020-07-01 14:11:57 +02:00
|
|
|
// callIdentifier: string; // currently not parsed
|
2020-03-12 14:49:10 +01:00
|
|
|
funderShortname: string;
|
|
|
|
budget: string;
|
|
|
|
contribution: string;
|
|
|
|
currency: string;
|
|
|
|
startYear: number;
|
|
|
|
endYear: number;
|
|
|
|
openAccessMandatePublications: boolean;
|
|
|
|
openAccessMandateDatasets: boolean;
|
|
|
|
|
|
|
|
//organizations:
|
|
|
|
country: string;
|
|
|
|
|
|
|
|
//dataproviders:
|
|
|
|
englishname: string;
|
|
|
|
websiteURL: string;
|
|
|
|
OAIPMHURL: string;
|
|
|
|
compatibility: string;
|
|
|
|
compatibilityUNKNOWN: boolean;
|
|
|
|
subjects: string[];
|
|
|
|
|
|
|
|
resultType: string;
|
|
|
|
types: string[];
|
|
|
|
|
|
|
|
// Relation result
|
2022-01-07 11:16:23 +01:00
|
|
|
relationName: string;
|
2020-03-12 14:49:10 +01:00
|
|
|
relation: string;
|
|
|
|
percentage: number;
|
|
|
|
provenanceAction: string;
|
2021-04-02 11:17:00 +02:00
|
|
|
|
|
|
|
//enermaps id - image
|
|
|
|
enermapsId:string;
|
2020-03-12 14:49:10 +01:00
|
|
|
public static searchResultConvert(result: SearchResult, type: string): ResultPreview {
|
|
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
|
|
|
resultPreview.id = result.id;
|
2021-02-20 10:22:25 +01:00
|
|
|
resultPreview.relcanId = result.relcanId;
|
2020-03-12 14:49:10 +01:00
|
|
|
resultPreview.title = result.title.name;
|
|
|
|
resultPreview.accessMode = result.title.accessMode;
|
|
|
|
resultPreview.sc39 = result.title.sc39;
|
|
|
|
if(result.countriesForResults) {
|
2022-02-16 17:01:18 +01:00
|
|
|
resultPreview.countries = result.countriesForResults;
|
2020-03-12 14:49:10 +01:00
|
|
|
} else if(result.country) {
|
|
|
|
resultPreview.countries = [result.country];
|
|
|
|
} else {
|
|
|
|
resultPreview.countries = result.countries;
|
|
|
|
}
|
|
|
|
resultPreview.projects = result.projects;
|
|
|
|
resultPreview.description = result.description;
|
|
|
|
resultPreview.year = result.year;
|
|
|
|
resultPreview.embargoEndDate = result.embargoEndDate;
|
|
|
|
resultPreview.authors = result.authors;
|
|
|
|
resultPreview.languages = result.languages;
|
|
|
|
resultPreview.publisher = result.publisher;
|
|
|
|
resultPreview.programmingLanguages = result.programmingLanguages;
|
|
|
|
resultPreview.organizations = result.organizations;
|
|
|
|
resultPreview.acronym = result.acronym;
|
|
|
|
resultPreview.code = result.code;
|
2020-07-01 14:11:57 +02:00
|
|
|
// resultPreview.callIdentifier = result.callIdentifier; // currently not parsed
|
2020-03-12 14:49:10 +01:00
|
|
|
resultPreview.funderShortname = result.funderShortname;
|
|
|
|
resultPreview.budget = result.budget;
|
|
|
|
resultPreview.contribution = result.contribution;
|
|
|
|
resultPreview.currency = result.currency;
|
|
|
|
resultPreview.startYear = result.startYear;
|
|
|
|
resultPreview.endYear = result.endYear;
|
|
|
|
resultPreview.openAccessMandatePublications = result.openAccessMandatePublications;
|
|
|
|
resultPreview.openAccessMandateDatasets = result.openAccessMandateDatasets;
|
|
|
|
resultPreview.englishname = result.englishname;
|
|
|
|
if(result.type) {
|
|
|
|
resultPreview.types = [result.type];
|
|
|
|
} else {
|
|
|
|
resultPreview.types = result.types;
|
|
|
|
}
|
|
|
|
resultPreview.websiteURL = result.websiteURL;
|
|
|
|
resultPreview.OAIPMHURL = result.OAIPMHURL;
|
|
|
|
resultPreview.compatibility = result.compatibility;
|
|
|
|
resultPreview.compatibilityUNKNOWN = result.compatibilityUNKNOWN;
|
|
|
|
resultPreview.subjects = result.subjects;
|
|
|
|
resultPreview.resultType = type;
|
2020-04-06 16:49:38 +02:00
|
|
|
//impact factor;
|
2021-01-13 19:30:25 +01:00
|
|
|
// if(result.DOIs && result.DOIs.length > 0) {
|
|
|
|
// resultPreview.identifiers = new Map();
|
|
|
|
// resultPreview.identifiers.set("doi", result.DOIs);
|
|
|
|
// }
|
|
|
|
resultPreview.identifiers = result.identifiers;
|
2021-04-02 11:17:00 +02:00
|
|
|
resultPreview.enermapsId = result.enermapsId;
|
2020-03-12 14:49:10 +01:00
|
|
|
return resultPreview;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static resultLandingInfoConvert(result: ResultLandingInfo, type: string): ResultPreview {
|
|
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
|
|
|
resultPreview.title = result.title;
|
|
|
|
resultPreview.accessMode = result.accessMode;
|
|
|
|
resultPreview.countries = result.countries;
|
|
|
|
resultPreview.projects = result.fundedByProjects;
|
2022-02-14 16:04:09 +01:00
|
|
|
resultPreview.description = result.description.length > 0 ? result.description[0] : "";
|
2020-03-12 14:49:10 +01:00
|
|
|
if(result.dateofacceptance) {
|
|
|
|
resultPreview.year = new Date(result.dateofacceptance).getFullYear().toString();
|
|
|
|
}
|
|
|
|
resultPreview.embargoEndDate = result.embargoEndDate;
|
|
|
|
resultPreview.authors = result.authors;
|
|
|
|
resultPreview.languages = result.languages;
|
|
|
|
resultPreview.publisher = result.publisher;
|
|
|
|
resultPreview.programmingLanguages = result.programmingLanguages;
|
|
|
|
resultPreview.organizations = result.organizations;
|
|
|
|
resultPreview.types = result.types;
|
|
|
|
resultPreview.subjects = result.subjects;
|
|
|
|
resultPreview.resultType = type;
|
|
|
|
resultPreview.identifiers = result.identifiers;
|
|
|
|
resultPreview.hostedBy_collectedFrom = result.hostedBy_collectedFrom;
|
|
|
|
return resultPreview;
|
|
|
|
}
|
|
|
|
|
2022-01-07 11:16:23 +01:00
|
|
|
public static relationResultConvert(result: RelationResult): ResultPreview {
|
2020-03-12 14:49:10 +01:00
|
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
|
|
|
resultPreview.id = result.id;
|
|
|
|
resultPreview.title = result.name;
|
|
|
|
resultPreview.resultType = result.class;
|
|
|
|
if(result.date) {
|
|
|
|
resultPreview.year = result.date.toString();
|
|
|
|
}
|
2022-01-07 11:16:23 +01:00
|
|
|
resultPreview.relationName = result.relationName;
|
|
|
|
resultPreview.relation = result.percentageName;
|
2020-03-12 14:49:10 +01:00
|
|
|
resultPreview.percentage = result.percentage;
|
|
|
|
resultPreview.provenanceAction = result.provenanceAction;
|
|
|
|
return resultPreview;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static organizationConvert(result: Organization, relation: string = 'trust'): ResultPreview {
|
|
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
|
|
|
resultPreview.id = result.id;
|
|
|
|
if(result.name) {
|
|
|
|
resultPreview.title = result.name;
|
|
|
|
if(result.shortname) {
|
|
|
|
resultPreview.title += ' (' + result.shortname + ')';
|
|
|
|
}
|
|
|
|
} else if(result.shortname) {
|
|
|
|
resultPreview.title = result.shortname;
|
|
|
|
}
|
|
|
|
if(result.country) {
|
|
|
|
resultPreview.countries = [result.country];
|
|
|
|
}
|
|
|
|
resultPreview.relation = relation;
|
|
|
|
resultPreview.percentage = result.trust;
|
|
|
|
resultPreview.websiteURL = result.websiteUrl;
|
|
|
|
resultPreview.resultType = 'organization';
|
|
|
|
return resultPreview;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static organizationInfoConvert(result: OrganizationInfo): ResultPreview {
|
|
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
2020-07-14 11:57:11 +02:00
|
|
|
console.log(result);
|
2020-03-12 14:49:10 +01:00
|
|
|
if(result.title && result.title.name) {
|
|
|
|
resultPreview.title = result.title.name;
|
|
|
|
if(result.name) {
|
|
|
|
resultPreview.title += ' (' + result.name + ')';
|
|
|
|
}
|
|
|
|
} else if(result.name) {
|
|
|
|
resultPreview.title = result.name;
|
|
|
|
}
|
|
|
|
if(result.country) {
|
|
|
|
resultPreview.countries = [result.country];
|
|
|
|
}
|
|
|
|
if(result.title && result.title.url) {
|
|
|
|
resultPreview.websiteURL = result.title.url;
|
|
|
|
}
|
|
|
|
resultPreview.resultType = 'organization';
|
|
|
|
return resultPreview;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|