@sis-cc/dotstatsuite-components 14.2.5 → 14.3.2
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/table/factories/getLayoutData.js +5 -3
- package/lib/rules/src/v8-transformer.js +1 -3
- package/lib/rules2/src/getHCodelistsRefsInData.js +18 -15
- package/lib/rules2/src/hierarchiseDimensionWithAdvancedHierarchy.js +35 -6
- package/lib/rules2/src/index.js +9 -0
- package/package.json +2 -2
- package/src/rules/src/table/factories/getLayoutData.js +5 -3
- package/src/rules/src/v8-transformer.js +2 -4
- package/src/rules2/src/getHCodelistsRefsInData.js +16 -7
- package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy.js +48 -5
- package/src/rules2/src/index.js +1 -0
- package/test/getHCodelistsRefs.test.js +3 -0
- package/test/hierarchiseDimensionWithAdvancedHierarchy.test.js +65 -18
|
@@ -58,6 +58,9 @@ var getRowData = function getRowData(indexes, dimension) {
|
|
|
58
58
|
var data = _ref.data,
|
|
59
59
|
missingParents = _ref.missingParents;
|
|
60
60
|
|
|
61
|
+
if (R.isNil(_value)) {
|
|
62
|
+
return { data: data, missingParents: {} };
|
|
63
|
+
}
|
|
61
64
|
var raw = {
|
|
62
65
|
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
63
66
|
value: _value
|
|
@@ -146,7 +149,7 @@ var getLayoutData = function getLayoutData(layoutIndexes, layout) {
|
|
|
146
149
|
rest = (0, _objectWithoutProperties3.default)(layoutIndexes, ['header', 'sections']);
|
|
147
150
|
|
|
148
151
|
var headerData = R.map(function (i) {
|
|
149
|
-
return indexesToLayoutData(layout.header, i);
|
|
152
|
+
return R.pipe(indexesToLayoutData, R.filter(R.prop('value')))(layout.header, i);
|
|
150
153
|
}, header);
|
|
151
154
|
|
|
152
155
|
var sectionsData = R.map(function (_ref2) {
|
|
@@ -154,13 +157,12 @@ var getLayoutData = function getLayoutData(layoutIndexes, layout) {
|
|
|
154
157
|
sectionIndexes = _ref3[0],
|
|
155
158
|
rows = _ref3[1];
|
|
156
159
|
|
|
157
|
-
var sectionData = indexesToLayoutData(layout.sections, sectionIndexes);
|
|
160
|
+
var sectionData = R.pipe(indexesToLayoutData, R.filter(R.prop('value')))(layout.sections, sectionIndexes);
|
|
158
161
|
|
|
159
162
|
var rowsData = getRowsData(rows, layout.rows);
|
|
160
163
|
|
|
161
164
|
return [sectionData, rowsData];
|
|
162
165
|
}, sections);
|
|
163
|
-
|
|
164
166
|
return (0, _extends3.default)({ headerData: headerData, sectionsData: sectionsData }, rest);
|
|
165
167
|
};
|
|
166
168
|
exports.getLayoutData = getLayoutData;
|
|
@@ -146,15 +146,13 @@ var dataTransformer = exports.dataTransformer = function dataTransformer(dataNew
|
|
|
146
146
|
|
|
147
147
|
var getDimObservations = R.propOr([], 'observation');
|
|
148
148
|
var dimObservations = getDimObservations(dimensions);
|
|
149
|
-
var timePeriodDimension = (0, _dotstatsuiteSdmxjs.getTimePeriodObservation)(dimObservations);
|
|
150
|
-
var timePeriodId = timePeriodDimension.id;
|
|
151
149
|
|
|
152
150
|
var getObservations = function getObservations(locale) {
|
|
153
151
|
return R.addIndex(R.reduce)(function (acc, observation, obsIndex) {
|
|
154
152
|
var id = R.prop('id')(observation);
|
|
155
153
|
var dimAnnotations = (0, _sdmxData.getRelationnalAnnotations)(R.propOr([], 'annotations')(observation))(annotations);
|
|
156
154
|
var isHidden = R.has(id, hiddenIds) || (0, _sdmxData.getIsHidden)(dimAnnotations);
|
|
157
|
-
var isTime = observation
|
|
155
|
+
var isTime = (0, _dotstatsuiteSdmxjs.isTimePeriodDimension)(observation);
|
|
158
156
|
var values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([], 'values', observation));
|
|
159
157
|
|
|
160
158
|
return {
|
|
@@ -22,21 +22,24 @@ var getHCodelistsRefs = exports.getHCodelistsRefs = function getHCodelistsRefs(a
|
|
|
22
22
|
if (annotation.type !== 'HIER_CONTEXT') {
|
|
23
23
|
return acc;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
var references = annotation.text || annotation.title || '';
|
|
26
|
+
var refs = R.pipe(R.split(','), R.reduce(function (acc2, ref) {
|
|
27
|
+
var match = ref.match(/([\w@_.]+):([\w@_.]+):([\w@_.]+)\(([\d.]+)\).([\w@_.]+)$/);
|
|
28
|
+
if (R.isNil(match)) {
|
|
29
|
+
return acc2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var _R$tail = R.tail(match),
|
|
33
|
+
_R$tail2 = (0, _slicedToArray3.default)(_R$tail, 5),
|
|
34
|
+
codelistId = _R$tail2[0],
|
|
35
|
+
agencyId = _R$tail2[1],
|
|
36
|
+
code = _R$tail2[2],
|
|
37
|
+
version = _R$tail2[3],
|
|
38
|
+
hierarchy = _R$tail2[4];
|
|
39
|
+
|
|
40
|
+
return R.assoc(codelistId, { agencyId: agencyId, code: code, version: version, hierarchy: hierarchy, codelistId: codelistId }, acc2);
|
|
41
|
+
}, {}))(references);
|
|
42
|
+
return R.mergeRight(acc, refs);
|
|
40
43
|
}, {}, annotations);
|
|
41
44
|
};
|
|
42
45
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.hierarchiseDimensionWithAdvancedHierarchy = undefined;
|
|
6
|
+
exports.hierarchiseDimensionWithAdvancedHierarchy = exports.refinePartialHierarchy = undefined;
|
|
7
7
|
|
|
8
8
|
var _extends2 = require('babel-runtime/helpers/extends');
|
|
9
9
|
|
|
@@ -17,11 +17,40 @@ 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
|
|
20
|
+
var refinePartialHierarchy = exports.refinePartialHierarchy = function refinePartialHierarchy(hier, indexed) {
|
|
21
|
+
return R.pipe(R.keys, R.reduce(function (acc, key) {
|
|
22
|
+
var ids = R.prop(key, hier);
|
|
23
|
+
if (key === '#ROOT') {
|
|
24
|
+
return R.assoc(key, ids, acc);
|
|
25
|
+
}
|
|
26
|
+
var refinedKey = R.pipe(R.split('.'), R.takeLastWhile(function (id) {
|
|
27
|
+
return R.has(id, indexed);
|
|
28
|
+
}), R.join('.'))(key);
|
|
29
|
+
if (R.isEmpty(refinedKey)) {
|
|
30
|
+
return R.over(R.lensProp('#ROOT0'), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(acc);
|
|
31
|
+
}
|
|
32
|
+
return R.over(R.lensProp(refinedKey), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(acc);
|
|
33
|
+
}, {}), function (res) {
|
|
34
|
+
var roots = R.pipe(R.propOr([], '#ROOT0'), R.unnest, R.sortBy(function (id) {
|
|
35
|
+
return R.path([id, '__indexPosition'], indexed);
|
|
36
|
+
}))(res);
|
|
37
|
+
return R.pipe(R.over(R.lensProp('#ROOT'), function (ids) {
|
|
38
|
+
return [R.concat(roots, ids)];
|
|
39
|
+
}), R.dissoc('#ROOT0'))(res);
|
|
40
|
+
}, R.mapObjIndexed(function (ids) {
|
|
41
|
+
if (R.length(ids) > 1) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return R.head(ids);
|
|
45
|
+
}))(hier);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var hierarchiseDimensionWithAdvancedHierarchy = exports.hierarchiseDimensionWithAdvancedHierarchy = function hierarchiseDimensionWithAdvancedHierarchy(dimension, _hierarchy) {
|
|
21
49
|
var indexed = R.indexBy(R.prop('id'), dimension.values);
|
|
50
|
+
var hierarchy = refinePartialHierarchy(_hierarchy, indexed);
|
|
22
51
|
|
|
23
52
|
var rest = indexed;
|
|
24
|
-
var getChildren = function getChildren(parents) {
|
|
53
|
+
var getChildren = function getChildren(parents, hier) {
|
|
25
54
|
return R.pipe(function (ids) {
|
|
26
55
|
rest = R.omit(ids, rest);
|
|
27
56
|
return R.props(ids, indexed);
|
|
@@ -30,9 +59,9 @@ var hierarchiseDimensionWithAdvancedHierarchy = exports.hierarchiseDimensionWith
|
|
|
30
59
|
parent: R.last(parents),
|
|
31
60
|
parents: parents
|
|
32
61
|
});
|
|
33
|
-
var children = getChildren(R.append(val.id, parents));
|
|
62
|
+
var children = getChildren(R.append(val.id, parents), hier);
|
|
34
63
|
return R.prepend(_val, children);
|
|
35
|
-
}))(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents),
|
|
64
|
+
}))(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents), hier));
|
|
36
65
|
};
|
|
37
66
|
|
|
38
67
|
return R.set(R.lensProp('values'), R.pipe(getChildren, R.flatten, function (values) {
|
|
@@ -43,5 +72,5 @@ var hierarchiseDimensionWithAdvancedHierarchy = exports.hierarchiseDimensionWith
|
|
|
43
72
|
return (0, _extends3.default)({}, val, { parent: undefined, parents: [] });
|
|
44
73
|
}), R.sortBy(R.prop('__indexPosition')))(rest);
|
|
45
74
|
return R.concat(sortedRest, values);
|
|
46
|
-
})([]))(dimension);
|
|
75
|
+
})([], hierarchy))(dimension);
|
|
47
76
|
};
|
package/lib/rules2/src/index.js
CHANGED
|
@@ -95,4 +95,13 @@ Object.defineProperty(exports, 'parseHierarchicalCodelist', {
|
|
|
95
95
|
get: function get() {
|
|
96
96
|
return _parseHierarchicalCodelist.parseHierarchicalCodelist;
|
|
97
97
|
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
var _hierarchiseDimensionWithAdvancedHierarchy = require('./hierarchiseDimensionWithAdvancedHierarchy');
|
|
101
|
+
|
|
102
|
+
Object.defineProperty(exports, 'refinePartialHierarchy', {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get: function get() {
|
|
105
|
+
return _hierarchiseDimensionWithAdvancedHierarchy.refinePartialHierarchy;
|
|
106
|
+
}
|
|
98
107
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sis-cc/dotstatsuite-components",
|
|
3
3
|
"description": "Set components based on React.",
|
|
4
|
-
"version": "14.2
|
|
4
|
+
"version": "14.3.2",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "OECD",
|
|
7
7
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@material-ui/core": "^4.x",
|
|
39
39
|
"@sis-cc/dotstatsuite-visions": "^7.x",
|
|
40
|
-
"@sis-cc/dotstatsuite-sdmxjs": "^
|
|
40
|
+
"@sis-cc/dotstatsuite-sdmxjs": "^8.x",
|
|
41
41
|
"react": "16.x"
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -37,6 +37,9 @@ const getRowData = (indexes, dimension) => {
|
|
|
37
37
|
R.props(indexes),
|
|
38
38
|
R.reduce(
|
|
39
39
|
({ data, missingParents }, _value) => {
|
|
40
|
+
if (R.isNil(_value)) {
|
|
41
|
+
return ({ data, missingParents: {} });
|
|
42
|
+
}
|
|
40
43
|
const raw = {
|
|
41
44
|
dimension: R.pick(['id', 'name', '__index'], dimension),
|
|
42
45
|
value: _value,
|
|
@@ -151,11 +154,11 @@ const getRowsData = (rowsIndexes, dimensions) => {
|
|
|
151
154
|
|
|
152
155
|
export const getLayoutData = (layoutIndexes, layout) => {
|
|
153
156
|
const { header, sections, ...rest } = layoutIndexes;
|
|
154
|
-
const headerData = R.map(i => indexesToLayoutData(layout.header, i), header);
|
|
157
|
+
const headerData = R.map(i => R.pipe(indexesToLayoutData, R.filter(R.prop('value')))(layout.header, i), header);
|
|
155
158
|
|
|
156
159
|
const sectionsData = R.map(
|
|
157
160
|
([sectionIndexes, rows]) => {
|
|
158
|
-
const sectionData = indexesToLayoutData(layout.sections, sectionIndexes);
|
|
161
|
+
const sectionData = R.pipe(indexesToLayoutData, R.filter(R.prop('value')))(layout.sections, sectionIndexes);
|
|
159
162
|
|
|
160
163
|
|
|
161
164
|
const rowsData = getRowsData(rows, layout.rows);
|
|
@@ -164,6 +167,5 @@ export const getLayoutData = (layoutIndexes, layout) => {
|
|
|
164
167
|
},
|
|
165
168
|
sections
|
|
166
169
|
);
|
|
167
|
-
|
|
168
170
|
return ({ headerData, sectionsData, ...rest });
|
|
169
171
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
import dateFns from 'date-fns';
|
|
3
|
-
import { getCodeOrder, getRefinedName,
|
|
3
|
+
import { getCodeOrder, getRefinedName, isTimePeriodDimension } from '@sis-cc/dotstatsuite-sdmxjs';
|
|
4
4
|
import {
|
|
5
5
|
getRelationnalAnnotations, setAnnotationsLayout, getIsHidden } from './sdmx-data';
|
|
6
6
|
import { getReportedTimePeriodLabel, getReportedTimePeriodNote, getReportedTimePeriod } from './date';
|
|
@@ -146,14 +146,12 @@ export const dataTransformer = (dataNew, options = {}) => {
|
|
|
146
146
|
|
|
147
147
|
const getDimObservations = R.propOr([], 'observation');
|
|
148
148
|
const dimObservations = getDimObservations(dimensions);
|
|
149
|
-
const timePeriodDimension = getTimePeriodObservation(dimObservations);
|
|
150
|
-
const timePeriodId = timePeriodDimension.id;
|
|
151
149
|
|
|
152
150
|
const getObservations = locale => R.addIndex(R.reduce)((acc, observation, obsIndex) => {
|
|
153
151
|
const id = R.prop('id')(observation);
|
|
154
152
|
const dimAnnotations = getRelationnalAnnotations(R.propOr([],'annotations')(observation))(annotations)
|
|
155
153
|
const isHidden = R.has(id, hiddenIds) || getIsHidden(dimAnnotations);
|
|
156
|
-
const isTime = observation
|
|
154
|
+
const isTime = isTimePeriodDimension(observation);
|
|
157
155
|
const values = getValuesEnhanced(locale, annotations, isTime, id)(R.propOr([],'values', observation));
|
|
158
156
|
|
|
159
157
|
return ({
|
|
@@ -5,13 +5,22 @@ export const getHCodelistsRefs = annotations => R.reduce(
|
|
|
5
5
|
if (annotation.type !== 'HIER_CONTEXT') {
|
|
6
6
|
return acc;
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const references = annotation.text || annotation.title || '';
|
|
9
|
+
const refs = R.pipe(
|
|
10
|
+
R.split(','),
|
|
11
|
+
R.reduce(
|
|
12
|
+
(acc2, ref) => {
|
|
13
|
+
const match = ref.match(/([\w@_.]+):([\w@_.]+):([\w@_.]+)\(([\d.]+)\).([\w@_.]+)$/);
|
|
14
|
+
if (R.isNil(match)) {
|
|
15
|
+
return acc2;
|
|
16
|
+
}
|
|
17
|
+
const [codelistId, agencyId, code, version, hierarchy] = R.tail(match);
|
|
18
|
+
return R.assoc(codelistId, { agencyId, code, version, hierarchy, codelistId }, acc2);
|
|
19
|
+
},
|
|
20
|
+
{}
|
|
21
|
+
)
|
|
22
|
+
)(references);
|
|
23
|
+
return R.mergeRight(acc, refs);
|
|
15
24
|
},
|
|
16
25
|
{},
|
|
17
26
|
annotations,
|
|
@@ -1,10 +1,53 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const refinePartialHierarchy = (hier, indexed) => R.pipe(
|
|
4
|
+
R.keys,
|
|
5
|
+
R.reduce(
|
|
6
|
+
(acc, key) => {
|
|
7
|
+
const ids = R.prop(key, hier);
|
|
8
|
+
if (key === '#ROOT') {
|
|
9
|
+
return R.assoc(key, ids, acc);
|
|
10
|
+
}
|
|
11
|
+
const refinedKey = R.pipe(
|
|
12
|
+
R.split('.'),
|
|
13
|
+
R.takeLastWhile(id => R.has(id, indexed)),
|
|
14
|
+
R.join('.')
|
|
15
|
+
)(key);
|
|
16
|
+
if (R.isEmpty(refinedKey)) {
|
|
17
|
+
return R.over(R.lensProp('#ROOT0'), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(acc)
|
|
18
|
+
}
|
|
19
|
+
return R.over(R.lensProp(refinedKey), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(acc);
|
|
20
|
+
},
|
|
21
|
+
{}
|
|
22
|
+
),
|
|
23
|
+
(res) => {
|
|
24
|
+
const roots = R.pipe(
|
|
25
|
+
R.propOr([], '#ROOT0'),
|
|
26
|
+
R.unnest,
|
|
27
|
+
R.sortBy(id => R.path([id, '__indexPosition'], indexed))
|
|
28
|
+
)(res);
|
|
29
|
+
return R.pipe(
|
|
30
|
+
R.over(R.lensProp('#ROOT'), ids => [R.concat(roots, ids)]),
|
|
31
|
+
R.dissoc('#ROOT0')
|
|
32
|
+
)(res);
|
|
33
|
+
},
|
|
34
|
+
R.mapObjIndexed(
|
|
35
|
+
(ids) => {
|
|
36
|
+
if (R.length(ids) > 1) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
return R.head(ids);
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
)(hier);
|
|
43
|
+
|
|
44
|
+
export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, _hierarchy) => {
|
|
4
45
|
const indexed = R.indexBy(R.prop('id'), dimension.values);
|
|
46
|
+
const hierarchy = refinePartialHierarchy(_hierarchy, indexed);
|
|
47
|
+
|
|
5
48
|
|
|
6
49
|
let rest = indexed;
|
|
7
|
-
const getChildren = (parents) => R.pipe(
|
|
50
|
+
const getChildren = (parents, hier) => R.pipe(
|
|
8
51
|
ids => {
|
|
9
52
|
rest = R.omit(ids, rest);
|
|
10
53
|
return R.props(ids, indexed)
|
|
@@ -17,11 +60,11 @@ export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, hierarchy)
|
|
|
17
60
|
parent: R.last(parents),
|
|
18
61
|
parents
|
|
19
62
|
};
|
|
20
|
-
const children = getChildren(R.append(val.id, parents));
|
|
63
|
+
const children = getChildren(R.append(val.id, parents), hier);
|
|
21
64
|
return R.prepend(_val, children);
|
|
22
65
|
},
|
|
23
66
|
)
|
|
24
|
-
)(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents),
|
|
67
|
+
)(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents), hier));
|
|
25
68
|
|
|
26
69
|
return R.set(
|
|
27
70
|
R.lensProp('values'),
|
|
@@ -39,6 +82,6 @@ export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, hierarchy)
|
|
|
39
82
|
)(rest);
|
|
40
83
|
return R.concat(sortedRest, values);
|
|
41
84
|
}
|
|
42
|
-
)([])
|
|
85
|
+
)([], hierarchy)
|
|
43
86
|
)(dimension);
|
|
44
87
|
};
|
package/src/rules2/src/index.js
CHANGED
|
@@ -11,3 +11,4 @@ export { getMSDInformations } from './getMSDInformations';
|
|
|
11
11
|
export { getNotDisplayedIds } from './getNotDisplayedIds';
|
|
12
12
|
export { getHCodelistsRefs, getHCodelistsRefsInData } from './getHCodelistsRefsInData';
|
|
13
13
|
export { parseHierarchicalCodelist } from './parseHierarchicalCodelist';
|
|
14
|
+
export { refinePartialHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy';
|
|
@@ -8,11 +8,14 @@ describe('getHCodelistsRefs tests', () => {
|
|
|
8
8
|
{ type: 'HIER_CONTEXT', text: 'C1:A:HCL1(1.0).HIER1' },
|
|
9
9
|
{ type: 'HIER_CONTEXT', title: 'C2:A:HCL2(1.0).HIER1' },
|
|
10
10
|
{ type: 'HIER_CONTEXT', text: 'C1:A:HCL1(1.0).HIER2' },
|
|
11
|
+
{ type: 'HIER_CONTEXT', text: 'C3:A:HCL3(1.0).HIER,C4:A:HCL4(1.0).HIER' }
|
|
11
12
|
];
|
|
12
13
|
|
|
13
14
|
const expected = {
|
|
14
15
|
C1: { agencyId: 'A', codelistId: 'C1', code: 'HCL1', hierarchy: 'HIER2', version: '1.0' },
|
|
15
16
|
C2: { agencyId: 'A', codelistId: 'C2', code: 'HCL2', hierarchy: 'HIER1', version: '1.0' },
|
|
17
|
+
C3: { agencyId: 'A', codelistId: 'C3', code: 'HCL3', hierarchy: 'HIER', version: '1.0' },
|
|
18
|
+
C4: { agencyId: 'A', codelistId: 'C4', code: 'HCL4', hierarchy: 'HIER', version: '1.0' },
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
expect(getHCodelistsRefs(annotations)).to.deep.equal(expected);
|
|
@@ -55,33 +55,80 @@ describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
|
|
|
55
55
|
const dimension = {
|
|
56
56
|
id: 'test',
|
|
57
57
|
values: [
|
|
58
|
-
{ id: 'IDF' },
|
|
59
|
-
{ id: 'CAN' },
|
|
60
|
-
{ id: 'USA' },
|
|
61
|
-
{ id: 'AFK' },
|
|
62
|
-
{ id: 'GER' },
|
|
63
|
-
{ id: 'FRA' },
|
|
64
|
-
{ id: 'EA' },
|
|
65
|
-
{ id: 'A' },
|
|
66
|
-
{ id: 'W' },
|
|
58
|
+
{ id: 'IDF', __indexPosition: 0 },
|
|
59
|
+
{ id: 'CAN', __indexPosition: 1 },
|
|
60
|
+
{ id: 'USA', __indexPosition: 2 },
|
|
61
|
+
{ id: 'AFK', __indexPosition: 3 },
|
|
62
|
+
{ id: 'GER', __indexPosition: 4 },
|
|
63
|
+
{ id: 'FRA', __indexPosition: 5 },
|
|
64
|
+
{ id: 'EA', __indexPosition: 6 },
|
|
65
|
+
{ id: 'A', __indexPosition: 7 },
|
|
66
|
+
{ id: 'W', __indexPosition: 8 },
|
|
67
67
|
]
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
const hierarchised = {
|
|
71
71
|
id: 'test',
|
|
72
72
|
values: [
|
|
73
|
-
{ id: '
|
|
74
|
-
{ id: '
|
|
75
|
-
{ id: '
|
|
76
|
-
{ id: 'W', parent: undefined, parents: [] },
|
|
77
|
-
{ id: 'EA', parent: 'W', parents: ['W'] },
|
|
78
|
-
{ id: 'FRA', parent: 'EA', parents: ['W', 'EA'] },
|
|
79
|
-
{ id: 'IDF', parent: 'FRA', parents: ['W', 'EA', 'FRA'] },
|
|
80
|
-
{ id: 'GER', parent: 'EA', parents: ['W', 'EA'] },
|
|
81
|
-
{ id: 'A', parent: 'W', parents: ['W'] },
|
|
73
|
+
{ id: 'AFK', parent: undefined, parents: [], __indexPosition: 3 },
|
|
74
|
+
{ id: 'CAN', parent: undefined, parents: [], __indexPosition: 1 },
|
|
75
|
+
{ id: 'USA', parent: undefined, parents: [], __indexPosition: 2 },
|
|
76
|
+
{ id: 'W', parent: undefined, parents: [], __indexPosition: 8 },
|
|
77
|
+
{ id: 'EA', parent: 'W', parents: ['W'], __indexPosition: 6 },
|
|
78
|
+
{ id: 'FRA', parent: 'EA', parents: ['W', 'EA'], __indexPosition: 5 },
|
|
79
|
+
{ id: 'IDF', parent: 'FRA', parents: ['W', 'EA', 'FRA'], __indexPosition: 0 },
|
|
80
|
+
{ id: 'GER', parent: 'EA', parents: ['W', 'EA'], __indexPosition: 4 },
|
|
81
|
+
{ id: 'A', parent: 'W', parents: ['W'], __indexPosition: 7 },
|
|
82
82
|
]
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(hierarchised);
|
|
86
86
|
});
|
|
87
|
+
it('partial deep hierarchy', () => {
|
|
88
|
+
const hierarchy = {
|
|
89
|
+
'#ROOT': ['W'],
|
|
90
|
+
'W': ['OECD', 'UE'],
|
|
91
|
+
'W.OECD': ['USA', 'FRA'],
|
|
92
|
+
'W.OECD.USA': ['NY', 'SF', 'LA'],
|
|
93
|
+
'W.OECD.FRA': ['IDF'],
|
|
94
|
+
'W.UE': ['FRA', 'GER'],
|
|
95
|
+
'W.UE.FRA': ['IDF'],
|
|
96
|
+
'W.UE.GER': ['BER'],
|
|
97
|
+
};
|
|
98
|
+
const dimension = {
|
|
99
|
+
id: 'test',
|
|
100
|
+
values: [
|
|
101
|
+
{ id: 'OECD' },
|
|
102
|
+
{ id: 'UE' },
|
|
103
|
+
{ id: 'USA' },
|
|
104
|
+
{ id: 'FRA' },
|
|
105
|
+
{ id: 'GER' },
|
|
106
|
+
{ id: 'NY' },
|
|
107
|
+
{ id: 'SF' },
|
|
108
|
+
{ id: 'LA' },
|
|
109
|
+
{ id: 'IDF' },
|
|
110
|
+
{ id: 'BER' },
|
|
111
|
+
]
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const expected = {
|
|
115
|
+
id: 'test',
|
|
116
|
+
values: [
|
|
117
|
+
{ id: 'OECD', parents: [], parent: undefined },
|
|
118
|
+
{ id: 'USA', parents: ['OECD'], parent: 'OECD' },
|
|
119
|
+
{ id: 'NY', parents: ['OECD', 'USA'], parent: 'USA' },
|
|
120
|
+
{ id: 'SF', parents: ['OECD', 'USA'], parent: 'USA' },
|
|
121
|
+
{ id: 'LA', parents: ['OECD', 'USA'], parent: 'USA' },
|
|
122
|
+
{ id: 'FRA', parents: ['OECD'], parent: 'OECD' },
|
|
123
|
+
{ id: 'IDF', parents: ['OECD', 'FRA'], parent: 'FRA' },
|
|
124
|
+
{ id: 'UE', parents: [], parent: undefined },
|
|
125
|
+
{ id: 'FRA', parents: ['UE'], parent: 'UE' },
|
|
126
|
+
{ id: 'IDF', parents: ['UE', 'FRA'], parent: 'FRA' },
|
|
127
|
+
{ id: 'GER', parents: ['UE'], parent: 'UE' },
|
|
128
|
+
{ id: 'BER', parents: ['UE', 'GER'], parent: 'GER' },
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(expected);
|
|
133
|
+
});
|
|
87
134
|
});
|