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