diff --git a/build.gradle.kts b/build.gradle.kts index b6c11d1d9..38a6e2403 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ java { allprojects { group = "fr.insee.eno" - version = "3.29.0-hotfix.2" + version = "3.29.1" } 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); } 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 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