1 |
58275
|
k.triantaf
|
import {HostedByCollectedFrom, Journal, Project, RelationResult} from "../../utils/result-preview/result-preview";
|
2 |
58288
|
k.triantaf
|
import {Reference} from "../../utils/entities/resultLandingInfo";
|
3 |
50169
|
argiro.kok
|
|
4 |
|
|
export class ParsingFunctions {
|
5 |
59038
|
konstantin
|
public open = 'assets/common-assets/unlock.svg';
|
6 |
|
|
public closed = 'assets/common-assets/lock.svg';
|
7 |
|
|
public unknown = 'assets/common-assets/question.svg';
|
8 |
|
|
|
9 |
58275
|
k.triantaf
|
constructor() {
|
10 |
|
|
}
|
11 |
|
|
|
12 |
|
|
public ngOnDestroy() {
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
public parseFundingByProjects(fundedByProjects: Project[], relation: any,
|
16 |
|
|
provenanceActionVocabulary: any): Project[] {
|
17 |
|
|
if (fundedByProjects == undefined) {
|
18 |
|
|
fundedByProjects = [];
|
19 |
50169
|
argiro.kok
|
}
|
20 |
58275
|
k.triantaf
|
|
21 |
|
|
let fundedByProject: Project = {
|
22 |
|
|
"id": "", "acronym": "", "title": "",
|
23 |
|
|
"funderShortname": "", "funderName": "",
|
24 |
61003
|
konstantin
|
"funding": "", "code": "", "provenanceAction": "", "validated": false
|
25 |
58275
|
k.triantaf
|
};
|
26 |
|
|
|
27 |
|
|
if (relation.title != 'unidentified') {
|
28 |
50169
|
argiro.kok
|
fundedByProject['id'] = relation['to'].content;
|
29 |
|
|
fundedByProject['acronym'] = relation.acronym;
|
30 |
|
|
fundedByProject['title'] = relation.title;
|
31 |
|
|
fundedByProject['code'] = relation.code;
|
32 |
61003
|
konstantin
|
if(relation.validated && relation.validated.date) {
|
33 |
|
|
fundedByProject['validated'] = true;
|
34 |
|
|
}
|
35 |
|
|
|
36 |
58275
|
k.triantaf
|
if (provenanceActionVocabulary != null && relation.provenanceaction in provenanceActionVocabulary) {
|
37 |
57330
|
konstantin
|
fundedByProject['provenanceAction'] = provenanceActionVocabulary[relation.provenanceaction];
|
38 |
50169
|
argiro.kok
|
}
|
39 |
|
|
} else {
|
40 |
|
|
fundedByProject['id'] = "";
|
41 |
|
|
fundedByProject['acronym'] = "";
|
42 |
|
|
fundedByProject['title'] = "";
|
43 |
|
|
fundedByProject['code'] = "";
|
44 |
|
|
fundedByProject['provenanceAction'] = "";
|
45 |
|
|
}
|
46 |
58275
|
k.triantaf
|
|
47 |
|
|
if (relation.hasOwnProperty("funding")) {
|
48 |
|
|
let funding: { "funderName": string, "funderShortname": string, "stream": string };
|
49 |
50169
|
argiro.kok
|
funding = this.parseFundingTrees(relation.funding);
|
50 |
58275
|
k.triantaf
|
|
51 |
|
|
if (funding.funderName) {
|
52 |
50169
|
argiro.kok
|
fundedByProject['funderName'] = funding.funderName;
|
53 |
|
|
}
|
54 |
58275
|
k.triantaf
|
if (funding.funderShortname) {
|
55 |
50169
|
argiro.kok
|
fundedByProject['funderShortname'] = funding.funderShortname;
|
56 |
|
|
}
|
57 |
58275
|
k.triantaf
|
if (funding.stream) {
|
58 |
50169
|
argiro.kok
|
fundedByProject['funding'] = funding.stream;
|
59 |
|
|
}
|
60 |
|
|
}
|
61 |
|
|
fundedByProjects.push(fundedByProject);
|
62 |
|
|
return fundedByProjects;
|
63 |
|
|
}
|
64 |
58275
|
k.triantaf
|
|
65 |
50169
|
argiro.kok
|
// publication & research data : for fundedByProjects | project landing : for funding
|
66 |
58275
|
k.triantaf
|
public parseFundingTrees(fundingTree: any): { "funderName": string, "funderShortname": string, "stream": string } {
|
67 |
|
|
let funding: { "funderName": string, "funderShortname": string, "stream": string } = {
|
68 |
|
|
"funderName": "",
|
69 |
|
|
"funderShortname": "",
|
70 |
|
|
"stream": ""
|
71 |
|
|
};
|
72 |
50169
|
argiro.kok
|
let length = Array.isArray(fundingTree) ? fundingTree.length : 1;
|
73 |
58275
|
k.triantaf
|
|
74 |
|
|
for (let i = 0; i < length; i++) {
|
75 |
50169
|
argiro.kok
|
let fundingData = Array.isArray(fundingTree) ? fundingTree[i] : fundingTree;
|
76 |
58275
|
k.triantaf
|
|
77 |
|
|
if (fundingData.hasOwnProperty("funder")) {
|
78 |
50169
|
argiro.kok
|
funding.funderShortname = fundingData['funder'].shortname;
|
79 |
|
|
funding.funderName = fundingData['funder'].name;
|
80 |
|
|
}
|
81 |
58275
|
k.triantaf
|
|
82 |
50169
|
argiro.kok
|
funding.stream = this.addFundingLevel0(fundingData, funding.stream);
|
83 |
58275
|
k.triantaf
|
|
84 |
50169
|
argiro.kok
|
funding.stream = this.addFundingLevel1(fundingData, funding.stream);
|
85 |
58275
|
k.triantaf
|
|
86 |
50169
|
argiro.kok
|
funding.stream = this.addFundingLevel2(fundingData, funding.stream);
|
87 |
|
|
}
|
88 |
|
|
return funding;
|
89 |
|
|
}
|
90 |
58275
|
k.triantaf
|
|
91 |
|
|
addFundingLevel0(parent: string, fundingStream: string): string {
|
92 |
|
|
if (parent.hasOwnProperty("funding_level_0")) {
|
93 |
50169
|
argiro.kok
|
let level0 = parent['funding_level_0'];
|
94 |
58275
|
k.triantaf
|
|
95 |
50169
|
argiro.kok
|
fundingStream += (fundingStream) ? " ; " : "";
|
96 |
|
|
fundingStream += level0.name;
|
97 |
|
|
}
|
98 |
|
|
return fundingStream;
|
99 |
|
|
}
|
100 |
58275
|
k.triantaf
|
|
101 |
50169
|
argiro.kok
|
addFundingLevel1(parent: string, fundingStream: string): string {
|
102 |
58275
|
k.triantaf
|
if (parent.hasOwnProperty("funding_level_1")) {
|
103 |
50169
|
argiro.kok
|
let level1 = parent['funding_level_1'];
|
104 |
58275
|
k.triantaf
|
|
105 |
50169
|
argiro.kok
|
// For projects' parsing
|
106 |
58275
|
k.triantaf
|
if (level1.hasOwnProperty("parent")) {
|
107 |
50169
|
argiro.kok
|
fundingStream = this.addFundingLevel0(level1.parent, fundingStream);
|
108 |
|
|
}
|
109 |
58275
|
k.triantaf
|
|
110 |
50169
|
argiro.kok
|
fundingStream += (fundingStream) ? " | " : "";
|
111 |
|
|
fundingStream += level1.name;
|
112 |
|
|
}
|
113 |
|
|
return fundingStream;
|
114 |
|
|
}
|
115 |
58275
|
k.triantaf
|
|
116 |
50169
|
argiro.kok
|
addFundingLevel2(parent: string, fundingStream: string): string {
|
117 |
58275
|
k.triantaf
|
if (parent.hasOwnProperty("funding_level_2")) {
|
118 |
50169
|
argiro.kok
|
let level2 = parent['funding_level_2'];
|
119 |
58275
|
k.triantaf
|
|
120 |
50169
|
argiro.kok
|
// For projects' parsing
|
121 |
58275
|
k.triantaf
|
if (level2.hasOwnProperty("parent")) {
|
122 |
50169
|
argiro.kok
|
fundingStream = this.addFundingLevel1(level2.parent, fundingStream);
|
123 |
|
|
}
|
124 |
58275
|
k.triantaf
|
|
125 |
50169
|
argiro.kok
|
fundingStream += (fundingStream) ? " | " : "";
|
126 |
|
|
fundingStream += level2.name;
|
127 |
|
|
}
|
128 |
|
|
return fundingStream;
|
129 |
|
|
}
|
130 |
58275
|
k.triantaf
|
|
131 |
50169
|
argiro.kok
|
// publication & dataset landing : for collectedFrom
|
132 |
58275
|
k.triantaf
|
parseCollectedFrom(collectedFrom: { "name": string, "id": string }[],
|
133 |
50169
|
argiro.kok
|
_collectedFrom: any) {
|
134 |
|
|
let length: number = collectedFrom.length;
|
135 |
|
|
collectedFrom[length] = {"name": "", "id": ""};
|
136 |
|
|
collectedFrom[length]['name'] = _collectedFrom.name;
|
137 |
|
|
collectedFrom[length]['id'] = _collectedFrom.id;
|
138 |
|
|
}
|
139 |
58275
|
k.triantaf
|
|
140 |
50169
|
argiro.kok
|
// publication & dataset landing : for downloadFrom
|
141 |
58275
|
k.triantaf
|
addPublisherToHostedBy_collectedFrom(hostedBy_collectedFrom: HostedByCollectedFrom[],
|
142 |
|
|
publisher: string, journal: Journal,
|
143 |
|
|
identifiers: Map<string, string[]>/*, title: { "name": string, "url": string, "accessMode": string}*/) {
|
144 |
|
|
if (publisher && identifiers != null && identifiers.has('doi')) {
|
145 |
|
|
if (hostedBy_collectedFrom == null) {
|
146 |
|
|
hostedBy_collectedFrom = [];
|
147 |
50169
|
argiro.kok
|
}
|
148 |
58275
|
k.triantaf
|
let available: HostedByCollectedFrom = {
|
149 |
|
|
downloadName: "",
|
150 |
|
|
downloadUrl: null,
|
151 |
|
|
collectedName: "",
|
152 |
|
|
collectedId: "",
|
153 |
|
|
accessMode: null,
|
154 |
|
|
bestAccessMode: null,
|
155 |
|
|
type: "",
|
156 |
59038
|
konstantin
|
year: "",
|
157 |
|
|
icon: ""
|
158 |
58275
|
k.triantaf
|
};
|
159 |
|
|
|
160 |
|
|
if (journal && journal.journal) {
|
161 |
|
|
available.downloadName = publisher + "/ " + journal['journal'];
|
162 |
50169
|
argiro.kok
|
} else {
|
163 |
|
|
available.downloadName = publisher;
|
164 |
|
|
}
|
165 |
58275
|
k.triantaf
|
|
166 |
|
|
let url = "https://dx.doi.org/" + identifiers.get("doi")[0];
|
167 |
|
|
|
168 |
50169
|
argiro.kok
|
available.downloadUrl = new Array<string>();
|
169 |
|
|
available.accessMode = new Array<string>();
|
170 |
58275
|
k.triantaf
|
|
171 |
50169
|
argiro.kok
|
available.downloadUrl.push(url);
|
172 |
59038
|
konstantin
|
|
173 |
|
|
available.icon = this.unknown;
|
174 |
58275
|
k.triantaf
|
/*
|
175 |
|
|
if(title != undefined && title['url'] == "") {
|
176 |
|
|
title['url'] = url;
|
177 |
|
|
}
|
178 |
|
|
*/
|
179 |
50169
|
argiro.kok
|
hostedBy_collectedFrom.push(available);
|
180 |
|
|
}
|
181 |
|
|
return hostedBy_collectedFrom;
|
182 |
|
|
}
|
183 |
58275
|
k.triantaf
|
|
184 |
50169
|
argiro.kok
|
// publication & dataset landing : for downloadFrom
|
185 |
58275
|
k.triantaf
|
parseDownloadFrom(downloadFrom: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, url: string) {
|
186 |
50169
|
argiro.kok
|
let key: string = instance['hostedby'].name;
|
187 |
58275
|
k.triantaf
|
|
188 |
|
|
if (key) {
|
189 |
50169
|
argiro.kok
|
this.addUrlAndAccessMode(downloadFrom, instance, key, url);
|
190 |
|
|
}
|
191 |
|
|
}
|
192 |
58275
|
k.triantaf
|
|
193 |
50169
|
argiro.kok
|
// publication & dataset landing : for publishedIn
|
194 |
58275
|
k.triantaf
|
parsePublishedIn(publishedIn: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, result: any, url: string, counter: number): number {
|
195 |
|
|
if (result != null && result.hasOwnProperty("source")) {
|
196 |
50169
|
argiro.kok
|
let key: string;
|
197 |
58275
|
k.triantaf
|
if (Array.isArray(result.source)) {
|
198 |
|
|
if (counter == result.source.length) {
|
199 |
50169
|
argiro.kok
|
counter--;
|
200 |
|
|
}
|
201 |
|
|
key = result['source'][counter];
|
202 |
|
|
} else {
|
203 |
|
|
key = result['source'];
|
204 |
|
|
}
|
205 |
58275
|
k.triantaf
|
|
206 |
|
|
if (key) {
|
207 |
50169
|
argiro.kok
|
this.addUrlAndAccessMode(publishedIn, instance, key, url);
|
208 |
|
|
counter++;
|
209 |
|
|
}
|
210 |
|
|
}
|
211 |
|
|
return counter;
|
212 |
|
|
}
|
213 |
58275
|
k.triantaf
|
|
214 |
50169
|
argiro.kok
|
// publication & dataset landing : for downloadFrom and publishedIn
|
215 |
58275
|
k.triantaf
|
addUrlAndAccessMode(mapStructure: Map<string, { "url": string[], "accessMode": string[], "bestAccessMode": string }>, instance: any, key: string, url: string) {
|
216 |
|
|
if (!mapStructure.has(key)) {
|
217 |
50169
|
argiro.kok
|
mapStructure.set(key, {"url": null, "accessMode": null, "bestAccessMode": null});
|
218 |
|
|
}
|
219 |
58275
|
k.triantaf
|
|
220 |
|
|
if (mapStructure.get(key)['url'] == null) {
|
221 |
50169
|
argiro.kok
|
mapStructure.get(key)['url'] = new Array<string>();
|
222 |
|
|
}
|
223 |
58275
|
k.triantaf
|
|
224 |
|
|
if (url) {
|
225 |
50169
|
argiro.kok
|
mapStructure.get(key)['url'].push(url);
|
226 |
|
|
}
|
227 |
58275
|
k.triantaf
|
|
228 |
|
|
if (mapStructure.get(key)['accessMode'] == null) {
|
229 |
50169
|
argiro.kok
|
mapStructure.get(key)['accessMode'] = new Array<string>();
|
230 |
|
|
}
|
231 |
58275
|
k.triantaf
|
|
232 |
|
|
if (instance.hasOwnProperty("accessright")) {
|
233 |
|
|
if (url) {
|
234 |
|
|
mapStructure.get(key)['accessMode'].push(instance['accessright'].classname);
|
235 |
50169
|
argiro.kok
|
}
|
236 |
58275
|
k.triantaf
|
|
237 |
|
|
if (this.changeBestAccessMode(mapStructure.get(key)['bestAccessMode'], instance['accessright'])) {
|
238 |
|
|
mapStructure.get(key)['bestAccessMode'] = instance['accessright'].classname;
|
239 |
50169
|
argiro.kok
|
}
|
240 |
58275
|
k.triantaf
|
} else if (url) {
|
241 |
50169
|
argiro.kok
|
mapStructure.get(key)['accessMode'].push("");
|
242 |
|
|
}
|
243 |
|
|
}
|
244 |
58275
|
k.triantaf
|
|
245 |
|
|
|
246 |
|
|
parseHostedBy_collectedFrom(hostedBy_collectedFrom: HostedByCollectedFrom[],
|
247 |
52606
|
konstantin
|
instance: any, data: any, url: string, counter: number/*,
|
248 |
|
|
title: { "name": string, "url": string, "accessMode": string}*/, accessMode: string): number {
|
249 |
58275
|
k.triantaf
|
let available: HostedByCollectedFrom = {
|
250 |
|
|
"downloadName": "",
|
251 |
|
|
"downloadUrl": null,
|
252 |
|
|
"collectedName": "",
|
253 |
|
|
"collectedId": "",
|
254 |
|
|
"accessMode": null,
|
255 |
|
|
"bestAccessMode": null,
|
256 |
|
|
"type": "",
|
257 |
59038
|
konstantin
|
"year": "",
|
258 |
|
|
"icon": ""
|
259 |
58275
|
k.triantaf
|
};
|
260 |
|
|
|
261 |
|
|
if (instance['hostedby'].name && instance['hostedby'].name != "other resources" && instance['hostedby'].name != "Unknown Repository") {
|
262 |
|
|
available.downloadName = instance['hostedby'].name;
|
263 |
|
|
} else {
|
264 |
59124
|
konstantin
|
// if (data != null && data.hasOwnProperty("source")) {
|
265 |
|
|
// let downloadName: string;
|
266 |
|
|
// if (Array.isArray(data.source)) {
|
267 |
|
|
//
|
268 |
|
|
// if (counter == data.source.length) {
|
269 |
|
|
// counter--;
|
270 |
|
|
// }
|
271 |
|
|
// downloadName = data['source'][counter];
|
272 |
|
|
// } else {
|
273 |
|
|
// downloadName = data['source'];
|
274 |
|
|
// }
|
275 |
|
|
// if (downloadName) {
|
276 |
|
|
// counter++;
|
277 |
|
|
// available.downloadName = downloadName;
|
278 |
|
|
// }
|
279 |
|
|
// }
|
280 |
|
|
//
|
281 |
|
|
// }
|
282 |
|
|
//
|
283 |
|
|
// if(!available.downloadName) {
|
284 |
59038
|
konstantin
|
available.downloadName = url.substring(0, 30) + '...'; // substring(from, to);
|
285 |
|
|
}
|
286 |
|
|
|
287 |
58275
|
k.triantaf
|
if (available.downloadName) {
|
288 |
|
|
if (instance.hasOwnProperty("collectedfrom")) {
|
289 |
|
|
available.collectedId = instance['collectedfrom'].id;
|
290 |
|
|
available.collectedName = instance['collectedfrom'].name;
|
291 |
|
|
}
|
292 |
|
|
|
293 |
|
|
if (instance.hasOwnProperty("instancetype") && instance['instancetype'].classname) {
|
294 |
|
|
available.type = instance['instancetype'].classname;
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
if (instance.hasOwnProperty("dateofacceptance")) {
|
298 |
|
|
var date: string = (instance.dateofacceptance) + ""; // transform to string in case it is an integer
|
299 |
|
|
available.year = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
available.accessMode = new Array<string>();
|
303 |
|
|
available.downloadUrl = new Array<string>();
|
304 |
|
|
available['downloadUrl'].push(url);
|
305 |
|
|
if (instance.hasOwnProperty("accessright")) {
|
306 |
|
|
if (url) {
|
307 |
|
|
available['accessMode'].push(instance['accessright'].classname);
|
308 |
|
|
}
|
309 |
|
|
|
310 |
|
|
if (this.changeBestAccessMode(available.bestAccessMode, instance['accessright'])) {
|
311 |
|
|
available.bestAccessMode = instance['accessright'].classname;
|
312 |
|
|
/*
|
313 |
|
|
if(title != undefined) {
|
314 |
|
|
if(this.changeBestAccessMode(title['accessMode'], instance['accessright'])) {
|
315 |
|
|
title['accessMode'] = instance['accessright'].classid;
|
316 |
|
|
title['url'] = url;
|
317 |
|
|
}
|
318 |
|
|
}
|
319 |
|
|
*/
|
320 |
|
|
if (this.changeBestAccessMode(accessMode, instance['accessright'])) {
|
321 |
|
|
accessMode = instance['accessright'].classname;
|
322 |
|
|
}
|
323 |
|
|
}
|
324 |
|
|
/*
|
325 |
|
|
if(title != undefined) {
|
326 |
|
|
if(!title['url']) {
|
327 |
|
|
title['url'] = url;
|
328 |
|
|
}
|
329 |
|
|
}
|
330 |
|
|
*/
|
331 |
|
|
} else if (url) {
|
332 |
|
|
available['accessMode'].push("");
|
333 |
|
|
}
|
334 |
59038
|
konstantin
|
|
335 |
|
|
if (available.bestAccessMode) {
|
336 |
|
|
if (available.bestAccessMode.toLowerCase().indexOf('open') !== -1) {
|
337 |
|
|
available.icon = this.open;
|
338 |
|
|
} else if (available.bestAccessMode.toLowerCase().indexOf('not available') !== -1) {
|
339 |
|
|
available.icon = this.unknown;
|
340 |
|
|
} else {
|
341 |
|
|
available.icon = this.closed;
|
342 |
|
|
}
|
343 |
|
|
} else {
|
344 |
|
|
available.icon = this.unknown;
|
345 |
|
|
}
|
346 |
58275
|
k.triantaf
|
|
347 |
|
|
hostedBy_collectedFrom.push(available);
|
348 |
|
|
}
|
349 |
|
|
|
350 |
|
|
return counter;
|
351 |
50169
|
argiro.kok
|
}
|
352 |
58275
|
k.triantaf
|
|
353 |
50169
|
argiro.kok
|
// publication & dataset landing : for downloadFrom and publishedIn
|
354 |
|
|
changeBestAccessMode(currentAccessMode: string, accessMode: any): boolean {
|
355 |
58275
|
k.triantaf
|
if (!accessMode) {
|
356 |
50169
|
argiro.kok
|
return false;
|
357 |
|
|
}
|
358 |
|
|
accessMode = accessMode.classid;
|
359 |
58275
|
k.triantaf
|
|
360 |
50169
|
argiro.kok
|
switch (currentAccessMode) {
|
361 |
|
|
case null:
|
362 |
58275
|
k.triantaf
|
if (accessMode != "UNKNOWN") {
|
363 |
52606
|
konstantin
|
return true;
|
364 |
|
|
}
|
365 |
|
|
return false;
|
366 |
50169
|
argiro.kok
|
case "CLOSED":
|
367 |
58275
|
k.triantaf
|
if (accessMode == "OPEN" ||
|
368 |
|
|
accessMode == "OPEN SOURCE" ||
|
369 |
|
|
accessMode == "EMBARGO" ||
|
370 |
|
|
accessMode == "RESTRICTED") {
|
371 |
|
|
return true;
|
372 |
50169
|
argiro.kok
|
}
|
373 |
|
|
return false;
|
374 |
|
|
case "RESTRICTED":
|
375 |
58275
|
k.triantaf
|
if (accessMode == "OPEN" ||
|
376 |
|
|
accessMode == "OPEN SOURCE" ||
|
377 |
|
|
accessMode == "EMBARGO") {
|
378 |
|
|
return true;
|
379 |
50169
|
argiro.kok
|
}
|
380 |
|
|
return false;
|
381 |
|
|
case "EMBARGO":
|
382 |
58275
|
k.triantaf
|
if (accessMode == "OPEN" ||
|
383 |
|
|
accessMode == "OPEN SOURCE") {
|
384 |
50169
|
argiro.kok
|
return true;
|
385 |
52606
|
konstantin
|
}
|
386 |
|
|
return false;
|
387 |
|
|
case "OPEN SOURCE":
|
388 |
58275
|
k.triantaf
|
if (accessMode == "OPEN") {
|
389 |
52606
|
konstantin
|
return true;
|
390 |
|
|
}
|
391 |
|
|
return false;
|
392 |
50169
|
argiro.kok
|
}
|
393 |
|
|
return false;
|
394 |
|
|
}
|
395 |
58275
|
k.triantaf
|
|
396 |
52828
|
konstantin
|
// publication & dataset & software & orp landing : for relatedResearchResults
|
397 |
58275
|
k.triantaf
|
parseRelatedResearchResults(relatedResearchResults: RelationResult[], relation: any, provenanceAction: string):
|
398 |
|
|
RelationResult[] {
|
399 |
|
|
if (relatedResearchResults == undefined) {
|
400 |
|
|
relatedResearchResults = []
|
401 |
50169
|
argiro.kok
|
}
|
402 |
58275
|
k.triantaf
|
relatedResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "trust", provenanceAction));
|
403 |
50169
|
argiro.kok
|
return relatedResearchResults;
|
404 |
|
|
}
|
405 |
58275
|
k.triantaf
|
|
406 |
57404
|
konstantin
|
// publication & dataset & software & orp landing : for supplementaryResearchResults
|
407 |
58275
|
k.triantaf
|
parseSupplementaryResearchResults(supplementaryResearchResults: RelationResult[], relation: any): RelationResult[] {
|
408 |
|
|
if (supplementaryResearchResults == undefined) {
|
409 |
|
|
supplementaryResearchResults = [];
|
410 |
57404
|
konstantin
|
}
|
411 |
|
|
supplementaryResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "trust"));
|
412 |
|
|
return supplementaryResearchResults;
|
413 |
|
|
}
|
414 |
58275
|
k.triantaf
|
|
415 |
57404
|
konstantin
|
// publication & dataset & software & orp landing : for supplementedByResearchResults
|
416 |
58275
|
k.triantaf
|
parseSupplementedByResearchResults(supplementedByResearchResults: RelationResult[], relation: any): RelationResult[] {
|
417 |
|
|
if (supplementedByResearchResults == undefined) {
|
418 |
|
|
supplementedByResearchResults = [];
|
419 |
57404
|
konstantin
|
}
|
420 |
|
|
supplementedByResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "trust"));
|
421 |
|
|
return supplementedByResearchResults;
|
422 |
|
|
}
|
423 |
58275
|
k.triantaf
|
|
424 |
52828
|
konstantin
|
// publication & dataset & software & orp landing : for similarResearchResults
|
425 |
58275
|
k.triantaf
|
parseSimilarResearchResults(similarResearchResults: RelationResult[], relation: any): RelationResult[] {
|
426 |
|
|
if (similarResearchResults == undefined) {
|
427 |
|
|
similarResearchResults = [];
|
428 |
50169
|
argiro.kok
|
}
|
429 |
52103
|
konstantin
|
similarResearchResults.push(this.parseRelatedOrSimilarResearchResult(relation, "similarity"));
|
430 |
50169
|
argiro.kok
|
return similarResearchResults;
|
431 |
|
|
}
|
432 |
58275
|
k.triantaf
|
|
433 |
52828
|
konstantin
|
// publication & dataset & software & orp landing : for relatedResearchResults and similarResearchResults
|
434 |
58275
|
k.triantaf
|
parseRelatedOrSimilarResearchResult(relation: any, percentageName: string, provenanceAction: string = null): RelationResult {
|
435 |
|
|
let researchResult: RelationResult = {
|
436 |
|
|
name: "",
|
437 |
|
|
id: "",
|
438 |
|
|
date: "",
|
439 |
|
|
percentage: null,
|
440 |
|
|
class: "",
|
441 |
|
|
provenanceAction: provenanceAction
|
442 |
|
|
};
|
443 |
58496
|
argiro.kok
|
if(relation['resulttype']) {
|
444 |
|
|
if (relation['resulttype'].classname == "publication") {
|
445 |
|
|
researchResult['class'] = "publication";
|
446 |
|
|
} else if (relation['resulttype'].classname == "dataset") {
|
447 |
|
|
researchResult['class'] = "dataset";
|
448 |
|
|
} else if (relation['resulttype'].classname == "software") {
|
449 |
|
|
researchResult['class'] = "software";
|
450 |
|
|
} else if (relation['resulttype'].classname == "other") {
|
451 |
|
|
researchResult['class'] = "other";
|
452 |
|
|
}
|
453 |
50169
|
argiro.kok
|
}
|
454 |
|
|
researchResult['id'] = relation['to'].content;
|
455 |
58496
|
argiro.kok
|
let titleName = Array.isArray(relation['title']) ? relation['title'][0].content : (relation['title']?relation['title'].content:null);
|
456 |
50169
|
argiro.kok
|
researchResult['name'] = titleName;
|
457 |
58496
|
argiro.kok
|
if(!researchResult['name']) {
|
458 |
|
|
researchResult['name'] = "[no title available]";
|
459 |
|
|
}
|
460 |
58275
|
k.triantaf
|
if (relation.hasOwnProperty("dateofacceptance")) {
|
461 |
|
|
var date: string = ((Array.isArray(relation.dateofacceptance)) ? (relation.dateofacceptance[0]) : (relation.dateofacceptance)) + ""; // transform to string in case it is an integer
|
462 |
|
|
researchResult['date'] = (date && (date).indexOf('-') !== -1) ? date.split('-')[0] : date;
|
463 |
52606
|
konstantin
|
}
|
464 |
50169
|
argiro.kok
|
//researchResult['date'] = relation.dateofacceptance.substring(0,4);;
|
465 |
58275
|
k.triantaf
|
researchResult['percentage'] = Math.round(relation[percentageName] * 100);
|
466 |
50169
|
argiro.kok
|
return researchResult;
|
467 |
|
|
}
|
468 |
58275
|
k.triantaf
|
|
469 |
|
|
sortByPercentage(results: RelationResult[]): RelationResult[] {
|
470 |
|
|
if (results) {
|
471 |
|
|
return results.sort(function (a, b) {
|
472 |
|
|
return b["percentage"] - a["percentage"]
|
473 |
|
|
});
|
474 |
52115
|
konstantin
|
}
|
475 |
|
|
return results;
|
476 |
|
|
}
|
477 |
58275
|
k.triantaf
|
|
478 |
50169
|
argiro.kok
|
// publication & dataset landing : for identifiers
|
479 |
|
|
parseIdentifiers(pid: any): Map<string, string[]> {
|
480 |
|
|
let identifiers = new Map<string, string[]>();
|
481 |
58275
|
k.triantaf
|
|
482 |
59087
|
konstantin
|
if (pid.hasOwnProperty("classid") && pid['classid'] != "") {
|
483 |
|
|
if (pid.classid == "doi" || pid.classid == "pmc" || pid.classid == "handle" || pid.classid == "pmid") {
|
484 |
|
|
if (!identifiers.has(pid.classid)) {
|
485 |
|
|
identifiers.set(pid.classid, new Array<string>());
|
486 |
50169
|
argiro.kok
|
}
|
487 |
58275
|
k.triantaf
|
|
488 |
59087
|
konstantin
|
identifiers.get(pid.classid).push(pid.content);
|
489 |
50169
|
argiro.kok
|
}
|
490 |
|
|
} else {
|
491 |
58275
|
k.triantaf
|
for (let i = 0; i < pid.length; i++) {
|
492 |
59087
|
konstantin
|
if (pid[i].classid == "doi" || pid[i].classid == "pmc" || pid[i].classid == "handle" || pid[i].classid == "pmid") {
|
493 |
|
|
if (!identifiers.has(pid[i].classid)) {
|
494 |
|
|
identifiers.set(pid[i].classid, new Array<string>());
|
495 |
50169
|
argiro.kok
|
}
|
496 |
59087
|
konstantin
|
identifiers.get(pid[i].classid).push(pid[i].content);
|
497 |
50169
|
argiro.kok
|
}
|
498 |
|
|
}
|
499 |
|
|
}
|
500 |
|
|
return identifiers;
|
501 |
|
|
}
|
502 |
58275
|
k.triantaf
|
|
503 |
50169
|
argiro.kok
|
// publication & dataset landing : for subjects and otherSubjects and classifiedSubjects
|
504 |
|
|
parseAllSubjects(_subjects: any): [string[], Map<string, string[]>, Map<string, string[]>] {
|
505 |
|
|
let subjects: string[];
|
506 |
|
|
let otherSubjects: Map<string, string[]>;
|
507 |
|
|
let classifiedSubjects: Map<string, string[]>;
|
508 |
58275
|
k.triantaf
|
|
509 |
50169
|
argiro.kok
|
let subject;
|
510 |
|
|
let length = Array.isArray(_subjects) ? _subjects.length : 1;
|
511 |
58275
|
k.triantaf
|
|
512 |
|
|
for (let i = 0; i < length; i++) {
|
513 |
50169
|
argiro.kok
|
subject = Array.isArray(_subjects) ? _subjects[i] : _subjects;
|
514 |
58275
|
k.triantaf
|
if (subject.classid != "") {
|
515 |
|
|
if (subject.inferred && subject.inferred == true) {
|
516 |
|
|
if (classifiedSubjects == undefined) {
|
517 |
50169
|
argiro.kok
|
classifiedSubjects = new Map<string, string[]>();
|
518 |
|
|
}
|
519 |
58275
|
k.triantaf
|
|
520 |
|
|
if (!classifiedSubjects.has(subject.classname)) {
|
521 |
50169
|
argiro.kok
|
classifiedSubjects.set(subject.classname, new Array<string>());
|
522 |
|
|
}
|
523 |
58275
|
k.triantaf
|
|
524 |
50169
|
argiro.kok
|
classifiedSubjects.get(subject.classname).push(subject.content);
|
525 |
|
|
} else {
|
526 |
58275
|
k.triantaf
|
if (subject.classid == "keyword") {
|
527 |
|
|
if (subjects == undefined) {
|
528 |
50169
|
argiro.kok
|
subjects = new Array<string>();
|
529 |
|
|
}
|
530 |
58275
|
k.triantaf
|
|
531 |
50169
|
argiro.kok
|
subjects.push(subject.content);
|
532 |
|
|
} else {
|
533 |
58275
|
k.triantaf
|
if (otherSubjects == undefined) {
|
534 |
50169
|
argiro.kok
|
otherSubjects = new Map<string, string[]>();
|
535 |
|
|
}
|
536 |
58275
|
k.triantaf
|
|
537 |
|
|
if (!otherSubjects.has(subject.classname)) {
|
538 |
50169
|
argiro.kok
|
otherSubjects.set(subject.classname, new Array<string>());
|
539 |
|
|
}
|
540 |
|
|
otherSubjects.get(subject.classname).push(subject.content);
|
541 |
|
|
}
|
542 |
|
|
}
|
543 |
|
|
}
|
544 |
|
|
}
|
545 |
|
|
return [subjects, otherSubjects, classifiedSubjects];
|
546 |
|
|
}
|
547 |
58275
|
k.triantaf
|
|
548 |
|
|
parseContexts(_contexts: any): {
|
549 |
60780
|
konstantin
|
"labelContext": string, "idContext": string,
|
550 |
|
|
"labelCategory": string, "idCategory": string,
|
551 |
61002
|
argiro.kok
|
"labelConcept": string, "idConcept": string
|
552 |
58275
|
k.triantaf
|
}[] {
|
553 |
|
|
let contexts = new Array<{
|
554 |
60780
|
konstantin
|
"labelContext": string, "idContext": string,
|
555 |
|
|
"labelCategory": string, "idCategory": string,
|
556 |
61002
|
argiro.kok
|
"labelConcept": string, "idConcept": string
|
557 |
58275
|
k.triantaf
|
}>();
|
558 |
|
|
|
559 |
50169
|
argiro.kok
|
let position = 0;
|
560 |
|
|
let labels = "";
|
561 |
|
|
let context;
|
562 |
|
|
let length = Array.isArray(_contexts) ? _contexts.length : 1;
|
563 |
58275
|
k.triantaf
|
for (let i = 0; i < length; i++) {
|
564 |
50169
|
argiro.kok
|
context = Array.isArray(_contexts) ? _contexts[i] : _contexts;
|
565 |
58275
|
k.triantaf
|
|
566 |
|
|
if (context.hasOwnProperty("type") && (context['type'] == "community" || context['type'] == "ri")) {
|
567 |
|
|
if (context.hasOwnProperty("category")) {
|
568 |
56937
|
konstantin
|
let category;
|
569 |
|
|
let length2 = Array.isArray(context['category']) ? context['category'].length : 1;
|
570 |
|
|
for (let z = 0; z < length2; z++) {
|
571 |
|
|
category = Array.isArray(context['category']) ? context['category'][z] : context['category'];
|
572 |
|
|
if (category.hasOwnProperty("concept")) {
|
573 |
|
|
let categoryConcept;
|
574 |
|
|
let length1 = Array.isArray(category['concept']) ? category['concept'].length : 1;
|
575 |
|
|
for (let j = 0; j < length1; j++) {
|
576 |
|
|
categoryConcept = Array.isArray(category['concept']) ? category['concept'][j] : category['concept'];
|
577 |
58275
|
k.triantaf
|
|
578 |
60780
|
konstantin
|
contexts[position] = {"labelContext": "", "idContext": "",
|
579 |
|
|
"labelCategory": "", "idCategory": "",
|
580 |
61002
|
argiro.kok
|
"labelConcept": "", "idConcept": ""};
|
581 |
56937
|
konstantin
|
contexts[position]['labelContext'] = context.label;
|
582 |
60780
|
konstantin
|
contexts[position]['idContext'] = context.id;
|
583 |
56937
|
konstantin
|
contexts[position]['labelCategory'] = category.label;
|
584 |
60780
|
konstantin
|
contexts[position]['idCategory'] = category.id;
|
585 |
56937
|
konstantin
|
contexts[position]['labelConcept'] = categoryConcept.label;
|
586 |
60780
|
konstantin
|
contexts[position]['idConcept'] = categoryConcept.id;
|
587 |
|
|
|
588 |
56937
|
konstantin
|
position++;
|
589 |
|
|
}
|
590 |
|
|
} else {
|
591 |
60780
|
konstantin
|
contexts[position] = {"labelContext": "", "idContext": "",
|
592 |
|
|
"labelCategory": "", "idCategory": "",
|
593 |
61002
|
argiro.kok
|
"labelConcept": "", "idConcept": ""};
|
594 |
50169
|
argiro.kok
|
contexts[position]['labelContext'] = context.label;
|
595 |
60780
|
konstantin
|
contexts[position]['idContext'] = context.id;
|
596 |
56937
|
konstantin
|
contexts[position]['labelCategory'] = category.label;
|
597 |
60780
|
konstantin
|
contexts[position]['idCategory'] = category.id;
|
598 |
56937
|
konstantin
|
contexts[position]['labelConcept'] = null;
|
599 |
60780
|
konstantin
|
contexts[position]['idConcept'] = null;
|
600 |
50169
|
argiro.kok
|
position++;
|
601 |
|
|
}
|
602 |
|
|
}
|
603 |
57082
|
konstantin
|
} else {
|
604 |
60780
|
konstantin
|
contexts[position] = {"labelContext": "", "idContext": "",
|
605 |
|
|
"labelCategory": "", "idCategory": "",
|
606 |
61002
|
argiro.kok
|
"labelConcept": "", "idConcept": ""};
|
607 |
57082
|
konstantin
|
contexts[position]['labelContext'] = context.label;
|
608 |
60780
|
konstantin
|
contexts[position]['idContext'] = context.id;
|
609 |
57082
|
konstantin
|
contexts[position]['labelCategory'] = null;
|
610 |
60780
|
konstantin
|
contexts[position]['idCategory'] = null;
|
611 |
57082
|
konstantin
|
contexts[position]['labelConcept'] = null;
|
612 |
60780
|
konstantin
|
contexts[position]['idConcept'] = null;
|
613 |
57082
|
konstantin
|
contexts[position]['new'] = false;
|
614 |
|
|
position++;
|
615 |
50169
|
argiro.kok
|
}
|
616 |
|
|
}
|
617 |
|
|
}
|
618 |
|
|
return contexts;
|
619 |
|
|
}
|
620 |
60783
|
argiro.kok
|
public static getEnermapsConceptId(contexts: any): string{
|
621 |
60814
|
argiro.kok
|
// let enermapsconcepts = contexts.filter(c=> {return c.idCategory == "enermaps::selection" && c.idConcept});
|
622 |
|
|
// return enermapsconcepts && enermapsconcepts.length > 0?enermapsconcepts[0].idConcept.split("enermaps::selection::")[1]:null;
|
623 |
|
|
return "hotmaps_heat_tot_curr_density"
|
624 |
60783
|
argiro.kok
|
}
|
625 |
50169
|
argiro.kok
|
parseTypes(types: string[], uniqueTypes: Set<string>, instance: any) {
|
626 |
59223
|
argiro.kok
|
if (instance && instance.hasOwnProperty("instancetype") && instance['instancetype'].classname) {
|
627 |
58275
|
k.triantaf
|
if (!uniqueTypes.has(instance['instancetype'].classname)) {
|
628 |
50169
|
argiro.kok
|
types.push(instance['instancetype'].classname);
|
629 |
|
|
uniqueTypes.add(instance['instancetype'].classname);
|
630 |
|
|
}
|
631 |
|
|
}
|
632 |
|
|
}
|
633 |
58275
|
k.triantaf
|
|
634 |
50728
|
konstantin
|
parseLanguages(_languages: any) {
|
635 |
|
|
var languages = new Array<string>();
|
636 |
60780
|
konstantin
|
|
637 |
58275
|
k.triantaf
|
if (!Array.isArray(_languages)) {
|
638 |
|
|
if (_languages.classname != "Undetermined" && _languages.classname) {
|
639 |
50728
|
konstantin
|
languages.push(_languages.classname);
|
640 |
|
|
}
|
641 |
|
|
} else {
|
642 |
58275
|
k.triantaf
|
for (let i = 0; i < _languages.length; i++) {
|
643 |
|
|
if (_languages[i].classname != "Undetermined" && _languages[i].classname) {
|
644 |
50728
|
konstantin
|
languages.push(_languages[i].classname);
|
645 |
|
|
}
|
646 |
|
|
}
|
647 |
|
|
}
|
648 |
|
|
return languages;
|
649 |
|
|
}
|
650 |
58275
|
k.triantaf
|
|
651 |
52606
|
konstantin
|
parseCountries(_countries: any) {
|
652 |
|
|
var countries = new Array<string>();
|
653 |
58275
|
k.triantaf
|
|
654 |
|
|
if (!Array.isArray(_countries)) {
|
655 |
|
|
if (_countries.classname != "Undetermined" && _countries.classname) {
|
656 |
52606
|
konstantin
|
countries.push(_countries.classname);
|
657 |
|
|
}
|
658 |
|
|
} else {
|
659 |
58275
|
k.triantaf
|
for (let i = 0; i < countries.length; i++) {
|
660 |
|
|
if (_countries[i].classname != "Undetermined" && _countries[i].classname) {
|
661 |
52606
|
konstantin
|
countries.push(_countries[i].classname);
|
662 |
|
|
}
|
663 |
|
|
}
|
664 |
|
|
}
|
665 |
|
|
return countries;
|
666 |
|
|
}
|
667 |
58275
|
k.triantaf
|
|
668 |
52606
|
konstantin
|
parseProgrammingLanguages(_pLanguages) {
|
669 |
|
|
var pLanguages = new Array<string>();
|
670 |
58275
|
k.triantaf
|
|
671 |
|
|
if (!Array.isArray(_pLanguages)) {
|
672 |
|
|
if (_pLanguages.classname != "Undetermined" && _pLanguages.classname) {
|
673 |
52606
|
konstantin
|
pLanguages.push(_pLanguages.classname);
|
674 |
|
|
}
|
675 |
|
|
} else {
|
676 |
58275
|
k.triantaf
|
for (let i = 0; i < _pLanguages.length; i++) {
|
677 |
|
|
if (_pLanguages[i].classname != "Undetermined" && _pLanguages[i].classname) {
|
678 |
52606
|
konstantin
|
pLanguages.push(_pLanguages[i].classname);
|
679 |
|
|
}
|
680 |
|
|
}
|
681 |
|
|
}
|
682 |
|
|
return pLanguages;
|
683 |
|
|
}
|
684 |
58275
|
k.triantaf
|
|
685 |
58288
|
k.triantaf
|
parseReferences(citations: any): Reference[] {
|
686 |
|
|
let references: Reference[] = [];
|
687 |
|
|
citations = Array.isArray(citations) ? citations : [citations];
|
688 |
|
|
citations.forEach(citation => {
|
689 |
|
|
let reference: Reference = {name: null, ids: []};
|
690 |
|
|
if(citation.rawText) {
|
691 |
|
|
reference.name = citation.rawText;
|
692 |
54905
|
konstantin
|
}
|
693 |
58288
|
k.triantaf
|
if(citation.id) {
|
694 |
|
|
let ids: any[] = Array.isArray(citation.id) ? citation.id : [citation.id];
|
695 |
|
|
ids.forEach(id => {
|
696 |
|
|
reference.ids.push({
|
697 |
|
|
type: id.type,
|
698 |
|
|
value: id.value,
|
699 |
|
|
trust: id.confidenceLevel
|
700 |
|
|
});
|
701 |
|
|
});
|
702 |
|
|
}
|
703 |
|
|
references[citation.position - 1] = reference;
|
704 |
|
|
});
|
705 |
54905
|
konstantin
|
return references;
|
706 |
|
|
}
|
707 |
59293
|
argiro.kok
|
static parseRelCanonicalId(record, type){
|
708 |
|
|
try{
|
709 |
|
|
if(record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"] && record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"][type]){
|
710 |
|
|
for(let child of record["result"]["metadata"]["oaf:entity"][("oaf:"+type)]["children"][type]){
|
711 |
|
|
return child["objidentifier"];
|
712 |
|
|
}
|
713 |
|
|
}
|
714 |
|
|
}catch(e){
|
715 |
|
|
// console.error(e);
|
716 |
|
|
}
|
717 |
|
|
return record["result"]["header"]["dri:objIdentifier"];
|
718 |
|
|
|
719 |
|
|
}
|
720 |
50169
|
argiro.kok
|
}
|