1
|
import { Injectable } from '@angular/core';
|
2
|
import { RawData, Row } from '../domain/raw-data';
|
3
|
import {
|
4
|
CountryOverviewData,
|
5
|
CountryMapData,
|
6
|
EuropeData,
|
7
|
OverviewMapData,
|
8
|
CountryTableData,
|
9
|
CountryPageOverviewData, RnDExpenditure
|
10
|
} from '../domain/overview-map-data';
|
11
|
import {Indicator} from '../domain/overview-data';
|
12
|
import {TreemapHighchartsData} from '../domain/treemap-highcharts-data';
|
13
|
|
14
|
@Injectable ()
|
15
|
export class DataHandlerService {
|
16
|
|
17
|
public convertRawDataToLastUpdateDate(rawData: RawData) {
|
18
|
|
19
|
let lastUpdateDate: string;
|
20
|
|
21
|
for (const series of rawData.datasets) {
|
22
|
|
23
|
if (series.series.query.name === 'creation_date') {
|
24
|
lastUpdateDate = series.series.result[0].row[0];
|
25
|
}
|
26
|
}
|
27
|
|
28
|
return lastUpdateDate;
|
29
|
}
|
30
|
|
31
|
public convertRawMapDataToMapData(rawData: RawData) {
|
32
|
|
33
|
const overviewMapData: OverviewMapData = new OverviewMapData();
|
34
|
|
35
|
for (const series of rawData.datasets) {
|
36
|
|
37
|
if (series.series.query.name === 'oso.results.affiliated' && series.series.query.parameters.includes('publication')) {
|
38
|
overviewMapData.publications = this.rawResultToCountryMapData(series.series.result);
|
39
|
} else if (series.series.query.name === 'oso.results.affiliated' && series.series.query.parameters.includes('dataset')) {
|
40
|
overviewMapData.datasets = this.rawResultToCountryMapData(series.series.result);
|
41
|
} else if (series.series.query.name === 'oso.repositories.doar_re3data') {
|
42
|
overviewMapData.repositories = this.rawResultToCountryMapData(series.series.result);
|
43
|
} else if (series.series.query.name === 'oso.journals.doaj') {
|
44
|
overviewMapData.journals = this.rawResultToCountryMapData(series.series.result);
|
45
|
} else if (series.series.query.name === 'oso.oa_policies') {
|
46
|
overviewMapData.policies = this.rawResultToCountryMapData(series.series.result);
|
47
|
}
|
48
|
}
|
49
|
|
50
|
// console.log('Overview map data (data-handler)', overviewMapData);
|
51
|
|
52
|
return overviewMapData;
|
53
|
}
|
54
|
|
55
|
public createJoinedPublicationsCountryMap(rawData: RawData) {
|
56
|
|
57
|
const joinedPublicationsMap = new Map();
|
58
|
|
59
|
for (const series of rawData.datasets) {
|
60
|
if (series.series.query.name === 'oso.results.affiliated' && series.series.query.parameters.includes('publication')) {
|
61
|
|
62
|
for (const rowResult of series.series.result) {
|
63
|
if (joinedPublicationsMap.has(rowResult.row[1])) {
|
64
|
const deposited = joinedPublicationsMap.get(rowResult.row[1]).deposited;
|
65
|
joinedPublicationsMap.delete(rowResult.row[1]);
|
66
|
joinedPublicationsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
67
|
affiliated: Number(rowResult.row[0]), deposited: deposited});
|
68
|
} else {
|
69
|
joinedPublicationsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
70
|
affiliated: Number(rowResult.row[0]), deposited: 0});
|
71
|
}
|
72
|
}
|
73
|
|
74
|
} else if (series.series.query.name === 'oso.results.deposited' && series.series.query.parameters.includes('publication')) {
|
75
|
|
76
|
for (const rowResult of series.series.result) {
|
77
|
if (joinedPublicationsMap.has(rowResult.row[1])) {
|
78
|
const affiliated = joinedPublicationsMap.get(rowResult.row[1]).affiliated;
|
79
|
joinedPublicationsMap.delete(rowResult.row[1]);
|
80
|
joinedPublicationsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
81
|
affiliated: affiliated, deposited: Number(rowResult.row[0])});
|
82
|
}
|
83
|
joinedPublicationsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
84
|
affiliated: 0, deposited: Number(rowResult.row[0])});
|
85
|
}
|
86
|
}
|
87
|
}
|
88
|
|
89
|
return joinedPublicationsMap;
|
90
|
}
|
91
|
|
92
|
public createJoinedDatasetsCountryMap(rawData: RawData) {
|
93
|
|
94
|
const joinedDatasetsMap = new Map();
|
95
|
|
96
|
for (const series of rawData.datasets) {
|
97
|
if (series.series.query.name === 'oso.results.affiliated' && series.series.query.parameters.includes('dataset')) {
|
98
|
|
99
|
for (const rowResult of series.series.result) {
|
100
|
if (joinedDatasetsMap.has(rowResult.row[1])) {
|
101
|
const deposited = joinedDatasetsMap.get(rowResult.row[1]).deposited;
|
102
|
joinedDatasetsMap.delete(rowResult.row[1]);
|
103
|
joinedDatasetsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
104
|
affiliated: Number(rowResult.row[0]), deposited: deposited});
|
105
|
} else {
|
106
|
joinedDatasetsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
107
|
affiliated: Number(rowResult.row[0]), deposited: 0});
|
108
|
}
|
109
|
}
|
110
|
|
111
|
} else if (series.series.query.name === 'oso.results.deposited' && series.series.query.parameters.includes('dataset')) {
|
112
|
|
113
|
for (const rowResult of series.series.result) {
|
114
|
if (joinedDatasetsMap.has(rowResult.row[1])) {
|
115
|
const affiliated = joinedDatasetsMap.get(rowResult.row[1]).affiliated;
|
116
|
joinedDatasetsMap.delete(rowResult.row[1]);
|
117
|
joinedDatasetsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
118
|
affiliated: affiliated, deposited: Number(rowResult.row[0])});
|
119
|
}
|
120
|
joinedDatasetsMap.set(rowResult.row[1], { countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
121
|
affiliated: 0, deposited: Number(rowResult.row[0])});
|
122
|
}
|
123
|
}
|
124
|
}
|
125
|
|
126
|
return joinedDatasetsMap;
|
127
|
|
128
|
}
|
129
|
|
130
|
public createJoinedRepositoriesCountryMap(rawData: RawData) {
|
131
|
|
132
|
const joinedRepositoriesMap = new Map();
|
133
|
|
134
|
for (const series of rawData.datasets) {
|
135
|
if (series.series.query.name === 'oso.repositories.doar_re3data') {
|
136
|
|
137
|
for (const rowResult of series.series.result) {
|
138
|
if (joinedRepositoriesMap.has(rowResult.row[1])) {
|
139
|
const simple = joinedRepositoriesMap.get(rowResult.row[1]).simple;
|
140
|
joinedRepositoriesMap.delete(rowResult.row[1]);
|
141
|
joinedRepositoriesMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
142
|
doar_re3data: Number(rowResult.row[0]), simple: simple});
|
143
|
} else {
|
144
|
joinedRepositoriesMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
145
|
doar_re3data: Number(rowResult.row[0]), simple: 0});
|
146
|
}
|
147
|
}
|
148
|
|
149
|
} else if (series.series.query.name === 'oso.repositories') {
|
150
|
|
151
|
for (const rowResult of series.series.result) {
|
152
|
if (joinedRepositoriesMap.has(rowResult.row[1])) {
|
153
|
const doar_re3data = joinedRepositoriesMap.get(rowResult.row[1]).doar_re3data;
|
154
|
joinedRepositoriesMap.delete(rowResult.row[1]);
|
155
|
joinedRepositoriesMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
156
|
doar_re3data: doar_re3data, simple: Number(rowResult.row[0])});
|
157
|
}
|
158
|
joinedRepositoriesMap.set(rowResult.row[1], { countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
159
|
doar_re3data: 0, simple: Number(rowResult.row[0])});
|
160
|
}
|
161
|
}
|
162
|
}
|
163
|
|
164
|
return joinedRepositoriesMap;
|
165
|
|
166
|
}
|
167
|
|
168
|
public createJoinedJournalsCountryMap(rawData: RawData) {
|
169
|
|
170
|
const joinedJournalsMap = new Map();
|
171
|
|
172
|
for (const series of rawData.datasets) {
|
173
|
if (series.series.query.name === 'oso.journals.doaj') {
|
174
|
|
175
|
for (const rowResult of series.series.result) {
|
176
|
if (joinedJournalsMap.has(rowResult.row[1])) {
|
177
|
const simple = joinedJournalsMap.get(rowResult.row[1]).simple;
|
178
|
joinedJournalsMap.delete(rowResult.row[1]);
|
179
|
joinedJournalsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
180
|
doaj: Number(rowResult.row[0]), simple: simple});
|
181
|
} else {
|
182
|
joinedJournalsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
183
|
doaj: Number(rowResult.row[0]), simple: 0});
|
184
|
}
|
185
|
}
|
186
|
|
187
|
} else if (series.series.query.name === 'oso.journals') {
|
188
|
|
189
|
for (const rowResult of series.series.result) {
|
190
|
if (joinedJournalsMap.has(rowResult.row[1])) {
|
191
|
const doaj = joinedJournalsMap.get(rowResult.row[1]).doaj;
|
192
|
joinedJournalsMap.delete(rowResult.row[1]);
|
193
|
joinedJournalsMap.set(rowResult.row[1], {countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
194
|
doaj: doaj, simple: Number(rowResult.row[0])});
|
195
|
}
|
196
|
joinedJournalsMap.set(rowResult.row[1], { countryName: rowResult.row[1], countryCode: rowResult.row[2],
|
197
|
doaj: 0, simple: Number(rowResult.row[0])});
|
198
|
}
|
199
|
}
|
200
|
}
|
201
|
|
202
|
return joinedJournalsMap;
|
203
|
|
204
|
}
|
205
|
|
206
|
public convertRawDataToCountryOverviewData(rawData: RawData) {
|
207
|
|
208
|
const countryData: CountryOverviewData = new CountryOverviewData();
|
209
|
|
210
|
for (const series of rawData.datasets) {
|
211
|
|
212
|
if (series.series.query.name === 'oso.results.affiliated.country' && series.series.query.parameters.includes('publication')) {
|
213
|
countryData.publicationsAffiliated = Number(series.series.result[0].row[0]);
|
214
|
} else if (series.series.query.name === 'oso.results.deposited.country' && series.series.query.parameters.includes('publication')) {
|
215
|
countryData.publicationsDeposited = Number(series.series.result[0].row[0]);
|
216
|
} else if (series.series.query.name === 'oso.results.affiliated.country' && series.series.query.parameters.includes('dataset')) {
|
217
|
countryData.datasetsAffiliated = Number(series.series.result[0].row[0]);
|
218
|
} else if (series.series.query.name === 'oso.results.deposited.country' && series.series.query.parameters.includes('dataset')) {
|
219
|
countryData.datasetsDeposited = Number(series.series.result[0].row[0]);
|
220
|
} else if (series.series.query.name === 'oso.repositories.doar_re3data.country') {
|
221
|
countryData.repositories = Number(series.series.result[0].row[0]);
|
222
|
} else if (series.series.query.name === 'oso.journals.doaj.country') {
|
223
|
countryData.journals = Number(series.series.result[0].row[0]);
|
224
|
} else if (series.series.query.name === 'oso.oa_policies.country') {
|
225
|
countryData.policies = Number(series.series.result[0].row[0]);
|
226
|
}
|
227
|
}
|
228
|
|
229
|
return countryData;
|
230
|
}
|
231
|
|
232
|
public convertRawDataToEuropeOverviewData(rawData: RawData) {
|
233
|
|
234
|
const europeData: EuropeData = new EuropeData();
|
235
|
|
236
|
for (const series of rawData.datasets) {
|
237
|
|
238
|
if (series.series.query.name === 'oso.results.oa_percentage' && series.series.query.parameters.includes('publication')) {
|
239
|
|
240
|
const publicationsIndicator: Indicator = new Indicator();
|
241
|
publicationsIndicator.percentage = Number(series.series.result[0].row[0]);
|
242
|
publicationsIndicator.oa = Number(series.series.result[0].row[1]);
|
243
|
publicationsIndicator.total = Number(series.series.result[0].row[2]);
|
244
|
europeData.publications = publicationsIndicator;
|
245
|
|
246
|
} else if (series.series.query.name === 'oso.results.oa_percentage' && series.series.query.parameters.includes('dataset')) {
|
247
|
|
248
|
const datasetsIndicator: Indicator = new Indicator();
|
249
|
datasetsIndicator.percentage = Number(series.series.result[0].row[0]);
|
250
|
datasetsIndicator.oa = Number(series.series.result[0].row[1]);
|
251
|
datasetsIndicator.total = Number(series.series.result[0].row[2]);
|
252
|
europeData.datasets = datasetsIndicator;
|
253
|
|
254
|
} else if (series.series.query.name === 'oso.results.oa_percentage' && series.series.query.parameters.includes('software')) {
|
255
|
|
256
|
const softwareIndicator: Indicator = new Indicator();
|
257
|
softwareIndicator.percentage = Number(series.series.result[0].row[0]);
|
258
|
softwareIndicator.oa = Number(series.series.result[0].row[1]);
|
259
|
softwareIndicator.total = Number(series.series.result[0].row[2]);
|
260
|
europeData.software = softwareIndicator;
|
261
|
|
262
|
} else if (series.series.query.name === 'oso.results.oa_percentage' && series.series.query.parameters.includes('other')) {
|
263
|
|
264
|
const otherIndicator: Indicator = new Indicator();
|
265
|
otherIndicator.percentage = Number(series.series.result[0].row[0]);
|
266
|
otherIndicator.oa = Number(series.series.result[0].row[1]);
|
267
|
otherIndicator.total = Number(series.series.result[0].row[2]);
|
268
|
europeData.other = otherIndicator;
|
269
|
|
270
|
} else if (series.series.query.name === 'oso.repositories.doar_re3data.validated') {
|
271
|
|
272
|
const repositoriesIndicator: Indicator = new Indicator();
|
273
|
repositoriesIndicator.percentage = Number(series.series.result[0].row[0]);
|
274
|
repositoriesIndicator.oa = Number(series.series.result[0].row[1]);
|
275
|
repositoriesIndicator.total = Number(series.series.result[0].row[2]);
|
276
|
europeData.repositories = repositoriesIndicator;
|
277
|
|
278
|
} else if (series.series.query.name === 'oso.journals.doaj.validated') {
|
279
|
|
280
|
const journalsIndicator: Indicator = new Indicator();
|
281
|
journalsIndicator.percentage = Number(series.series.result[0].row[0]);
|
282
|
journalsIndicator.oa = Number(series.series.result[0].row[1]);
|
283
|
journalsIndicator.total = Number(series.series.result[0].row[2]);
|
284
|
europeData.journals = journalsIndicator;
|
285
|
|
286
|
} else if (series.series.query.name === 'oso.oa_policies.europe') {
|
287
|
|
288
|
const policiesIndicator: Indicator = new Indicator();
|
289
|
policiesIndicator.percentage = Number(series.series.result[0].row[0]);
|
290
|
policiesIndicator.oa = Number(series.series.result[0].row[1]);
|
291
|
policiesIndicator.total = Number(series.series.result[0].row[2]);
|
292
|
europeData.policies = policiesIndicator;
|
293
|
|
294
|
}
|
295
|
}
|
296
|
|
297
|
return europeData;
|
298
|
}
|
299
|
|
300
|
public convertRawDataToAbsoluteTableData(rawData: RawData) {
|
301
|
|
302
|
const mapTableData: Map<string, CountryTableData> = new Map();
|
303
|
|
304
|
for (const series of rawData.datasets) {
|
305
|
|
306
|
if (series.series.query.name.includes('oso.results') && series.series.query.parameters.includes('publication')) {
|
307
|
for (const rowResult of series.series.result) {
|
308
|
|
309
|
// remove unwanted countries
|
310
|
if (this.isCountryToBeRemoved(rowResult.row[2])) {
|
311
|
continue;
|
312
|
}
|
313
|
|
314
|
if (mapTableData.has(rowResult.row[2])) {
|
315
|
const countryTableData = mapTableData.get(rowResult.row[2]);
|
316
|
countryTableData.publications = Number(rowResult.row[0]);
|
317
|
} else {
|
318
|
const countryTableData: CountryTableData = new CountryTableData();
|
319
|
countryTableData.publications = Number(rowResult.row[0]);
|
320
|
countryTableData.name = rowResult.row[1];
|
321
|
countryTableData.code = rowResult.row[2];
|
322
|
mapTableData.set(rowResult.row[2], countryTableData);
|
323
|
}
|
324
|
}
|
325
|
|
326
|
} else if (series.series.query.name.includes('oso.results') && series.series.query.parameters.includes('dataset')) {
|
327
|
|
328
|
for (const rowResult of series.series.result) {
|
329
|
|
330
|
// remove unwanted countries
|
331
|
if (this.isCountryToBeRemoved(rowResult.row[2])) {
|
332
|
continue;
|
333
|
}
|
334
|
|
335
|
if (mapTableData.has(rowResult.row[2])) {
|
336
|
const countryTableData = mapTableData.get(rowResult.row[2]);
|
337
|
countryTableData.datasets = Number(rowResult.row[0]);
|
338
|
} else {
|
339
|
const countryTableData: CountryTableData = new CountryTableData();
|
340
|
countryTableData.datasets = Number(rowResult.row[0]);
|
341
|
countryTableData.name = rowResult.row[1];
|
342
|
countryTableData.code = rowResult.row[2];
|
343
|
mapTableData.set(rowResult.row[2], countryTableData);
|
344
|
}
|
345
|
}
|
346
|
} else if (series.series.query.name.includes('oso.results') && series.series.query.parameters.includes('software')) {
|
347
|
|
348
|
for (const rowResult of series.series.result) {
|
349
|
|
350
|
// remove unwanted countries
|
351
|
if (this.isCountryToBeRemoved(rowResult.row[2])) {
|
352
|
continue;
|
353
|
}
|
354
|
|
355
|
if (mapTableData.has(rowResult.row[2])) {
|
356
|
const countryTableData = mapTableData.get(rowResult.row[2]);
|
357
|
countryTableData.software = Number(rowResult.row[0]);
|
358
|
} else {
|
359
|
const countryTableData: CountryTableData = new CountryTableData();
|
360
|
countryTableData.software = Number(rowResult.row[0]);
|
361
|
countryTableData.name = rowResult.row[1];
|
362
|
countryTableData.code = rowResult.row[2];
|
363
|
mapTableData.set(rowResult.row[2], countryTableData);
|
364
|
}
|
365
|
}
|
366
|
} else if (series.series.query.name.includes('oso.results') && series.series.query.parameters.includes('other')) {
|
367
|
|
368
|
for (const rowResult of series.series.result) {
|
369
|
|
370
|
// remove unwanted countries
|
371
|
if (this.isCountryToBeRemoved(rowResult.row[2])) {
|
372
|
continue;
|
373
|
}
|
374
|
|
375
|
if (mapTableData.has(rowResult.row[2])) {
|
376
|
const countryTableData = mapTableData.get(rowResult.row[2]);
|
377
|
countryTableData.other = Number(rowResult.row[0]);
|
378
|
} else {
|
379
|
const countryTableData: CountryTableData = new CountryTableData();
|
380
|
countryTableData.other = Number(rowResult.row[0]);
|
381
|
countryTableData.name = rowResult.row[1];
|
382
|
countryTableData.code = rowResult.row[2];
|
383
|
mapTableData.set(rowResult.row[2], countryTableData);
|
384
|
}
|
385
|
}
|
386
|
} else if (series.series.query.name.includes('oso.repositories')) {
|
387
|
|
388
|
for (const rowResult of series.series.result) {
|
389
|
|
390
|
// remove unwanted countries
|
391
|
if (this.isCountryToBeRemoved(rowResult.row[2])) {
|
392
|
continue;
|
393
|
}
|
394
|
|
395
|
if (mapTableData.has(rowResult.row[2])) {
|
396
|
const countryTableData = mapTableData.get(rowResult.row[2]);
|
397
|
countryTableData.repositories = Number(rowResult.row[0]);
|
398
|
} else {
|
399
|
const countryTableData: CountryTableData = new CountryTableData();
|
400
|
countryTableData.repositories = Number(rowResult.row[0]);
|
401
|
countryTableData.name = rowResult.row[1];
|
402
|
countryTableData.code = rowResult.row[2];
|
403
|
mapTableData.set(rowResult.row[2], countryTableData);
|
404
|
}
|
405
|
}
|
406
|
} else if (series.series.query.name.includes('oso.journals')) {
|
407
|
|
408
|
for (const rowResult of series.series.result) {
|
409
|
|
410
|
// remove unwanted countries
|
411
|
if (this.isCountryToBeRemoved(rowResult.row[2])) {
|
412
|
continue;
|
413
|
}
|
414
|
|
415
|
if (mapTableData.has(rowResult.row[2])) {
|
416
|
const countryTableData = mapTableData.get(rowResult.row[2]);
|
417
|
countryTableData.journals = Number(rowResult.row[0]);
|
418
|
} else {
|
419
|
const countryTableData: CountryTableData = new CountryTableData();
|
420
|
countryTableData.journals = Number(rowResult.row[0]);
|
421
|
countryTableData.name = rowResult.row[1];
|
422
|
countryTableData.code = rowResult.row[2];
|
423
|
mapTableData.set(rowResult.row[2], countryTableData);
|
424
|
}
|
425
|
}
|
426
|
}
|
427
|
}
|
428
|
|
429
|
const tableData: CountryTableData[] = [];
|
430
|
|
431
|
mapTableData.forEach((value: CountryTableData, key: string) => {
|
432
|
// console.log(key, value);
|
433
|
tableData.push(value);
|
434
|
});
|
435
|
|
436
|
return tableData;
|
437
|
}
|
438
|
|
439
|
public convertRawDataToPercentageTableData(rawData: RawData) {
|
440
|
|
441
|
const mapTableData: Map<string, CountryTableData> = new Map();
|
442
|
|
443
|
for (const series of rawData.datasets) {
|
444
|
|
445
|
if (series.series.query.name.includes('oso.results')
|
446
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'publication') {
|
447
|
for (const rowResult of series.series.result) {
|
448
|
|
449
|
// remove unwanted countries
|
450
|
if (this.isCountryToBeRemoved(rowResult.row[4])) {
|
451
|
continue;
|
452
|
}
|
453
|
|
454
|
if (mapTableData.has(rowResult.row[4])) {
|
455
|
const countryTableData = mapTableData.get(rowResult.row[4]);
|
456
|
if (rowResult.row[0] !== 'NaN') {
|
457
|
countryTableData.publications = Number(rowResult.row[0]);
|
458
|
}
|
459
|
} else {
|
460
|
const countryTableData: CountryTableData = new CountryTableData();
|
461
|
if (rowResult.row[0] !== 'NaN') {
|
462
|
countryTableData.publications = Number(rowResult.row[0]);
|
463
|
}
|
464
|
countryTableData.name = rowResult.row[3];
|
465
|
countryTableData.code = rowResult.row[4];
|
466
|
mapTableData.set(rowResult.row[4], countryTableData);
|
467
|
}
|
468
|
}
|
469
|
|
470
|
} else if (series.series.query.name.includes('oso.results')
|
471
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'dataset') {
|
472
|
|
473
|
for (const rowResult of series.series.result) {
|
474
|
|
475
|
// remove unwanted countries
|
476
|
if (this.isCountryToBeRemoved(rowResult.row[4])) {
|
477
|
continue;
|
478
|
}
|
479
|
|
480
|
if (mapTableData.has(rowResult.row[4])) {
|
481
|
const countryTableData = mapTableData.get(rowResult.row[4]);
|
482
|
if (rowResult.row[0] !== 'NaN') {
|
483
|
countryTableData.datasets = Number(rowResult.row[0]);
|
484
|
}
|
485
|
} else {
|
486
|
const countryTableData: CountryTableData = new CountryTableData();
|
487
|
if (rowResult.row[0] !== 'NaN') {
|
488
|
countryTableData.datasets = Number(rowResult.row[0]);
|
489
|
}
|
490
|
countryTableData.name = rowResult.row[3];
|
491
|
countryTableData.code = rowResult.row[4];
|
492
|
mapTableData.set(rowResult.row[4], countryTableData);
|
493
|
}
|
494
|
}
|
495
|
} else if (series.series.query.name.includes('oso.results')
|
496
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'software') {
|
497
|
|
498
|
for (const rowResult of series.series.result) {
|
499
|
|
500
|
// remove unwanted countries
|
501
|
if (this.isCountryToBeRemoved(rowResult.row[4])) {
|
502
|
continue;
|
503
|
}
|
504
|
|
505
|
if (mapTableData.has(rowResult.row[4])) {
|
506
|
const countryTableData = mapTableData.get(rowResult.row[4]);
|
507
|
if (rowResult.row[0] !== 'NaN') {
|
508
|
countryTableData.software = Number(rowResult.row[0]);
|
509
|
}
|
510
|
} else {
|
511
|
const countryTableData: CountryTableData = new CountryTableData();
|
512
|
if (rowResult.row[0] !== 'NaN') {
|
513
|
countryTableData.software = Number(rowResult.row[0]);
|
514
|
}
|
515
|
countryTableData.name = rowResult.row[3];
|
516
|
countryTableData.code = rowResult.row[4];
|
517
|
mapTableData.set(rowResult.row[4], countryTableData);
|
518
|
}
|
519
|
}
|
520
|
} else if (series.series.query.name.includes('oso.results')
|
521
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'other') {
|
522
|
|
523
|
for (const rowResult of series.series.result) {
|
524
|
|
525
|
// remove unwanted countries
|
526
|
if (this.isCountryToBeRemoved(rowResult.row[4])) {
|
527
|
continue;
|
528
|
}
|
529
|
|
530
|
if (mapTableData.has(rowResult.row[4])) {
|
531
|
const countryTableData = mapTableData.get(rowResult.row[4]);
|
532
|
if (rowResult.row[0] !== 'NaN') {
|
533
|
countryTableData.other = Number(rowResult.row[0]);
|
534
|
}
|
535
|
} else {
|
536
|
const countryTableData: CountryTableData = new CountryTableData();
|
537
|
if (rowResult.row[0] !== 'NaN') {
|
538
|
countryTableData.other = Number(rowResult.row[0]);
|
539
|
}
|
540
|
countryTableData.name = rowResult.row[3];
|
541
|
countryTableData.code = rowResult.row[4];
|
542
|
mapTableData.set(rowResult.row[4], countryTableData);
|
543
|
}
|
544
|
}
|
545
|
} else if (series.series.query.name.includes('oso.repositories')) {
|
546
|
|
547
|
for (const rowResult of series.series.result) {
|
548
|
|
549
|
// remove unwanted countries
|
550
|
if (this.isCountryToBeRemoved(rowResult.row[4])) {
|
551
|
continue;
|
552
|
}
|
553
|
|
554
|
if (mapTableData.has(rowResult.row[4])) {
|
555
|
const countryTableData = mapTableData.get(rowResult.row[4]);
|
556
|
countryTableData.repositories = Number(rowResult.row[0]);
|
557
|
} else {
|
558
|
const countryTableData: CountryTableData = new CountryTableData();
|
559
|
countryTableData.repositories = Number(rowResult.row[0]);
|
560
|
countryTableData.name = rowResult.row[3];
|
561
|
countryTableData.code = rowResult.row[4];
|
562
|
mapTableData.set(rowResult.row[4], countryTableData);
|
563
|
}
|
564
|
}
|
565
|
} else if (series.series.query.name.includes('oso.journals')) {
|
566
|
|
567
|
for (const rowResult of series.series.result) {
|
568
|
|
569
|
// remove unwanted countries
|
570
|
if (this.isCountryToBeRemoved(rowResult.row[4])) {
|
571
|
continue;
|
572
|
}
|
573
|
|
574
|
if (mapTableData.has(rowResult.row[4])) {
|
575
|
const countryTableData = mapTableData.get(rowResult.row[4]);
|
576
|
countryTableData.journals = Number(rowResult.row[0]);
|
577
|
} else {
|
578
|
const countryTableData: CountryTableData = new CountryTableData();
|
579
|
countryTableData.journals = Number(rowResult.row[0]);
|
580
|
countryTableData.name = rowResult.row[3];
|
581
|
countryTableData.code = rowResult.row[4];
|
582
|
mapTableData.set(rowResult.row[4], countryTableData);
|
583
|
}
|
584
|
}
|
585
|
}
|
586
|
}
|
587
|
|
588
|
const tableData: CountryTableData[] = [];
|
589
|
|
590
|
mapTableData.forEach((value: CountryTableData, key: string) => {
|
591
|
// console.log(key, value);
|
592
|
tableData.push(value);
|
593
|
});
|
594
|
|
595
|
return tableData;
|
596
|
}
|
597
|
|
598
|
public convertRawDataToIndicatorsTableData(rawData: RawData) {
|
599
|
|
600
|
const mapTableData: Map<string, CountryTableData> = new Map();
|
601
|
|
602
|
for (const series of rawData.datasets) {
|
603
|
|
604
|
if (series.series.query.name.includes('oso.results.pid_percentage')) {
|
605
|
for (const rowResult of series.series.result) {
|
606
|
|
607
|
const pidIndicator = new Indicator();
|
608
|
|
609
|
// remove unwanted countries
|
610
|
if (this.isCountryToBeRemoved(rowResult.row[3])) {
|
611
|
continue;
|
612
|
}
|
613
|
|
614
|
if (mapTableData.has(rowResult.row[3])) {
|
615
|
const countryTableData = mapTableData.get(rowResult.row[3]);
|
616
|
if (rowResult.row[0] !== 'NaN') {
|
617
|
pidIndicator.total = Number(rowResult.row[2]);
|
618
|
pidIndicator.oa = Number(rowResult.row[1]);
|
619
|
pidIndicator.percentage = Number(rowResult.row[0]);
|
620
|
countryTableData.pid = pidIndicator;
|
621
|
}
|
622
|
} else {
|
623
|
const countryTableData: CountryTableData = new CountryTableData();
|
624
|
if (rowResult.row[0] !== 'NaN') {
|
625
|
pidIndicator.total = Number(rowResult.row[2]);
|
626
|
pidIndicator.oa = Number(rowResult.row[1]);
|
627
|
pidIndicator.percentage = Number(rowResult.row[0]);
|
628
|
countryTableData.pid = pidIndicator;
|
629
|
}
|
630
|
countryTableData.name = rowResult.row[4];
|
631
|
countryTableData.code = rowResult.row[3];
|
632
|
mapTableData.set(rowResult.row[3], countryTableData);
|
633
|
}
|
634
|
}
|
635
|
|
636
|
} else if (series.series.query.name.includes('oso.results.licence_percentage')) {
|
637
|
|
638
|
for (const rowResult of series.series.result) {
|
639
|
|
640
|
const licenceIndicator = new Indicator();
|
641
|
|
642
|
// remove unwanted countries
|
643
|
if (this.isCountryToBeRemoved(rowResult.row[3])) {
|
644
|
continue;
|
645
|
}
|
646
|
|
647
|
if (mapTableData.has(rowResult.row[3])) {
|
648
|
const countryTableData = mapTableData.get(rowResult.row[3]);
|
649
|
if (rowResult.row[0] !== 'NaN') {
|
650
|
licenceIndicator.total = Number(rowResult.row[2]);
|
651
|
licenceIndicator.oa = Number(rowResult.row[1]);
|
652
|
licenceIndicator.percentage = Number(rowResult.row[0]);
|
653
|
countryTableData.licence = licenceIndicator;
|
654
|
}
|
655
|
} else {
|
656
|
const countryTableData: CountryTableData = new CountryTableData();
|
657
|
if (rowResult.row[0] !== 'NaN') {
|
658
|
licenceIndicator.total = Number(rowResult.row[2]);
|
659
|
licenceIndicator.oa = Number(rowResult.row[1]);
|
660
|
licenceIndicator.percentage = Number(rowResult.row[0]);
|
661
|
countryTableData.licence = licenceIndicator;
|
662
|
}
|
663
|
countryTableData.name = rowResult.row[4];
|
664
|
countryTableData.code = rowResult.row[3];
|
665
|
mapTableData.set(rowResult.row[3], countryTableData);
|
666
|
}
|
667
|
}
|
668
|
} else if (series.series.query.name.includes('oso.results.green_percentage')) {
|
669
|
|
670
|
for (const rowResult of series.series.result) {
|
671
|
|
672
|
const greenIndicator = new Indicator();
|
673
|
|
674
|
// remove unwanted countries
|
675
|
if (this.isCountryToBeRemoved(rowResult.row[3])) {
|
676
|
continue;
|
677
|
}
|
678
|
|
679
|
if (mapTableData.has(rowResult.row[3])) {
|
680
|
const countryTableData = mapTableData.get(rowResult.row[3]);
|
681
|
if (rowResult.row[0] !== 'NaN') {
|
682
|
greenIndicator.total = Number(rowResult.row[2]);
|
683
|
greenIndicator.oa = Number(rowResult.row[1]);
|
684
|
greenIndicator.percentage = Number(rowResult.row[0]);
|
685
|
countryTableData.green = greenIndicator;
|
686
|
}
|
687
|
} else {
|
688
|
const countryTableData: CountryTableData = new CountryTableData();
|
689
|
if (rowResult.row[0] !== 'NaN') {
|
690
|
greenIndicator.total = Number(rowResult.row[2]);
|
691
|
greenIndicator.oa = Number(rowResult.row[1]);
|
692
|
greenIndicator.percentage = Number(rowResult.row[0]);
|
693
|
countryTableData.green = greenIndicator;
|
694
|
}
|
695
|
countryTableData.name = rowResult.row[4];
|
696
|
countryTableData.code = rowResult.row[3];
|
697
|
mapTableData.set(rowResult.row[3], countryTableData);
|
698
|
}
|
699
|
}
|
700
|
} else if (series.series.query.name.includes('oso.results.gold_percentage')) {
|
701
|
|
702
|
for (const rowResult of series.series.result) {
|
703
|
|
704
|
const goldIndicator = new Indicator();
|
705
|
|
706
|
// remove unwanted countries
|
707
|
if (this.isCountryToBeRemoved(rowResult.row[3])) {
|
708
|
continue;
|
709
|
}
|
710
|
|
711
|
if (mapTableData.has(rowResult.row[3])) {
|
712
|
const countryTableData = mapTableData.get(rowResult.row[3]);
|
713
|
if (rowResult.row[0] !== 'NaN') {
|
714
|
goldIndicator.total = Number(rowResult.row[2]);
|
715
|
goldIndicator.oa = Number(rowResult.row[1]);
|
716
|
goldIndicator.percentage = Number(rowResult.row[0]);
|
717
|
countryTableData.gold = goldIndicator;
|
718
|
}
|
719
|
} else {
|
720
|
const countryTableData: CountryTableData = new CountryTableData();
|
721
|
if (rowResult.row[0] !== 'NaN') {
|
722
|
goldIndicator.total = Number(rowResult.row[2]);
|
723
|
goldIndicator.oa = Number(rowResult.row[1]);
|
724
|
goldIndicator.percentage = Number(rowResult.row[0]);
|
725
|
countryTableData.gold = goldIndicator;
|
726
|
}
|
727
|
countryTableData.name = rowResult.row[4];
|
728
|
countryTableData.code = rowResult.row[3];
|
729
|
mapTableData.set(rowResult.row[3], countryTableData);
|
730
|
}
|
731
|
}
|
732
|
}
|
733
|
}
|
734
|
|
735
|
const tableData: CountryTableData[] = [];
|
736
|
|
737
|
mapTableData.forEach((value: CountryTableData, key: string) => {
|
738
|
// console.log(key, value);
|
739
|
tableData.push(value);
|
740
|
});
|
741
|
|
742
|
return tableData;
|
743
|
}
|
744
|
|
745
|
public convertRawDataToLeadingOpenScienceData(rawData: RawData) {
|
746
|
|
747
|
const leadingOpenScienceData: CountryOverviewData[] = [];
|
748
|
|
749
|
for (const series of rawData.datasets) {
|
750
|
if (series.series.query.name === 'oso.mobile.overview') {
|
751
|
for (const rowResult of series.series.result) {
|
752
|
|
753
|
const countryOverviewData: CountryOverviewData = new CountryOverviewData();
|
754
|
countryOverviewData.name = rowResult.row[1];
|
755
|
countryOverviewData.code = rowResult.row[0];
|
756
|
countryOverviewData.publicationsAffiliated = Number(rowResult.row[2]);
|
757
|
countryOverviewData.publicationsDeposited = Number(rowResult.row[3]);
|
758
|
|
759
|
leadingOpenScienceData.push(countryOverviewData);
|
760
|
}
|
761
|
}
|
762
|
}
|
763
|
|
764
|
return leadingOpenScienceData;
|
765
|
}
|
766
|
|
767
|
public convertRawDataToCountryPageOverviewData(rawData: RawData) {
|
768
|
|
769
|
const countryPageOverviewData: CountryPageOverviewData = new CountryPageOverviewData();
|
770
|
|
771
|
for (const series of rawData.datasets) {
|
772
|
|
773
|
if ((series.series.query.name === 'oso.results.oa_percentage.country')
|
774
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'publication'
|
775
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
776
|
|
777
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
778
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
779
|
|
780
|
const publicationsAffiliatedIndicator: Indicator = new Indicator();
|
781
|
publicationsAffiliatedIndicator.percentage = Number(series.series.result[0].row[0]);
|
782
|
publicationsAffiliatedIndicator.oa = Number(series.series.result[0].row[1]);
|
783
|
publicationsAffiliatedIndicator.total = Number(series.series.result[0].row[2]);
|
784
|
countryPageOverviewData.publicationsAffiliated = publicationsAffiliatedIndicator;
|
785
|
|
786
|
} else if ((series.series.query.name === 'oso.results.oa_percentage.deposited.country')
|
787
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'publication'
|
788
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
789
|
|
790
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
791
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
792
|
|
793
|
const publicationsDepositedIndicator: Indicator = new Indicator();
|
794
|
publicationsDepositedIndicator.percentage = Number(series.series.result[0].row[0]);
|
795
|
publicationsDepositedIndicator.oa = Number(series.series.result[0].row[1]);
|
796
|
publicationsDepositedIndicator.total = Number(series.series.result[0].row[2]);
|
797
|
countryPageOverviewData.publicationsDeposited = publicationsDepositedIndicator;
|
798
|
|
799
|
} else if ((series.series.query.name === 'oso.results.oa_percentage.country')
|
800
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'dataset'
|
801
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
802
|
|
803
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
804
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
805
|
|
806
|
const datasetsAffiliatedIndicator: Indicator = new Indicator();
|
807
|
datasetsAffiliatedIndicator.percentage = Number(series.series.result[0].row[0]);
|
808
|
datasetsAffiliatedIndicator.oa = Number(series.series.result[0].row[1]);
|
809
|
datasetsAffiliatedIndicator.total = Number(series.series.result[0].row[2]);
|
810
|
countryPageOverviewData.datasetsAffiliated = datasetsAffiliatedIndicator;
|
811
|
|
812
|
} else if ((series.series.query.name === 'oso.results.oa_percentage.deposited.country')
|
813
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'dataset'
|
814
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
815
|
|
816
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
817
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
818
|
|
819
|
const datasetsDepositedIndicator: Indicator = new Indicator();
|
820
|
datasetsDepositedIndicator.percentage = Number(series.series.result[0].row[0]);
|
821
|
datasetsDepositedIndicator.oa = Number(series.series.result[0].row[1]);
|
822
|
datasetsDepositedIndicator.total = Number(series.series.result[0].row[2]);
|
823
|
countryPageOverviewData.datasetsDeposited = datasetsDepositedIndicator;
|
824
|
|
825
|
} else if (series.series.query.name === 'oso.repositories.doar_re3data.validated.country'
|
826
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
827
|
|
828
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
829
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
830
|
|
831
|
const repositoriesIndicator: Indicator = new Indicator();
|
832
|
repositoriesIndicator.percentage = Number(series.series.result[0].row[0]);
|
833
|
repositoriesIndicator.oa = Number(series.series.result[0].row[1]);
|
834
|
repositoriesIndicator.total = Number(series.series.result[0].row[2]);
|
835
|
countryPageOverviewData.repositories = repositoriesIndicator;
|
836
|
|
837
|
} else if (series.series.query.name === 'oso.journals.doaj.validated.country'
|
838
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
839
|
|
840
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
841
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
842
|
|
843
|
const journalsIndicator: Indicator = new Indicator();
|
844
|
journalsIndicator.percentage = Number(series.series.result[0].row[0]);
|
845
|
journalsIndicator.oa = Number(series.series.result[0].row[1]);
|
846
|
journalsIndicator.total = Number(series.series.result[0].row[2]);
|
847
|
countryPageOverviewData.journals = journalsIndicator;
|
848
|
|
849
|
} else if (series.series.query.name === 'oso.oa_policies.country'
|
850
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
851
|
|
852
|
countryPageOverviewData.policies = Number(series.series.result[0].row[0]);
|
853
|
|
854
|
} else if (series.series.query.name === 'oso.rnd.country'
|
855
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
856
|
|
857
|
const rndExpenditure: RnDExpenditure = new RnDExpenditure();
|
858
|
rndExpenditure.expenditure = Number(series.series.result[0].row[0]);
|
859
|
rndExpenditure.year = Number(series.series.result[0].row[1]);
|
860
|
countryPageOverviewData.rndExpenditure = rndExpenditure;
|
861
|
|
862
|
} else if (series.series.query.name === 'oso.funder.country'
|
863
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
864
|
|
865
|
countryPageOverviewData.funders = Number(series.series.result[0].row[0]);
|
866
|
|
867
|
} else if (series.series.query.name === 'oso.funding_organizations.country'
|
868
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
869
|
|
870
|
countryPageOverviewData.fundingOrganizations = Number(series.series.result[0].row[0]);
|
871
|
|
872
|
} else if (series.series.query.name === 'oso.ec_funded_organizations.country'
|
873
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
874
|
|
875
|
countryPageOverviewData.ec_fundedOrganizations = Number(series.series.result[0].row[0]);
|
876
|
}
|
877
|
}
|
878
|
|
879
|
return countryPageOverviewData;
|
880
|
}
|
881
|
|
882
|
public convertRawDataToCountryPageOAData(rawData: RawData) {
|
883
|
|
884
|
const countryPageOverviewData: CountryPageOverviewData = new CountryPageOverviewData();
|
885
|
|
886
|
for (const series of rawData.datasets) {
|
887
|
|
888
|
if ((series.series.query.name === 'oso.results.oa_percentage.country')
|
889
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'publication'
|
890
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
891
|
|
892
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
893
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
894
|
|
895
|
const publicationsAffiliatedIndicator: Indicator = new Indicator();
|
896
|
publicationsAffiliatedIndicator.percentage = Number(series.series.result[0].row[0]);
|
897
|
publicationsAffiliatedIndicator.oa = Number(series.series.result[0].row[1]);
|
898
|
publicationsAffiliatedIndicator.total = Number(series.series.result[0].row[2]);
|
899
|
countryPageOverviewData.publicationsAffiliated = publicationsAffiliatedIndicator;
|
900
|
|
901
|
} else if ((series.series.query.name === 'oso.results.oa_percentage.country')
|
902
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'dataset'
|
903
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
904
|
|
905
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
906
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
907
|
|
908
|
const datasetsAffiliatedIndicator: Indicator = new Indicator();
|
909
|
datasetsAffiliatedIndicator.percentage = Number(series.series.result[0].row[0]);
|
910
|
datasetsAffiliatedIndicator.oa = Number(series.series.result[0].row[1]);
|
911
|
datasetsAffiliatedIndicator.total = Number(series.series.result[0].row[2]);
|
912
|
countryPageOverviewData.datasetsAffiliated = datasetsAffiliatedIndicator;
|
913
|
|
914
|
} else if ((series.series.query.name === 'oso.results.oa_percentage.country')
|
915
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'software'
|
916
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
917
|
|
918
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
919
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
920
|
|
921
|
const softwareIndicator: Indicator = new Indicator();
|
922
|
softwareIndicator.percentage = Number(series.series.result[0].row[0]);
|
923
|
softwareIndicator.oa = Number(series.series.result[0].row[1]);
|
924
|
softwareIndicator.total = Number(series.series.result[0].row[2]);
|
925
|
countryPageOverviewData.software = softwareIndicator;
|
926
|
|
927
|
} else if ((series.series.query.name === 'oso.results.oa_percentage.country')
|
928
|
&& series.series.query.parameters && series.series.query.parameters[0] === 'other'
|
929
|
&& series.series.result && series.series.result.length > 0 && series.series.result[0].row) {
|
930
|
|
931
|
countryPageOverviewData.name = series.series.result[0].row[3];
|
932
|
countryPageOverviewData.code = series.series.result[0].row[4];
|
933
|
|
934
|
const otherIndicator: Indicator = new Indicator();
|
935
|
otherIndicator.percentage = Number(series.series.result[0].row[0]);
|
936
|
otherIndicator.oa = Number(series.series.result[0].row[1]);
|
937
|
otherIndicator.total = Number(series.series.result[0].row[2]);
|
938
|
countryPageOverviewData.other = otherIndicator;
|
939
|
|
940
|
}
|
941
|
}
|
942
|
|
943
|
return countryPageOverviewData;
|
944
|
}
|
945
|
|
946
|
public convertRawDataToTreemapHighchartsData(rawData: RawData) {
|
947
|
|
948
|
const treeMapData: TreemapHighchartsData[] = [];
|
949
|
|
950
|
for (const series of rawData.datasets) {
|
951
|
// let index = 1;
|
952
|
for (const rowResult of series.series.result) {
|
953
|
|
954
|
const treeMapItemData: TreemapHighchartsData = new TreemapHighchartsData();
|
955
|
treeMapItemData.name = rowResult.row[1];
|
956
|
treeMapItemData.value = Number(rowResult.row[0]);
|
957
|
treeMapItemData.colorValue = Number(rowResult.row[0]);
|
958
|
// treeMapItemData.colorValue = index;
|
959
|
|
960
|
treeMapData.push(treeMapItemData);
|
961
|
|
962
|
// index = index + 1;
|
963
|
}
|
964
|
}
|
965
|
|
966
|
return treeMapData;
|
967
|
}
|
968
|
|
969
|
private rawResultToCountryMapData(result: Row[]) {
|
970
|
|
971
|
const entityMapData: CountryMapData[] = [];
|
972
|
for (const rowResult of result) {
|
973
|
|
974
|
// remove unwanted countries
|
975
|
if (this.isCountryToBeRemoved(rowResult.row[2])) {
|
976
|
continue;
|
977
|
}
|
978
|
|
979
|
const countryMapData: CountryMapData = new CountryMapData();
|
980
|
countryMapData.value = Number(rowResult.row[0]);
|
981
|
countryMapData.name = rowResult.row[1];
|
982
|
countryMapData.code = rowResult.row[2];
|
983
|
|
984
|
entityMapData.push(countryMapData);
|
985
|
}
|
986
|
|
987
|
return entityMapData;
|
988
|
}
|
989
|
|
990
|
private isCountryToBeRemoved(countryCode: string) {
|
991
|
return (countryCode === 'GG' || countryCode === 'FO' || countryCode === 'GI' || countryCode === 'VA' || countryCode === 'IM'
|
992
|
|| countryCode === 'JE' || countryCode === 'LI' || countryCode === 'MC' || countryCode === 'SM' || countryCode === 'SJ'
|
993
|
|| countryCode === 'AX');
|
994
|
}
|
995
|
}
|