Skip to content

Commit

Permalink
Fix minor SDMX module issues
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoLaval committed Jan 23, 2025
1 parent e6d3094 commit 803caca
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static Map<String, DataStructureBean> dataflows(SdmxBeans sdmxBeans) {
.distinct()
.flatMap(Collection::stream)
.collect(Collectors.toMap(
dataStructureBean -> dataStructureBean.getId(),
INamedBean::getId,
dataStructureBean -> dataStructureBean
));
}
Expand Down
18 changes: 9 additions & 9 deletions vtl-sdmx/src/test/java/fr/insee/vtl/BPETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ public void bpeV1() throws ScriptException {
assertThat(bpeDetailDs.getDataStructure().size()).isEqualTo(6);

ScriptContext context = engine.getContext();
context.setAttribute("BPE_DETAIL", bpeDetailDs, ScriptContext.ENGINE_SCOPE);
context.setAttribute("BPE_DETAIL_VTL", bpeDetailDs, ScriptContext.ENGINE_SCOPE);

// Step 1
engine.eval("" +
"define datapoint ruleset UNIQUE_MUNICIPALITY (variable DEPCOM) is\n" +
" MUNICIPALITY_FORMAT_RULE : match_characters(DEPCOM, \"[0-9]{5}|2[A-B][0-9]{3}\") errorcode \"Municipality code is not in the correct format\"\n" +
"end datapoint ruleset;\n" +
"\n" +
"CHECK_MUNICIPALITY := check_datapoint(BPE_DETAIL, UNIQUE_MUNICIPALITY invalid);");
"CHECK_MUNICIPALITY := check_datapoint(BPE_DETAIL_VTL, UNIQUE_MUNICIPALITY invalid);");

Dataset checkMunicipality = (Dataset) engine.getContext().getAttribute("CHECK_MUNICIPALITY");

Expand Down Expand Up @@ -101,8 +101,8 @@ public void bpeV1() throws ScriptException {
assertThat(bpeMunicipalityStructure.get("facility_type").getType()).isEqualTo(String.class);
assertThat(bpeMunicipalityStructure.get("facility_type").getRole()).isEqualTo(Dataset.Role.IDENTIFIER);

assertThat(bpeMunicipalityStructure.get("year").getType()).isEqualTo(String.class);
assertThat(bpeMunicipalityStructure.get("year").getRole()).isEqualTo(Dataset.Role.IDENTIFIER);
assertThat(bpeMunicipalityStructure.get("TIME_PERIOD").getType()).isEqualTo(String.class);
assertThat(bpeMunicipalityStructure.get("TIME_PERIOD").getRole()).isEqualTo(Dataset.Role.IDENTIFIER);


assertThat(bpeMunicipalityStructure.get("nb").getType()).isEqualTo(Long.class);
Expand All @@ -121,8 +121,8 @@ public void bpeV1() throws ScriptException {
assertThat(bpeNutsStructure.get("facility_type").getType()).isEqualTo(String.class);
assertThat(bpeNutsStructure.get("facility_type").getRole()).isEqualTo(Dataset.Role.IDENTIFIER);

assertThat(bpeNutsStructure.get("year").getType()).isEqualTo(String.class);
assertThat(bpeNutsStructure.get("year").getRole()).isEqualTo(Dataset.Role.IDENTIFIER);
assertThat(bpeNutsStructure.get("TIME_PERIOD").getType()).isEqualTo(String.class);
assertThat(bpeNutsStructure.get("TIME_PERIOD").getRole()).isEqualTo(Dataset.Role.IDENTIFIER);


assertThat(bpeNutsStructure.get("nb").getType()).isEqualTo(Long.class);
Expand All @@ -142,9 +142,9 @@ public void bpeV1() throws ScriptException {
assertThat(checkNutsTypes.getDataPoints()).isEmpty();

// Step 6
Structured.DataStructure censusStructure = TrevasSDMXUtils.buildStructureFromSDMX3("src/test/resources/DSD_BPE_CENSUS.xml", "LEGAL_POP_CUBE");
Structured.DataStructure censusStructure = TrevasSDMXUtils.buildStructureFromSDMX3("src/test/resources/DSD_BPE_CENSUS.xml", "LEGAL_POP");

SparkDataset censusNuts = new SparkDataset(
SparkDataset legalPop = new SparkDataset(
spark.read()
.option("header", "true")
.option("delimiter", ";")
Expand All @@ -153,7 +153,7 @@ public void bpeV1() throws ScriptException {
censusStructure
);

context.setAttribute("CENSUS_NUTS3_2021", censusNuts, ScriptContext.ENGINE_SCOPE);
context.setAttribute("LEGAL_POP", legalPop, ScriptContext.ENGINE_SCOPE);

engine.eval("CENSUS_NUTS3_2021 := LEGAL_POP [rename REF_AREA to nuts3, POP_TOT to pop]\n" +
"[filter TIME_PERIOD = \"2021\"]\n" +
Expand Down
4 changes: 2 additions & 2 deletions vtl-sdmx/src/test/java/fr/insee/vtl/SDMXVTLWorkflowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public void testGetRulesetsVTL() {
ReadableDataLocation rdl = new ReadableDataLocationTmp("src/test/resources/DSD_BPE_CENSUS.xml");
SDMXVTLWorkflow sdmxVtlWorkflow = new SDMXVTLWorkflow(engine, rdl, Java8Helpers.mapOf());
assertThat(sdmxVtlWorkflow.getRulesetsVTL()).isEqualTo(
"define datapoint ruleset UNIQUE_MUNICIPALITY (valuedomain CL_DEPCOM) is\n" +
" MUNICIPALITY_FORMAT_RULE : match_characters(CL_DEPCOM, \"[0-9]{5}|2[A-B][0-9]{3}\") errorcode \"Municipality code is not in the correct format\"\n" +
"define datapoint ruleset UNIQUE_MUNICIPALITY (variable DEPCOM) is\n" +
" MUNICIPALITY_FORMAT_RULE : match_characters(DEPCOM, \"[0-9]{5}|2[A-B][0-9]{3}\") errorcode \"Municipality code is not in the correct format\"\n" +
" end datapoint ruleset;\n" +
"\n" +
"define datapoint ruleset NUTS3_TYPES (variable facility_type, nb) is\n" +
Expand Down

0 comments on commit 803caca

Please sign in to comment.