@sis-cc/dotstatsuite-components 17.12.6 → 17.13.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/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +22 -17
- package/lib/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +10 -5
- package/lib/rules2/src/index.js +21 -12
- package/lib/rules2/src/prepareData.js +2 -2
- package/lib/rules2/src/refineDimensions.js +3 -6
- package/lib/rules2/src/table/getLayoutData2.js +218 -0
- package/lib/rules2/src/table/getTableProps.js +6 -9
- package/lib/rules2/src/table/parseSeriesIndexesHierarchies.js +96 -0
- package/lib/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +53 -34
- package/package.json +1 -1
- package/src/rules2/src/{hierarchiseDimensionWithAdvancedHierarchy.js → hierarchiseDimensionWithAdvancedHierarchy2.js} +24 -23
- package/src/rules2/src/{hierarchiseDimensionWithNativeHierarchy.js → hierarchiseDimensionWithNativeHierarchy2.js} +31 -28
- package/src/rules2/src/index.js +5 -5
- package/src/rules2/src/prepareData.js +2 -2
- package/src/rules2/src/refineDimensions.js +3 -6
- package/src/rules2/src/table/getLayoutData2.js +175 -0
- package/src/rules2/src/table/getTableProps.js +8 -4
- package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +62 -0
- package/src/rules2/src/table/{refineLayoutSize.js → refineLayoutSize2.js} +50 -21
- package/test/getLayoutData2.test.js +268 -0
- package/test/{hierarchiseDimensionWithAdvancedHierarchy.test.js → hierarchiseDimensionWithAdvancedHierarchy2.test.js} +34 -69
- package/test/{hierarchiseDimensionWithNativeHierarchy.test.js → hierarchiseDimensionWithNativeHierarchy2.test.js} +14 -14
- package/test/parseSeriesIndexesHierarchies.test.js +104 -0
- package/test/{refineLayoutSize.test.js → refineLayoutSize2.test.js} +63 -64
- package/test/refinedDimensions.test.js +8 -8
- package/lib/rules2/src/table/getLayoutData.js +0 -209
- package/src/rules2/src/table/getLayoutData.js +0 -193
- package/test/getLayoutData.test.js +0 -284
|
@@ -50,12 +50,12 @@ export const getCuratedCells = ({ layout, observations, shape }) => {
|
|
|
50
50
|
export const refineSections = (sections, extractedKeys, curatedObs) => R.pipe(
|
|
51
51
|
R.map(
|
|
52
52
|
(section) => {
|
|
53
|
-
const sectionKey = toKey(R.head(section)
|
|
53
|
+
const sectionKey = toKey(R.propOr([], 'indexes', R.head(section)));
|
|
54
54
|
return R.over(
|
|
55
55
|
R.lensIndex(1),
|
|
56
56
|
R.filter(
|
|
57
|
-
|
|
58
|
-
const rowKey = toKey(
|
|
57
|
+
row => {
|
|
58
|
+
const rowKey = toKey(R.prop('indexes', row));
|
|
59
59
|
return R.pipe(
|
|
60
60
|
R.path([sectionKey, rowKey]),
|
|
61
61
|
R.omit(extractedKeys),
|
|
@@ -74,7 +74,7 @@ export const refineSections = (sections, extractedKeys, curatedObs) => R.pipe(
|
|
|
74
74
|
|
|
75
75
|
export const refineHeader = (header, extractedKeys, curatedObs) => R.filter( // extracted : { [sectionKey]: [...rowKeys] }
|
|
76
76
|
(header) => {
|
|
77
|
-
const headerKey = toKey(header);
|
|
77
|
+
const headerKey = toKey(R.prop('indexes', header));
|
|
78
78
|
return R.pipe(
|
|
79
79
|
R.prop(headerKey),
|
|
80
80
|
(sections) => {
|
|
@@ -93,6 +93,12 @@ export const refineHeader = (header, extractedKeys, curatedObs) => R.filter( //
|
|
|
93
93
|
}
|
|
94
94
|
)(header);
|
|
95
95
|
|
|
96
|
+
const getSerieLinesCount = serie => {
|
|
97
|
+
const missingParents = R.propOr([], 'missingParents', serie);
|
|
98
|
+
const missingParentsRowsCount = R.pipe(R.flatten, R.length)(missingParents);
|
|
99
|
+
return missingParentsRowsCount + 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
96
102
|
export const truncateSectionRows = (n, sectionsData) => {
|
|
97
103
|
let truncated = sectionsData;
|
|
98
104
|
let extractedKeys = {};
|
|
@@ -101,26 +107,42 @@ export const truncateSectionRows = (n, sectionsData) => {
|
|
|
101
107
|
const lastSection = R.last(truncated);
|
|
102
108
|
const rows = lastSection[1];
|
|
103
109
|
const rowsLength = R.length(rows);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
extractedKeys = { ...extractedKeys, [sectionKey]: R.map(toKey, extracted) };
|
|
110
|
-
_n = 0;
|
|
110
|
+
let truncatedRowsCount = 0;
|
|
111
|
+
while (_n > 0 && truncatedRowsCount !== rowsLength) {
|
|
112
|
+
const rowsCount = getSerieLinesCount(R.nth(-1 * truncatedRowsCount, rows));
|
|
113
|
+
_n = _n - rowsCount;
|
|
114
|
+
truncatedRowsCount++;
|
|
111
115
|
}
|
|
112
|
-
|
|
116
|
+
const sectionKey = R.pipe(R.head, R.prop('indexes'), toKey)(lastSection);
|
|
117
|
+
extractedKeys = {
|
|
118
|
+
...extractedKeys,
|
|
119
|
+
[sectionKey]: R.pipe(
|
|
120
|
+
R.takeLast(truncatedRowsCount),
|
|
121
|
+
R.map(r => toKey(R.prop('indexes', r)))
|
|
122
|
+
)(rows)
|
|
123
|
+
};
|
|
124
|
+
if (_n > 0) {
|
|
113
125
|
truncated = R.dropLast(1, truncated);
|
|
114
|
-
|
|
115
|
-
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
truncated = R.over(R.lensIndex(-1), R.over(R.lensIndex(1), R.dropLast(truncatedRowsCount)))(truncated);
|
|
116
129
|
}
|
|
117
130
|
}
|
|
118
131
|
return ({ truncated, extractedKeys });
|
|
119
132
|
};
|
|
120
133
|
|
|
121
134
|
export const truncateHeader = (n, headerData) => {
|
|
122
|
-
|
|
123
|
-
|
|
135
|
+
let { truncated, extractedKeys } = { truncated: headerData, extractedKeys: [] };
|
|
136
|
+
let _n = n;
|
|
137
|
+
while (_n > 0) {
|
|
138
|
+
const lastHeader = R.last(truncated);
|
|
139
|
+
const columnsCount = getSerieLinesCount(lastHeader);
|
|
140
|
+
const extractedKey = toKey(R.prop('indexes', lastHeader));
|
|
141
|
+
extractedKeys = R.append(extractedKey, extractedKeys);
|
|
142
|
+
truncated = R.dropLast(1, truncated);
|
|
143
|
+
_n = _n - columnsCount;
|
|
144
|
+
}
|
|
145
|
+
return ({ truncated, extractedKeys });
|
|
124
146
|
};
|
|
125
147
|
|
|
126
148
|
const truncateLayout = (isVertical) => R.ifElse(
|
|
@@ -161,13 +183,17 @@ export const refineLayoutSize = ({ layout, observations, limit }) => layoutIndex
|
|
|
161
183
|
//number of dimensions in header
|
|
162
184
|
const headerDimCount = R.pipe(
|
|
163
185
|
R.head, // first column
|
|
164
|
-
R.when(R.isNil, R.always(
|
|
186
|
+
R.when(R.isNil, R.always({})),
|
|
187
|
+
R.propOr([], 'indexes'),
|
|
165
188
|
R.length // number of dims
|
|
166
189
|
)(header);
|
|
167
190
|
|
|
168
191
|
//number of columns for values
|
|
169
192
|
const headerValuesCount = R.pipe(
|
|
170
|
-
R.
|
|
193
|
+
R.reduce((acc, header) => {
|
|
194
|
+
const columnsCount = getSerieLinesCount(header);
|
|
195
|
+
return acc + columnsCount;
|
|
196
|
+
}, 0),
|
|
171
197
|
R.when(R.equals(0), R.always(1))
|
|
172
198
|
)(header);
|
|
173
199
|
|
|
@@ -179,6 +205,7 @@ export const refineLayoutSize = ({ layout, observations, limit }) => layoutIndex
|
|
|
179
205
|
R.head, // firstSection
|
|
180
206
|
R.last, // rows,
|
|
181
207
|
R.head, // first row
|
|
208
|
+
R.propOr([], 'indexes'),
|
|
182
209
|
R.length
|
|
183
210
|
)(sections);
|
|
184
211
|
|
|
@@ -189,8 +216,10 @@ export const refineLayoutSize = ({ layout, observations, limit }) => layoutIndex
|
|
|
189
216
|
const rowsCount = R.pipe(
|
|
190
217
|
R.map(R.last),
|
|
191
218
|
R.unnest,
|
|
192
|
-
R.
|
|
193
|
-
|
|
219
|
+
R.reduce((acc, row) => {
|
|
220
|
+
const rowsCount = getSerieLinesCount(row);
|
|
221
|
+
return acc + rowsCount;
|
|
222
|
+
}, 1)
|
|
194
223
|
)(sections);
|
|
195
224
|
|
|
196
225
|
// total of cells in all rows
|
|
@@ -198,7 +227,7 @@ export const refineLayoutSize = ({ layout, observations, limit }) => layoutIndex
|
|
|
198
227
|
|
|
199
228
|
// number of sections cells
|
|
200
229
|
const sectionsCellsCount = R.ifElse(
|
|
201
|
-
R.pipe(R.head, R.head, R.length, R.equals(0)),
|
|
230
|
+
R.pipe(R.head, R.head, R.propOr([], 'indexes'), R.length, R.equals(0)),
|
|
202
231
|
R.always(0),
|
|
203
232
|
R.length
|
|
204
233
|
)(sections);
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getSerieDatas } from '../src/rules2/src/table/getLayoutData2';
|
|
3
|
+
|
|
4
|
+
describe('getLayoutData 2 tests', () => {
|
|
5
|
+
it('getSerieDatas test 1', () => {
|
|
6
|
+
const dimensions = [
|
|
7
|
+
{
|
|
8
|
+
id: 'D0',
|
|
9
|
+
values: [
|
|
10
|
+
{ id: 'v0' },
|
|
11
|
+
{ id: 'v1' },
|
|
12
|
+
{ id: 'v2' },
|
|
13
|
+
{ id: 'v3' },
|
|
14
|
+
{ id: 'v4' },
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'D1',
|
|
19
|
+
values: [
|
|
20
|
+
{ id: 'W', isSelected: true },
|
|
21
|
+
{ id: 'NA', parentsIndexes: [0], isSelected: false },
|
|
22
|
+
{ id: 'A', parentsIndexes: [0, 1], isSelected: true },
|
|
23
|
+
{ id: 'USA', parentsIndexes: [0, 1, 2], isSelected: true },
|
|
24
|
+
{ id: 'CAN', parentsIndexes: [0, 1, 2], isSelected: true },
|
|
25
|
+
{ id: 'MEX', parentsIndexes: [0, 1, 2], isSelected: true }
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const serie = { indexes: [0, 3], parentsIndexes: [[], []], missingIndexes: [[], [0, 2]] };
|
|
31
|
+
expect(getSerieDatas(serie, dimensions, {}, {}, {}, {})).to.deep.equal([
|
|
32
|
+
{
|
|
33
|
+
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [] } }, { dimension: { id: 'D1' }, value: { id: 'W', parents: [] } }],
|
|
34
|
+
coordinates: { D0: 'v0', D1: 'W' },
|
|
35
|
+
key: 'D0=v0:D1=W',
|
|
36
|
+
flags: [],
|
|
37
|
+
sideProps: null,
|
|
38
|
+
isEmpty: true,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [] } }, { dimension: { id: 'D1' }, value: { id: 'A', parents: [0] } }],
|
|
42
|
+
coordinates: { D0: 'v0', D1: 'A' },
|
|
43
|
+
key: 'D0=v0:D1=A',
|
|
44
|
+
flags: [],
|
|
45
|
+
sideProps: null,
|
|
46
|
+
isEmpty: true
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
data: [{ dimension: { id: 'D0' }, value: { id: 'v0', parents: [] } }, { dimension: { id: 'D1' }, value: { id: 'USA', parents: [0, 2] } }],
|
|
50
|
+
coordinates: { D0: 'v0', D1: 'USA' },
|
|
51
|
+
key: 'D0=v0:D1=USA',
|
|
52
|
+
flags: [],
|
|
53
|
+
sideProps: null,
|
|
54
|
+
}
|
|
55
|
+
]);
|
|
56
|
+
});
|
|
57
|
+
it('getSerieDatas test 2', () => {
|
|
58
|
+
const dimensions = [
|
|
59
|
+
{
|
|
60
|
+
id: 'D0',
|
|
61
|
+
values: [
|
|
62
|
+
{ id: 'W' },
|
|
63
|
+
{ id: 'NA', parentsIndexes: [0] },
|
|
64
|
+
{ id: 'A', parentsIndexes: [0, 1] },
|
|
65
|
+
{ id: 'USA', parentsIndexes: [0, 1, 2] },
|
|
66
|
+
{ id: 'CAN', parentsIndexes: [0, 1, 2] },
|
|
67
|
+
{ id: 'MEX', parentsIndexes: [0, 1, 2] }
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: 'COMB0',
|
|
72
|
+
concepts: ['D1', 'A0', 'D2'],
|
|
73
|
+
dimensions: [
|
|
74
|
+
{
|
|
75
|
+
id: 'D1',
|
|
76
|
+
values: [
|
|
77
|
+
{ id: 'D1ROOT' },
|
|
78
|
+
{ id: 'D1ROOT>CHILD' },
|
|
79
|
+
{ id: 'D1ROOT>CHILD>CHILD' },
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 'D2',
|
|
84
|
+
values: [
|
|
85
|
+
{ id: 'D2ROOT' },
|
|
86
|
+
{ id: 'D2ROOT>CHILD' },
|
|
87
|
+
{ id: 'D2ROOT>CHILD>CHILD' },
|
|
88
|
+
]
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 'COMB1',
|
|
94
|
+
concepts: ['D3', 'D4'],
|
|
95
|
+
dimensions: [
|
|
96
|
+
{
|
|
97
|
+
id: 'D3',
|
|
98
|
+
values: [
|
|
99
|
+
{ id: 'D3ROOT' },
|
|
100
|
+
{ id: 'D3ROOT>CHILD' },
|
|
101
|
+
{ id: 'D3ROOT>CHILD>CHILD' },
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: 'D4',
|
|
106
|
+
values: [
|
|
107
|
+
{ id: 'D4ROOT' },
|
|
108
|
+
{ id: 'D4ROOT>CHILD' },
|
|
109
|
+
{ id: 'D4ROOT>CHILD>CHILD' },
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
const attributesSeries = {
|
|
117
|
+
'D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD': {
|
|
118
|
+
A0: { id: 'A0', value: { id: 'A0VAL' }, coordinates: { D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD' } },
|
|
119
|
+
A1: { id: 'A1', value: { id: 'A1VAL' }, coordinates: { D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD' } },
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const topCoordinates = {};
|
|
124
|
+
|
|
125
|
+
const serie = {
|
|
126
|
+
indexes: [3, [2, 2], [2, 2]],
|
|
127
|
+
parentsIndexes: [[], [[], []], [[], []]],
|
|
128
|
+
missingIndexes: [[0, 2], [[0, 1], [0, 1]], [[0, 1], [0, 1]]],
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
expect(getSerieDatas(serie, dimensions, topCoordinates, attributesSeries, {}, {})).to.deep.equal([
|
|
132
|
+
{
|
|
133
|
+
data: [
|
|
134
|
+
{ dimension: { id: 'D0' }, value: { id: 'W', parents: [] } }
|
|
135
|
+
],
|
|
136
|
+
coordinates: { D0: 'W' },
|
|
137
|
+
key: 'D0=W',
|
|
138
|
+
flags: [],
|
|
139
|
+
sideProps: null,
|
|
140
|
+
isEmpty: true
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
data: [
|
|
144
|
+
{ dimension: { id: 'D0' }, value: { id: 'A', parents: [0] } }
|
|
145
|
+
],
|
|
146
|
+
coordinates: { D0: 'A' },
|
|
147
|
+
key: 'D0=A',
|
|
148
|
+
flags: [],
|
|
149
|
+
sideProps: null,
|
|
150
|
+
isEmpty: true
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
data: [
|
|
154
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
155
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT', parents: [] }] }
|
|
156
|
+
],
|
|
157
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT' },
|
|
158
|
+
key: 'D0=USA:D1=D1ROOT',
|
|
159
|
+
flags: [],
|
|
160
|
+
sideProps: null,
|
|
161
|
+
isEmpty: true
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
data: [
|
|
165
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
166
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD', parents: [0] }] }
|
|
167
|
+
],
|
|
168
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD' },
|
|
169
|
+
key: 'D0=USA:D1=D1ROOT>CHILD',
|
|
170
|
+
flags: [],
|
|
171
|
+
sideProps: null,
|
|
172
|
+
isEmpty: true
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
data: [
|
|
176
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
177
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D2ROOT', parents: [] }] }
|
|
178
|
+
],
|
|
179
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT' },
|
|
180
|
+
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT',
|
|
181
|
+
flags: [],
|
|
182
|
+
sideProps: null,
|
|
183
|
+
isEmpty: true
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
data: [
|
|
187
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
188
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D2ROOT>CHILD', parents: [0] }] }
|
|
189
|
+
],
|
|
190
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD' },
|
|
191
|
+
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD',
|
|
192
|
+
flags: [],
|
|
193
|
+
sideProps: null,
|
|
194
|
+
isEmpty: true
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
data: [
|
|
198
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
199
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
200
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT', parents: [] }] }
|
|
201
|
+
],
|
|
202
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT' },
|
|
203
|
+
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT',
|
|
204
|
+
flags: [],
|
|
205
|
+
sideProps: null,
|
|
206
|
+
isEmpty: true
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
data: [
|
|
210
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
211
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
212
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD', parents: [0] }] }
|
|
213
|
+
],
|
|
214
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD' },
|
|
215
|
+
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD',
|
|
216
|
+
flags: [],
|
|
217
|
+
sideProps: null,
|
|
218
|
+
isEmpty: true
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
data: [
|
|
222
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
223
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
224
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D4ROOT', parents: [] }] }
|
|
225
|
+
],
|
|
226
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD>CHILD', D4: 'D4ROOT' },
|
|
227
|
+
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD>CHILD:D4=D4ROOT',
|
|
228
|
+
flags: [],
|
|
229
|
+
sideProps: null,
|
|
230
|
+
isEmpty: true
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
{
|
|
234
|
+
data: [
|
|
235
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
236
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
237
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D4ROOT>CHILD', parents: [0] }] }
|
|
238
|
+
],
|
|
239
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD>CHILD', D4: 'D4ROOT>CHILD' },
|
|
240
|
+
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD>CHILD:D4=D4ROOT>CHILD',
|
|
241
|
+
flags: [],
|
|
242
|
+
sideProps: null,
|
|
243
|
+
isEmpty: true
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
data: [
|
|
247
|
+
{ dimension: { id: 'D0' }, value: { id: 'USA', parents: [0, 2] } },
|
|
248
|
+
{ dimension: { id: 'COMB0' }, values: [{ id: 'D1ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'A0VAL' }, { id: 'D2ROOT>CHILD>CHILD', parents: [0, 1] }] },
|
|
249
|
+
{ dimension: { id: 'COMB1' }, values: [{ id: 'D3ROOT>CHILD>CHILD', parents: [0, 1] }, { id: 'D4ROOT>CHILD>CHILD', parents: [0, 1] }] }
|
|
250
|
+
],
|
|
251
|
+
coordinates: { D0: 'USA', D1: 'D1ROOT>CHILD>CHILD', D2: 'D2ROOT>CHILD>CHILD', D3: 'D3ROOT>CHILD>CHILD', D4: 'D4ROOT>CHILD>CHILD' },
|
|
252
|
+
key: 'D0=USA:D1=D1ROOT>CHILD>CHILD:D2=D2ROOT>CHILD>CHILD:D3=D3ROOT>CHILD>CHILD:D4=D4ROOT>CHILD>CHILD',
|
|
253
|
+
flags: [],
|
|
254
|
+
sideProps: {
|
|
255
|
+
coordinates: {
|
|
256
|
+
D0: 'USA',
|
|
257
|
+
D1: 'D1ROOT>CHILD>CHILD',
|
|
258
|
+
D2: 'D2ROOT>CHILD>CHILD',
|
|
259
|
+
D3: 'D3ROOT>CHILD>CHILD',
|
|
260
|
+
D4: 'D4ROOT>CHILD>CHILD',
|
|
261
|
+
},
|
|
262
|
+
hasAdvancedAttributes: true,
|
|
263
|
+
hasMetadata: false
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
]);
|
|
267
|
+
});
|
|
268
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
|
-
import { hierarchiseDimensionWithAdvancedHierarchy } from '../src/rules2/src/
|
|
2
|
+
import { hierarchiseDimensionWithAdvancedHierarchy } from '../src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2';
|
|
3
3
|
|
|
4
4
|
describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
|
|
5
5
|
it('basic test', () => {
|
|
@@ -26,16 +26,16 @@ describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
|
|
|
26
26
|
const hierarchised = {
|
|
27
27
|
id: 'test',
|
|
28
28
|
values: [
|
|
29
|
-
{ id: 'OECD', parent: undefined, parents: [] },
|
|
30
|
-
{ id: 'GER', parent: 'OECD', parents: [
|
|
31
|
-
{ id: 'FRA', parent: 'OECD', parents: [
|
|
32
|
-
{ id: 'USA', parent: 'OECD', parents: [
|
|
33
|
-
{ id: 'A', parent: undefined, parents: [] },
|
|
34
|
-
{ id: 'USA', parent: 'A', parents: [
|
|
35
|
-
{ id: 'MEX', parent: 'A', parents: [
|
|
36
|
-
{ id: 'EA', parent: undefined, parents: [] },
|
|
37
|
-
{ id: 'FRA', parent: 'EA', parents: [
|
|
38
|
-
{ id: 'GER', parent: 'EA', parents: [
|
|
29
|
+
{ id: 'OECD', parent: undefined, parents: [], __indexPosition: 0 },
|
|
30
|
+
{ id: 'GER', parent: 'OECD', parents: [0], __indexPosition: 1 },
|
|
31
|
+
{ id: 'FRA', parent: 'OECD', parents: [0], __indexPosition: 2 },
|
|
32
|
+
{ id: 'USA', parent: 'OECD', parents: [0], __indexPosition: 3 },
|
|
33
|
+
{ id: 'A', parent: undefined, parents: [], __indexPosition: 4 },
|
|
34
|
+
{ id: 'USA', parent: 'A', parents: [4], __indexPosition: 5 },
|
|
35
|
+
{ id: 'MEX', parent: 'A', parents: [4], __indexPosition: 6 },
|
|
36
|
+
{ id: 'EA', parent: undefined, parents: [], __indexPosition: 7 },
|
|
37
|
+
{ id: 'FRA', parent: 'EA', parents: [7], __indexPosition: 8 },
|
|
38
|
+
{ id: 'GER', parent: 'EA', parents: [7], __indexPosition: 9 },
|
|
39
39
|
]
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -70,15 +70,15 @@ describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
|
|
|
70
70
|
const hierarchised = {
|
|
71
71
|
id: 'test',
|
|
72
72
|
values: [
|
|
73
|
-
{ id: 'AFK', parent: undefined, parents: [], __indexPosition:
|
|
74
|
-
{ id: 'USA', parent: undefined, parents: [], __indexPosition:
|
|
75
|
-
{ id: 'CAN', parent: undefined, parents: [], __indexPosition:
|
|
76
|
-
{ id: 'W', parent: undefined, parents: [], __indexPosition:
|
|
77
|
-
{ id: 'EA', parent: 'W', parents: [
|
|
78
|
-
{ id: 'FRA', parent: 'EA', parents: [
|
|
79
|
-
{ id: 'IDF', parent: 'FRA', parents: [
|
|
80
|
-
{ id: 'GER', parent: 'EA', parents: [
|
|
81
|
-
{ id: 'A', parent: 'W', parents: [
|
|
73
|
+
{ id: 'AFK', parent: undefined, parents: [], __indexPosition: 0 },
|
|
74
|
+
{ id: 'USA', parent: undefined, parents: [], __indexPosition: 1 },
|
|
75
|
+
{ id: 'CAN', parent: undefined, parents: [], __indexPosition: 2 },
|
|
76
|
+
{ id: 'W', parent: undefined, parents: [], __indexPosition: 3 },
|
|
77
|
+
{ id: 'EA', parent: 'W', parents: [3], __indexPosition: 4 },
|
|
78
|
+
{ id: 'FRA', parent: 'EA', parents: [3, 4], __indexPosition: 5 },
|
|
79
|
+
{ id: 'IDF', parent: 'FRA', parents: [3, 4, 5], __indexPosition: 6 },
|
|
80
|
+
{ id: 'GER', parent: 'EA', parents: [3, 4], __indexPosition: 7 },
|
|
81
|
+
{ id: 'A', parent: 'W', parents: [3], __indexPosition: 8 },
|
|
82
82
|
]
|
|
83
83
|
};
|
|
84
84
|
|
|
@@ -114,18 +114,18 @@ describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
|
|
|
114
114
|
const expected = {
|
|
115
115
|
id: 'test',
|
|
116
116
|
values: [
|
|
117
|
-
{ id: 'OECD', parents: [], parent: undefined },
|
|
118
|
-
{ id: 'USA', parents: [
|
|
119
|
-
{ id: 'NY', parents: [
|
|
120
|
-
{ id: 'SF', parents: [
|
|
121
|
-
{ id: 'LA', parents: [
|
|
122
|
-
{ id: 'FRA', parents: [
|
|
123
|
-
{ id: 'IDF', parents: [
|
|
124
|
-
{ id: 'UE', parents: [], parent: undefined },
|
|
125
|
-
{ id: 'FRA', parents: [
|
|
126
|
-
{ id: 'IDF', parents: [
|
|
127
|
-
{ id: 'GER', parents: [
|
|
128
|
-
{ id: 'BER', parents: [
|
|
117
|
+
{ id: 'OECD', parents: [], parent: undefined, __indexPosition: 0 },
|
|
118
|
+
{ id: 'USA', parents: [0], parent: 'OECD', __indexPosition: 1 },
|
|
119
|
+
{ id: 'NY', parents: [0, 1], parent: 'USA', __indexPosition: 2 },
|
|
120
|
+
{ id: 'SF', parents: [0, 1], parent: 'USA', __indexPosition: 3 },
|
|
121
|
+
{ id: 'LA', parents: [0, 1], parent: 'USA', __indexPosition: 4 },
|
|
122
|
+
{ id: 'FRA', parents: [0], parent: 'OECD', __indexPosition: 5 },
|
|
123
|
+
{ id: 'IDF', parents: [0, 5], parent: 'FRA', __indexPosition: 6 },
|
|
124
|
+
{ id: 'UE', parents: [], parent: undefined, __indexPosition: 7 },
|
|
125
|
+
{ id: 'FRA', parents: [7], parent: 'UE', __indexPosition: 8 },
|
|
126
|
+
{ id: 'IDF', parents: [7, 8], parent: 'FRA', __indexPosition: 9 },
|
|
127
|
+
{ id: 'GER', parents: [7], parent: 'UE', __indexPosition: 10 },
|
|
128
|
+
{ id: 'BER', parents: [7, 10], parent: 'GER', __indexPosition: 11 },
|
|
129
129
|
]
|
|
130
130
|
};
|
|
131
131
|
|
|
@@ -149,46 +149,11 @@ describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
|
|
|
149
149
|
const expected = {
|
|
150
150
|
id: 'REF_AREA',
|
|
151
151
|
values: [
|
|
152
|
-
{ id: 'FRA', parents: [], parent: undefined },
|
|
153
|
-
{ id: 'USA', parents: [], parent: undefined }
|
|
152
|
+
{ id: 'FRA', parents: [], parent: undefined, __indexPosition: 0 },
|
|
153
|
+
{ id: 'USA', parents: [], parent: undefined, __indexPosition: 1 }
|
|
154
154
|
]
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(expected);
|
|
158
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
|
-
});
|
|
194
159
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expect } from 'chai';
|
|
2
|
-
import { hierarchiseDimensionWithNativeHierarchy } from '../src/rules2/src/
|
|
2
|
+
import { hierarchiseDimensionWithNativeHierarchy } from '../src/rules2/src/hierarchiseDimensionWithNativeHierarchy2';
|
|
3
3
|
|
|
4
4
|
describe('hierarchiseDimensionWithNativeHierarchy tests', () => {
|
|
5
5
|
it('basic test', () => {
|
|
@@ -19,11 +19,11 @@ describe('hierarchiseDimensionWithNativeHierarchy tests', () => {
|
|
|
19
19
|
id: 'test',
|
|
20
20
|
values: [
|
|
21
21
|
{ id: 'CHI', parent: undefined, parents: [], __indexPosition: 0 },
|
|
22
|
-
{ id: 'W', parent: undefined, parents: [], __indexPosition:
|
|
23
|
-
{ id: 'A', parent: 'W', parents: [
|
|
24
|
-
{ id: 'EA', parent: 'W', parents: [
|
|
25
|
-
{ id: 'GER', parent: 'EA', parents: [
|
|
26
|
-
{ id: 'FRA', parent: 'EA', parents: [
|
|
22
|
+
{ id: 'W', parent: undefined, parents: [], __indexPosition: 1 },
|
|
23
|
+
{ id: 'A', parent: 'W', parents: [1], __indexPosition: 2 },
|
|
24
|
+
{ id: 'EA', parent: 'W', parents: [1], __indexPosition: 3 },
|
|
25
|
+
{ id: 'GER', parent: 'EA', parents: [1, 3], __indexPosition: 4 },
|
|
26
|
+
{ id: 'FRA', parent: 'EA', parents: [1, 3], __indexPosition: 5 }
|
|
27
27
|
]
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -45,10 +45,10 @@ describe('hierarchiseDimensionWithNativeHierarchy tests', () => {
|
|
|
45
45
|
id: 'test',
|
|
46
46
|
values: [
|
|
47
47
|
{ id: 'CHI', parent: undefined, parents: [], __indexPosition: 0 },
|
|
48
|
-
{ id: 'A', parent: undefined, parents: [], __indexPosition:
|
|
49
|
-
{ id: 'EA', parent: undefined, parents: [], __indexPosition:
|
|
50
|
-
{ id: 'GER', parent: 'EA', parents: [
|
|
51
|
-
{ id: 'FRA', parent: 'EA', parents: [
|
|
48
|
+
{ id: 'A', parent: undefined, parents: [], __indexPosition: 1 },
|
|
49
|
+
{ id: 'EA', parent: undefined, parents: [], __indexPosition: 2 },
|
|
50
|
+
{ id: 'GER', parent: 'EA', parents: [2], __indexPosition: 3 },
|
|
51
|
+
{ id: 'FRA', parent: 'EA', parents: [2], __indexPosition: 4 }
|
|
52
52
|
]
|
|
53
53
|
};
|
|
54
54
|
|
|
@@ -70,10 +70,10 @@ describe('hierarchiseDimensionWithNativeHierarchy tests', () => {
|
|
|
70
70
|
id: 'test',
|
|
71
71
|
values: [
|
|
72
72
|
{ id: 'CHI', parent: undefined, parents: [], __indexPosition: 0 },
|
|
73
|
-
{ id: 'A', parent: undefined, parents: [], __indexPosition:
|
|
74
|
-
{ id: 'EA', parent: undefined, parents: [], __indexPosition:
|
|
75
|
-
{ id: 'GER', parent: 'EA', parents: [
|
|
76
|
-
{ id: '', parent: undefined, parents: [], __indexPosition:
|
|
73
|
+
{ id: 'A', parent: undefined, parents: [], __indexPosition: 1 },
|
|
74
|
+
{ id: 'EA', parent: undefined, parents: [], __indexPosition: 2 },
|
|
75
|
+
{ id: 'GER', parent: 'EA', parents: [2], __indexPosition: 3 },
|
|
76
|
+
{ id: '', parent: undefined, parents: [], __indexPosition: 4 }
|
|
77
77
|
]
|
|
78
78
|
};
|
|
79
79
|
|