@sis-cc/dotstatsuite-components 12.1.4 → 12.2.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/getMSDInformations.js +40 -0
- package/lib/rules2/src/getSidebarData.js +3 -2
- package/lib/rules2/src/index.js +9 -0
- package/lib/rules2/src/parseMetadataSeries.js +3 -2
- package/package.json +1 -1
- package/src/rules2/src/getMSDInformations.js +20 -0
- package/src/rules2/src/getSidebarData.js +3 -2
- package/src/rules2/src/index.js +1 -0
- package/src/rules2/src/parseMetadataSeries.js +3 -2
- package/test/getMSDInformations.test.js +35 -0
- package/test/metadata-parsing-perf.test.js +400 -400
- package/test/mocks/MSD_TEST.json +484 -0
- package/test/parseMetadataSeries.test.js +13 -6
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMSDInformations = undefined;
|
|
7
|
+
|
|
8
|
+
var _defineProperty2 = require('babel-runtime/helpers/defineProperty');
|
|
9
|
+
|
|
10
|
+
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
|
|
11
|
+
|
|
12
|
+
var _extends3 = require('babel-runtime/helpers/extends');
|
|
13
|
+
|
|
14
|
+
var _extends4 = _interopRequireDefault(_extends3);
|
|
15
|
+
|
|
16
|
+
var _ramda = require('ramda');
|
|
17
|
+
|
|
18
|
+
var R = _interopRequireWildcard(_ramda);
|
|
19
|
+
|
|
20
|
+
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; } }
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
var getMSDInformations = exports.getMSDInformations = function getMSDInformations(msdJson) {
|
|
25
|
+
var attributesDefinitions = R.pathOr([], ['data', 'metadataStructures', 0, 'metadataStructureComponents', 'reportStructures', 0, 'metadataAttributes'], msdJson);
|
|
26
|
+
|
|
27
|
+
var parseAttributes = function parseAttributes(parent) {
|
|
28
|
+
return R.reduce(function (acc, attribute) {
|
|
29
|
+
var id = attribute.id;
|
|
30
|
+
var format = R.path(['localRepresentation', 'textFormat', 'textType'], attribute);
|
|
31
|
+
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 }));
|
|
34
|
+
}
|
|
35
|
+
return R.assoc(id, { format: format, parent: parent }, acc);
|
|
36
|
+
}, {});
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return { attributes: parseAttributes('#ROOT')(attributesDefinitions) };
|
|
40
|
+
};
|
|
@@ -13,13 +13,14 @@ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj;
|
|
|
13
13
|
|
|
14
14
|
var dimensionValueDisplay = function dimensionValueDisplay(display) {
|
|
15
15
|
return function (data) {
|
|
16
|
+
var name = R.isNil(data.name) ? '[' + data.id + ']' : data.name;
|
|
16
17
|
if (display === 'code') {
|
|
17
18
|
return R.prop('id', data);
|
|
18
19
|
}
|
|
19
20
|
if (display === 'both') {
|
|
20
|
-
return R.prop('id', data) + ': ' +
|
|
21
|
+
return R.prop('id', data) + ': ' + name;
|
|
21
22
|
}
|
|
22
|
-
return
|
|
23
|
+
return name;
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
|
package/lib/rules2/src/index.js
CHANGED
|
@@ -44,4 +44,13 @@ Object.defineProperty(exports, 'sdmx_3_0_DataFormatPatch', {
|
|
|
44
44
|
get: function get() {
|
|
45
45
|
return _sdmx.sdmx_3_0_DataFormatPatch;
|
|
46
46
|
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var _getMSDInformations = require('./getMSDInformations');
|
|
50
|
+
|
|
51
|
+
Object.defineProperty(exports, 'getMSDInformations', {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function get() {
|
|
54
|
+
return _getMSDInformations.getMSDInformations;
|
|
55
|
+
}
|
|
47
56
|
});
|
|
@@ -24,7 +24,7 @@ var dimensionValueDisplay = function dimensionValueDisplay(locale, display) {
|
|
|
24
24
|
return (0, _dotstatsuiteSdmxjs.getLocalisedName)(locale)(data);
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
// options = { locale, display, dimensions = [] };
|
|
27
|
+
// options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
|
|
28
28
|
var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSeries(metadataJson, options) {
|
|
29
29
|
var metadataAttributes = R.pathOr([], ['data', 'structures', 0, 'attributes', 'dimensionGroup'], metadataJson);
|
|
30
30
|
var metaAttrLength = R.length(metadataAttributes);
|
|
@@ -71,7 +71,8 @@ var parseMetadataSeries = exports.parseMetadataSeries = function parseMetadataSe
|
|
|
71
71
|
return R.append({
|
|
72
72
|
id: attribute.id,
|
|
73
73
|
label: label,
|
|
74
|
-
value: R.is(Object, value) ? R.prop(options.locale, value) : value
|
|
74
|
+
value: R.is(Object, value) ? R.prop(options.locale, value) : value,
|
|
75
|
+
handlerProps: R.pathOr({}, ['attributes', attribute.id], options)
|
|
75
76
|
}, acc);
|
|
76
77
|
}, [], metaIndexes);
|
|
77
78
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as R from 'ramda';
|
|
2
|
+
|
|
3
|
+
export const getMSDInformations = (msdJson) => {
|
|
4
|
+
const attributesDefinitions = R.pathOr([], ['data', 'metadataStructures', 0, 'metadataStructureComponents', 'reportStructures', 0, 'metadataAttributes'], msdJson);
|
|
5
|
+
|
|
6
|
+
const parseAttributes = (parent) => R.reduce(
|
|
7
|
+
(acc, attribute) => {
|
|
8
|
+
const id = attribute.id;
|
|
9
|
+
const format = R.path(['localRepresentation', 'textFormat', 'textType'], attribute);
|
|
10
|
+
if (R.has('metadataAttributes', attribute)) {
|
|
11
|
+
const collection = parseAttributes(attribute.id)(attribute.metadataAttributes);
|
|
12
|
+
return ({ ...acc, ...collection, [id]: { format, parent } });
|
|
13
|
+
}
|
|
14
|
+
return R.assoc(id, { format, parent }, acc);
|
|
15
|
+
},
|
|
16
|
+
{}
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
return ({ attributes: parseAttributes('#ROOT')(attributesDefinitions) });
|
|
20
|
+
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import * as R from 'ramda';
|
|
2
2
|
|
|
3
3
|
const dimensionValueDisplay = (display) => data => {
|
|
4
|
+
const name = R.isNil(data.name) ? `[${data.id}]` : data.name;
|
|
4
5
|
if (display === 'code') {
|
|
5
6
|
return R.prop('id', data);
|
|
6
7
|
}
|
|
7
8
|
if (display === 'both') {
|
|
8
|
-
return `${R.prop('id', data)}: ${
|
|
9
|
+
return `${R.prop('id', data)}: ${name}`;
|
|
9
10
|
}
|
|
10
|
-
return
|
|
11
|
+
return name;
|
|
11
12
|
};
|
|
12
13
|
|
|
13
14
|
const sortByCoordinates = (a, b) => {
|
package/src/rules2/src/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const dimensionValueDisplay = (locale, display) => data => {
|
|
|
10
10
|
}
|
|
11
11
|
return getLocalisedName(locale)(data);
|
|
12
12
|
};
|
|
13
|
-
// options = { locale, display, dimensions = [] };
|
|
13
|
+
// options = { locale, display, dimensions = [], attributes = { [id]: { format, parent } } };
|
|
14
14
|
export const parseMetadataSeries = (metadataJson, options) => {
|
|
15
15
|
const metadataAttributes = R.pathOr([], ['data', 'structures', 0, 'attributes', 'dimensionGroup'], metadataJson);
|
|
16
16
|
const metaAttrLength = R.length(metadataAttributes);
|
|
@@ -63,7 +63,8 @@ export const parseMetadataSeries = (metadataJson, options) => {
|
|
|
63
63
|
return R.append({
|
|
64
64
|
id: attribute.id,
|
|
65
65
|
label,
|
|
66
|
-
value: R.is(Object, value) ? R.prop(options.locale, value) : value
|
|
66
|
+
value: R.is(Object, value) ? R.prop(options.locale, value) : value,
|
|
67
|
+
handlerProps: R.pathOr({}, ['attributes', attribute.id], options)
|
|
67
68
|
}, acc);
|
|
68
69
|
},
|
|
69
70
|
[],
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { expect } from 'chai';
|
|
2
|
+
import { getMSDInformations } from '../src/rules2/src/getMSDInformations';
|
|
3
|
+
import msd from './mocks/MSD_TEST.json';
|
|
4
|
+
|
|
5
|
+
describe('getMSDInformations tests', () => {
|
|
6
|
+
it('complete test', () => {
|
|
7
|
+
const expected = {
|
|
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' }
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
expect(getMSDInformations(msd)).to.deep.equal(expected);
|
|
34
|
+
});
|
|
35
|
+
});
|