1 |
61381
|
k.triantaf
|
import {SearchResult} from "../entities/searchResult";
|
2 |
|
|
import {ResultLandingInfo} from "../entities/resultLandingInfo";
|
3 |
|
|
import {OrganizationInfo} from "../entities/organizationInfo";
|
4 |
|
|
|
5 |
|
|
export interface HostedByCollectedFrom {
|
6 |
|
|
downloadName: string;
|
7 |
|
|
downloadUrl: string[];
|
8 |
|
|
collectedName: string;
|
9 |
|
|
collectedId: string;
|
10 |
|
|
accessMode: string[];
|
11 |
|
|
bestAccessMode: string;
|
12 |
|
|
type: string;
|
13 |
|
|
year: string;
|
14 |
|
|
icon: string
|
15 |
|
|
}
|
16 |
|
|
|
17 |
|
|
export interface Journal {
|
18 |
|
|
journal?: string;
|
19 |
|
|
issn?: string;
|
20 |
|
|
lissn: string;
|
21 |
|
|
eissn?: string;
|
22 |
|
|
issue?: string;
|
23 |
|
|
volume?: string;
|
24 |
|
|
start_page?: string;
|
25 |
|
|
end_page?: string;
|
26 |
|
|
}
|
27 |
|
|
|
28 |
|
|
export interface RelationResult {
|
29 |
|
|
name: string;
|
30 |
|
|
id: string;
|
31 |
|
|
date: string;
|
32 |
|
|
percentage: number;
|
33 |
|
|
class: string
|
34 |
|
|
provenanceAction?: string;
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
export interface Project {
|
38 |
|
|
id: string;
|
39 |
|
|
acronym: string;
|
40 |
|
|
title: string;
|
41 |
|
|
funderShortname: string;
|
42 |
|
|
funderName: string;
|
43 |
|
|
funding?: string;
|
44 |
|
|
code: string;
|
45 |
|
|
validated?: boolean;
|
46 |
|
|
budget?: string;
|
47 |
|
|
contribution?: string;
|
48 |
|
|
currency?: string;
|
49 |
|
|
provenanceAction?: string;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
export interface Author {
|
53 |
|
|
fullName: string;
|
54 |
|
|
orcid: string;
|
55 |
|
|
orcid_pending: string;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
export interface ResultTitle {
|
59 |
|
|
name: string;
|
60 |
|
|
accessMode: string;
|
61 |
|
|
sc39: string;
|
62 |
|
|
}
|
63 |
|
|
|
64 |
|
|
export interface Organization {
|
65 |
|
|
id: string;
|
66 |
|
|
name: string;
|
67 |
|
|
shortname?: string;
|
68 |
|
|
websiteUrl?: string;
|
69 |
|
|
country?: string;
|
70 |
|
|
trust?: number;
|
71 |
|
|
}
|
72 |
|
|
|
73 |
|
|
export class ResultPreview {
|
74 |
|
|
relcanId: string;
|
75 |
|
|
id: string;
|
76 |
|
|
title: string;
|
77 |
|
|
accessMode: string;
|
78 |
|
|
sc39: string;
|
79 |
|
|
countries: string[];
|
80 |
|
|
|
81 |
|
|
//Impact factor
|
82 |
|
|
DOI:string;
|
83 |
|
|
pop_inf;
|
84 |
|
|
//publications & datasets & orp & software & organizations:
|
85 |
|
|
projects: Project[];
|
86 |
|
|
|
87 |
|
|
//datasets & orp & publications & software
|
88 |
|
|
description: string;
|
89 |
|
|
year: string;
|
90 |
|
|
embargoEndDate: Date | string;
|
91 |
|
|
authors: Author[];
|
92 |
|
|
languages: string[];
|
93 |
|
|
identifiers: Map<string, string[]>; //key is the classname
|
94 |
|
|
hostedBy_collectedFrom: HostedByCollectedFrom[];
|
95 |
|
|
orcidPutCodes: string[];
|
96 |
|
|
orcidUpdateDates: string [];
|
97 |
|
|
orcidCreationDates: string [];
|
98 |
|
|
|
99 |
|
|
//datasets & orp & software:
|
100 |
|
|
publisher: string;
|
101 |
|
|
|
102 |
|
|
//software
|
103 |
|
|
programmingLanguages: string[];
|
104 |
|
|
|
105 |
|
|
//dataproviders & projects:
|
106 |
|
|
organizations: Organization[];
|
107 |
|
|
|
108 |
|
|
//projects:
|
109 |
|
|
acronym: string;
|
110 |
|
|
code: string;
|
111 |
|
|
// callIdentifier: string; // currently not parsed
|
112 |
|
|
funderShortname: string;
|
113 |
|
|
budget: string;
|
114 |
|
|
contribution: string;
|
115 |
|
|
currency: string;
|
116 |
|
|
startYear: number;
|
117 |
|
|
endYear: number;
|
118 |
|
|
openAccessMandatePublications: boolean;
|
119 |
|
|
openAccessMandateDatasets: boolean;
|
120 |
|
|
|
121 |
|
|
//organizations:
|
122 |
|
|
country: string;
|
123 |
|
|
|
124 |
|
|
//dataproviders:
|
125 |
|
|
englishname: string;
|
126 |
|
|
websiteURL: string;
|
127 |
|
|
OAIPMHURL: string;
|
128 |
|
|
compatibility: string;
|
129 |
|
|
compatibilityUNKNOWN: boolean;
|
130 |
|
|
subjects: string[];
|
131 |
|
|
|
132 |
|
|
resultType: string;
|
133 |
|
|
types: string[];
|
134 |
|
|
|
135 |
|
|
// Relation result
|
136 |
|
|
relation: string;
|
137 |
|
|
percentage: number;
|
138 |
|
|
provenanceAction: string;
|
139 |
|
|
|
140 |
|
|
//enermaps id - image
|
141 |
|
|
enermapsId:string;
|
142 |
|
|
public static searchResultConvert(result: SearchResult, type: string): ResultPreview {
|
143 |
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
144 |
|
|
resultPreview.id = result.id;
|
145 |
|
|
resultPreview.relcanId = result.relcanId;
|
146 |
|
|
resultPreview.title = result.title.name;
|
147 |
|
|
resultPreview.accessMode = result.title.accessMode;
|
148 |
|
|
resultPreview.sc39 = result.title.sc39;
|
149 |
|
|
if(result.countriesForResults) {
|
150 |
|
|
resultPreview.countries = result.countries;
|
151 |
|
|
} else if(result.country) {
|
152 |
|
|
resultPreview.countries = [result.country];
|
153 |
|
|
} else {
|
154 |
|
|
resultPreview.countries = result.countries;
|
155 |
|
|
}
|
156 |
|
|
resultPreview.projects = result.projects;
|
157 |
|
|
resultPreview.description = result.description;
|
158 |
|
|
resultPreview.year = result.year;
|
159 |
|
|
resultPreview.embargoEndDate = result.embargoEndDate;
|
160 |
|
|
resultPreview.authors = result.authors;
|
161 |
|
|
resultPreview.languages = result.languages;
|
162 |
|
|
resultPreview.publisher = result.publisher;
|
163 |
|
|
resultPreview.programmingLanguages = result.programmingLanguages;
|
164 |
|
|
resultPreview.organizations = result.organizations;
|
165 |
|
|
resultPreview.acronym = result.acronym;
|
166 |
|
|
resultPreview.code = result.code;
|
167 |
|
|
// resultPreview.callIdentifier = result.callIdentifier; // currently not parsed
|
168 |
|
|
resultPreview.funderShortname = result.funderShortname;
|
169 |
|
|
resultPreview.budget = result.budget;
|
170 |
|
|
resultPreview.contribution = result.contribution;
|
171 |
|
|
resultPreview.currency = result.currency;
|
172 |
|
|
resultPreview.startYear = result.startYear;
|
173 |
|
|
resultPreview.endYear = result.endYear;
|
174 |
|
|
resultPreview.openAccessMandatePublications = result.openAccessMandatePublications;
|
175 |
|
|
resultPreview.openAccessMandateDatasets = result.openAccessMandateDatasets;
|
176 |
|
|
resultPreview.englishname = result.englishname;
|
177 |
|
|
if(result.type) {
|
178 |
|
|
resultPreview.types = [result.type];
|
179 |
|
|
} else {
|
180 |
|
|
resultPreview.types = result.types;
|
181 |
|
|
}
|
182 |
|
|
resultPreview.websiteURL = result.websiteURL;
|
183 |
|
|
resultPreview.OAIPMHURL = result.OAIPMHURL;
|
184 |
|
|
resultPreview.compatibility = result.compatibility;
|
185 |
|
|
resultPreview.compatibilityUNKNOWN = result.compatibilityUNKNOWN;
|
186 |
|
|
resultPreview.subjects = result.subjects;
|
187 |
|
|
resultPreview.resultType = type;
|
188 |
|
|
//impact factor;
|
189 |
|
|
// if(result.DOIs && result.DOIs.length > 0) {
|
190 |
|
|
// resultPreview.identifiers = new Map();
|
191 |
|
|
// resultPreview.identifiers.set("doi", result.DOIs);
|
192 |
|
|
// }
|
193 |
|
|
resultPreview.identifiers = result.identifiers;
|
194 |
|
|
resultPreview.enermapsId = result.enermapsId;
|
195 |
|
|
return resultPreview;
|
196 |
|
|
}
|
197 |
|
|
|
198 |
|
|
public static resultLandingInfoConvert(result: ResultLandingInfo, type: string): ResultPreview {
|
199 |
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
200 |
|
|
resultPreview.title = result.title;
|
201 |
|
|
resultPreview.accessMode = result.accessMode;
|
202 |
|
|
resultPreview.countries = result.countries;
|
203 |
|
|
resultPreview.projects = result.fundedByProjects;
|
204 |
|
|
resultPreview.description = result.description;
|
205 |
|
|
if(result.dateofacceptance) {
|
206 |
|
|
resultPreview.year = new Date(result.dateofacceptance).getFullYear().toString();
|
207 |
|
|
}
|
208 |
|
|
resultPreview.embargoEndDate = result.embargoEndDate;
|
209 |
|
|
resultPreview.authors = result.authors;
|
210 |
|
|
resultPreview.languages = result.languages;
|
211 |
|
|
resultPreview.publisher = result.publisher;
|
212 |
|
|
resultPreview.programmingLanguages = result.programmingLanguages;
|
213 |
|
|
resultPreview.organizations = result.organizations;
|
214 |
|
|
resultPreview.types = result.types;
|
215 |
|
|
resultPreview.subjects = result.subjects;
|
216 |
|
|
resultPreview.resultType = type;
|
217 |
|
|
resultPreview.identifiers = result.identifiers;
|
218 |
|
|
resultPreview.hostedBy_collectedFrom = result.hostedBy_collectedFrom;
|
219 |
|
|
return resultPreview;
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
public static relationResultConvert(result: RelationResult, relation: string = 'trust'): ResultPreview {
|
223 |
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
224 |
|
|
resultPreview.id = result.id;
|
225 |
|
|
resultPreview.title = result.name;
|
226 |
|
|
resultPreview.resultType = result.class;
|
227 |
|
|
if(result.date) {
|
228 |
|
|
resultPreview.year = result.date.toString();
|
229 |
|
|
}
|
230 |
|
|
resultPreview.relation = relation;
|
231 |
|
|
resultPreview.percentage = result.percentage;
|
232 |
|
|
resultPreview.provenanceAction = result.provenanceAction;
|
233 |
|
|
return resultPreview;
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
public static organizationConvert(result: Organization, relation: string = 'trust'): ResultPreview {
|
237 |
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
238 |
|
|
resultPreview.id = result.id;
|
239 |
|
|
if(result.name) {
|
240 |
|
|
resultPreview.title = result.name;
|
241 |
|
|
if(result.shortname) {
|
242 |
|
|
resultPreview.title += ' (' + result.shortname + ')';
|
243 |
|
|
}
|
244 |
|
|
} else if(result.shortname) {
|
245 |
|
|
resultPreview.title = result.shortname;
|
246 |
|
|
}
|
247 |
|
|
if(result.country) {
|
248 |
|
|
resultPreview.countries = [result.country];
|
249 |
|
|
}
|
250 |
|
|
resultPreview.relation = relation;
|
251 |
|
|
resultPreview.percentage = result.trust;
|
252 |
|
|
resultPreview.websiteURL = result.websiteUrl;
|
253 |
|
|
resultPreview.resultType = 'organization';
|
254 |
|
|
return resultPreview;
|
255 |
|
|
}
|
256 |
|
|
|
257 |
|
|
public static organizationInfoConvert(result: OrganizationInfo): ResultPreview {
|
258 |
|
|
let resultPreview: ResultPreview = new ResultPreview();
|
259 |
|
|
console.log(result);
|
260 |
|
|
if(result.title && result.title.name) {
|
261 |
|
|
resultPreview.title = result.title.name;
|
262 |
|
|
if(result.name) {
|
263 |
|
|
resultPreview.title += ' (' + result.name + ')';
|
264 |
|
|
}
|
265 |
|
|
} else if(result.name) {
|
266 |
|
|
resultPreview.title = result.name;
|
267 |
|
|
}
|
268 |
|
|
if(result.country) {
|
269 |
|
|
resultPreview.countries = [result.country];
|
270 |
|
|
}
|
271 |
|
|
if(result.title && result.title.url) {
|
272 |
|
|
resultPreview.websiteURL = result.title.url;
|
273 |
|
|
}
|
274 |
|
|
resultPreview.resultType = 'organization';
|
275 |
|
|
return resultPreview;
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
}
|