@sis-cc/dotstatsuite-components 14.3.0 → 14.3.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/getHCodelistsRefsInData.js +18 -15
- package/lib/rules2/src/hierarchiseDimensionWithAdvancedHierarchy.js +54 -6
- package/lib/rules2/src/index.js +9 -0
- package/package.json +1 -1
- package/src/rules2/src/getHCodelistsRefsInData.js +16 -7
- package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy.js +62 -5
- package/src/rules2/src/index.js +1 -0
- package/test/getHCodelistsRefs.test.js +3 -0
- package/test/hierarchiseDimensionWithAdvancedHierarchy.test.js +125 -18
|
@@ -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,59 @@ 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 uniq = R.pipe(R.reduce(function (_ref, id) {
|
|
21
|
+
var ids = _ref.ids,
|
|
22
|
+
list = _ref.list;
|
|
23
|
+
|
|
24
|
+
if (R.has(id, list)) {
|
|
25
|
+
return { ids: ids, list: list };
|
|
26
|
+
}
|
|
27
|
+
return { ids: R.append(id, ids), list: R.assoc(id, id, list) };
|
|
28
|
+
}, { ids: [], list: {} }), R.prop('ids'));
|
|
29
|
+
|
|
30
|
+
var refinePartialHierarchy = exports.refinePartialHierarchy = function refinePartialHierarchy(hier, indexed) {
|
|
31
|
+
var _R$pipe = R.pipe(R.keys, R.reduce(function (_ref2, key) {
|
|
32
|
+
var intact = _ref2.intact,
|
|
33
|
+
broken = _ref2.broken;
|
|
34
|
+
|
|
35
|
+
var ids = R.filter(function (id) {
|
|
36
|
+
return R.has(id, indexed);
|
|
37
|
+
}, hier[key]);
|
|
38
|
+
if (key === '#ROOT') {
|
|
39
|
+
return { broken: broken, intact: R.assoc(key, ids, intact) };
|
|
40
|
+
}
|
|
41
|
+
var splitKey = R.split('.', key);
|
|
42
|
+
var filtered = R.takeLastWhile(function (id) {
|
|
43
|
+
return R.has(id, indexed);
|
|
44
|
+
}, splitKey);
|
|
45
|
+
if (R.length(filtered) === R.length(splitKey)) {
|
|
46
|
+
return { broken: broken, intact: R.assoc(key, ids, intact) };
|
|
47
|
+
}
|
|
48
|
+
var refinedKey = R.isEmpty(filtered) ? '#ROOT' : R.join('.', filtered);
|
|
49
|
+
return {
|
|
50
|
+
intact: intact,
|
|
51
|
+
broken: R.over(R.lensProp(refinedKey), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(broken)
|
|
52
|
+
};
|
|
53
|
+
}, { intact: {}, broken: {} }))(hier),
|
|
54
|
+
intact = _R$pipe.intact,
|
|
55
|
+
broken = _R$pipe.broken;
|
|
56
|
+
|
|
57
|
+
var intactIds = R.pipe(R.values, R.unnest)(intact);
|
|
58
|
+
var refinedBroken = R.pipe(R.omit(intactIds), R.over(R.lensProp('#ROOT'), R.pipe(function (i) {
|
|
59
|
+
return R.isNil(i) ? [] : i;
|
|
60
|
+
}, R.unnest, R.reject(R.flip(R.includes)(intactIds)))), R.map(R.pipe(R.unnest, uniq)))(broken);
|
|
61
|
+
|
|
62
|
+
return (0, _extends3.default)({}, refinedBroken, intact, {
|
|
63
|
+
'#ROOT': R.concat(refinedBroken['#ROOT'], intact['#ROOT'])
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
var hierarchiseDimensionWithAdvancedHierarchy = exports.hierarchiseDimensionWithAdvancedHierarchy = function hierarchiseDimensionWithAdvancedHierarchy(dimension, _hierarchy) {
|
|
21
68
|
var indexed = R.indexBy(R.prop('id'), dimension.values);
|
|
69
|
+
var hierarchy = refinePartialHierarchy(_hierarchy, indexed);
|
|
22
70
|
|
|
23
71
|
var rest = indexed;
|
|
24
|
-
var getChildren = function getChildren(parents) {
|
|
72
|
+
var getChildren = function getChildren(parents, hier) {
|
|
25
73
|
return R.pipe(function (ids) {
|
|
26
74
|
rest = R.omit(ids, rest);
|
|
27
75
|
return R.props(ids, indexed);
|
|
@@ -30,9 +78,9 @@ var hierarchiseDimensionWithAdvancedHierarchy = exports.hierarchiseDimensionWith
|
|
|
30
78
|
parent: R.last(parents),
|
|
31
79
|
parents: parents
|
|
32
80
|
});
|
|
33
|
-
var children = getChildren(R.append(val.id, parents));
|
|
81
|
+
var children = getChildren(R.append(val.id, parents), hier);
|
|
34
82
|
return R.prepend(_val, children);
|
|
35
|
-
}))(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents),
|
|
83
|
+
}))(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents), hier));
|
|
36
84
|
};
|
|
37
85
|
|
|
38
86
|
return R.set(R.lensProp('values'), R.pipe(getChildren, R.flatten, function (values) {
|
|
@@ -43,5 +91,5 @@ var hierarchiseDimensionWithAdvancedHierarchy = exports.hierarchiseDimensionWith
|
|
|
43
91
|
return (0, _extends3.default)({}, val, { parent: undefined, parents: [] });
|
|
44
92
|
}), R.sortBy(R.prop('__indexPosition')))(rest);
|
|
45
93
|
return R.concat(sortedRest, values);
|
|
46
|
-
})([]))(dimension);
|
|
94
|
+
})([], hierarchy))(dimension);
|
|
47
95
|
};
|
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
|
@@ -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,67 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const uniq = R.pipe(
|
|
4
|
+
R.reduce(
|
|
5
|
+
({ ids, list }, id) => {
|
|
6
|
+
if (R.has(id, list)) {
|
|
7
|
+
return ({ ids, list });
|
|
8
|
+
}
|
|
9
|
+
return ({ ids: R.append(id, ids), list: R.assoc(id, id, list) });
|
|
10
|
+
},
|
|
11
|
+
{ ids: [], list: {} }
|
|
12
|
+
),
|
|
13
|
+
R.prop('ids')
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const refinePartialHierarchy = (hier, indexed) => {
|
|
17
|
+
const { intact, broken } = R.pipe(
|
|
18
|
+
R.keys,
|
|
19
|
+
R.reduce(
|
|
20
|
+
({ intact, broken }, key) => {
|
|
21
|
+
const ids = R.filter(id => R.has(id, indexed), hier[key]);
|
|
22
|
+
if (key === '#ROOT') {
|
|
23
|
+
return ({ broken, intact: R.assoc(key, ids, intact) });
|
|
24
|
+
}
|
|
25
|
+
const splitKey = R.split('.', key);
|
|
26
|
+
const filtered = R.takeLastWhile(id => R.has(id, indexed), splitKey);
|
|
27
|
+
if (R.length(filtered) === R.length(splitKey)) {
|
|
28
|
+
return ({ broken, intact: R.assoc(key, ids, intact) });
|
|
29
|
+
}
|
|
30
|
+
const refinedKey = R.isEmpty(filtered) ? '#ROOT' : R.join('.', filtered);
|
|
31
|
+
return ({
|
|
32
|
+
intact,
|
|
33
|
+
broken: R.over(R.lensProp(refinedKey), R.ifElse(R.isNil, R.always([ids]), R.append(ids)))(broken)
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
{ intact: {}, broken: {} }
|
|
37
|
+
)
|
|
38
|
+
)(hier);
|
|
39
|
+
const intactIds = R.pipe(R.values, R.unnest)(intact);
|
|
40
|
+
const refinedBroken = R.pipe(
|
|
41
|
+
R.omit(intactIds),
|
|
42
|
+
R.over(
|
|
43
|
+
R.lensProp('#ROOT'),
|
|
44
|
+
R.pipe(
|
|
45
|
+
i => R.isNil(i) ? [] : i,
|
|
46
|
+
R.unnest,
|
|
47
|
+
R.reject(R.flip(R.includes)(intactIds)))
|
|
48
|
+
),
|
|
49
|
+
R.map(R.pipe(R.unnest, uniq))
|
|
50
|
+
)(broken);
|
|
51
|
+
|
|
52
|
+
return ({
|
|
53
|
+
...refinedBroken,
|
|
54
|
+
...intact,
|
|
55
|
+
'#ROOT': R.concat(refinedBroken['#ROOT'], intact['#ROOT'])
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, _hierarchy) => {
|
|
4
60
|
const indexed = R.indexBy(R.prop('id'), dimension.values);
|
|
61
|
+
const hierarchy = refinePartialHierarchy(_hierarchy, indexed);
|
|
5
62
|
|
|
6
63
|
let rest = indexed;
|
|
7
|
-
const getChildren = (parents) => R.pipe(
|
|
64
|
+
const getChildren = (parents, hier) => R.pipe(
|
|
8
65
|
ids => {
|
|
9
66
|
rest = R.omit(ids, rest);
|
|
10
67
|
return R.props(ids, indexed)
|
|
@@ -17,11 +74,11 @@ export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, hierarchy)
|
|
|
17
74
|
parent: R.last(parents),
|
|
18
75
|
parents
|
|
19
76
|
};
|
|
20
|
-
const children = getChildren(R.append(val.id, parents));
|
|
77
|
+
const children = getChildren(R.append(val.id, parents), hier);
|
|
21
78
|
return R.prepend(_val, children);
|
|
22
79
|
},
|
|
23
80
|
)
|
|
24
|
-
)(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents),
|
|
81
|
+
)(R.propOr([], R.isEmpty(parents) ? '#ROOT' : R.join('.', parents), hier));
|
|
25
82
|
|
|
26
83
|
return R.set(
|
|
27
84
|
R.lensProp('values'),
|
|
@@ -39,6 +96,6 @@ export const hierarchiseDimensionWithAdvancedHierarchy = (dimension, hierarchy)
|
|
|
39
96
|
)(rest);
|
|
40
97
|
return R.concat(sortedRest, values);
|
|
41
98
|
}
|
|
42
|
-
)([])
|
|
99
|
+
)([], hierarchy)
|
|
43
100
|
)(dimension);
|
|
44
101
|
};
|
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,140 @@ 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: 'USA', parent: undefined, parents: [] },
|
|
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: 'USA', parent: undefined, parents: [], __indexPosition: 2 },
|
|
75
|
+
{ id: 'CAN', parent: undefined, parents: [], __indexPosition: 1 },
|
|
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
|
+
});
|
|
134
|
+
it('non duplicates case 1', () => {
|
|
135
|
+
const hierarchy = {
|
|
136
|
+
'#ROOT': ['ONU', 'OECD'],
|
|
137
|
+
'OECD': ['FRA', 'USA'],
|
|
138
|
+
'ONU': ['USA', 'FRA'],
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const dimension = {
|
|
142
|
+
id: 'REF_AREA',
|
|
143
|
+
values: [
|
|
144
|
+
{ id: 'FRA' },
|
|
145
|
+
{ id: 'USA' }
|
|
146
|
+
]
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
const expected = {
|
|
150
|
+
id: 'REF_AREA',
|
|
151
|
+
values: [
|
|
152
|
+
{ id: 'FRA', parents: [], parent: undefined },
|
|
153
|
+
{ id: 'USA', parents: [], parent: undefined }
|
|
154
|
+
]
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(expected);
|
|
158
|
+
});
|
|
159
|
+
it('non duplicates case 2', () => {
|
|
160
|
+
const hierarchy = {
|
|
161
|
+
'#ROOT': ['ONU', 'OECD'],
|
|
162
|
+
'ONU': ['USA', 'FRA'],
|
|
163
|
+
'OECD': ['FRA', 'USA'],
|
|
164
|
+
'ONU.USA': ['NY', 'LA'],
|
|
165
|
+
'ONU.FRA': ['PA', 'LY']
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const dimension = {
|
|
169
|
+
id: 'REF_AREA',
|
|
170
|
+
values: [
|
|
171
|
+
{ id: 'OECD' },
|
|
172
|
+
{ id: 'FRA' },
|
|
173
|
+
{ id: 'PA' },
|
|
174
|
+
{ id: 'LY' },
|
|
175
|
+
{ id: 'USA' },
|
|
176
|
+
{ id: 'NY' },
|
|
177
|
+
{ id: 'LA' },
|
|
178
|
+
]
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const expected = {
|
|
182
|
+
id: 'REF_AREA',
|
|
183
|
+
values: [
|
|
184
|
+
{ id: 'OECD', parents: [], parent: undefined },
|
|
185
|
+
{ id: 'FRA', parents: ['OECD'], parent: 'OECD' },
|
|
186
|
+
{ id: 'PA', parents: ['OECD.FRA'], parent: 'FRA' },
|
|
187
|
+
{ id: 'LY', parents: ['OECD.FRA'], parent: 'FRA' },
|
|
188
|
+
{ id: 'USA', parents: ['OECD'], parent: 'OECD' },
|
|
189
|
+
{ id: 'NY', parents: ['OECD.USA'], parent: 'USA' },
|
|
190
|
+
{ id: 'LA', parents: ['OECD.USA'], parent: 'USA' },
|
|
191
|
+
]
|
|
192
|
+
};
|
|
193
|
+
});
|
|
87
194
|
});
|