@sis-cc/dotstatsuite-components 17.32.2 → 18.1.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.
Files changed (32) hide show
  1. package/lib/app.js +8 -4
  2. package/lib/rules2/src/applyHierarchicalCodesToDim.js +128 -0
  3. package/lib/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2.js +1 -36
  4. package/lib/rules2/src/index.js +9 -6
  5. package/lib/rules2/src/parseCombinations.js +2 -1
  6. package/lib/rules2/src/prepareData.js +3 -3
  7. package/lib/rules2/src/table/getLayoutData2.js +2 -2
  8. package/lib/rules2/src/table/parseSeriesIndexesHierarchies.js +1 -1
  9. package/lib/viewer/src/app.js +16 -20
  10. package/lib/viewer/src/index.js +1 -1
  11. package/lib/viewer/src/legends/AxisLegend.js +4 -2
  12. package/lib/viewer/src/legends/ChartLegends.js +1 -1
  13. package/lib/viewer/src/legends/Legend.js +4 -2
  14. package/package.json +10 -3
  15. package/src/app.js +7 -5
  16. package/src/rules2/src/applyHierarchicalCodesToDim.js +101 -0
  17. package/src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2.js +0 -45
  18. package/src/rules2/src/index.js +2 -1
  19. package/src/rules2/src/parseCombinations.js +2 -1
  20. package/src/rules2/src/prepareData.js +2 -2
  21. package/src/rules2/src/table/getLayoutData2.js +2 -2
  22. package/src/rules2/src/table/parseSeriesIndexesHierarchies.js +1 -1
  23. package/src/viewer/src/app.js +16 -14
  24. package/src/viewer/src/index.js +1 -1
  25. package/src/viewer/src/legends/AxisLegend.js +1 -1
  26. package/src/viewer/src/legends/ChartLegends.js +1 -1
  27. package/src/viewer/src/legends/Legend.js +1 -1
  28. package/test/applyHierarchicalCodesToDim.test.js +147 -0
  29. package/test/getLayoutData2.test.js +0 -48
  30. package/test/parseCombinations.test.js +0 -14
  31. package/test/parseSeriesIndexesHierarchies.test.js +0 -90
  32. package/test/hierarchiseDimensionWithAdvancedHierarchy2.test.js +0 -159
@@ -12,12 +12,12 @@ import { getAttributesSeries } from './getAttributesSeries';
12
12
  import { getManyValuesDimensions } from './getManyValuesDimensions';
13
13
  import { getOneValueDimensions } from './getOneValueDimensions';
14
14
  import { hierarchiseDimensionWithNativeHierarchy } from './hierarchiseDimensionWithNativeHierarchy2';
15
- import { hierarchiseDimensionWithAdvancedHierarchy } from './hierarchiseDimensionWithAdvancedHierarchy2';
16
15
  import { getDataflowAttributes } from './getDataflowAttributes';
17
16
  import { getHeaderTitle } from './getHeaderTitle';
18
17
  import { getHeaderSubtitle } from './getHeaderSubtitle';
19
18
  import { getHeaderCombinations } from './getHeaderCombinations';
20
19
  import { getHeaderCoordinates } from './getHeaderCoordinates';
20
+ import { applyHierarchicalCodesToDim } from './applyHierarchicalCodesToDim';
21
21
 
22
22
  export const prepareData = (sdmxJson, { customAttributes, locale, hierarchies, dataflow, display, defaultCombinations, dataquery }) => {
23
23
  const dimensions = R.pathOr([], ['data', 'structure', 'dimensions', 'observation'], sdmxJson);
@@ -46,7 +46,7 @@ export const prepareData = (sdmxJson, { customAttributes, locale, hierarchies, d
46
46
  if (R.isEmpty(R.propOr({}, dim.id, hierarchies))) {
47
47
  return hierarchiseDimensionWithNativeHierarchy(dim);
48
48
  }
49
- return hierarchiseDimensionWithAdvancedHierarchy(dim, R.prop(dim.id, hierarchies));
49
+ return applyHierarchicalCodesToDim(R.prop(dim.id, hierarchies), dim);
50
50
  }, manyValuesDimensions)
51
51
  const duplicatedObservations = duplicateObs(R.values(hierarchisedDimensions), enhancedObservations);
52
52
 
@@ -51,7 +51,7 @@ const getCoordinates = (indexes, topCoordinates, definition) => R.addIndex(R.red
51
51
  }, topCoordinates, definition);
52
52
 
53
53
  const getAttributesSeries = (validator, attributesSeries) => R.reduce((acc, attrs) => {
54
- const attr = R.head(R.values(attrs)) || {};
54
+ const attr = R.head(R.values(attrs));
55
55
  if (R.length(attr.relationship || []) === 1 && !attr.combined) {
56
56
  return acc;
57
57
  }
@@ -87,7 +87,7 @@ const getSerieFlagsAndSideProps = (coordinates, validator, attributesValues, cus
87
87
  const flags = getFlagsAndNotes(layoutAttrValues, customAttributes);
88
88
  const hasMetadata = !R.isNil(R.find(validator, metadataCoordinates));
89
89
  const hasDataAdvancedAttributes = R.any(
90
- d => R.has('value', d) ? R.prop('hasAdvancedAttributes', d.value) : R.any(R.prop('hasAdvancedAttributes'), d.values)
90
+ d => R.has('value', d) ? d.hasAdvancedAttributes : R.any(R.prop('hasAdvancedAttributes'), d.values)
91
91
  , data);
92
92
  const hasAdvancedAttributes = hasDataAdvancedAttributes || getHasAdvancedAttributes(layoutAttrValues, customAttributes);
93
93
  const sideProps = hasMetadata || hasAdvancedAttributes
@@ -23,7 +23,7 @@ const parseSerieIndexesHierarchies = (serieIndexes, previousSerie, dimensions, d
23
23
  if (previousRegisteredIndexes.has(i)) {
24
24
  return R.over(R.lensProp('presentParentsIndexes'), p => R.isNil(p) ? [i] : R.append(i, p), _acc);
25
25
  }
26
- else if (i > previousIndex && R.pathOr(false, [dimensionIndex, 'values', i, 'isSelected'], dimensions)) {
26
+ else if (i > previousIndex) {
27
27
  registeredIndexes.add(i);
28
28
  return R.over(R.lensProp('missingParentsIndexes'), m => R.isNil(m) ? [i] : R.append(i, m), _acc);
29
29
  }
@@ -1,8 +1,8 @@
1
1
  import React, { useState } from 'react';
2
2
  import { Helmet } from 'react-helmet';
3
3
  import { Tab2, Tabs2, Intent, Icon, Tooltip, Position } from '@blueprintjs/core';
4
- import { ThemeProvider } from '@material-ui/core/styles';
5
- import { createTheme } from '@material-ui/core/styles';
4
+ import { ThemeProvider, StyledEngineProvider } from '@mui/material/styles';
5
+ import { createTheme } from '@mui/material/styles';
6
6
  import { sisccTheme } from '@sis-cc/dotstatsuite-visions';
7
7
  import UseCase1 from './app/use-case-1';
8
8
  import TableCase from './app/table';
@@ -100,18 +100,20 @@ export default () => {
100
100
  */
101
101
 
102
102
  return (
103
- <div style={{padding: 10}}>
104
- <ThemeProvider theme={theme}>
105
- <Helmet htmlAttributes={{ dir: isRtl ? 'rtl' : 'ltr' }} />
106
- <button onClick={() => setRtl(!isRtl)}>{isRtl ? 'left to right' : 'right to left'}</button>
107
- <Tabs2 renderActiveTabPanelOnly={false}>
108
- <Tab2
109
- id="uc1"
110
- title={<AppTab label="full screen resizable chart" iconName="fullscreen" />}
111
- panel={<UseCase1 isRtl={isRtl} config={config} style={style} options={options} />}
112
- />
113
- </Tabs2>
114
- </ThemeProvider>
103
+ <div style={{ padding: 10 }}>
104
+ {/* <StyledEngineProvider injectFirst>
105
+ <ThemeProvider theme={theme}> */}
106
+ <Helmet htmlAttributes={{ dir: isRtl ? 'rtl' : 'ltr' }} />
107
+ <button onClick={() => setRtl(!isRtl)}>{isRtl ? 'left to right' : 'right to left'}</button>
108
+ <Tabs2 renderActiveTabPanelOnly={false}>
109
+ <Tab2
110
+ id="uc1"
111
+ title={<AppTab label="full screen resizable chart" iconName="fullscreen" />}
112
+ panel={<UseCase1 isRtl={isRtl} config={config} style={style} options={options} />}
113
+ />
114
+ </Tabs2>
115
+ {/* </ThemeProvider>
116
+ </StyledEngineProvider> */}
115
117
  </div>
116
118
  );
117
119
  };
@@ -3,7 +3,7 @@ import * as R from 'ramda';
3
3
  import cx from 'classnames';
4
4
  import useSize from '@react-hook/size';
5
5
  import { Loading, NoData, TableHtml5 } from '@sis-cc/dotstatsuite-visions';
6
- import { useTheme, makeStyles } from '@material-ui/core/styles';
6
+ import { makeStyles, useTheme } from '@mui/styles';
7
7
  import getChartOptions from './chartUtils/options';
8
8
  import Header from './header';
9
9
  import Chart from './chart';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import * as R from 'ramda';
4
- import { makeStyles } from '@material-ui/core/styles';
4
+ import makeStyles from '@mui/styles/makeStyles';
5
5
  import { SCATTER } from '../../../rules/src/constants';
6
6
  import { getFontFromTheme } from '../utils';
7
7
 
@@ -3,7 +3,7 @@ import * as R from 'ramda';
3
3
  import numeral from 'numeral';
4
4
  import { computeOptions } from '@sis-cc/dotstatsuite-d3-charts';
5
5
  import { ChoroplethLegend } from '../../../bridge-d3-react/src';
6
- import { useTheme } from '@material-ui/core/styles';
6
+ import { useTheme } from '@mui/material/styles';
7
7
  import AxisLegend from './AxisLegend';
8
8
  import FocusLegend from './FocusLegend';
9
9
  import SeriesLegend from './SeriesLegend';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import * as R from 'ramda';
4
- import { makeStyles } from '@material-ui/core/styles';
4
+ import makeStyles from '@mui/styles/makeStyles';
5
5
  import { getFontFromTheme } from '../utils';
6
6
 
7
7
  const useStyles = makeStyles(theme => ({
@@ -0,0 +1,147 @@
1
+ import { applyHierarchicalCodesToDim } from '../src/rules2/src/applyHierarchicalCodesToDim';
2
+ import { expect } from 'chai';
3
+ import * as R from 'ramda';
4
+
5
+ const hCodes = [
6
+ { codeID: 'PARENT_A', hierarchicalCodes: [
7
+ { codeID: 'ITEM', hierarchicalCodes: [
8
+ { codeID: 'CHILD_A', hierarchicalCodes: [] },
9
+ { codeID: 'CHILD_B', hierarchicalCodes: [] },
10
+ ] },
11
+ { codeID: 'BROTHER_A', hierarchicalCodes: [] },
12
+ ] },
13
+ { codeID: 'PARENT_B', hierarchicalCodes: [
14
+ { codeID: 'ITEM', hierarchicalCodes: [
15
+ { codeID: 'CHILD_A', hierarchicalCodes: [] },
16
+ { codeID: 'CHILD_C', hierarchicalCodes: [] },
17
+ ] },
18
+ { codeID: 'BROTHER_B', hierarchicalCodes: [] },
19
+ ] },
20
+ ];
21
+
22
+ const dim = {
23
+ id: 'DIM',
24
+ values: [
25
+ { id: 'PARENT_A', isSelected: true },
26
+ { id: 'PARENT_B', isSelected: true },
27
+ { id: 'ITEM', isSelected: true },
28
+ { id: 'BROTHER_A', isSelected: true },
29
+ { id: 'BROTHER_B', isSelected: true },
30
+ { id: 'CHILD_A', isSelected: true },
31
+ { id: 'CHILD_B', isSelected: true },
32
+ { id: 'CHILD_C', isSelected: true },
33
+ ]
34
+ };
35
+
36
+ const deselectedDim = (indexes) => R.over(
37
+ R.lensProp('values'),
38
+ R.addIndex(R.map)((v, i) => R.includes(i, indexes) ? { ...v, isSelected: false } : v)
39
+ )(dim);
40
+
41
+ describe('refineHierarchicalCodelist tests', () => {
42
+ it('complete test', () => {
43
+ const expected = {
44
+ id: 'DIM',
45
+ values: [
46
+ { id: 'PARENT_A', parents: [], parent: undefined, isSelected: true, __indexPosition: 0 },
47
+ { id: 'ITEM', parents: [0], parent: 'PARENT_A', isSelected: true, __indexPosition: 1 },
48
+ { id: 'CHILD_A', parents: [0, 1], parent: 'PARENT_A.ITEM', isSelected: true, __indexPosition: 2 },
49
+ { id: 'CHILD_B', parents: [0, 1], parent: 'PARENT_A.ITEM', isSelected: true, __indexPosition: 3 },
50
+ { id: 'BROTHER_A', parents: [0], parent: 'PARENT_A', isSelected: true, __indexPosition: 4 },
51
+ { id: 'PARENT_B', parents: [], parent: undefined, isSelected: true, __indexPosition: 5 },
52
+ { id: 'ITEM', parents: [5], parent: 'PARENT_B', isSelected: true, __indexPosition: 6 },
53
+ { id: 'CHILD_A', parents: [5, 6], parent: 'PARENT_B.ITEM', isSelected: true, __indexPosition: 7 },
54
+ { id: 'CHILD_C', parents: [5, 6], parent: 'PARENT_B.ITEM', isSelected: true, __indexPosition: 8 },
55
+ { id: 'BROTHER_B', parents: [5], parent: 'PARENT_B', isSelected: true, __indexPosition: 9 },
56
+ ]
57
+ };
58
+
59
+ expect(applyHierarchicalCodesToDim(hCodes, dim)).to.deep.equal(expected);
60
+ });
61
+ it('partial test 1', () => {
62
+ const partialDim = deselectedDim([0]);
63
+
64
+ const expected = {
65
+ id: 'DIM',
66
+ values: [
67
+ { id: 'ITEM', parents: [], parent: undefined, isSelected: true, __indexPosition: 0 },
68
+ { id: 'CHILD_A', parents: [0], parent: 'ITEM', isSelected: true, __indexPosition: 1 },
69
+ { id: 'CHILD_B', parents: [0], parent: 'ITEM', isSelected: true, __indexPosition: 2 },
70
+ { id: 'BROTHER_A', parents: [], parent: undefined, isSelected: true, __indexPosition: 3 },
71
+ { id: 'PARENT_B', parents: [], parent: undefined, isSelected: true, __indexPosition: 4 },
72
+ { id: 'ITEM', parents: [4], parent: 'PARENT_B', isSelected: true, __indexPosition: 5 },
73
+ { id: 'CHILD_A', parents: [4, 5], parent: 'PARENT_B.ITEM', isSelected: true, __indexPosition: 6 },
74
+ { id: 'CHILD_C', parents: [4, 5], parent: 'PARENT_B.ITEM', isSelected: true, __indexPosition: 7 },
75
+ { id: 'BROTHER_B', parents: [4], parent: 'PARENT_B', isSelected: true, __indexPosition: 8 },
76
+ ]
77
+ };
78
+
79
+ expect(applyHierarchicalCodesToDim(hCodes, partialDim)).to.deep.equal(expected);
80
+ });
81
+ it('partial test 2', () => {
82
+ const partialDim = deselectedDim([1, 4, 7]);
83
+
84
+ const expected = {
85
+ id: 'DIM',
86
+ values: [
87
+ { id: 'PARENT_A', parents: [], parent: undefined, isSelected: true, __indexPosition: 0 },
88
+ { id: 'ITEM', parents: [0], parent: 'PARENT_A', isSelected: true, __indexPosition: 1 },
89
+ { id: 'CHILD_A', parents: [0, 1], parent: 'PARENT_A.ITEM', isSelected: true, __indexPosition: 2 },
90
+ { id: 'CHILD_B', parents: [0, 1], parent: 'PARENT_A.ITEM', isSelected: true, __indexPosition: 3 },
91
+ { id: 'BROTHER_A', parents: [0], parent: 'PARENT_A', isSelected: true, __indexPosition: 4 },
92
+ ]
93
+ };
94
+
95
+ expect(applyHierarchicalCodesToDim(hCodes, partialDim)).to.deep.equal(expected);
96
+ });
97
+ it('partial test 3', () => {
98
+ const partialDim = deselectedDim([0, 6]);
99
+
100
+ const expected = {
101
+ id: 'DIM',
102
+ values: [
103
+ { id: 'BROTHER_A', parents: [], parent: undefined, isSelected: true, __indexPosition: 0 },
104
+ { id: 'PARENT_B', parents: [], parent: undefined, isSelected: true, __indexPosition: 1 },
105
+ { id: 'ITEM', parents: [1], parent: 'PARENT_B', isSelected: true, __indexPosition: 2 },
106
+ { id: 'CHILD_A', parents: [1, 2], parent: 'PARENT_B.ITEM', isSelected: true, __indexPosition: 3 },
107
+ { id: 'CHILD_C', parents: [1, 2], parent: 'PARENT_B.ITEM', isSelected: true, __indexPosition: 4 },
108
+ { id: 'BROTHER_B', parents: [1], parent: 'PARENT_B', isSelected: true, __indexPosition: 5 },
109
+ ]
110
+ };
111
+
112
+ expect(applyHierarchicalCodesToDim(hCodes, partialDim)).to.deep.equal(expected);
113
+ });
114
+ it('partial test 4', () => {
115
+ const partialDim = deselectedDim([6]);
116
+
117
+ const expected = {
118
+ id: 'DIM',
119
+ values: [
120
+ { id: 'PARENT_A', parents: [], parent: undefined, isSelected: true, __indexPosition: 0 },
121
+ { id: 'ITEM', parents: [0], parent: 'PARENT_A', isSelected: true, __indexPosition: 1 },
122
+ { id: 'CHILD_A', parents: [0, 1], parent: 'PARENT_A.ITEM', isSelected: true, __indexPosition: 2 },
123
+ { id: 'BROTHER_A', parents: [0], parent: 'PARENT_A', isSelected: true, __indexPosition: 3 },
124
+ { id: 'PARENT_B', parents: [], parent: undefined, isSelected: true, __indexPosition: 4 },
125
+ { id: 'ITEM', parents: [4], parent: 'PARENT_B', isSelected: true, __indexPosition: 5 },
126
+ { id: 'CHILD_A', parents: [4, 5], parent: 'PARENT_B.ITEM', isSelected: true, __indexPosition: 6 },
127
+ { id: 'CHILD_C', parents: [4, 5], parent: 'PARENT_B.ITEM', isSelected: true, __indexPosition: 7 },
128
+ { id: 'BROTHER_B', parents: [4], parent: 'PARENT_B', isSelected: true, __indexPosition: 8 },
129
+ ]
130
+ };
131
+
132
+ expect(applyHierarchicalCodesToDim(hCodes, partialDim)).to.deep.equal(expected);
133
+ });
134
+ it('partial test 5', () => {
135
+ const partialDim = deselectedDim([0, 1, 2, 3, 4]);
136
+
137
+ const expected = {
138
+ id: 'DIM',
139
+ values: [
140
+ { id: 'CHILD_A', parents: [], parent: undefined, isSelected: true, __indexPosition: 0 },
141
+ { id: 'CHILD_B', parents: [], parent: undefined, isSelected: true, __indexPosition: 1 },
142
+ { id: 'CHILD_C', parents: [], parent: undefined, isSelected: true, __indexPosition: 2 },
143
+ ]
144
+ };
145
+ expect(applyHierarchicalCodesToDim(hCodes, partialDim)).to.deep.equal(expected);
146
+ });
147
+ });
@@ -439,52 +439,4 @@ describe('getLayoutData 2 tests', () => {
439
439
  }
440
440
  });
441
441
  });
442
- it('getSerieDataWithMissingLines, advanced attributes as dim level plus enpty series', () => {
443
- const dimensions = [
444
- {
445
- id: 'D0',
446
- values: [
447
- { id: 'D0V0', flags: [], hasAdvancedAttributes: true },
448
- { id: 'D0V1' }
449
- ]
450
- }
451
- ];
452
-
453
- const attributesSeries = {
454
- 'D1=D1V0': {},
455
- 'D0=D0V0:D1=D1V0': {},
456
- };
457
-
458
- const topCoordinates = {};
459
-
460
- const serie = {
461
- indexes: [0],
462
- parentsIndexes: [[]],
463
- missingIndexes: [[]],
464
- };
465
-
466
- const customAttributes = {
467
- flags: [],
468
- notes: ['A0', 'A2']
469
- }
470
-
471
- expect(getSerieDataWithMissingLines(serie, dimensions, topCoordinates, attributesSeries, customAttributes, {})).to.deep.equal([{
472
- data: [
473
- {
474
- dimension: { id: 'D0' },
475
- value: { id: 'D0V0', missingParents: [], parents: [], flags: [], hasAdvancedAttributes: true }
476
- },
477
- ],
478
- coordinates: { D0: 'D0V0' },
479
- key: 'D0=D0V0',
480
- flags: [],
481
- sideProps: {
482
- coordinates: {
483
- D0: 'D0V0',
484
- },
485
- hasAdvancedAttributes: true,
486
- hasMetadata: false
487
- }
488
- }]);
489
- });
490
442
  });
@@ -146,20 +146,6 @@ describe('parseCombinations tests', () => {
146
146
  relationship: ['DIM4'],
147
147
  display: true,
148
148
  },
149
- {
150
- id: 'COMB11',
151
- concepts: ['DIM4'],
152
- relationship: ['DIM4'],
153
- series: true,
154
- display: true
155
- },
156
- {
157
- id: 'COMB12',
158
- concepts: ['DIM4'],
159
- relationship: ['DIM4'],
160
- series: true,
161
- display: true
162
- },
163
149
  {
164
150
  id: 'COMB14',
165
151
  concepts: ['DIM3', 'ATTR5', 'ATTR8'],
@@ -1,4 +1,3 @@
1
- import * as R from 'ramda';
2
1
  import { expect } from 'chai';
3
2
  import { parseSeriesIndexesHierarchies } from '../src/rules2/src/table/parseSeriesIndexesHierarchies';
4
3
 
@@ -29,43 +28,6 @@ describe('parseSeriesIndexesHierarchies tests', () => {
29
28
  { indexes: [4], parentsIndexes: [[]], missingIndexes: [[]], registeredIndexes: [new Set([2, 3, 4])] },
30
29
  ])
31
30
  });
32
- it('more complex stuff', () => {
33
- const dimensions = [
34
- {
35
- id: 'D0',
36
- values: [
37
- { id: 'v0' },
38
- { id: 'v1' },
39
- { id: 'v2' },
40
- { id: 'v3' },
41
- { id: 'v4' },
42
- ]
43
- },
44
- {
45
- id: 'D1',
46
- values: [
47
- { id: 'W', isSelected: true },
48
- { id: 'NA', parents: [0], isSelected: false },
49
- { id: 'A', parents: [0, 1], isSelected: true },
50
- { id: 'USA', parents: [0, 1, 2], isSelected: true },
51
- { id: 'CAN', parents: [0, 1, 2], isSelected: true },
52
- { id: 'MEX', parents: [0, 1, 2], isSelected: true }
53
- ]
54
- }
55
- ];
56
-
57
- const seriesIndexes = [
58
- [0, 3],
59
- [0, 4],
60
- [1, 5]
61
- ];
62
-
63
- expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions)).to.deep.equal([
64
- { indexes: [0, 3], parentsIndexes: [[], []], missingIndexes: [[], [0, 2]], registeredIndexes: [new Set([0]), new Set([0, 2, 3])] },
65
- { indexes: [0, 4], parentsIndexes: [[], [0, 2]], missingIndexes: [[], []], registeredIndexes: [new Set([0]), new Set([0, 2, 3, 4])] },
66
- { indexes: [1, 5], parentsIndexes: [[], []], missingIndexes: [[], [0, 2]], registeredIndexes: [new Set([0, 1]), new Set([0, 2, 5])] },
67
- ])
68
- });
69
31
  it('with combination', () => {
70
32
  const dimensions = [
71
33
  {
@@ -102,56 +64,4 @@ describe('parseSeriesIndexesHierarchies tests', () => {
102
64
  { indexes: [[0, 1]], parentsIndexes: [[[], [0]]], missingIndexes: [[[], []]], registeredIndexes: [[new Set([0]), new Set([0, 1])]] },
103
65
  ])
104
66
  });
105
- it('combinations and inversed dimension', () => {
106
- const dimensions = [
107
- {
108
- id: 'D',
109
- values: [
110
- { id: 'A' },
111
- { id: 'B' },
112
- { id: 'C' }
113
- ]
114
- },
115
- {
116
- id: 'COMB',
117
- dimensions: [{
118
- values: [
119
- { id: 'v0' },
120
- { id: 'v1' },
121
- { id: 'v2' },
122
- { id: 'v3' },
123
- { id: 'v4' },
124
- ]
125
- },
126
- {
127
- values: [
128
- { id: 'W', isSelected: true },
129
- { id: 'NA', parents: [0], isSelected: false },
130
- { id: 'A', parents: [0, 1], isSelected: true },
131
- { id: 'USA', parents: [0, 1, 2], isSelected: true },
132
- { id: 'CAN', parents: [0, 1, 2], isSelected: true },
133
- { id: 'MEX', parents: [0, 1, 2], isSelected: true }
134
- ]
135
- }]
136
- },
137
- ];
138
-
139
- const seriesIndexes = [
140
- [-2, [0, 2]],
141
- [-2, [0, 3]],
142
- [-1, [0, 2]],
143
- [-1, [0, 3]],
144
- [0, [0, 2]],
145
- [0, [0, 3]],
146
- ];
147
-
148
- expect(parseSeriesIndexesHierarchies(seriesIndexes, dimensions)).to.deep.equal([
149
- { indexes: [-2, [0, 2]], parentsIndexes: [[], [[], []]], missingIndexes: [[], [[], [0]]], registeredIndexes: [new Set([2]), [new Set([0]), new Set([0, 2])]] },
150
- { indexes: [-2, [0, 3]], parentsIndexes: [[], [[], [0, 2]]], missingIndexes: [[], [[], []]], registeredIndexes: [new Set([2]), [new Set([0]), new Set([0, 2, 3])]] },
151
- { indexes: [-1, [0, 2]], parentsIndexes: [[], [[], []]], missingIndexes: [[], [[], [0]]], registeredIndexes: [new Set([1, 2]), [new Set([0]), new Set([0, 2])]] },
152
- { indexes: [-1, [0, 3]], parentsIndexes: [[], [[], [0, 2]]], missingIndexes: [[], [[], []]], registeredIndexes: [new Set([1, 2]), [new Set([0]), new Set([0, 2, 3])]] },
153
- { indexes: [0, [0, 2]], parentsIndexes: [[], [[], []]], missingIndexes: [[], [[], [0]]], registeredIndexes: [new Set([0, 1, 2]), [new Set([0]), new Set([0, 2])]] },
154
- { indexes: [0, [0, 3]], parentsIndexes: [[], [[], [0, 2]]], missingIndexes: [[], [[], []]], registeredIndexes: [new Set([0, 1, 2]), [new Set([0]), new Set([0, 2, 3])]] },
155
- ])
156
- })
157
67
  });
@@ -1,159 +0,0 @@
1
- import { expect } from 'chai';
2
- import { hierarchiseDimensionWithAdvancedHierarchy } from '../src/rules2/src/hierarchiseDimensionWithAdvancedHierarchy2';
3
-
4
- describe('hierarchiseDimensionWithAdvancedHierarchy tests', () => {
5
- it('basic test', () => {
6
- const dimension = {
7
- id: 'test',
8
- values: [
9
- { id: 'FRA' },
10
- { id: 'GER' },
11
- { id: 'OECD' },
12
- { id: 'USA' },
13
- { id: 'A' },
14
- { id: 'EA' },
15
- { id: 'MEX' },
16
- ]
17
- };
18
-
19
- const hierarchy = {
20
- '#ROOT': ['OECD', 'A', 'EA'],
21
- OECD: ['GER', 'FRA', 'USA'],
22
- A: ['USA', 'MEX'],
23
- EA: ['FRA', 'GER']
24
- };
25
-
26
- const hierarchised = {
27
- id: 'test',
28
- values: [
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
- ]
40
- }
41
-
42
- expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(hierarchised);
43
- });
44
- it('missing ids defined in the hierarchy', () => {
45
- const hierarchy = {
46
- '#ROOT': ['W'],
47
- W: ['EA', 'A'],
48
- 'W.A': ['NA', 'SA'],
49
- 'W.A.NA': ['USA', 'CAN'],
50
- 'W.A.SA': ['BRA'],
51
- 'W.EA': ['FRA', 'GER'],
52
- 'W.EA.FRA': ['IDF', 'BRE', 'ALS']
53
- };
54
-
55
- const dimension = {
56
- id: 'test',
57
- values: [
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
- ]
68
- };
69
-
70
- const hierarchised = {
71
- id: 'test',
72
- values: [
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
- ]
83
- };
84
-
85
- expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(hierarchised);
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, __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
- ]
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, __indexPosition: 0 },
153
- { id: 'USA', parents: [], parent: undefined, __indexPosition: 1 }
154
- ]
155
- };
156
-
157
- expect(hierarchiseDimensionWithAdvancedHierarchy(dimension, hierarchy)).to.deep.equal(expected);
158
- });
159
- });