diff --git a/SdmxStructureParser/src/main/java/org/sdmxsource/sdmx/structureparser/builder/sdmxbeans/impl/SdmxObjectsJsonV1Builder.java b/SdmxStructureParser/src/main/java/org/sdmxsource/sdmx/structureparser/builder/sdmxbeans/impl/SdmxObjectsJsonV1Builder.java index eb9923e..47e0ef1 100644 --- a/SdmxStructureParser/src/main/java/org/sdmxsource/sdmx/structureparser/builder/sdmxbeans/impl/SdmxObjectsJsonV1Builder.java +++ b/SdmxStructureParser/src/main/java/org/sdmxsource/sdmx/structureparser/builder/sdmxbeans/impl/SdmxObjectsJsonV1Builder.java @@ -306,9 +306,11 @@ private void processDatastructures(JsonNode dataStructures, SdmxBeansImpl beans) for (DataStructureDTO.Group groupDto : dataStructureDto.dataStructureComponents.groups) { GroupMutableBean group = new GroupMutableBeanImpl(); group.setId(groupDto.id); + group.setDimensionRef(new ArrayList<>(groupDto.groupDimensions.length)); - for (String groupDimension : groupDto.groupDimensions) + for (String groupDimension : groupDto.groupDimensions) { group.getDimensionRef().add(groupDimension); + } structureMutableObject.addGroup(group); } } diff --git a/SdmxStructureParser/src/test/java/org/sdmxsource/sdmx/structureparser/test/SdmxObjectsJsonV1BuilderTest.java b/SdmxStructureParser/src/test/java/org/sdmxsource/sdmx/structureparser/test/SdmxObjectsJsonV1BuilderTest.java index 9ab3d1a..14580cc 100644 --- a/SdmxStructureParser/src/test/java/org/sdmxsource/sdmx/structureparser/test/SdmxObjectsJsonV1BuilderTest.java +++ b/SdmxStructureParser/src/test/java/org/sdmxsource/sdmx/structureparser/test/SdmxObjectsJsonV1BuilderTest.java @@ -39,4 +39,21 @@ public void shouldBuildSdmxBeans() { assertThat(contentConstraint.getAnnotations().size()).isEqualTo(1); } + @Test + public void shouldBuildSdmxBeans_dataStructure() { + ReadableDataLocation fileReadableDataLocation = new ReadableDataLocationTmp("src/test/resources/json/datastructure.json"); + SdmxBeans beans; + + try (InputStream stream = fileReadableDataLocation.getInputStream()) { + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = mapper.readTree(stream); + beans = sdmxObjectsJsonV1Builder.build(node); + beans.getDataflows(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + assertThat(beans.getDataStructures()).isNotEmpty(); + assertThat(beans.getDataStructures().size()).isEqualTo(1); + } } diff --git a/SdmxStructureParser/src/test/resources/json/datastructure.json b/SdmxStructureParser/src/test/resources/json/datastructure.json new file mode 100644 index 0000000..fd03b33 --- /dev/null +++ b/SdmxStructureParser/src/test/resources/json/datastructure.json @@ -0,0 +1,118 @@ +{ + "meta": {}, + "data": { + "dataStructures": [ + { + "annotations": [ + { + "texts": { + "en": "text" + }, + "id": "1", + "text": "text", + "type": "type1" + } + ], + "description": "Some artefact", + "agencyID": "QH", + "descriptions": { + "en": "Some artefact" + }, + "version": "1.2", + "names": { + "en": "Maintanable artefact", + "fr-CA": "artefact" + }, + "dataStructureComponents": { + "groups": [ + { + "id": "GROUP1", + "groupDimensions": [ + "DIM1" + ] + } + ], + "attributeList": { + "attributes": [ + { + "assignmentStatus": "Conditional", + "conceptIdentity": "urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=QH:ADVANCED_RELEASE_CALANDER_DIAGNOSTICS_COLLECTION_SCHEME(1.5.1).DATE_VALUE", + "attributeRelationship": { + "dimensions": [ + "DIM1" + ], + "attachmentGroups": [ + "GROUP1" + ] + }, + "localRepresentation": { + "textFormat": { + "textType": "AlphaNumeric" + } + }, + "conceptRoles": [ + "urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=QH:ADVANCED_RELEASE_CALANDER(1.5.1).DATE_VALUE", + "urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=QH:ADVANCED_RELEASE_CALANDER_DIAGNOSTICS(1.5.2).DATE_VALUE" + ], + "id": "DA1" + } + ], + "id": "AttributeDescriptor" + }, + "dimensionList": { + "timeDimensions": [ + { + "conceptIdentity": "urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=QH:TIME_DIMENSION(1.6.1).DATE_VALUE", + "localRepresentation": { + "textFormat": { + "textType": "BasicTimePeriod" + } + }, + "id": "TIME_PERIOD", + "position": 2, + "type": "TimeDimension" + } + ], + "id": "DimensionDescriptor", + "dimensions": [ + { + "conceptIdentity": "urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=QH:DIMENSION(1.6.1).DATE_VALUE", + "localRepresentation": { + "enumeration": "urn:sdmx:org.sdmx.infomodel.codelist.Codelist=QH:CODELIST(1.0)" + }, + "conceptRoles": [ + "urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=QH:ADVANCED_RELEASE_CALANDER(1.5.1).DATE_VALUE" + ], + "id": "DIM1", + "position": 1, + "type": "Dimension" + } + ] + }, + "measureList": { + "primaryMeasure": { + "conceptIdentity": "urn:sdmx:org.sdmx.infomodel.conceptscheme.Concept=QH:MEASURE(1.5.2).DATE_VALUE", + "localRepresentation": { + "textFormat": { + "textType": "BasicTimePeriod" + } + }, + "id": "MES1" + }, + "id": "MeasureDescriptor" + } + }, + "name": "Maintanable artefact", + "links": [ + { + "urn": "urn:sdmx:org.sdmx.infomodel.datastructure.DataStructure=QH:ARTEFACT(1.2)", + "rel": "self", + "type": "datastructure" + } + ], + "id": "ARTEFACT", + "isFinal": true + } + ] + } +} \ No newline at end of file