@sis-cc/dotstatsuite-components 15.0.21 → 16.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/rules/src/index.js +1 -145
- package/lib/rules/src/table/index.js +0 -42
- package/lib/rules2/src/constants.js +3 -1
- package/lib/rules2/src/enhanceObservations.js +98 -0
- package/lib/rules2/src/getAttributesSeries.js +33 -0
- package/lib/rules2/src/getCombinationDefinitions.js +48 -0
- package/lib/rules2/src/getHeaderCombinations.js +42 -0
- package/lib/rules2/src/getHeaderSubtitle.js +41 -0
- package/lib/rules2/src/getManyValuesDimensions.js +39 -0
- package/lib/rules2/src/getOneValueDimensions.js +46 -0
- package/lib/rules2/src/hasCellMetadata.js +1 -1
- package/lib/rules2/src/index.js +186 -18
- package/lib/rules2/src/parseAttributes.js +50 -0
- package/lib/rules2/src/parseCombinations.js +54 -0
- package/lib/rules2/src/prepareData.js +74 -0
- package/lib/{rules/src/table/preparators/getAttributeValue.js → rules2/src/refineAttributes.js} +13 -11
- package/lib/rules2/src/table/getCells.js +74 -0
- package/lib/rules2/src/table/getCellsAttributesIds.js +63 -0
- package/lib/rules2/src/table/getCombinationDimensionsData.js +47 -0
- package/lib/rules2/src/table/getCuratedCells.js +28 -0
- package/lib/rules2/src/table/getFlagsAndNotes.js +28 -0
- package/lib/rules2/src/table/getIndexedCombinationsByDisplay.js +31 -0
- package/lib/rules2/src/table/getLayout.js +93 -0
- package/lib/rules2/src/table/getLayoutData.js +202 -0
- package/lib/{rules/src/table/factories → rules2/src/table}/getSortedLayoutIndexes.js +55 -40
- package/lib/rules2/src/table/getTableProps.js +64 -0
- package/lib/rules2/src/table/parseValueHierarchy.js +55 -0
- package/lib/{rules/src/table/factories → rules2/src/table}/refineLayoutSize.js +17 -8
- package/lib/rules2/src/{hasLayoutEntryMetadata.js → utils.js} +9 -6
- package/package.json +1 -1
- package/src/rules/src/index.js +1 -19
- package/src/rules/src/table/index.js +0 -4
- package/src/rules2/src/constants.js +2 -0
- package/src/rules2/src/enhanceObservations.js +88 -0
- package/src/rules2/src/getAttributesSeries.js +29 -0
- package/src/rules2/src/getCombinationDefinitions.js +29 -0
- package/src/rules2/src/getHeaderCombinations.js +39 -0
- package/src/rules2/src/getHeaderSubtitle.js +34 -0
- package/src/rules2/src/getManyValuesDimensions.js +34 -0
- package/src/rules2/src/getOneValueDimensions.js +33 -0
- package/src/rules2/src/hasCellMetadata.js +1 -1
- package/src/rules2/src/index.js +21 -6
- package/src/rules2/src/parseAttributes.js +36 -0
- package/src/rules2/src/parseCombinations.js +36 -0
- package/src/rules2/src/prepareData.js +50 -0
- package/src/rules2/src/refineAttributes.js +16 -0
- package/src/rules2/src/table/getCells.js +72 -0
- package/src/rules2/src/table/getCellsAttributesIds.js +38 -0
- package/src/rules2/src/table/getCombinationDimensionsData.js +38 -0
- package/src/rules2/src/table/getCuratedCells.js +33 -0
- package/src/rules2/src/table/getFlagsAndNotes.js +21 -0
- package/src/rules2/src/table/getIndexedCombinationsByDisplay.js +16 -0
- package/src/rules2/src/table/getLayout.js +80 -0
- package/src/rules2/src/table/getLayoutData.js +183 -0
- package/src/rules2/src/table/getSortedLayoutIndexes.js +119 -0
- package/src/rules2/src/table/getTableProps.js +36 -0
- package/src/rules2/src/table/parseValueHierarchy.js +27 -0
- package/src/{rules/src/table/factories → rules2/src/table}/refineLayoutSize.js +24 -8
- package/src/rules2/src/utils.js +12 -0
- package/test/enhanceObservations2.test.js +219 -0
- package/test/getAttributesSeries.test.js +58 -0
- package/test/getCells.test.js +6 -40
- package/test/getCombinationDimensionsData.test.js +48 -0
- package/test/getSortedLayoutIndexes.test.js +1025 -3
- package/test/parseAttributes.test.js +17 -62
- package/test/parseValueHierarchy.test.js +88 -0
- package/test/refineLayoutSize.test.js +2621 -1
- package/lib/rules/src/table/factories/getCells.js +0 -97
- package/lib/rules/src/table/factories/getConfirmedSeriesAttributesIds.js +0 -26
- package/lib/rules/src/table/factories/getCuratedCells.js +0 -45
- package/lib/rules/src/table/factories/getLayoutData.js +0 -168
- package/lib/rules/src/table/factories/getLayoutWithFlags.js +0 -133
- package/lib/rules/src/table/factories/getTableCells.js +0 -24
- package/lib/rules/src/table/factories/getTableData.js +0 -98
- package/lib/rules/src/table/preparators/getDimensionsAttributesRegisters.js +0 -43
- package/lib/rules/src/table/preparators/getManyValuesDimensions.js +0 -33
- package/lib/rules/src/table/preparators/getOneValueDimensions.js +0 -24
- package/lib/rules/src/table/preparators/getUniqValuesAttributes.js +0 -36
- package/lib/rules/src/table/preparators/parseAttributes.js +0 -84
- package/lib/rules/src/table/preparators/parseAttributesValuesFromObservations.js +0 -22
- package/lib/rules/src/table/preparators/parseDimensionsIds.js +0 -22
- package/lib/rules/src/table/preparators/prepareData.js +0 -191
- package/lib/rules/src/table/preparators/refineObservationsAttributesValues.js +0 -31
- package/lib/rules/src/table/preparators/refineSeriesAttributesValues.js +0 -23
- package/lib/rules/src/table/units/appendUnitsInLayoutData.js +0 -82
- package/lib/rules/src/table/units/appendUnitsInLayoutDataEntry.js +0 -45
- package/lib/rules/src/table/units/cleanUnitsInLayoutData.js +0 -66
- package/lib/rules/src/table/units/getAttachmentSeriesIndexes.js +0 -25
- package/lib/rules/src/table/units/getHeaderUnits.js +0 -35
- package/lib/rules/src/table/units/getUnitsArtefacts.js +0 -85
- package/lib/rules/src/table/units/getUnitsCodes.js +0 -23
- package/lib/rules/src/table/units/getUnitsDefinition.js +0 -33
- package/lib/rules/src/table/units/getUnitsDisplay.js +0 -33
- package/lib/rules/src/table/units/getUnitsSerieIndexes.js +0 -23
- package/lib/rules/src/table/units/getUnitsSeries.js +0 -49
- package/lib/rules/src/table/units/getUnitsinLayout.js +0 -74
- package/lib/rules/src/table/units/refineDimSeriesUnits.js +0 -44
- package/lib/rules2/src/getAdvancedAttributes.js +0 -124
- package/lib/rules2/src/invertTime.js +0 -33
- package/src/rules/src/table/factories/getCells.js +0 -102
- package/src/rules/src/table/factories/getConfirmedSeriesAttributesIds.js +0 -27
- package/src/rules/src/table/factories/getCuratedCells.js +0 -40
- package/src/rules/src/table/factories/getLayoutData.js +0 -171
- package/src/rules/src/table/factories/getLayoutWithFlags.js +0 -137
- package/src/rules/src/table/factories/getSortedLayoutIndexes.js +0 -108
- package/src/rules/src/table/factories/getTableCells.js +0 -16
- package/src/rules/src/table/factories/getTableData.js +0 -86
- package/src/rules/src/table/preparators/getAttributeValue.js +0 -17
- package/src/rules/src/table/preparators/getDimensionsAttributesRegisters.js +0 -51
- package/src/rules/src/table/preparators/getManyValuesDimensions.js +0 -19
- package/src/rules/src/table/preparators/getOneValueDimensions.js +0 -17
- package/src/rules/src/table/preparators/getUniqValuesAttributes.js +0 -24
- package/src/rules/src/table/preparators/parseAttributes.js +0 -113
- package/src/rules/src/table/preparators/parseAttributesValuesFromObservations.js +0 -16
- package/src/rules/src/table/preparators/parseDimensionsIds.js +0 -17
- package/src/rules/src/table/preparators/prepareData.js +0 -197
- package/src/rules/src/table/preparators/refineObservationsAttributesValues.js +0 -22
- package/src/rules/src/table/preparators/refineSeriesAttributesValues.js +0 -11
- package/src/rules/src/table/units/appendUnitsInLayoutData.js +0 -56
- package/src/rules/src/table/units/appendUnitsInLayoutDataEntry.js +0 -38
- package/src/rules/src/table/units/cleanUnitsInLayoutData.js +0 -65
- package/src/rules/src/table/units/getAttachmentSeriesIndexes.js +0 -27
- package/src/rules/src/table/units/getHeaderUnits.js +0 -32
- package/src/rules/src/table/units/getUnitsArtefacts.js +0 -90
- package/src/rules/src/table/units/getUnitsCodes.js +0 -22
- package/src/rules/src/table/units/getUnitsDefinition.js +0 -34
- package/src/rules/src/table/units/getUnitsDisplay.js +0 -19
- package/src/rules/src/table/units/getUnitsSerieIndexes.js +0 -12
- package/src/rules/src/table/units/getUnitsSeries.js +0 -41
- package/src/rules/src/table/units/getUnitsinLayout.js +0 -71
- package/src/rules/src/table/units/refineDimSeriesUnits.js +0 -26
- package/src/rules2/src/getAdvancedAttributes.js +0 -111
- package/src/rules2/src/hasLayoutEntryMetadata.js +0 -9
- package/src/rules2/src/invertTime.js +0 -22
- package/test/advanced-attributes-parsing-perf.test.js +0 -16
- package/test/appendUnitsInLayoutDataEntry.test.js +0 -65
- package/test/cleanUnitsInLayoutData.test.js +0 -85
- package/test/enhanceObservations.test.js +0 -340
- package/test/getAttachmentSeriesIndexes.test.js +0 -35
- package/test/getConfirmedSeriesAttributesIds.test.js +0 -27
- package/test/getDataflowAdvancedAttributes.test.js +0 -32
- package/test/getHeaderUnits.test.js +0 -51
- package/test/getLayoutData.test.js +0 -206
- package/test/getLayoutDataWithFlags.test.js +0 -142
- package/test/getOneValueDimensions.test.js +0 -26
- package/test/getSeriesAdvancedAttributes.test.js +0 -32
- package/test/getSubtitleFlags.test.js +0 -42
- package/test/getTableData.test.js +0 -1317
- package/test/getUnitsArtefacts.test.js +0 -117
- package/test/getUnitsDefinition.test.js +0 -37
- package/test/getUnitsInLayout.test.js +0 -77
- package/test/getUnitsSeries.test.js +0 -154
- package/test/invertTime.test.js +0 -77
- package/test/parseAttributesValuesFromObservations.test.js +0 -45
- package/test/parseDimensionsIds.test.js +0 -20
- package/test/prepareData.test.js +0 -29
- package/test/refineObservationsAttributesValues.test.js +0 -33
- package/test/table-invert-time-perf.test.js +0 -11
- package/test/table-layout-perf.test.js +0 -74
- package/test/table-prep-duplicate-perf.test.js +0 -15
- package/test/table-prep-perf.test.js +0 -61
|
@@ -25,12 +25,21 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
25
25
|
|
|
26
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
27
|
|
|
28
|
+
var toKey = function toKey(indexes) {
|
|
29
|
+
return R.reduce(function (acc, _ind) {
|
|
30
|
+
var ind = R.is(Array, _ind) ? toKey(_ind) : Math.abs(_ind);
|
|
31
|
+
return R.isEmpty(acc) ? String(ind) : acc + ':' + ind;
|
|
32
|
+
}, '', indexes);
|
|
33
|
+
};
|
|
34
|
+
|
|
28
35
|
var getPivotKey = function getPivotKey(indexes) {
|
|
29
36
|
return R.pipe(R.props(indexes), R.join(':'));
|
|
30
37
|
};
|
|
31
38
|
|
|
32
39
|
var getPivots = function getPivots(layout, shape) {
|
|
33
|
-
return R.pipe(R.props(shape), R.map(R.pipe(R.
|
|
40
|
+
return R.pipe(R.props(shape), R.map(R.pipe(R.map(function (entry) {
|
|
41
|
+
return R.has('dimensions', entry) ? R.pluck('__index', entry.dimensions || []) : entry.__index;
|
|
42
|
+
}), R.unnest, getPivotKey)))(layout);
|
|
34
43
|
};
|
|
35
44
|
|
|
36
45
|
var indexWithPivots = function indexWithPivots(pivots, observations) {
|
|
@@ -53,9 +62,9 @@ var getCuratedCells = exports.getCuratedCells = function getCuratedCells(_ref) {
|
|
|
53
62
|
|
|
54
63
|
var refineSections = exports.refineSections = function refineSections(sections, extractedKeys, curatedObs) {
|
|
55
64
|
return R.pipe(R.map(function (section) {
|
|
56
|
-
var sectionKey =
|
|
65
|
+
var sectionKey = toKey(R.head(section) || []);
|
|
57
66
|
return R.over(R.lensIndex(1), R.filter(function (rowData) {
|
|
58
|
-
var rowKey =
|
|
67
|
+
var rowKey = toKey(rowData);
|
|
59
68
|
return R.pipe(R.path([sectionKey, rowKey]), R.omit(extractedKeys), R.isEmpty, R.not)(curatedObs);
|
|
60
69
|
}))(section);
|
|
61
70
|
}), R.filter(R.pipe(R.nth(1), R.isEmpty, R.not)))(sections);
|
|
@@ -64,7 +73,7 @@ var refineSections = exports.refineSections = function refineSections(sections,
|
|
|
64
73
|
var refineHeader = exports.refineHeader = function refineHeader(header, extractedKeys, curatedObs) {
|
|
65
74
|
return R.filter( // extracted : { [sectionKey]: [...rowKeys] }
|
|
66
75
|
function (header) {
|
|
67
|
-
var headerKey =
|
|
76
|
+
var headerKey = toKey(header);
|
|
68
77
|
return R.pipe(R.prop(headerKey), function (sections) {
|
|
69
78
|
return R.pickBy(function (rows, section) {
|
|
70
79
|
return R.pipe(R.omit(R.propOr([], section, extractedKeys)), R.isEmpty, R.not)(rows);
|
|
@@ -81,7 +90,7 @@ var truncateSectionRows = exports.truncateSectionRows = function truncateSection
|
|
|
81
90
|
var lastSection = R.last(truncated);
|
|
82
91
|
var rows = lastSection[1];
|
|
83
92
|
var rowsLength = R.length(rows);
|
|
84
|
-
var sectionKey =
|
|
93
|
+
var sectionKey = toKey(R.head(lastSection));
|
|
85
94
|
if (rowsLength > _n) {
|
|
86
95
|
var _R$splitAt = R.splitAt(R.negate(_n), rows),
|
|
87
96
|
_R$splitAt2 = (0, _slicedToArray3.default)(_R$splitAt, 2),
|
|
@@ -90,11 +99,11 @@ var truncateSectionRows = exports.truncateSectionRows = function truncateSection
|
|
|
90
99
|
|
|
91
100
|
var updatedSection = R.set(R.lensIndex(1), rest)(lastSection);
|
|
92
101
|
truncated = R.set(R.lensIndex(-1), updatedSection)(truncated);
|
|
93
|
-
extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(
|
|
102
|
+
extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(toKey, extracted)));
|
|
94
103
|
_n = 0;
|
|
95
104
|
} else {
|
|
96
105
|
truncated = R.dropLast(1, truncated);
|
|
97
|
-
extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(
|
|
106
|
+
extractedKeys = (0, _extends5.default)({}, extractedKeys, (0, _defineProperty3.default)({}, sectionKey, R.map(toKey, rows)));
|
|
98
107
|
_n = _n - rowsLength;
|
|
99
108
|
}
|
|
100
109
|
}
|
|
@@ -107,7 +116,7 @@ var truncateHeader = exports.truncateHeader = function truncateHeader(n, headerD
|
|
|
107
116
|
truncated = _R$splitAt4[0],
|
|
108
117
|
extracted = _R$splitAt4[1];
|
|
109
118
|
|
|
110
|
-
return { truncated: truncated, extractedKeys: R.map(
|
|
119
|
+
return { truncated: truncated, extractedKeys: R.map(toKey, extracted) };
|
|
111
120
|
};
|
|
112
121
|
|
|
113
122
|
var truncateLayout = function truncateLayout(isVertical) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.trimedProps = undefined;
|
|
7
7
|
|
|
8
8
|
var _ramda = require('ramda');
|
|
9
9
|
|
|
@@ -11,8 +11,11 @@ var R = _interopRequireWildcard(_ramda);
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
var trimedProps = exports.trimedProps = function trimedProps(properties, obj) {
|
|
15
|
+
return R.reduce(function (acc, prop) {
|
|
16
|
+
if (!R.has(prop, obj)) {
|
|
17
|
+
return acc;
|
|
18
|
+
}
|
|
19
|
+
return R.append(obj[prop], acc);
|
|
20
|
+
}, [], properties);
|
|
21
|
+
};
|
package/package.json
CHANGED
package/src/rules/src/index.js
CHANGED
|
@@ -381,10 +381,7 @@ export {
|
|
|
381
381
|
} from './properties';
|
|
382
382
|
export { dataTransformer as v8Transformer } from './v8-transformer';
|
|
383
383
|
export {
|
|
384
|
-
prepareData,
|
|
385
384
|
getCellValue,
|
|
386
|
-
getTableProps,
|
|
387
|
-
getFlags,
|
|
388
385
|
} from './table';
|
|
389
386
|
export {
|
|
390
387
|
getFullName,
|
|
@@ -396,20 +393,5 @@ export { getObservationsType } from './properties/getObservationsType';
|
|
|
396
393
|
export { getAvailableChartTypes } from './properties/getAvailableChartTypes';
|
|
397
394
|
export { isSharedLayoutCompatible } from './layout';
|
|
398
395
|
|
|
399
|
-
export { parseDimensionsIds } from './table/preparators/parseDimensionsIds';
|
|
400
|
-
export { parseAttributes } from './table/preparators/parseAttributes';
|
|
401
|
-
export { getDimensionsAttributesRegisters } from './table/preparators/getDimensionsAttributesRegisters';
|
|
402
|
-
export { parseAttributesValuesFromObservations } from './table/preparators/parseAttributesValuesFromObservations';
|
|
403
|
-
export { getOneValueDimensions } from './table/preparators/getOneValueDimensions';
|
|
404
|
-
export { getManyValuesDimensions } from './table/preparators/getManyValuesDimensions';
|
|
405
|
-
export { getAttributeValue } from './table/preparators/getAttributeValue';
|
|
406
|
-
export { refineSeriesAttributesValues } from './table/preparators/refineSeriesAttributesValues';
|
|
407
|
-
|
|
408
|
-
export { getUnitsDefinition } from './table/units/getUnitsDefinition';
|
|
409
|
-
export { getUnitsArtefacts } from './table/units/getUnitsArtefacts';
|
|
410
|
-
export { getHeaderUnits } from './table/units/getHeaderUnits';
|
|
411
|
-
export { getAttachmentSeriesIndexes } from './table/units/getAttachmentSeriesIndexes';
|
|
412
|
-
export { getUnitsSeries } from './table/units/getUnitsSeries';
|
|
413
|
-
|
|
414
396
|
export { getObservations } from './preparators/getObservations';
|
|
415
|
-
|
|
397
|
+
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
export { prepareData } from './preparators/prepareData';
|
|
2
|
-
export { getCells, getFlags } from './factories/getCells';
|
|
3
|
-
export { getTableCells } from './factories/getTableCells';
|
|
4
|
-
export { getTableProps } from './factories/getTableData';
|
|
5
1
|
export { getCellValue } from './factories/getCellValue';
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export const SDMX_3_0_JSON_DATA_FORMAT = 'application/vnd.sdmx.data+json;version=2.0';
|
|
2
2
|
export const SDMX_3_0_CSV_DATA_FORMAT = 'application/vnd.sdmx.data+csv;version=2.0';
|
|
3
|
+
export const REPORTING_YEAR_START_DAY = 'REPORTING_YEAR_START_DAY';
|
|
4
|
+
export const REPYEARSTART = 'REPYEARSTART';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
import { formatValue } from '../../rules/src/preparators/formatValue';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
options = {
|
|
6
|
+
customAttributes: {
|
|
7
|
+
decimals: id,
|
|
8
|
+
prefscale: id,
|
|
9
|
+
},
|
|
10
|
+
rejectedValueIds,
|
|
11
|
+
}
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const parseAttributesValues = (obs, attributes, indexedDimensions, rejectedValueIds) => {
|
|
15
|
+
const { attrValuesIndexes, dimValuesIndexes } = obs;
|
|
16
|
+
return R.addIndex(R.reduce)(
|
|
17
|
+
(acc, valueIndex, attrIndex) => {
|
|
18
|
+
const attribute = R.nth(attrIndex, attributes);
|
|
19
|
+
if (R.isNil(attribute) || !R.propOr(true, 'display', attribute) || !R.prop('series', attribute)) {
|
|
20
|
+
return acc;
|
|
21
|
+
}
|
|
22
|
+
let value = R.nth(valueIndex, attribute.values || []);
|
|
23
|
+
if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), rejectedValueIds)) {
|
|
24
|
+
value = null;
|
|
25
|
+
}
|
|
26
|
+
const relationship = R.propOr([], 'relationship', attribute);
|
|
27
|
+
let coordinates = {};
|
|
28
|
+
const serieKey = R.pipe(
|
|
29
|
+
dims => R.isEmpty(relationship) ? R.values(dims) : R.props(relationship, dims),
|
|
30
|
+
R.map(dim => {
|
|
31
|
+
const valueIndex = R.nth(dim.__index, dimValuesIndexes);
|
|
32
|
+
const valueId = R.path(['values', valueIndex, 'id'], dim);
|
|
33
|
+
coordinates = R.assoc(dim.id, valueId, coordinates);
|
|
34
|
+
return `${dim.id}=${valueId}`;
|
|
35
|
+
}),
|
|
36
|
+
R.ifElse(R.isEmpty, R.always(null), R.join(':'))
|
|
37
|
+
)(indexedDimensions);
|
|
38
|
+
|
|
39
|
+
return R.assoc(attribute.id, { ...R.pick(['id', 'name', 'relationship'], attribute), value, serieKey, coordinates, isObs: R.isEmpty(relationship) }, acc);
|
|
40
|
+
},
|
|
41
|
+
{},
|
|
42
|
+
attrValuesIndexes
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const getFormatAttributesIndexes = (attributes, customAttributes) => R.addIndex(R.reduce)(
|
|
47
|
+
(acc, attribute, index) => {
|
|
48
|
+
if (R.equals(attribute.id, customAttributes.decimals)) {
|
|
49
|
+
return ({ ...acc, decimals: index });
|
|
50
|
+
}
|
|
51
|
+
if (R.equals(attribute.id, customAttributes.prefscale)) {
|
|
52
|
+
return ({ ...acc, prefscale: index });
|
|
53
|
+
}
|
|
54
|
+
return acc;
|
|
55
|
+
},
|
|
56
|
+
{ prefscale: null, decimals: null },
|
|
57
|
+
attributes
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export const enhanceObservations = (dimensions = [], observations = {}, attributes = [], options = {}) => {
|
|
61
|
+
const formatAttributesIndexes = getFormatAttributesIndexes(attributes, R.propOr({}, 'customAttributes', options));
|
|
62
|
+
const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
|
|
63
|
+
|
|
64
|
+
return R.mapObjIndexed(
|
|
65
|
+
(observation) => {
|
|
66
|
+
const { dimValuesIndexes } = observation;
|
|
67
|
+
|
|
68
|
+
const indexedDimValIds = R.addIndex(R.reduce)(
|
|
69
|
+
(acc, dimension, dimensionIndex) => {
|
|
70
|
+
const id = dimension.id;
|
|
71
|
+
const valueIndex = R.nth(dimensionIndex, dimValuesIndexes);
|
|
72
|
+
const valueId = R.path(['values', Number(valueIndex), 'id'], dimension);
|
|
73
|
+
return R.assoc(id, valueId, acc);
|
|
74
|
+
},
|
|
75
|
+
{},
|
|
76
|
+
dimensions
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return ({
|
|
80
|
+
...observation,
|
|
81
|
+
attributes: parseAttributesValues(observation, attributes, indexedDimensions, R.propOr([], 'rejectedValueIds', options)),
|
|
82
|
+
formattedValue: formatValue(observation, formatAttributesIndexes, attributes),
|
|
83
|
+
indexedDimValIds,
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
observations
|
|
87
|
+
);
|
|
88
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getAttributesSeries = observations => R.pipe(
|
|
4
|
+
R.values,
|
|
5
|
+
R.reduce(
|
|
6
|
+
(acc, { attributes }) => {
|
|
7
|
+
let res = acc.res;
|
|
8
|
+
let rejected = acc.rejected;
|
|
9
|
+
R.forEachObjIndexed(
|
|
10
|
+
(attribute) => {
|
|
11
|
+
if (!R.isNil(attribute.serieKey)) {
|
|
12
|
+
const valueInRes = R.path([attribute.serieKey, attribute.id, 'value', 'id'], res);
|
|
13
|
+
if (!R.isNil(valueInRes) && valueInRes !== R.path(['value', 'id'], attribute)) {
|
|
14
|
+
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|
|
15
|
+
rejected = R.assocPath([attribute.serieKey, attribute.id], true, rejected);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
res = R.assocPath([attribute.serieKey, attribute.id], attribute, res);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
attributes
|
|
23
|
+
);
|
|
24
|
+
return ({ res, rejected });
|
|
25
|
+
},
|
|
26
|
+
{ res: {}, rejected: {}, }
|
|
27
|
+
),
|
|
28
|
+
R.prop('res')
|
|
29
|
+
)(observations);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getCombinationDefinitions = (annotations, locale) => {
|
|
4
|
+
const annotation = R.find(annot => annot.type === 'COMBINED_CONCEPTS', annotations);
|
|
5
|
+
if (R.isNil(annotation)) {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
const title = R.propOr('', 'title', annotation);
|
|
9
|
+
const texts = R.propOr({}, 'texts', annotation);
|
|
10
|
+
|
|
11
|
+
return R.useWith(
|
|
12
|
+
(titles, texts) =>
|
|
13
|
+
R.addIndex(R.map)((title, index) => {
|
|
14
|
+
const split = R.split(':', title);
|
|
15
|
+
if (R.length(split !== 2)) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const [id, codes] = split;
|
|
19
|
+
return {
|
|
20
|
+
id,
|
|
21
|
+
concepts: R.split(',', codes),
|
|
22
|
+
name: R.has(locale, texts)
|
|
23
|
+
? R.pipe(R.prop(locale), R.nth(index), R.split(':'), R.last)(texts)
|
|
24
|
+
: `[${id}]`,
|
|
25
|
+
};
|
|
26
|
+
}, titles),
|
|
27
|
+
[R.split(';'), R.map(R.split(';'))],
|
|
28
|
+
)(title, texts);
|
|
29
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
import { dimensionValueDisplay } from '../../rules/src';
|
|
3
|
+
|
|
4
|
+
export const getHeaderCombinations = (combinations, dimensions, attributes, display) => {
|
|
5
|
+
const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
|
|
6
|
+
const indexedAttributes = R.indexBy(R.prop('id'), attributes);
|
|
7
|
+
return R.reduce(
|
|
8
|
+
(acc, comb) => {
|
|
9
|
+
if (!R.prop('header', comb)) {
|
|
10
|
+
return acc;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const header = dimensionValueDisplay(display)(comb);
|
|
14
|
+
|
|
15
|
+
const values = R.pipe(
|
|
16
|
+
R.reduce((_acc, concept) => {
|
|
17
|
+
const artefact = R.has(concept, indexedDimensions)
|
|
18
|
+
? R.prop(concept, indexedDimensions)
|
|
19
|
+
: R.prop(concept, indexedAttributes);
|
|
20
|
+
if (R.isNil(artefact) || !R.prop('display', artefact || {})) {
|
|
21
|
+
return _acc;
|
|
22
|
+
}
|
|
23
|
+
const value = R.path(['values', 0], artefact);
|
|
24
|
+
if (R.isNil(value) || !R.prop('display', value || {})) {
|
|
25
|
+
return _acc;
|
|
26
|
+
}
|
|
27
|
+
return R.append(dimensionValueDisplay(display)(value), _acc);
|
|
28
|
+
}, []),
|
|
29
|
+
R.join(', '),
|
|
30
|
+
)(comb.concepts || []);
|
|
31
|
+
if (R.isEmpty(values)) {
|
|
32
|
+
return acc;
|
|
33
|
+
}
|
|
34
|
+
return R.append({ header, label: values }, acc);
|
|
35
|
+
},
|
|
36
|
+
[],
|
|
37
|
+
combinations,
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
import { getFlagsAndNotes } from './table/getFlagsAndNotes';
|
|
3
|
+
import { dimensionValueDisplay } from '../../rules/src/';
|
|
4
|
+
|
|
5
|
+
export const getHeaderSubtitle = (dimensions, combinations, customAttributes, display, microdataDimension) => {
|
|
6
|
+
const combinationsConepts = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
|
|
7
|
+
const DEFAULT_REJECTED_SUBTITLE_IDS = ['_L', '_T', '_Z'];
|
|
8
|
+
|
|
9
|
+
return R.reduce(
|
|
10
|
+
(acc, dim) => {
|
|
11
|
+
if (!R.propOr(true, 'display', dim) || R.propEq('id', microdataDimension, dim)
|
|
12
|
+
|| R.includes(dim.id, combinationsConepts)) {
|
|
13
|
+
return acc;
|
|
14
|
+
}
|
|
15
|
+
const value = R.path(['values', 0], dim);
|
|
16
|
+
if (!R.propOr(true, 'display', value) || R.includes(value.id, DEFAULT_REJECTED_SUBTITLE_IDS)) {
|
|
17
|
+
return acc;
|
|
18
|
+
}
|
|
19
|
+
const header = `${dimensionValueDisplay(display)(dim)}:`;
|
|
20
|
+
const label = dimensionValueDisplay(display)(value);
|
|
21
|
+
const flags = R.pipe(
|
|
22
|
+
getFlagsAndNotes,
|
|
23
|
+
R.map(entry => ({
|
|
24
|
+
code: entry.code,
|
|
25
|
+
header: `${dimensionValueDisplay(display)(entry)}:`,
|
|
26
|
+
label: dimensionValueDisplay(display)(entry.value),
|
|
27
|
+
})),
|
|
28
|
+
)(dim.attrValues, customAttributes);
|
|
29
|
+
return R.append({ header, label, flags }, acc);
|
|
30
|
+
},
|
|
31
|
+
[],
|
|
32
|
+
dimensions,
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
import { getFlagsAndNotes } from './table/getFlagsAndNotes';
|
|
3
|
+
|
|
4
|
+
export const getManyValuesDimensions = (dimensions, attributesSeries, customAttributes, combinations) => {
|
|
5
|
+
const combConceptsIds = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
|
|
6
|
+
return R.reduce(
|
|
7
|
+
(acc, dim) => {
|
|
8
|
+
if (R.length(dim.values || []) < 2) {
|
|
9
|
+
return acc;
|
|
10
|
+
}
|
|
11
|
+
const enhancedValues = R.map(val => {
|
|
12
|
+
const attrSeries = R.propOr({}, `${dim.id}=${val.id}`, attributesSeries);
|
|
13
|
+
if (R.isEmpty(attrSeries)) {
|
|
14
|
+
return val;
|
|
15
|
+
}
|
|
16
|
+
const flags = getFlagsAndNotes(attrSeries, customAttributes);
|
|
17
|
+
const hasAdvancedAttributes = R.pipe(
|
|
18
|
+
R.omit(
|
|
19
|
+
R.unnest([
|
|
20
|
+
customAttributes.flags || [],
|
|
21
|
+
customAttributes.notes || [],
|
|
22
|
+
combConceptsIds,
|
|
23
|
+
]),
|
|
24
|
+
),
|
|
25
|
+
R.complement(R.isEmpty),
|
|
26
|
+
)(attrSeries);
|
|
27
|
+
return { ...val, flags, hasAdvancedAttributes };
|
|
28
|
+
}, dim.values);
|
|
29
|
+
return R.append(R.assoc('values', enhancedValues, dim), acc);
|
|
30
|
+
},
|
|
31
|
+
[],
|
|
32
|
+
dimensions,
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getOneValueDimensions = (dimensions, attributes) => {
|
|
4
|
+
const indexedRelevantAttributes = R.reduce(
|
|
5
|
+
(acc, attr) => {
|
|
6
|
+
if (!attr.header || !attr.display || R.length(attr.relationship || []) !== 1) {
|
|
7
|
+
return acc;
|
|
8
|
+
}
|
|
9
|
+
const value = R.path(['values', 0], attr);
|
|
10
|
+
if (R.isNil(value) || !R.prop('display', value)) {
|
|
11
|
+
return acc;
|
|
12
|
+
}
|
|
13
|
+
const dim = R.head(attr.relationship);
|
|
14
|
+
return R.over(R.lensProp(dim), (values = {}) => ({
|
|
15
|
+
...values,
|
|
16
|
+
[attr.id]: { ...attr, value },
|
|
17
|
+
}))(acc);
|
|
18
|
+
},
|
|
19
|
+
{},
|
|
20
|
+
attributes,
|
|
21
|
+
);
|
|
22
|
+
return R.reduce(
|
|
23
|
+
(acc, dim) => {
|
|
24
|
+
if (R.length(dim.values || []) !== 1) {
|
|
25
|
+
return acc;
|
|
26
|
+
}
|
|
27
|
+
const attrValues = R.propOr({}, dim.id, indexedRelevantAttributes);
|
|
28
|
+
return R.append({ ...dim, attrValues }, acc);
|
|
29
|
+
},
|
|
30
|
+
[],
|
|
31
|
+
dimensions,
|
|
32
|
+
);
|
|
33
|
+
};
|
|
@@ -4,7 +4,7 @@ export const hasCellMetadata = (metadataCoordinates, cellCoordinates) => {
|
|
|
4
4
|
return R.pipe(
|
|
5
5
|
R.find(coordinates => {
|
|
6
6
|
const mergedCoord = R.mergeLeft(coordinates, cellCoordinates);
|
|
7
|
-
return R.equals(mergedCoord, cellCoordinates);
|
|
7
|
+
return !R.isEmpty(coordinates) && R.equals(mergedCoord, cellCoordinates);
|
|
8
8
|
}),
|
|
9
9
|
R.complement(R.isNil)
|
|
10
10
|
)(metadataCoordinates);
|
package/src/rules2/src/index.js
CHANGED
|
@@ -13,13 +13,28 @@ export { getHCodelistsRefs, getHCodelistsRefsInData } from './getHCodelistsRefsI
|
|
|
13
13
|
export { parseHierarchicalCodelist } from './parseHierarchicalCodelist';
|
|
14
14
|
export { refinePartialHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
|
|
15
15
|
export { getMetadataCoordinates } from './getMetadataCoordinates';
|
|
16
|
-
export {
|
|
17
|
-
getDataflowAdvancedAttributes,
|
|
18
|
-
getObservationsAdvancedAttributes,
|
|
19
|
-
getSeriesAdvancedAttributes
|
|
20
|
-
} from './getAdvancedAttributes';
|
|
21
16
|
export { duplicateObs } from './duplicateObservations';
|
|
22
17
|
export { hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
|
|
23
18
|
export { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy';
|
|
24
19
|
export { getDimensionValuesIndexes } from './getDimensionValuesIndexes';
|
|
25
|
-
|
|
20
|
+
export { getCombinationDefinitions } from './getCombinationDefinitions';
|
|
21
|
+
export { parseAttributes } from './parseAttributes';
|
|
22
|
+
export { parseCombinations } from './parseCombinations';
|
|
23
|
+
export { refineAttributes } from './refineAttributes';
|
|
24
|
+
export { enhanceObservations } from './enhanceObservations';
|
|
25
|
+
export { getAttributesSeries } from './getAttributesSeries';
|
|
26
|
+
export { getManyValuesDimensions } from './getManyValuesDimensions';
|
|
27
|
+
export { getOneValueDimensions } from './getOneValueDimensions';
|
|
28
|
+
export { getHeaderSubtitle } from './getHeaderSubtitle';
|
|
29
|
+
export { getHeaderCombinations } from './getHeaderCombinations';
|
|
30
|
+
export { getLayout } from './table/getLayout';
|
|
31
|
+
export { getSortedLayoutIndexes } from './table/getSortedLayoutIndexes';
|
|
32
|
+
export { refineLayoutSize } from './table/refineLayoutSize';
|
|
33
|
+
export { getFlagsAndNotes } from './table/getFlagsAndNotes';
|
|
34
|
+
export { getLayoutData } from './table/getLayoutData';
|
|
35
|
+
export { getCellsAttributesIds } from './table/getCellsAttributesIds';
|
|
36
|
+
export { getIndexedCombinationsByDisplay } from './table/getIndexedCombinationsByDisplay';
|
|
37
|
+
export { getCells } from './table/getCells';
|
|
38
|
+
export { getCuratedCells } from './table/getCuratedCells';
|
|
39
|
+
export { prepareData } from './prepareData';
|
|
40
|
+
export { getTableProps } from './table/getTableProps';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
import { REPORTING_YEAR_START_DAY, REPYEARSTART } from './constants';
|
|
3
|
+
|
|
4
|
+
export const parseAttributes = (attributes, dimensions, customAttributes) => {
|
|
5
|
+
const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
|
|
6
|
+
return R.addIndex(R.map)((attr, index) => {
|
|
7
|
+
let res = R.assoc('index', index, attr);
|
|
8
|
+
if (R.isEmpty(attr.values || []) || !R.propOr(true, 'display', attr)
|
|
9
|
+
|| attr.id === REPORTING_YEAR_START_DAY || attr.id === REPYEARSTART) {
|
|
10
|
+
return R.assoc('display', false, res);
|
|
11
|
+
}
|
|
12
|
+
if (R.propEq('id', customAttributes.prefscale, attr)) {
|
|
13
|
+
return R.assoc('prefscale', true, res);
|
|
14
|
+
}
|
|
15
|
+
if (R.propEq('id', customAttributes.decimals, attr)) {
|
|
16
|
+
return R.assoc('decimals', true, res);
|
|
17
|
+
}
|
|
18
|
+
if (R.hasPath(['relationship', 'none'], attr) || R.hasPath(['relationship', 'dataflow'], attr)) {
|
|
19
|
+
return { ...res, header: true, relationship: [] };
|
|
20
|
+
}
|
|
21
|
+
if (R.hasPath(['relationship', 'primaryMeasure'], attr) || R.hasPath(['relationship', 'observation'], attr)) {
|
|
22
|
+
return { ...res, series: true, relationship: [] };
|
|
23
|
+
}
|
|
24
|
+
const seriesDimensions = R.pipe(
|
|
25
|
+
R.pathOr([], ['relationship', 'dimensions']),
|
|
26
|
+
R.filter(id => {
|
|
27
|
+
const values = R.path([id, 'values'], indexedDimensions);
|
|
28
|
+
return R.length(values) > 1;
|
|
29
|
+
}),
|
|
30
|
+
)(attr);
|
|
31
|
+
if (R.length(seriesDimensions) > 0) {
|
|
32
|
+
return { ...res, series: true, relationship: seriesDimensions };
|
|
33
|
+
}
|
|
34
|
+
return { ...res, header: true, relationship: R.prop('dimensions', attr.relationship || []) };
|
|
35
|
+
}, attributes);
|
|
36
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const parseCombinations = (combinations, parsedAttributes, dimensions) => {
|
|
4
|
+
const indexedDimensions = R.indexBy(R.prop('id'), dimensions);
|
|
5
|
+
const indexedAttributes = R.indexBy(R.prop('id'), parsedAttributes);
|
|
6
|
+
|
|
7
|
+
return R.map(comb => {
|
|
8
|
+
let relationship = [];
|
|
9
|
+
let ids = {};
|
|
10
|
+
const seriesConcepts = R.filter(concept => {
|
|
11
|
+
if (R.has(concept, ids)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
if (R.has(concept, indexedDimensions)) {
|
|
15
|
+
const values = R.path([concept, 'values'], indexedDimensions);
|
|
16
|
+
relationship = R.length(values) > 1 ? R.append(concept, relationship) : relationship;
|
|
17
|
+
ids = { ...ids, [concept]: concept };
|
|
18
|
+
return R.length(values) > 1;
|
|
19
|
+
}
|
|
20
|
+
const attribute = R.prop(concept, indexedAttributes);
|
|
21
|
+
relationship = attribute.series
|
|
22
|
+
? R.pipe(
|
|
23
|
+
R.reject(id => R.has(id, ids)),
|
|
24
|
+
R.concat(relationship),
|
|
25
|
+
)(attribute.relationship)
|
|
26
|
+
: relationship;
|
|
27
|
+
ids = attribute.series ? { ...ids, ...R.indexBy(R.identity, attribute.relationship) } : ids;
|
|
28
|
+
return true;
|
|
29
|
+
}, comb.concepts);
|
|
30
|
+
|
|
31
|
+
if (R.isEmpty(seriesConcepts) || R.isEmpty(relationship)) {
|
|
32
|
+
return { ...comb, header: true };
|
|
33
|
+
}
|
|
34
|
+
return { ...comb, series: true, relationship };
|
|
35
|
+
}, combinations);
|
|
36
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
import { getObservations } from '../../rules/src';
|
|
3
|
+
import { enhanceObservations } from './enhanceObservations';
|
|
4
|
+
import { parseAttributes } from './parseAttributes';
|
|
5
|
+
import { getCombinationDefinitions } from './getCombinationDefinitions';
|
|
6
|
+
import { parseCombinations } from './parseCombinations';
|
|
7
|
+
import { refineAttributes } from './refineAttributes';
|
|
8
|
+
import { duplicateObs } from './duplicateObservations';
|
|
9
|
+
import { getMetadataCoordinates } from './getMetadataCoordinates';
|
|
10
|
+
import { getAttributesSeries } from './getAttributesSeries';
|
|
11
|
+
import { getManyValuesDimensions } from './getManyValuesDimensions';
|
|
12
|
+
import { getOneValueDimensions } from './getOneValueDimensions';
|
|
13
|
+
import { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy';
|
|
14
|
+
import { hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
|
|
15
|
+
|
|
16
|
+
export const prepareData = (sdmxJson, customAttributes, locale, hierarchies) => {
|
|
17
|
+
const dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], sdmxJson);
|
|
18
|
+
const attributes = R.pathOr([], ['data', 'structure', 'attributes', 'observation'], sdmxJson);
|
|
19
|
+
const annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
|
|
20
|
+
const observations = getObservations(sdmxJson);
|
|
21
|
+
const combinations = getCombinationDefinitions(annotations, locale);
|
|
22
|
+
const metadataCoordinates = getMetadataCoordinates(sdmxJson);
|
|
23
|
+
|
|
24
|
+
const parsedAttributes = parseAttributes(attributes, dimensions, customAttributes);
|
|
25
|
+
const parsedCombinations = parseCombinations(combinations, parsedAttributes, dimensions);
|
|
26
|
+
const seriesCombinations = R.filter(R.prop('series'), parsedCombinations);
|
|
27
|
+
const refinedAttributes = refineAttributes(parsedAttributes, seriesCombinations);
|
|
28
|
+
|
|
29
|
+
const enhancedObservations = enhanceObservations(dimensions, observations, refinedAttributes, { customAttributes });
|
|
30
|
+
const attributesSeries = getAttributesSeries(enhancedObservations);
|
|
31
|
+
const manyValuesDimensions = getManyValuesDimensions(dimensions, attributesSeries, customAttributes, seriesCombinations);
|
|
32
|
+
const oneValueDimensions = getOneValueDimensions(dimensions, parsedAttributes);
|
|
33
|
+
const hierarchisedDimensions = R.map(dim => {
|
|
34
|
+
if (R.isEmpty(R.propOr({}, dim.id, hierarchies))) {
|
|
35
|
+
return hierarchiseDimensionWithNativeHierarchy(dim);
|
|
36
|
+
}
|
|
37
|
+
return hierarchiseDimensionWithAdvancedHierarchy(dim, R.prop(dim.id, hierarchies));
|
|
38
|
+
}, manyValuesDimensions)
|
|
39
|
+
const duplicatedObservations = duplicateObs(R.values(hierarchisedDimensions), enhancedObservations);
|
|
40
|
+
|
|
41
|
+
return ({
|
|
42
|
+
observations: duplicatedObservations,
|
|
43
|
+
dimensions: hierarchisedDimensions,
|
|
44
|
+
combinations: parsedCombinations,
|
|
45
|
+
oneValueDimensions,
|
|
46
|
+
attributesSeries,
|
|
47
|
+
metadataCoordinates,
|
|
48
|
+
attributes: refinedAttributes
|
|
49
|
+
});
|
|
50
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const refineAttributes = (parsedAttributes, seriesCombinations) => {
|
|
4
|
+
const indexedRelationships = R.reduce(
|
|
5
|
+
(acc, comb) =>
|
|
6
|
+
R.reduce((_acc, concept) => R.assoc(concept, comb.relationship, _acc), acc, comb.concepts),
|
|
7
|
+
{},
|
|
8
|
+
seriesCombinations,
|
|
9
|
+
);
|
|
10
|
+
return R.map(attr => {
|
|
11
|
+
if (R.has(attr.id, indexedRelationships)) {
|
|
12
|
+
return { ...attr, series: true, relationship: R.prop(attr.id, indexedRelationships) };
|
|
13
|
+
}
|
|
14
|
+
return attr;
|
|
15
|
+
}, parsedAttributes);
|
|
16
|
+
};
|