From f3a9d5ce532e3509e3c4591ccaf6af4c6339b44b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:50:14 +0100 Subject: [PATCH 1/3] chore(deps): update gradle to v8.11 (#1151) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index df97d72b8..94113f200 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME From f226a9edeb0084f395a628e00d2b92430d0a4912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20S=C3=A9nave?= <59770457+nsenave@users.noreply.github.com> Date: Mon, 18 Nov 2024 11:22:44 +0100 Subject: [PATCH 2/3] refactor: dynamic table mapping (#1152) * refactor: more robust mapping of ddi rank 1 dimension * refactor: simplify big integer to string * chore: bump version --- build.gradle.kts | 2 +- .../model/question/DynamicTableQuestion.java | 21 +++++++++---------- .../table/DynamicTableQuestionProcessing.java | 4 ++-- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c90a3c77d..54d21f454 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ java { allprojects { group = "fr.insee.eno" - version = "3.29.0" + version = "3.29.1-SNAPSHOT" } subprojects { diff --git a/eno-core/src/main/java/fr/insee/eno/core/model/question/DynamicTableQuestion.java b/eno-core/src/main/java/fr/insee/eno/core/model/question/DynamicTableQuestion.java index 6688a126b..d7beef5f3 100644 --- a/eno-core/src/main/java/fr/insee/eno/core/model/question/DynamicTableQuestion.java +++ b/eno-core/src/main/java/fr/insee/eno/core/model/question/DynamicTableQuestion.java @@ -1,5 +1,6 @@ package fr.insee.eno.core.model.question; +import fr.insee.ddi.lifecycle33.datacollection.GridDimensionType; import fr.insee.ddi.lifecycle33.datacollection.QuestionGridType; import fr.insee.ddi.lifecycle33.reusable.CommandCodeType; import fr.insee.ddi.lifecycle33.reusable.CommandType; @@ -92,22 +93,20 @@ public class DynamicTableQuestion extends MultipleResponseQuestion implements En List cellLabels = new ArrayList<>(); public static CommandType mapDDISizeExpression(QuestionGridType ddiDynamicTableQuestion) { - checkRank1Dimension(ddiDynamicTableQuestion); - CommandCodeType conditionForContinuation = ddiDynamicTableQuestion.getGridDimensionArray(0).getRoster() - .getConditionForContinuation(); + GridDimensionType rank1Dimension = checkRank1Dimension(ddiDynamicTableQuestion); + CommandCodeType conditionForContinuation = rank1Dimension.getRoster().getConditionForContinuation(); if (conditionForContinuation == null) return null; return conditionForContinuation.getCommandArray(0); } - private static void checkRank1Dimension(QuestionGridType ddiDynamicTableQuestion) { - boolean hasRank1Dimension = ddiDynamicTableQuestion.getGridDimensionList().stream() - .filter(gridDimensionType -> gridDimensionType.getRank() != null) - .anyMatch(gridDimensionType -> 1 == gridDimensionType.getRank().intValue()); - if (! hasRank1Dimension) - throw new IllegalDDIElementException( - "DDI dynamic table question '" + ddiDynamicTableQuestion.getIDArray(0).getStringValue() + - "' has no rank 1 dimension."); + private static GridDimensionType checkRank1Dimension(QuestionGridType ddiDynamicTableQuestion) { + return ddiDynamicTableQuestion.getGridDimensionList().stream() + .filter(gridDimensionType -> BigInteger.ONE.equals(gridDimensionType.getRank())) + .findAny() + .orElseThrow(() -> new IllegalDDIElementException( + "DDI dynamic table question '" + ddiDynamicTableQuestion.getIDArray(0).getStringValue() + + "' has no rank 1 dimension.")); } } diff --git a/eno-core/src/main/java/fr/insee/eno/core/processing/out/steps/lunatic/table/DynamicTableQuestionProcessing.java b/eno-core/src/main/java/fr/insee/eno/core/processing/out/steps/lunatic/table/DynamicTableQuestionProcessing.java index a81f36fcd..9f07c2219 100644 --- a/eno-core/src/main/java/fr/insee/eno/core/processing/out/steps/lunatic/table/DynamicTableQuestionProcessing.java +++ b/eno-core/src/main/java/fr/insee/eno/core/processing/out/steps/lunatic/table/DynamicTableQuestionProcessing.java @@ -52,12 +52,12 @@ else if (enoTable.getSizeExpression() != null) private static void setMinMaxProperties(DynamicTableQuestion enoTable, LinesRoster lines) { LabelType minLabel = new LabelType(); minLabel.setType(LabelTypeEnum.VTL); - minLabel.setValue(Integer.toString(enoTable.getMinLines().intValue())); + minLabel.setValue(enoTable.getMinLines().toString()); lines.setMin(minLabel); LabelType maxLabel = new LabelType(); maxLabel.setType(LabelTypeEnum.VTL); - maxLabel.setValue(Integer.toString(enoTable.getMaxLines().intValue())); + maxLabel.setValue(enoTable.getMaxLines().toString()); lines.setMax(maxLabel); } From 03d0828ac0bb2835f0a764d489738bce65afd83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20S=C3=A9nave?= <59770457+nsenave@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:32:15 +0100 Subject: [PATCH 3/3] fix: duration and suggester components in resizing (#1159) --- .../fr/insee/eno/core/utils/LunaticUtils.java | 15 ++++++++++----- .../resizing/LunaticLoopResizingLogicTest.java | 13 +++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/eno-core/src/main/java/fr/insee/eno/core/utils/LunaticUtils.java b/eno-core/src/main/java/fr/insee/eno/core/utils/LunaticUtils.java index 6e8f76aba..d563a2fd5 100644 --- a/eno-core/src/main/java/fr/insee/eno/core/utils/LunaticUtils.java +++ b/eno-core/src/main/java/fr/insee/eno/core/utils/LunaticUtils.java @@ -117,9 +117,13 @@ public static List getCollectedVariablesInLoop(Loop loop) { List result = new ArrayList<>(); loop.getComponents().forEach(component -> { switch (component.getComponentType()) { - case CHECKBOX_BOOLEAN, INPUT_NUMBER, INPUT, TEXTAREA, DATEPICKER, RADIO, CHECKBOX_ONE, DROPDOWN, - CHECKBOX_GROUP, TABLE -> + case CHECKBOX_BOOLEAN, INPUT_NUMBER, INPUT, TEXTAREA, SUGGESTER, DATEPICKER, DURATION, RADIO, + CHECKBOX_ONE, DROPDOWN, CHECKBOX_GROUP, TABLE -> result.addAll(getDirectResponseNames(component)); + case QUESTIONNAIRE, SEQUENCE, SUBSEQUENCE, TEXT, ACCORDION -> + doNothing(); + case QUESTION -> + throw new IllegalStateException("This method does not support the question component."); case ROSTER_FOR_LOOP -> throw new LunaticLoopException(String.format( "Dynamic tables are forbidden in loops: loop '%s' contains a dynamic table.", @@ -132,14 +136,15 @@ public static List getCollectedVariablesInLoop(Loop loop) { throw new LunaticLoopException(String.format( "Pairwise components are forbidden in loops: loop '%s' contains a pairwise component.", loop.getId())); - default -> - log.debug("(Variables in Lunatic loop) Component of type {} has no response.", - component.getComponentType()); } }); return result; } + private static void doNothing() { + /* No-op method */ + } + /** * Return the response name of the component that belong to the given pairwise links. This method checks if * the inner component is valid. diff --git a/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/resizing/LunaticLoopResizingLogicTest.java b/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/resizing/LunaticLoopResizingLogicTest.java index 872aed90b..c15860a3d 100644 --- a/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/resizing/LunaticLoopResizingLogicTest.java +++ b/eno-core/src/test/java/fr/insee/eno/core/processing/out/steps/lunatic/resizing/LunaticLoopResizingLogicTest.java @@ -121,6 +121,10 @@ void simpleResponseComponents_resizedVariables() { input.setResponse(new ResponseType()); input.getResponse().setName("INPUT_VAR"); lunaticLoop.getComponents().add(input); + Suggester suggester = new Suggester(); // The suggester component type is set by the constructor + suggester.setResponse(new ResponseType()); + suggester.getResponse().setName("SUGGESTER_VAR"); + lunaticLoop.getComponents().add(suggester); Textarea textarea = new Textarea(); textarea.setComponentType(ComponentTypeEnum.TEXTAREA); textarea.setResponse(new ResponseType()); @@ -136,6 +140,11 @@ void simpleResponseComponents_resizedVariables() { datepicker.setResponse(new ResponseType()); datepicker.getResponse().setName("DATE_VAR"); lunaticLoop.getComponents().add(datepicker); + Duration duration = new Duration(); + duration.setComponentType(ComponentTypeEnum.DURATION); + duration.setResponse(new ResponseType()); + duration.getResponse().setName("DURATION_VAR"); + lunaticLoop.getComponents().add(duration); Dropdown dropdown = new Dropdown(); dropdown.setComponentType(ComponentTypeEnum.DROPDOWN); dropdown.setResponse(new ResponseType()); @@ -160,8 +169,8 @@ void simpleResponseComponents_resizedVariables() { // Then assertThat(lunaticResizing.getResizingEntry("LOOP_SIZE_VAR").getVariables()) .containsExactlyInAnyOrderElementsOf(Set.of( - "BOOLEAN_VAR", "INPUT_VAR", "TEXT_VAR", "NUMBER_VAR", "DATE_VAR", - "DROPDOWN_VAR", "RADIO_VAR", "CHECKBOX_VAR")); + "BOOLEAN_VAR", "INPUT_VAR", "SUGGESTER_VAR", "TEXT_VAR", "NUMBER_VAR", + "DATE_VAR", "DURATION_VAR", "DROPDOWN_VAR", "RADIO_VAR", "CHECKBOX_VAR")); } @Test