@sis-cc/dotstatsuite-components 13.3.1 → 13.4.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.
@@ -116,11 +116,9 @@ var getSeriesAdvancedAttributes = exports.getSeriesAdvancedAttributes = function
116
116
  var dim = R.nth(Number(dInd), dimensions);
117
117
  var valId = R.path(['values', Number(vInd), 'id'], dim);
118
118
  var coordinates = (0, _defineProperty3.default)({}, dim.id, valId);
119
- var refinedKey = keyTemplate;
120
- refinedKey[Number(dInd)] = vInd;
119
+ var refinedKey = R.set(R.lensIndex(Number(dInd)), vInd)(keyTemplate);
121
120
  return R.assoc(R.join(':', refinedKey), { attributes: advancedAttributes, coordinates: coordinates }, acc);
122
121
  }, {}, R.keys(series));
123
122
  })(seriesAttributes);
124
-
125
123
  return R.merge(seriesAdvancedAttributes, dimensionsAdvancedAttributes);
126
124
  };
@@ -27,12 +27,13 @@ var getMSDInformations = exports.getMSDInformations = function getMSDInformation
27
27
  var parseAttributes = function parseAttributes(parent) {
28
28
  return R.reduce(function (acc, attribute) {
29
29
  var id = attribute.id;
30
+ var hierarchicalId = parent === '#ROOT' ? id : parent + '.' + id;
30
31
  var format = R.path(['localRepresentation', 'textFormat', 'textType'], attribute);
31
32
  if (R.has('metadataAttributes', attribute)) {
32
- var collection = parseAttributes(attribute.id)(attribute.metadataAttributes);
33
- return (0, _extends4.default)({}, acc, collection, (0, _defineProperty3.default)({}, id, { format: format, parent: parent }));
33
+ var collection = parseAttributes(hierarchicalId)(attribute.metadataAttributes);
34
+ return (0, _extends4.default)({}, acc, collection, (0, _defineProperty3.default)({}, hierarchicalId, { format: format, parent: parent, id: id }));
34
35
  }
35
- return R.assoc(id, { format: format, parent: parent }, acc);
36
+ return R.assoc(hierarchicalId, { format: format, parent: parent, id: id }, acc);
36
37
  }, {});
37
38
  };
38
39
 
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.parseMetadataSeries = undefined;
7
7
 
8
+ var _extends2 = require('babel-runtime/helpers/extends');
9
+
10
+ var _extends3 = _interopRequireDefault(_extends2);
11
+
8
12
  var _ramda = require('ramda');
9
13
 
10
14
  var R = _interopRequireWildcard(_ramda);
@@ -13,6 +17,8 @@ var _dotstatsuiteSdmxjs = require('@sis-cc/dotstatsuite-sdmxjs');
13
17
 
14
18
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
15
19
 
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
16
22
  var dimensionValueDisplay = function dimensionValueDisplay(display) {
17
23
  return function (data) {
18
24
  if (display === 'code') {
@@ -60,22 +66,50 @@ var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSe
60
66
  return R.propOr('', '__index', originalVal);
61
67
  }), R.join(':'))(serieKey);
62
68
 
63
- var attributes = R.addIndex(R.reduce)(function (acc, valueIndex, attrIndex) {
64
- if (R.isNil(valueIndex)) {
69
+ var attributes = R.pipe(R.addIndex(R.reduce)(function (acc, valueIndex, attrIndex) {
70
+ var attribute = R.nth(attrIndex, metadataAttributes);
71
+ if (R.isNil(valueIndex) && !attribute.isPresentational) {
65
72
  return acc;
66
73
  }
67
- var attribute = R.nth(attrIndex, metadataAttributes);
68
- var label = dimensionValueDisplay(options.display)(attribute);
74
+ var attrOptions = R.pathOr({}, ['attributes', attribute.id], options);
75
+ var id = attrOptions.id;
76
+ var label = dimensionValueDisplay(options.display)((0, _extends3.default)({}, attribute, { id: id }));
69
77
 
70
- var value = R.prop('value', R.nth(valueIndex, attribute.values || []));
78
+ var _value = R.prop('value', R.nth(valueIndex, attribute.values || []));
79
+ var value = R.is(Object, _value) ? R.prop(options.locale, _value) : _value;
71
80
 
72
- return R.append({
81
+ return R.append((0, _extends3.default)({}, R.isNil(value) ? {} : { value: value }, {
73
82
  id: attribute.id,
74
83
  label: label,
75
- value: R.is(Object, value) ? R.prop(options.locale, value) : value,
76
- handlerProps: R.pathOr({}, ['attributes', attribute.id], options)
77
- }, acc);
78
- }, [], metaIndexes);
84
+ handlerProps: R.omit(['id'], R.pathOr({}, ['attributes', attribute.id], options))
85
+ }), acc);
86
+ }, []), function (attributes) {
87
+ // missing parents in metadata response
88
+ var groupedAttrs = R.groupBy(R.pathOr('#ROOT', ['handlerProps', 'parent']), attributes);
89
+ var indexedAttrs = R.indexBy(R.prop('id'), attributes);
90
+
91
+ return R.reduce(function (acc, id) {
92
+ if (R.has(id, indexedAttrs) || id === '#ROOT') {
93
+ return acc;
94
+ }
95
+ return R.append({
96
+ id: id,
97
+ label: dimensionValueDisplay(options.display)({ id: id }),
98
+ handlerProps: R.omit(['id'], R.pathOr({}, ['attributes', id], options))
99
+ }, acc);
100
+ }, attributes, R.keys(groupedAttrs));
101
+ }, function (attributes) {
102
+ var groupedAttrs = R.groupBy(R.pathOr('#ROOT', ['handlerProps', 'parent']), attributes);
103
+ var makeTree = R.map(function (attr) {
104
+ if (R.has(attr.id, groupedAttrs)) {
105
+ var children = makeTree(R.prop(attr.id, groupedAttrs));
106
+ return R.assoc('children', children, attr);
107
+ }
108
+ return attr;
109
+ });
110
+
111
+ return makeTree(R.propOr([], '#ROOT', groupedAttrs));
112
+ })(metaIndexes);
79
113
 
80
114
  return R.assoc(evolvedKey, attributes, acc);
81
115
  }, {}, R.keys(series));
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": "13.3.1",
4
+ "version": "13.4.2",
5
5
  "main": "lib/index.js",
6
6
  "author": "OECD",
7
7
  "license": "MIT",
@@ -100,14 +100,12 @@ export const getSeriesAdvancedAttributes = (seriesAttributes, dimensions, advanc
100
100
  const dim = R.nth(Number(dInd), dimensions);
101
101
  const valId = R.path(['values', Number(vInd), 'id'], dim);
102
102
  const coordinates = { [dim.id]: valId };
103
- let refinedKey = keyTemplate;
104
- refinedKey[Number(dInd)] = vInd;
103
+ const refinedKey = R.set(R.lensIndex(Number(dInd)), vInd)(keyTemplate);
105
104
  return R.assoc(R.join(':', refinedKey), { attributes: advancedAttributes, coordinates }, acc);
106
105
  },
107
106
  {},
108
107
  R.keys(series)
109
108
  )
110
109
  )(seriesAttributes);
111
-
112
110
  return R.merge(seriesAdvancedAttributes, dimensionsAdvancedAttributes);
113
111
  };
@@ -6,12 +6,13 @@ export const getMSDInformations = (msdJson) => {
6
6
  const parseAttributes = (parent) => R.reduce(
7
7
  (acc, attribute) => {
8
8
  const id = attribute.id;
9
+ const hierarchicalId = parent === '#ROOT' ? id : `${parent}.${id}`;
9
10
  const format = R.path(['localRepresentation', 'textFormat', 'textType'], attribute);
10
11
  if (R.has('metadataAttributes', attribute)) {
11
- const collection = parseAttributes(attribute.id)(attribute.metadataAttributes);
12
- return ({ ...acc, ...collection, [id]: { format, parent } });
12
+ const collection = parseAttributes(hierarchicalId)(attribute.metadataAttributes);
13
+ return ({ ...acc, ...collection, [hierarchicalId]: { format, parent, id } });
13
14
  }
14
- return R.assoc(id, { format, parent }, acc);
15
+ return R.assoc(hierarchicalId, { format, parent, id }, acc);
15
16
  },
16
17
  {}
17
18
  )
@@ -49,28 +49,63 @@ export const parseMetadataSeries = (metadataJson, options) => {
49
49
  return R.propOr('', '__index', originalVal);
50
50
  }),
51
51
  R.join(':')
52
- )(serieKey)
52
+ )(serieKey);
53
53
 
54
- const attributes = R.addIndex(R.reduce)(
55
- (acc, valueIndex, attrIndex) => {
56
- if (R.isNil(valueIndex)) {
57
- return acc;
58
- }
59
- const attribute = R.nth(attrIndex, metadataAttributes);
60
- const label = dimensionValueDisplay(options.display)(attribute);
54
+ const attributes = R.pipe(
55
+ R.addIndex(R.reduce)(
56
+ (acc, valueIndex, attrIndex) => {
57
+ const attribute = R.nth(attrIndex, metadataAttributes);
58
+ if (R.isNil(valueIndex) && !(attribute.isPresentational)) {
59
+ return acc;
60
+ }
61
+ const attrOptions = R.pathOr({}, ['attributes', attribute.id], options);
62
+ const id = attrOptions.id;
63
+ const label = dimensionValueDisplay(options.display)({ ...attribute, id });
64
+
65
+ const _value = R.prop('value', R.nth(valueIndex, attribute.values || []));
66
+ const value = R.is(Object, _value) ? R.prop(options.locale, _value) : _value;
61
67
 
62
- const value = R.prop('value', R.nth(valueIndex, attribute.values || []));
68
+ return R.append({
69
+ ...(R.isNil(value) ? {} : { value }),
70
+ id: attribute.id,
71
+ label,
72
+ handlerProps: R.omit(['id'], R.pathOr({}, ['attributes', attribute.id], options))
73
+ }, acc);
74
+ },
75
+ [],
76
+ ),
77
+ attributes => { // missing parents in metadata response
78
+ const groupedAttrs = R.groupBy(R.pathOr('#ROOT', ['handlerProps', 'parent']), attributes);
79
+ const indexedAttrs = R.indexBy(R.prop('id'), attributes);
80
+
81
+ return R.reduce(
82
+ (acc, id) => {
83
+ if (R.has(id, indexedAttrs) || id === '#ROOT') {
84
+ return acc;
85
+ }
86
+ return R.append({
87
+ id,
88
+ label: dimensionValueDisplay(options.display)({ id }),
89
+ handlerProps: R.omit(['id'], R.pathOr({}, ['attributes', id], options))
90
+ }, acc);
91
+ },
92
+ attributes,
93
+ R.keys(groupedAttrs)
94
+ );
95
+ },
96
+ attributes => {
97
+ const groupedAttrs = R.groupBy(R.pathOr('#ROOT', ['handlerProps', 'parent']), attributes);
98
+ const makeTree = R.map(attr => {
99
+ if (R.has(attr.id, groupedAttrs)) {
100
+ const children = makeTree(R.prop(attr.id, groupedAttrs));
101
+ return R.assoc('children', children, attr);
102
+ }
103
+ return attr;
104
+ });
63
105
 
64
- return R.append({
65
- id: attribute.id,
66
- label,
67
- value: R.is(Object, value) ? R.prop(options.locale, value) : value,
68
- handlerProps: R.pathOr({}, ['attributes', attribute.id], options)
69
- }, acc);
106
+ return makeTree(R.propOr([], '#ROOT', groupedAttrs));
70
107
  },
71
- [],
72
- metaIndexes
73
- );
108
+ )(metaIndexes);
74
109
 
75
110
  return R.assoc(evolvedKey, attributes, acc);
76
111
  },
@@ -6,27 +6,27 @@ describe('getMSDInformations tests', () => {
6
6
  it('complete test', () => {
7
7
  const expected = {
8
8
  attributes: {
9
- STRING_TYPE: { format: 'String', parent: '#ROOT' },
10
- STRING_MULTILANG_TYPE: { format: 'String', parent: '#ROOT' },
11
- ALPHANUMERIC_TYPE: { format: 'AlphaNumeric', parent: '#ROOT' },
12
- ALPHANUMERIC_MULTILANG_TYPE: { format: 'AlphaNumeric', parent: '#ROOT' },
13
- BOOLEAN_TYPE: { format: 'Boolean', parent: '#ROOT' },
14
- XHTML_TYPE: { format: 'XHTML', parent: '#ROOT' },
15
- XHTML_MULTILANG_TYPE: { format: 'XHTML', parent: '#ROOT' },
16
- INTEGER_TYPE: { format: 'Integer', parent: '#ROOT' },
17
- INTEGER_MULTILANG_TYPE: { format: 'Integer', parent: '#ROOT' },
18
- DECIMAL_TYPE: { format: 'Decimal', parent: '#ROOT' },
19
- DECIMAL_MULTILANG_TYPE: { format: 'Decimal', parent: '#ROOT' },
20
- DATETIME_TYPE: { format: 'DateTime', parent: '#ROOT' },
21
- TIME_TYPE: { format: 'Time', parent: '#ROOT' },
22
- GREGORIANDAY_TYPE: { format: 'GregorianDay', parent: '#ROOT' },
23
- GREGORIAN_YEAR_TYPE: { format: 'GregorianYear', parent: '#ROOT' },
24
- GREGORIAN_YEARMONTH_TYPE: { format: 'GregorianYearMonth', parent: '#ROOT' },
25
- CONTACT: { format: 'String', parent: '#ROOT' },
26
- CONTACT_NAME: { format: 'String', parent: 'CONTACT' },
27
- CONTACT_EMAIL: { format: 'String', parent: 'CONTACT' },
28
- CONTACT_PHONE: { format: 'Numeric', parent: 'CONTACT' },
29
- CONTACT_ORGANISATION: { format: 'String', parent: 'CONTACT' }
9
+ STRING_TYPE: { format: 'String', parent: '#ROOT', id: 'STRING_TYPE' },
10
+ STRING_MULTILANG_TYPE: { format: 'String', parent: '#ROOT', id: 'STRING_MULTILANG_TYPE' },
11
+ ALPHANUMERIC_TYPE: { format: 'AlphaNumeric', parent: '#ROOT', id: 'ALPHANUMERIC_TYPE' },
12
+ ALPHANUMERIC_MULTILANG_TYPE: { format: 'AlphaNumeric', parent: '#ROOT', id: 'ALPHANUMERIC_MULTILANG_TYPE' },
13
+ BOOLEAN_TYPE: { format: 'Boolean', parent: '#ROOT', id: 'BOOLEAN_TYPE' },
14
+ XHTML_TYPE: { format: 'XHTML', parent: '#ROOT', id: 'XHTML_TYPE' },
15
+ XHTML_MULTILANG_TYPE: { format: 'XHTML', parent: '#ROOT', id: 'XHTML_MULTILANG_TYPE' },
16
+ INTEGER_TYPE: { format: 'Integer', parent: '#ROOT', id: 'INTEGER_TYPE' },
17
+ INTEGER_MULTILANG_TYPE: { format: 'Integer', parent: '#ROOT', id: 'INTEGER_MULTILANG_TYPE' },
18
+ DECIMAL_TYPE: { format: 'Decimal', parent: '#ROOT', id: 'DECIMAL_TYPE' },
19
+ DECIMAL_MULTILANG_TYPE: { format: 'Decimal', parent: '#ROOT', id: 'DECIMAL_MULTILANG_TYPE' },
20
+ DATETIME_TYPE: { format: 'DateTime', parent: '#ROOT', id: 'DATETIME_TYPE' },
21
+ TIME_TYPE: { format: 'Time', parent: '#ROOT', id: 'TIME_TYPE' },
22
+ GREGORIANDAY_TYPE: { format: 'GregorianDay', parent: '#ROOT', id: 'GREGORIANDAY_TYPE' },
23
+ GREGORIAN_YEAR_TYPE: { format: 'GregorianYear', parent: '#ROOT', id: 'GREGORIAN_YEAR_TYPE' },
24
+ GREGORIAN_YEARMONTH_TYPE: { format: 'GregorianYearMonth', parent: '#ROOT', id: 'GREGORIAN_YEARMONTH_TYPE' },
25
+ CONTACT: { format: 'String', parent: '#ROOT', id: 'CONTACT' },
26
+ 'CONTACT.CONTACT_NAME': { format: 'String', parent: 'CONTACT', id: 'CONTACT_NAME' },
27
+ 'CONTACT.CONTACT_EMAIL': { format: 'String', parent: 'CONTACT', id: 'CONTACT_EMAIL' },
28
+ 'CONTACT.CONTACT_PHONE': { format: 'Numeric', parent: 'CONTACT', id: 'CONTACT_PHONE' },
29
+ 'CONTACT.CONTACT_ORGANISATION': { format: 'String', parent: 'CONTACT', id: 'CONTACT_ORGANISATION' }
30
30
  }
31
31
  };
32
32
 
@@ -9,6 +9,7 @@ describe('getSeriesAdvancedAttributes tests', () => {
9
9
  '0:1:0:x:x': { attributes: { a0: { id: 'a0' }, a1: { id: 'a1' } } },
10
10
  },
11
11
  dimensions: {
12
+ '2:0': { attributes: { a1: { id: 'a1' } } },
12
13
  '3:0': { attributes: { a0: { id: 'a0' } } },
13
14
  '4:1': { attributes: { a0: { id: 'a0' }, a1: { id: 'a1' } } },
14
15
  }
@@ -24,6 +25,7 @@ describe('getSeriesAdvancedAttributes tests', () => {
24
25
 
25
26
  expect(getSeriesAdvancedAttributes(seriesAttributes, dimensions, advancedAttributesIds)).to.deep.equal({
26
27
  '0:1:0::': { attributes: { a1: { id: 'a1' } }, coordinates: { d0: 'v0', d1: 'v1', d2: 'v0' } },
28
+ '::0::': { attributes: { a1: { id: 'a1' } }, coordinates: { d2: 'v0' } },
27
29
  '::::1': { attributes: { a1: { id: 'a1' } }, coordinates: { d4: 'v1' } }
28
30
  });
29
31
  });
@@ -41,7 +41,29 @@ describe('metadata parsing performance tests', () => {
41
41
  id: 'TIME_PERIOD',
42
42
  }
43
43
  ]
44
- expect(parseMetadataSeries(metadataMock, { locale: 'en', display: 'both', dimensions })).to.deep.equal({
44
+ const attributes = {
45
+ METADATA_ATTR_0: { id: 'METADATA_ATTR_0' },
46
+ METADATA_ATTR_1: { id: 'METADATA_ATTR_1' },
47
+ METADATA_ATTR_2: { id: 'METADATA_ATTR_2' },
48
+ METADATA_ATTR_3: { id: 'METADATA_ATTR_3' },
49
+ METADATA_ATTR_4: { id: 'METADATA_ATTR_4' },
50
+ METADATA_ATTR_5: { id: 'METADATA_ATTR_5' },
51
+ METADATA_ATTR_6: { id: 'METADATA_ATTR_6' },
52
+ METADATA_ATTR_7: { id: 'METADATA_ATTR_7' },
53
+ METADATA_ATTR_8: { id: 'METADATA_ATTR_8' },
54
+ METADATA_ATTR_9: { id: 'METADATA_ATTR_9' },
55
+ METADATA_ATTR_10: { id: 'METADATA_ATTR_10' },
56
+ METADATA_ATTR_11: { id: 'METADATA_ATTR_11' },
57
+ METADATA_ATTR_12: { id: 'METADATA_ATTR_12' },
58
+ METADATA_ATTR_13: { id: 'METADATA_ATTR_13' },
59
+ METADATA_ATTR_14: { id: 'METADATA_ATTR_14' },
60
+ METADATA_ATTR_15: { id: 'METADATA_ATTR_15' },
61
+ METADATA_ATTR_16: { id: 'METADATA_ATTR_16' },
62
+ METADATA_ATTR_17: { id: 'METADATA_ATTR_17' },
63
+ METADATA_ATTR_18: { id: 'METADATA_ATTR_18' },
64
+ METADATA_ATTR_19: { id: 'METADATA_ATTR_19' }
65
+ }
66
+ expect(parseMetadataSeries(metadataMock, { locale: 'en', display: 'both', dimensions, attributes })).to.deep.equal({
45
67
  ":::": [
46
68
  { id: 'METADATA_ATTR_0', label: 'METADATA_ATTR_0: Metadata Attribute 0', value: 'v0', handlerProps: {} },
47
69
  { id: 'METADATA_ATTR_1', label: 'METADATA_ATTR_1: Metadata Attribute 1', value: 'v0', handlerProps: {} },
@@ -14,11 +14,18 @@ const dimensions = [
14
14
  id: "MEASURE", values: [{ id: "V", __index: 0 }]
15
15
  },
16
16
  {
17
- id: "TIME_PERIOD"
17
+ id: "TIME_PERIOD"
18
18
  }
19
19
  ];
20
20
 
21
- const attributes = { DIRECT_SOURCE: { prop: 'test' }, RANDOM: { prop: 'invalid' } }
21
+ const attributes = {
22
+ DIRECT_SOURCE: { id: 'DIRECT_SOURCE', prop: 'test', parent: '#ROOT' },
23
+ KEY_STATISTICAL_CONCEPT: { id: 'KEY_STATISTICAL_CONCEPT', parent: '#ROOT' },
24
+ UNIT_OF_MEASURE_USED: { id: 'UNIT_OF_MEASURE_USED', parent: '#ROOT' },
25
+ POWER_CODE: { id: 'POWER_CODE', parent: '#ROOT' },
26
+ POREFERENCE_PERIODWER_CODE: { id: 'POREFERENCE_PERIODWER_CODE', parent: '#ROOT' },
27
+ RANDOM: { prop: 'invalid' }
28
+ }
22
29
 
23
30
  describe('parseMetadataSeries test', () => {
24
31
  it('complete case', () => {
@@ -28,13 +35,13 @@ describe('parseMetadataSeries test', () => {
28
35
  id: 'DIRECT_SOURCE',
29
36
  label: 'DIRECT_SOURCE: Direct source',
30
37
  value: "Reply to the National Accounts Questionnaire from the Australian Bureau of Statistics, Canberra. The official estimates are published in 'Australian system of national accounts', ABS, catalogue 5204.0.",
31
- handlerProps: { prop: 'test' }
38
+ handlerProps: { prop: 'test', parent: '#ROOT' }
32
39
  },
33
40
  {
34
41
  id: 'KEY_STATISTICAL_CONCEPT',
35
42
  label: 'KEY_STATISTICAL_CONCEPT: Key statistical concept',
36
43
  value: "As from December 2009, national accounts estimates are compiled according to the 2008 SNA ('System of National Accounts 2008', Commission of the European Communities-Eurostat, International Monetary Fund, Organisation for Economic Co-operation and Development, United Nations and World Bank, 2009).<br><br>Detailed information about the implementation of the 2008 SNA in Australian national accounts could be found in ABS website: <br><br><a href=\"http://www.abs.gov.au/ausstats/abs@.nsf/mf/5310.0.55.002\">ABS website</a><br><br>All the data refer to fiscal years beginning on the 1st July of the year indicated.<br><br>The financial intermediation services indirectly measured (FISIM) are allocated to industries and institutional sectors. <br><br>Original chain constant price estimates for main aggregates are referenced to fiscal year 2019-2020.",
37
- handlerProps: {}
44
+ handlerProps: { parent: '#ROOT' }
38
45
  }
39
46
  ],
40
47
  '0::0:': [
@@ -42,19 +49,78 @@ describe('parseMetadataSeries test', () => {
42
49
  id: 'UNIT_OF_MEASURE_USED',
43
50
  label: 'UNIT_OF_MEASURE_USED: Unit of measure used',
44
51
  value: 'Australian Dollar',
45
- handlerProps: {}
52
+ handlerProps: { parent: '#ROOT' }
46
53
  },
47
54
  {
48
55
  id: 'POWER_CODE',
49
56
  label: 'POWER_CODE: Power code',
50
57
  value: 6,
51
- handlerProps: {}
58
+ handlerProps: { parent: '#ROOT' }
52
59
  },
53
60
  {
54
61
  id: 'POREFERENCE_PERIODWER_CODE',
55
62
  label: 'POREFERENCE_PERIODWER_CODE: Reference period',
56
63
  value: '2019',
57
- handlerProps: {}
64
+ handlerProps: { parent: '#ROOT' }
65
+ }
66
+ ]
67
+ });
68
+ });
69
+ it('hierarchy test', () => {
70
+ const attributes = {
71
+ ROOT1: { id: 'ROOT1', parent: '#ROOT' },
72
+ ROOT2: { id: 'ROOT2', parent: '#ROOT' },
73
+ PARENT1: { id: 'PARENT1', parent: '#ROOT' },
74
+ 'PARENT1.CHILD1': { id: 'CHILD1', parent: 'PARENT1' },
75
+ 'PARENT1.CHILD2': { id: 'CHILD2', parent: 'PARENT1' },
76
+ PARENT2: { id: 'PARENT1', parent: '#ROOT' },
77
+ 'PARENT2.CHILD3': { id: 'CHILD3', parent: 'PARENT2' },
78
+ 'PARENT2.CHILD4': { id: 'CHILD4', parent: 'PARENT2' },
79
+ };
80
+ const metadata = {
81
+ data: {
82
+ dataSets: [{
83
+ dimensionGroupAttributes: {
84
+ '::': [0, 0, null, 0, 0, 0, 0]
85
+ }
86
+ }],
87
+ structures: [{
88
+ attributes: {
89
+ dimensionGroup: [
90
+ { id: 'ROOT1', name: 'Root 1', values: [{ value: 'v' }] },
91
+ { id: 'ROOT2', name: 'Root 2', values: [{ value: 'v' }] },
92
+ { id: 'PARENT1', name: 'Parent 1', isPresentational: true, values: [] },
93
+ { id: 'PARENT1.CHILD1', name: 'Child 1', values: [{ value: 'v' }] },
94
+ { id: 'PARENT1.CHILD2', name: 'Child 2', values: [{ value: 'v' }] },
95
+ { id: 'PARENT2.CHILD3', name: 'Child 3', values: [{ value: 'v' }] },
96
+ { id: 'PARENT2.CHILD4', name: 'Child 4', values: [{ value: 'v' }] },
97
+ ]
98
+ }
99
+ }]
100
+ }
101
+ };
102
+
103
+ expect(parseMetadataSeries(metadata, { display: 'name', locale: 'en', dimensions: [], attributes })).to.deep.equal({
104
+ '::': [
105
+ { id: 'ROOT1', label: 'Root 1', value: 'v', handlerProps: { parent: '#ROOT' } },
106
+ { id: 'ROOT2', label: 'Root 2', value: 'v', handlerProps: { parent: '#ROOT' } },
107
+ {
108
+ id: 'PARENT1',
109
+ label: 'Parent 1',
110
+ handlerProps: { parent: '#ROOT' },
111
+ children: [
112
+ { id: 'PARENT1.CHILD1', label: 'Child 1', value: 'v', handlerProps: { parent: 'PARENT1' } },
113
+ { id: 'PARENT1.CHILD2', label: 'Child 2', value: 'v', handlerProps: { parent: 'PARENT1' } },
114
+ ]
115
+ },
116
+ {
117
+ id: 'PARENT2',
118
+ label: '[PARENT2]',
119
+ handlerProps: { parent: '#ROOT' },
120
+ children: [
121
+ { id: 'PARENT2.CHILD3', label: 'Child 3', value: 'v', handlerProps: { parent: 'PARENT2' } },
122
+ { id: 'PARENT2.CHILD4', label: 'Child 4', value: 'v', handlerProps: { parent: 'PARENT2' } },
123
+ ]
58
124
  }
59
125
  ]
60
126
  });