@sis-cc/dotstatsuite-components 16.1.1 → 16.1.3
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/rules2/src/constants.js +2 -1
- package/lib/rules2/src/enhanceObservations.js +5 -4
- package/lib/rules2/src/getAttributesSeries.js +7 -0
- package/lib/rules2/src/getCombinationDefinitions.js +25 -19
- package/lib/rules2/src/getDataflowAttributes.js +34 -0
- package/lib/rules2/src/getHeaderTitle.js +29 -0
- package/lib/rules2/src/getOneValueDimensions.js +3 -1
- package/lib/rules2/src/getSidebarData.js +8 -17
- package/lib/rules2/src/index.js +27 -0
- package/lib/rules2/src/parseCombinations.js +4 -2
- package/lib/rules2/src/prepareData.js +33 -2
- package/lib/rules2/src/table/getCells.js +4 -2
- package/lib/rules2/src/table/getCellsMetadataCoordinates.js +30 -0
- package/lib/rules2/src/table/getCombinationDimensionsData.js +5 -4
- package/lib/rules2/src/table/getLayoutData.js +15 -6
- package/lib/rules2/src/table/parseValueHierarchy.js +9 -8
- package/package.json +1 -1
- package/src/rules2/src/constants.js +1 -0
- package/src/rules2/src/enhanceObservations.js +4 -4
- package/src/rules2/src/getAttributesSeries.js +7 -0
- package/src/rules2/src/getCombinationDefinitions.js +20 -18
- package/src/rules2/src/getDataflowAttributes.js +23 -0
- package/src/rules2/src/getHeaderTitle.js +15 -0
- package/src/rules2/src/getOneValueDimensions.js +2 -1
- package/src/rules2/src/getSidebarData.js +4 -12
- package/src/rules2/src/index.js +3 -0
- package/src/rules2/src/parseCombinations.js +5 -2
- package/src/rules2/src/prepareData.js +22 -4
- package/src/rules2/src/table/getCells.js +4 -2
- package/src/rules2/src/table/getCellsMetadataCoordinates.js +13 -0
- package/src/rules2/src/table/getCombinationDimensionsData.js +5 -4
- package/src/rules2/src/table/getLayoutData.js +13 -5
- package/src/rules2/src/table/parseValueHierarchy.js +7 -8
- package/test/getAttributesSeries.test.js +2 -0
- package/test/getCells.test.js +1 -0
- package/test/getCellsMetadataCoordinates.test.js +40 -0
- package/test/getCombinationDimensionsData.test.js +7 -2
- package/test/getDataflowAttributes.test.js +23 -0
- package/test/getHeaderTitle.test.js +25 -0
- package/test/getLayoutData.test.js +130 -0
- package/test/parseCombinations.test.js +36 -0
- package/test/parseValueHierarchy.test.js +54 -4
|
@@ -7,4 +7,5 @@ var SDMX_3_0_JSON_DATA_FORMAT = exports.SDMX_3_0_JSON_DATA_FORMAT = 'application
|
|
|
7
7
|
var SDMX_3_0_CSV_DATA_FORMAT = exports.SDMX_3_0_CSV_DATA_FORMAT = 'application/vnd.sdmx.data+csv;version=2.0';
|
|
8
8
|
var EMPTY_ATTACHMENT_LEVEL_CHAR = exports.EMPTY_ATTACHMENT_LEVEL_CHAR = '~';
|
|
9
9
|
var REPORTING_YEAR_START_DAY = exports.REPORTING_YEAR_START_DAY = 'REPORTING_YEAR_START_DAY';
|
|
10
|
-
var REPYEARSTART = exports.REPYEARSTART = 'REPYEARSTART';
|
|
10
|
+
var REPYEARSTART = exports.REPYEARSTART = 'REPYEARSTART';
|
|
11
|
+
var REJECTED_VALUE_IDS = exports.REJECTED_VALUE_IDS = ['_L', '_T', '_Z'];
|
|
@@ -15,6 +15,8 @@ var R = _interopRequireWildcard(_ramda);
|
|
|
15
15
|
|
|
16
16
|
var _formatValue = require('../../rules/src/preparators/formatValue');
|
|
17
17
|
|
|
18
|
+
var _constants = require('./constants');
|
|
19
|
+
|
|
18
20
|
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; } }
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -25,11 +27,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
27
|
decimals: id,
|
|
26
28
|
prefscale: id,
|
|
27
29
|
},
|
|
28
|
-
rejectedValueIds,
|
|
29
30
|
}
|
|
30
31
|
*/
|
|
31
32
|
|
|
32
|
-
var parseAttributesValues = function parseAttributesValues(obs, attributes, indexedDimensions
|
|
33
|
+
var parseAttributesValues = function parseAttributesValues(obs, attributes, indexedDimensions) {
|
|
33
34
|
var attrValuesIndexes = obs.attrValuesIndexes,
|
|
34
35
|
dimValuesIndexes = obs.dimValuesIndexes;
|
|
35
36
|
|
|
@@ -39,7 +40,7 @@ var parseAttributesValues = function parseAttributesValues(obs, attributes, inde
|
|
|
39
40
|
return acc;
|
|
40
41
|
}
|
|
41
42
|
var value = R.nth(valueIndex, attribute.values || []);
|
|
42
|
-
if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value),
|
|
43
|
+
if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), _constants.REJECTED_VALUE_IDS)) {
|
|
43
44
|
value = null;
|
|
44
45
|
}
|
|
45
46
|
var relationship = R.propOr([], 'relationship', attribute);
|
|
@@ -90,7 +91,7 @@ var enhanceObservations = exports.enhanceObservations = function enhanceObservat
|
|
|
90
91
|
}, {}, dimensions);
|
|
91
92
|
|
|
92
93
|
return (0, _extends3.default)({}, observation, {
|
|
93
|
-
attributes: parseAttributesValues(observation, attributes, indexedDimensions
|
|
94
|
+
attributes: parseAttributesValues(observation, attributes, indexedDimensions),
|
|
94
95
|
formattedValue: (0, _formatValue.formatValue)(observation, formatAttributesIndexes, attributes),
|
|
95
96
|
indexedDimValIds: indexedDimValIds
|
|
96
97
|
});
|
|
@@ -19,6 +19,13 @@ var getAttributesSeries = exports.getAttributesSeries = function getAttributesSe
|
|
|
19
19
|
var rejected = acc.rejected;
|
|
20
20
|
R.forEachObjIndexed(function (attribute) {
|
|
21
21
|
if (!R.isNil(attribute.serieKey)) {
|
|
22
|
+
if (R.isNil(attribute.value)) {
|
|
23
|
+
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|
|
24
|
+
rejected = R.assocPath([attribute.serieKey, attribute.id], true, rejected);
|
|
25
|
+
}
|
|
26
|
+
if (R.path([attribute.serieKey, attribute.id], rejected)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
22
29
|
var valueInRes = R.path([attribute.serieKey, attribute.id, 'value', 'id'], res);
|
|
23
30
|
if (!R.isNil(valueInRes) && valueInRes !== R.path(['value', 'id'], attribute)) {
|
|
24
31
|
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getCombinationDefinitions = undefined;
|
|
6
|
+
exports.getCombinationDefinitions = exports.parseCombinationDefinition = undefined;
|
|
7
7
|
|
|
8
8
|
var _slicedToArray2 = require('babel-runtime/helpers/slicedToArray');
|
|
9
9
|
|
|
@@ -17,6 +17,29 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
19
|
|
|
20
|
+
var parseCombinationDefinition = exports.parseCombinationDefinition = function parseCombinationDefinition(locale) {
|
|
21
|
+
return function (title, texts) {
|
|
22
|
+
return R.useWith(function (titles, texts) {
|
|
23
|
+
return R.addIndex(R.map)(function (title, index) {
|
|
24
|
+
var split = R.split(':', title);
|
|
25
|
+
if (R.length(split !== 2)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var _split = (0, _slicedToArray3.default)(split, 2),
|
|
30
|
+
id = _split[0],
|
|
31
|
+
codes = _split[1];
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
id: id,
|
|
35
|
+
concepts: R.split(',', codes),
|
|
36
|
+
name: R.has(locale, texts) ? R.pipe(R.prop(locale), R.nth(index), R.split(':'), R.last)(texts) : '[' + id + ']'
|
|
37
|
+
};
|
|
38
|
+
}, titles);
|
|
39
|
+
}, [R.split(';'), R.map(R.split(';'))])(title, texts);
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
20
43
|
var getCombinationDefinitions = exports.getCombinationDefinitions = function getCombinationDefinitions(annotations, locale) {
|
|
21
44
|
var annotation = R.find(function (annot) {
|
|
22
45
|
return annot.type === 'COMBINED_CONCEPTS';
|
|
@@ -27,22 +50,5 @@ var getCombinationDefinitions = exports.getCombinationDefinitions = function get
|
|
|
27
50
|
var title = R.propOr('', 'title', annotation);
|
|
28
51
|
var texts = R.propOr({}, 'texts', annotation);
|
|
29
52
|
|
|
30
|
-
return
|
|
31
|
-
return R.addIndex(R.map)(function (title, index) {
|
|
32
|
-
var split = R.split(':', title);
|
|
33
|
-
if (R.length(split !== 2)) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
var _split = (0, _slicedToArray3.default)(split, 2),
|
|
38
|
-
id = _split[0],
|
|
39
|
-
codes = _split[1];
|
|
40
|
-
|
|
41
|
-
return {
|
|
42
|
-
id: id,
|
|
43
|
-
concepts: R.split(',', codes),
|
|
44
|
-
name: R.has(locale, texts) ? R.pipe(R.prop(locale), R.nth(index), R.split(':'), R.last)(texts) : '[' + id + ']'
|
|
45
|
-
};
|
|
46
|
-
}, titles);
|
|
47
|
-
}, [R.split(';'), R.map(R.split(';'))])(title, texts);
|
|
53
|
+
return parseCombinationDefinition(locale)(title, texts);
|
|
48
54
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDataflowAttributes = undefined;
|
|
7
|
+
|
|
8
|
+
var _extends2 = require('babel-runtime/helpers/extends');
|
|
9
|
+
|
|
10
|
+
var _extends3 = _interopRequireDefault(_extends2);
|
|
11
|
+
|
|
12
|
+
var _ramda = require('ramda');
|
|
13
|
+
|
|
14
|
+
var R = _interopRequireWildcard(_ramda);
|
|
15
|
+
|
|
16
|
+
var _constants = require('./constants');
|
|
17
|
+
|
|
18
|
+
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; } }
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
var getDataflowAttributes = exports.getDataflowAttributes = function getDataflowAttributes(attributes, combinations) {
|
|
23
|
+
var combinationsConceptsIds = R.pipe(R.pluck('concepts'), R.unnest)(combinations);
|
|
24
|
+
return R.reduce(function (acc, attribute) {
|
|
25
|
+
if (!R.prop('header', attribute) || !R.isEmpty(attribute.relationship) || R.includes(attribute.id, combinationsConceptsIds)) {
|
|
26
|
+
return acc;
|
|
27
|
+
}
|
|
28
|
+
var value = R.head(attribute.values);
|
|
29
|
+
if (!R.propOr(true, 'display', attribute) || R.isNil(value) || !R.propOr(true, 'display', value) || R.includes(R.prop('id', value), _constants.REJECTED_VALUE_IDS)) {
|
|
30
|
+
return acc;
|
|
31
|
+
}
|
|
32
|
+
return R.assoc(attribute.id, (0, _extends3.default)({}, R.pick(['id', 'name'], attribute), { value: value }), acc);
|
|
33
|
+
}, {}, attributes);
|
|
34
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getHeaderTitle = undefined;
|
|
7
|
+
|
|
8
|
+
var _ramda = require('ramda');
|
|
9
|
+
|
|
10
|
+
var R = _interopRequireWildcard(_ramda);
|
|
11
|
+
|
|
12
|
+
var _src = require('../../rules/src');
|
|
13
|
+
|
|
14
|
+
var _getFlagsAndNotes = require('./table/getFlagsAndNotes');
|
|
15
|
+
|
|
16
|
+
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; } }
|
|
17
|
+
|
|
18
|
+
var getHeaderTitle = exports.getHeaderTitle = function getHeaderTitle(dataflow, attributes, display, customAttributes) {
|
|
19
|
+
return {
|
|
20
|
+
label: (0, _src.dimensionValueDisplay)(display)(dataflow),
|
|
21
|
+
flags: R.pipe(_getFlagsAndNotes.getFlagsAndNotes, R.map(function (entry) {
|
|
22
|
+
return {
|
|
23
|
+
code: entry.code,
|
|
24
|
+
header: (0, _src.dimensionValueDisplay)(display)(entry) + ':',
|
|
25
|
+
label: (0, _src.dimensionValueDisplay)(display)(entry.value)
|
|
26
|
+
};
|
|
27
|
+
}))(attributes, customAttributes)
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -17,6 +17,8 @@ var _ramda = require('ramda');
|
|
|
17
17
|
|
|
18
18
|
var R = _interopRequireWildcard(_ramda);
|
|
19
19
|
|
|
20
|
+
var _constants = require('./constants');
|
|
21
|
+
|
|
20
22
|
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; } }
|
|
21
23
|
|
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -27,7 +29,7 @@ var getOneValueDimensions = exports.getOneValueDimensions = function getOneValue
|
|
|
27
29
|
return acc;
|
|
28
30
|
}
|
|
29
31
|
var value = R.path(['values', 0], attr);
|
|
30
|
-
if (R.isNil(value) || !R.prop('display', value)) {
|
|
32
|
+
if (R.isNil(value) || !R.prop('display', value) || R.includes(R.prop('id', value), _constants.REJECTED_VALUE_IDS)) {
|
|
31
33
|
return acc;
|
|
32
34
|
}
|
|
33
35
|
var dim = R.head(attr.relationship);
|
|
@@ -13,23 +13,14 @@ var _ramda = require('ramda');
|
|
|
13
13
|
|
|
14
14
|
var R = _interopRequireWildcard(_ramda);
|
|
15
15
|
|
|
16
|
+
var _src = require('../../rules/src');
|
|
17
|
+
|
|
18
|
+
var _constants = require('./constants');
|
|
19
|
+
|
|
16
20
|
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; } }
|
|
17
21
|
|
|
18
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
23
|
|
|
20
|
-
var dimensionValueDisplay = function dimensionValueDisplay(display) {
|
|
21
|
-
return function (data) {
|
|
22
|
-
var name = R.isNil(data.name) ? '[' + data.id + ']' : data.name;
|
|
23
|
-
if (display === 'code') {
|
|
24
|
-
return R.prop('id', data);
|
|
25
|
-
}
|
|
26
|
-
if (display === 'both') {
|
|
27
|
-
return R.prop('id', data) + ': ' + name;
|
|
28
|
-
}
|
|
29
|
-
return name;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
24
|
var sortByCoordinates = function sortByCoordinates(a, b) {
|
|
34
25
|
var splitACoord = a.splitCoord;
|
|
35
26
|
var splitBCoord = b.splitCoord;
|
|
@@ -65,11 +56,11 @@ var getSidebarData = exports.getSidebarData = function getSidebarData(attributes
|
|
|
65
56
|
var dim = R.nth(dimIndex, dimensions);
|
|
66
57
|
var values = R.propOr([], 'values', dim || {});
|
|
67
58
|
var value = R.nth(Number(valIndex), values);
|
|
68
|
-
if (!value || !R.propOr(true, 'display', dim) || !R.propOr(true, 'display', value)) {
|
|
59
|
+
if (!value || !R.propOr(true, 'display', dim) || !R.propOr(true, 'display', value) || R.includes(R.prop('id', value), _constants.REJECTED_VALUE_IDS)) {
|
|
69
60
|
return (0, _extends3.default)({}, acc, { split: R.append('', acc.split) });
|
|
70
61
|
}
|
|
71
|
-
var dimLabel = dimensionValueDisplay(options.display)(dim);
|
|
72
|
-
var valLabel = dimensionValueDisplay(options.display)(value);
|
|
62
|
+
var dimLabel = (0, _src.dimensionValueDisplay)(options.display)(dim);
|
|
63
|
+
var valLabel = (0, _src.dimensionValueDisplay)(options.display)(value);
|
|
73
64
|
return {
|
|
74
65
|
labels: R.append(dimLabel + ': ' + valLabel, acc.labels),
|
|
75
66
|
split: R.append(valIndex, acc.split)
|
|
@@ -78,7 +69,7 @@ var getSidebarData = exports.getSidebarData = function getSidebarData(attributes
|
|
|
78
69
|
split = _R$addIndex.split,
|
|
79
70
|
labels = _R$addIndex.labels;
|
|
80
71
|
|
|
81
|
-
var label = R.isEmpty(labels) ? dimensionValueDisplay(options.display)(dataflow) : R.join(' - ', labels);
|
|
72
|
+
var label = R.isEmpty(labels) ? (0, _src.dimensionValueDisplay)(options.display)(dataflow) : R.join(' - ', labels);
|
|
82
73
|
|
|
83
74
|
return {
|
|
84
75
|
id: R.join(':', split),
|
package/lib/rules2/src/index.js
CHANGED
|
@@ -220,6 +220,24 @@ Object.defineProperty(exports, 'getOneValueDimensions', {
|
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
222
|
|
|
223
|
+
var _getDataflowAttributes = require('./getDataflowAttributes');
|
|
224
|
+
|
|
225
|
+
Object.defineProperty(exports, 'getDataflowAttributes', {
|
|
226
|
+
enumerable: true,
|
|
227
|
+
get: function get() {
|
|
228
|
+
return _getDataflowAttributes.getDataflowAttributes;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
var _getHeaderTitle = require('./getHeaderTitle');
|
|
233
|
+
|
|
234
|
+
Object.defineProperty(exports, 'getHeaderTitle', {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
get: function get() {
|
|
237
|
+
return _getHeaderTitle.getHeaderTitle;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
|
|
223
241
|
var _getHeaderSubtitle = require('./getHeaderSubtitle');
|
|
224
242
|
|
|
225
243
|
Object.defineProperty(exports, 'getHeaderSubtitle', {
|
|
@@ -292,6 +310,15 @@ Object.defineProperty(exports, 'getCellsAttributesIds', {
|
|
|
292
310
|
}
|
|
293
311
|
});
|
|
294
312
|
|
|
313
|
+
var _getCellsMetadataCoordinates = require('./table/getCellsMetadataCoordinates');
|
|
314
|
+
|
|
315
|
+
Object.defineProperty(exports, 'getCellsMetadataCoordinates', {
|
|
316
|
+
enumerable: true,
|
|
317
|
+
get: function get() {
|
|
318
|
+
return _getCellsMetadataCoordinates.getCellsMetadataCoordinates;
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
|
|
295
322
|
var _getIndexedCombinationsByDisplay = require('./table/getIndexedCombinationsByDisplay');
|
|
296
323
|
|
|
297
324
|
Object.defineProperty(exports, 'getIndexedCombinationsByDisplay', {
|
|
@@ -37,16 +37,18 @@ var parseCombinations = exports.parseCombinations = function parseCombinations(c
|
|
|
37
37
|
relationship = R.length(values) > 1 ? R.append(concept, relationship) : relationship;
|
|
38
38
|
ids = (0, _extends4.default)({}, ids, (0, _defineProperty3.default)({}, concept, concept));
|
|
39
39
|
return R.length(values) > 1;
|
|
40
|
+
} else if (!R.has(concept, indexedAttributes)) {
|
|
41
|
+
return false;
|
|
40
42
|
}
|
|
41
43
|
var attribute = R.prop(concept, indexedAttributes);
|
|
42
44
|
relationship = attribute.series ? R.pipe(R.reject(function (id) {
|
|
43
45
|
return R.has(id, ids);
|
|
44
46
|
}), R.concat(relationship))(attribute.relationship) : relationship;
|
|
45
47
|
ids = attribute.series ? (0, _extends4.default)({}, ids, R.indexBy(R.identity, attribute.relationship)) : ids;
|
|
46
|
-
return
|
|
48
|
+
return attribute.series;
|
|
47
49
|
}, comb.concepts);
|
|
48
50
|
|
|
49
|
-
if (R.isEmpty(seriesConcepts)
|
|
51
|
+
if (R.isEmpty(seriesConcepts)) {
|
|
50
52
|
return (0, _extends4.default)({}, comb, { header: true });
|
|
51
53
|
}
|
|
52
54
|
return (0, _extends4.default)({}, comb, { series: true, relationship: relationship });
|
|
@@ -35,14 +35,35 @@ var _hierarchiseDimensionWithNativeHierarchy = require('./hierarchiseDimensionWi
|
|
|
35
35
|
|
|
36
36
|
var _hierarchiseDimensionWithAdvancedHierarchy = require('./hierarchiseDimensionWithAdvancedHierarchy');
|
|
37
37
|
|
|
38
|
+
var _getDataflowAttributes = require('./getDataflowAttributes');
|
|
39
|
+
|
|
40
|
+
var _getHeaderTitle = require('./getHeaderTitle');
|
|
41
|
+
|
|
42
|
+
var _getHeaderSubtitle = require('./getHeaderSubtitle');
|
|
43
|
+
|
|
44
|
+
var _getHeaderCombinations = require('./getHeaderCombinations');
|
|
45
|
+
|
|
38
46
|
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; } }
|
|
39
47
|
|
|
40
|
-
var prepareData = exports.prepareData = function prepareData(sdmxJson,
|
|
48
|
+
var prepareData = exports.prepareData = function prepareData(sdmxJson, _ref) {
|
|
49
|
+
var customAttributes = _ref.customAttributes,
|
|
50
|
+
locale = _ref.locale,
|
|
51
|
+
hierarchies = _ref.hierarchies,
|
|
52
|
+
dataflow = _ref.dataflow,
|
|
53
|
+
display = _ref.display,
|
|
54
|
+
defaultCombinations = _ref.defaultCombinations;
|
|
55
|
+
|
|
41
56
|
var dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], sdmxJson);
|
|
42
57
|
var attributes = R.pathOr([], ['data', 'structure', 'attributes', 'observation'], sdmxJson);
|
|
43
58
|
var annotations = R.pathOr([], ['data', 'structure', 'annotations'], sdmxJson);
|
|
44
59
|
var observations = (0, _src.getObservations)(sdmxJson);
|
|
45
60
|
var combinations = (0, _getCombinationDefinitions.getCombinationDefinitions)(annotations, locale);
|
|
61
|
+
if (R.isEmpty(combinations) && !R.isEmpty(defaultCombinations)) {
|
|
62
|
+
var concepts = defaultCombinations.concepts,
|
|
63
|
+
names = defaultCombinations.names;
|
|
64
|
+
|
|
65
|
+
combinations = (0, _getCombinationDefinitions.parseCombinationDefinition)(locale)(concepts, names);
|
|
66
|
+
}
|
|
46
67
|
var metadataCoordinates = (0, _getMetadataCoordinates.getMetadataCoordinates)(sdmxJson);
|
|
47
68
|
|
|
48
69
|
var parsedAttributes = (0, _parseAttributes.parseAttributes)(attributes, dimensions, customAttributes);
|
|
@@ -62,6 +83,11 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
|
|
|
62
83
|
}, manyValuesDimensions);
|
|
63
84
|
var duplicatedObservations = (0, _duplicateObservations.duplicateObs)(R.values(hierarchisedDimensions), enhancedObservations);
|
|
64
85
|
|
|
86
|
+
var dataflowAttributes = (0, _getDataflowAttributes.getDataflowAttributes)(parsedAttributes, parsedCombinations);
|
|
87
|
+
var headerTitle = (0, _getHeaderTitle.getHeaderTitle)(dataflow, dataflowAttributes, display, customAttributes);
|
|
88
|
+
var headerSubtitle = (0, _getHeaderSubtitle.getHeaderSubtitle)(oneValueDimensions, parsedCombinations, customAttributes, display);
|
|
89
|
+
var headerCombinations = (0, _getHeaderCombinations.getHeaderCombinations)(parsedCombinations, oneValueDimensions, refinedAttributes, display);
|
|
90
|
+
|
|
65
91
|
return {
|
|
66
92
|
observations: duplicatedObservations,
|
|
67
93
|
dimensions: hierarchisedDimensions,
|
|
@@ -69,6 +95,11 @@ var prepareData = exports.prepareData = function prepareData(sdmxJson, customAtt
|
|
|
69
95
|
oneValueDimensions: oneValueDimensions,
|
|
70
96
|
attributesSeries: attributesSeries,
|
|
71
97
|
metadataCoordinates: metadataCoordinates,
|
|
72
|
-
attributes: refinedAttributes
|
|
98
|
+
attributes: refinedAttributes,
|
|
99
|
+
header: {
|
|
100
|
+
title: headerTitle,
|
|
101
|
+
subtitle: headerSubtitle,
|
|
102
|
+
combinations: headerCombinations
|
|
103
|
+
}
|
|
73
104
|
};
|
|
74
105
|
};
|
|
@@ -25,6 +25,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
|
|
26
26
|
var getCellRelevantAttributes = exports.getCellRelevantAttributes = function getCellRelevantAttributes(attributes, attributesSeries, cellAttributeIds) {
|
|
27
27
|
return R.filter(function (attr) {
|
|
28
|
+
if (R.isNil(attr.value)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
28
31
|
if (R.has(attr.id, cellAttributeIds)) {
|
|
29
32
|
return true;
|
|
30
33
|
}
|
|
@@ -56,9 +59,8 @@ var getCells = exports.getCells = function getCells(customAttributes, cellsAttri
|
|
|
56
59
|
|
|
57
60
|
return R.mapObjIndexed(function (obs) {
|
|
58
61
|
var relevantAttributes = getCellRelevantAttributes(obs.attributes, attributesSeries, cellsAttributesId);
|
|
59
|
-
var flagsAndNotes = (0, _getFlagsAndNotes.getFlagsAndNotes)(relevantAttributes, _customAttributes);
|
|
62
|
+
var flagsAndNotes = (0, _getFlagsAndNotes.getFlagsAndNotes)(R.omit(attributesInCellsCombination, relevantAttributes), _customAttributes);
|
|
60
63
|
var combinedAttributes = getCellCombinedAttributes(relevantAttributes, combinations.cells || []);
|
|
61
|
-
|
|
62
64
|
var hasAdvancedAttributes = R.pipe(R.omit(R.unnest([_customAttributes.flags || [], _customAttributes.notes || [], attributesInCellsCombination])), R.isEmpty, R.not)(relevantAttributes);
|
|
63
65
|
|
|
64
66
|
var hasMetadata = (0, _hasCellMetadata.hasCellMetadata)(metadataCoordinates, obs.indexedDimValIds);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCellsMetadataCoordinates = undefined;
|
|
7
|
+
|
|
8
|
+
var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
|
|
11
|
+
|
|
12
|
+
var _ramda = require('ramda');
|
|
13
|
+
|
|
14
|
+
var R = _interopRequireWildcard(_ramda);
|
|
15
|
+
|
|
16
|
+
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; } }
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
var getCellsMetadataCoordinates = exports.getCellsMetadataCoordinates = function getCellsMetadataCoordinates(metadataCoordinates, oneValueDimensions, layoutIds) {
|
|
21
|
+
var oneValueDimsIds = R.pluck('id', oneValueDimensions);
|
|
22
|
+
return R.reject(function (coordinates) {
|
|
23
|
+
var columnIds = R.concat(layoutIds.header, oneValueDimsIds);
|
|
24
|
+
if (R.isEmpty(R.omit(columnIds, coordinates))) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
var rowsIds = [].concat((0, _toConsumableArray3.default)(layoutIds.sections), (0, _toConsumableArray3.default)(layoutIds.rows), (0, _toConsumableArray3.default)(oneValueDimsIds));
|
|
28
|
+
return R.isEmpty(R.omit(rowsIds, coordinates));
|
|
29
|
+
}, metadataCoordinates);
|
|
30
|
+
};
|
|
@@ -26,16 +26,17 @@ var getCombinationDimensionsData = exports.getCombinationDimensionsData = functi
|
|
|
26
26
|
var dimension = R.nth(dimIndex, dimensions);
|
|
27
27
|
var value = R.nth(Math.abs(valIndex), R.propOr([], 'values', dimension));
|
|
28
28
|
hasAdvancedAttributes = !hasAdvancedAttributes ? value.hasAdvancedAttributes : true;
|
|
29
|
-
if (!value) {
|
|
30
|
-
return acc;
|
|
31
|
-
}
|
|
32
29
|
coordinates = R.assoc(dimension.id, value.id, coordinates);
|
|
33
30
|
ids = R.append(dimension.id + '=' + value.id, ids);
|
|
34
31
|
var previousValue = R.propOr({}, dimension.id, previous);
|
|
35
32
|
if (value.id === R.prop('id', previousValue || {}) && _sameSerie) {
|
|
36
33
|
return R.assoc(dimension.id, previousValue, acc);
|
|
37
34
|
} else {
|
|
38
|
-
var
|
|
35
|
+
var _parsedValue = (0, _parseValueHierarchy.parseValueHierarchy)(value, _sameSerie ? previousValue || {} : {}, dimension.indexedValues);
|
|
36
|
+
var parsedValue = R.over(R.lensProp('display'), function () {
|
|
37
|
+
var display = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
38
|
+
return display && R.propOr(true, 'display', dimension);
|
|
39
|
+
})(_parsedValue);
|
|
39
40
|
if (!R.isNil(previous)) {
|
|
40
41
|
_sameSerie = false;
|
|
41
42
|
}
|
|
@@ -29,6 +29,8 @@ var _getCombinationDimensionsData = require('./getCombinationDimensionsData');
|
|
|
29
29
|
|
|
30
30
|
var _parseValueHierarchy = require('./parseValueHierarchy');
|
|
31
31
|
|
|
32
|
+
var _constants = require('../constants');
|
|
33
|
+
|
|
32
34
|
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; } }
|
|
33
35
|
|
|
34
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -36,7 +38,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
36
38
|
var getSubLayoutData = function getSubLayoutData(series, _definition, _ref) {
|
|
37
39
|
var metadataCoordinates = _ref.metadataCoordinates,
|
|
38
40
|
attributesSeries = _ref.attributesSeries,
|
|
39
|
-
customAttributes = _ref.customAttributes
|
|
41
|
+
customAttributes = _ref.customAttributes,
|
|
42
|
+
_ref$topCoordinates = _ref.topCoordinates,
|
|
43
|
+
topCoordinates = _ref$topCoordinates === undefined ? {} : _ref$topCoordinates;
|
|
40
44
|
|
|
41
45
|
var getHasAdvancedAttributes = function getHasAdvancedAttributes(attrValues) {
|
|
42
46
|
return R.pipe(R.omit(R.concat(customAttributes.flags, customAttributes.notes)), R.isEmpty, R.not)(attrValues);
|
|
@@ -68,7 +72,7 @@ var getSubLayoutData = function getSubLayoutData(series, _definition, _ref) {
|
|
|
68
72
|
var sameSerie = true;
|
|
69
73
|
var i = 0;
|
|
70
74
|
var hasAdvancedAttributes = false;
|
|
71
|
-
var coordinates =
|
|
75
|
+
var coordinates = topCoordinates;
|
|
72
76
|
var ids = [];
|
|
73
77
|
while (i < serie.length) {
|
|
74
78
|
var entry = serie[i];
|
|
@@ -137,7 +141,11 @@ var getSubLayoutData = function getSubLayoutData(series, _definition, _ref) {
|
|
|
137
141
|
var fixedDimValues = R.propOr([], 'fixedDimValues', def);
|
|
138
142
|
var values = R.reduce(function (_acc, id) {
|
|
139
143
|
if (R.has(id, dimValues)) {
|
|
140
|
-
|
|
144
|
+
var _value = R.prop(id, dimValues);
|
|
145
|
+
if (!R.propOr(true, 'display', _value) || R.includes(R.prop('id', _value), _constants.REJECTED_VALUE_IDS)) {
|
|
146
|
+
return _acc;
|
|
147
|
+
}
|
|
148
|
+
return R.append(R.dissoc('display', _value), _acc);
|
|
141
149
|
}
|
|
142
150
|
if (R.has(id, fixedDimValues)) {
|
|
143
151
|
return R.append(R.prop(id, fixedDimValues), _acc);
|
|
@@ -162,7 +170,7 @@ var getSubLayoutData = function getSubLayoutData(series, _definition, _ref) {
|
|
|
162
170
|
var sideProps = hasMetadata || hasAdvancedAttributes ? { hasMetadata: hasMetadata, hasAdvancedAttributes: hasAdvancedAttributes, coordinates: coordinates } : null;
|
|
163
171
|
|
|
164
172
|
return {
|
|
165
|
-
res: R.append({ data: data, key: R.join(':', ids), flags: flags, sideProps: sideProps }, acc.res),
|
|
173
|
+
res: R.append({ data: data, key: R.join(':', ids), flags: flags, sideProps: sideProps, coordinates: coordinates }, acc.res),
|
|
166
174
|
previous: next
|
|
167
175
|
};
|
|
168
176
|
}, { res: [], previous: [] }, series),
|
|
@@ -190,8 +198,9 @@ var getLayoutData = function getLayoutData(layoutIndexes, layout, _ref2) {
|
|
|
190
198
|
return [];
|
|
191
199
|
}
|
|
192
200
|
var _sectionsData = getSubLayoutData(sections, layout.sections, opts);
|
|
193
|
-
var rowsData = R.map(function (rows) {
|
|
194
|
-
|
|
201
|
+
var rowsData = R.addIndex(R.map)(function (rows, sectionIndex) {
|
|
202
|
+
var sectionCoordinates = R.path([sectionIndex, 'coordinates'], _sectionsData);
|
|
203
|
+
return getSubLayoutData(rows, layout.rows, R.assoc('topCoordinates', sectionCoordinates, opts));
|
|
195
204
|
}, sectionsRows);
|
|
196
205
|
|
|
197
206
|
return R.transpose([_sectionsData, rowsData]);
|
|
@@ -34,19 +34,20 @@ var parseValueHierarchy = exports.parseValueHierarchy = function parseValueHiera
|
|
|
34
34
|
}, parentsIds),
|
|
35
35
|
_R$addIndex2 = (0, _slicedToArray3.default)(_R$addIndex, 2),
|
|
36
36
|
presentIds = _R$addIndex2[0],
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
_missingIds = _R$addIndex2[1];
|
|
38
|
+
|
|
39
|
+
var __previousParentsIds = R.pipe(R.propOr([], 'parents'), R.pluck('id'))(previousValue);
|
|
40
|
+
var missingIds = R.pipe(R.takeLastWhile(function (id) {
|
|
41
|
+
return !R.includes(id, __previousParentsIds) && id !== R.prop('id', previousValue);
|
|
42
|
+
}), function (ids) {
|
|
43
|
+
return R.concat(ids, _missingIds);
|
|
44
|
+
})(presentIds);
|
|
41
45
|
var _previousParents = R.propOr([], 'parents', previousValue);
|
|
42
46
|
var previousParents = R.isNil(previousValue) ? [] : R.append(R.pick(['id', 'name'], previousValue), _previousParents);
|
|
43
|
-
//console.log('previousParents', previousParents);
|
|
44
47
|
var parents = R.takeWhile(function (p) {
|
|
45
48
|
return R.includes(p.id, presentIds);
|
|
46
49
|
}, previousParents);
|
|
47
|
-
var missingParents = R.
|
|
48
|
-
return R.includes(p.id, presentIds);
|
|
49
|
-
}, R.propOr([], 'missingParents', previousValue)), R.props(missingIds, indexedValues));
|
|
50
|
+
var missingParents = R.props(missingIds, indexedValues);
|
|
50
51
|
return (0, _extends3.default)({}, value, {
|
|
51
52
|
parents: parents,
|
|
52
53
|
parentsIds: parentsIds,
|
package/package.json
CHANGED
|
@@ -3,3 +3,4 @@ export const SDMX_3_0_CSV_DATA_FORMAT = 'application/vnd.sdmx.data+csv;version=2
|
|
|
3
3
|
export const EMPTY_ATTACHMENT_LEVEL_CHAR = '~';
|
|
4
4
|
export const REPORTING_YEAR_START_DAY = 'REPORTING_YEAR_START_DAY';
|
|
5
5
|
export const REPYEARSTART = 'REPYEARSTART';
|
|
6
|
+
export const REJECTED_VALUE_IDS = ['_L', '_T', '_Z'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import { formatValue } from '../../rules/src/preparators/formatValue';
|
|
3
|
+
import { REJECTED_VALUE_IDS } from './constants';
|
|
3
4
|
|
|
4
5
|
/*
|
|
5
6
|
options = {
|
|
@@ -7,11 +8,10 @@ import { formatValue } from '../../rules/src/preparators/formatValue';
|
|
|
7
8
|
decimals: id,
|
|
8
9
|
prefscale: id,
|
|
9
10
|
},
|
|
10
|
-
rejectedValueIds,
|
|
11
11
|
}
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
const parseAttributesValues = (obs, attributes, indexedDimensions
|
|
14
|
+
const parseAttributesValues = (obs, attributes, indexedDimensions) => {
|
|
15
15
|
const { attrValuesIndexes, dimValuesIndexes } = obs;
|
|
16
16
|
return R.addIndex(R.reduce)(
|
|
17
17
|
(acc, valueIndex, attrIndex) => {
|
|
@@ -20,7 +20,7 @@ const parseAttributesValues = (obs, attributes, indexedDimensions, rejectedValue
|
|
|
20
20
|
return acc;
|
|
21
21
|
}
|
|
22
22
|
let value = R.nth(valueIndex, attribute.values || []);
|
|
23
|
-
if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value),
|
|
23
|
+
if (!R.propOr(true, 'display', value) || R.includes(R.prop('id', value), REJECTED_VALUE_IDS)) {
|
|
24
24
|
value = null;
|
|
25
25
|
}
|
|
26
26
|
const relationship = R.propOr([], 'relationship', attribute);
|
|
@@ -78,7 +78,7 @@ export const enhanceObservations = (dimensions = [], observations = {}, attribut
|
|
|
78
78
|
|
|
79
79
|
return ({
|
|
80
80
|
...observation,
|
|
81
|
-
attributes: parseAttributesValues(observation, attributes, indexedDimensions
|
|
81
|
+
attributes: parseAttributesValues(observation, attributes, indexedDimensions),
|
|
82
82
|
formattedValue: formatValue(observation, formatAttributesIndexes, attributes),
|
|
83
83
|
indexedDimValIds,
|
|
84
84
|
});
|
|
@@ -9,6 +9,13 @@ export const getAttributesSeries = observations => R.pipe(
|
|
|
9
9
|
R.forEachObjIndexed(
|
|
10
10
|
(attribute) => {
|
|
11
11
|
if (!R.isNil(attribute.serieKey)) {
|
|
12
|
+
if (R.isNil(attribute.value)) {
|
|
13
|
+
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|
|
14
|
+
rejected = R.assocPath([attribute.serieKey, attribute.id], true, rejected);
|
|
15
|
+
}
|
|
16
|
+
if (R.path([attribute.serieKey, attribute.id], rejected)) {
|
|
17
|
+
return ;
|
|
18
|
+
}
|
|
12
19
|
const valueInRes = R.path([attribute.serieKey, attribute.id, 'value', 'id'], res);
|
|
13
20
|
if (!R.isNil(valueInRes) && valueInRes !== R.path(['value', 'id'], attribute)) {
|
|
14
21
|
res = R.dissocPath([attribute.serieKey, attribute.id], res);
|