Skip to content

Commit

Permalink
Merge branch 'v3-main' into feat/dynamic-table-vtl-size
Browse files Browse the repository at this point in the history
  • Loading branch information
nsenave committed Nov 8, 2024
2 parents dc65830 + 21caa8a commit f8c6809
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.28.0] - 2024-11-08
### :sparkles: New Features
- [`d2bde07`](https://github.com/InseeFr/Eno/commit/d2bde07274042b207efb1cee21ceac350d474ff3) - roundabout controls *(PR [#1142](https://github.com/InseeFr/Eno/pull/1142) by [@nsenave](https://github.com/nsenave))*

### :bug: Bug Fixes
- [`5cd3739`](https://github.com/InseeFr/Eno/commit/5cd3739b9b3100132c927d6c403f90b707324fb1) - roundabout on subsequence *(PR [#1133](https://github.com/InseeFr/Eno/pull/1133) by [@nsenave](https://github.com/nsenave))*
- [`4535533`](https://github.com/InseeFr/Eno/commit/45355332b40b25239b206736244c695e0279faae) - allow suggester with option responses in tables *(PR [#1135](https://github.com/InseeFr/Eno/pull/1135) by [@nsenave](https://github.com/nsenave))*
- [`67fd88f`](https://github.com/InseeFr/Eno/commit/67fd88f7097ab8c86e34f1b9a6dd24b257d82eb1) - eno xforms zip incorrect *(PR [#1139](https://github.com/InseeFr/Eno/pull/1139) by [@RemiVerriez](https://github.com/RemiVerriez))*
- [`608fcac`](https://github.com/InseeFr/Eno/commit/608fcac2f487d6f1a05ebbfc3f3067f868dc34ed) - roundabout controls *(PR [#1150](https://github.com/InseeFr/Eno/pull/1150) by [@nsenave](https://github.com/nsenave))*


## [3.27.1] - 2024-09-30
### :bug: Bug Fixes
- [`603e2eb`](https://github.com/InseeFr/Eno/commit/603e2eb23794c6ac0404ed10fbecda32259f1293) - restrict to get requests for swagger redirection *(commit by [@nsenave](https://github.com/nsenave))*
Expand Down Expand Up @@ -331,3 +342,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[3.26.4]: https://github.com/InseeFr/Eno/compare/3.26.3...3.26.4
[3.27.0]: https://github.com/InseeFr/Eno/compare/3.26.4...3.27.0
[3.27.1]: https://github.com/InseeFr/Eno/compare/3.27.0...3.27.1
[3.28.0]: https://github.com/InseeFr/Eno/compare/3.27.1...3.28.0
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ java {

allprojects {
group = "fr.insee.eno"
version = "3.29.0-SNAPSHOT"
version = "3.29.0-SNAPSHOT.1"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package fr.insee.eno.core.model.sequence;

import fr.insee.ddi.lifecycle33.datacollection.ComputationItemType;
import fr.insee.ddi.lifecycle33.datacollection.SequenceType;
import fr.insee.eno.core.annotations.Contexts.Context;
import fr.insee.eno.core.annotations.DDI;
import fr.insee.eno.core.model.navigation.Control;
import fr.insee.eno.core.parameter.Format;
import fr.insee.eno.core.reference.DDIIndex;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* Special kind of sequence that describes a "roundabout".
Expand All @@ -22,14 +25,16 @@
@Context(format = Format.DDI, type = SequenceType.class)
public class RoundaboutSequence extends AbstractSequence {

private static final String DDI_LOCKED_CONTROL_TYPE = "roundabout-locked";

/** DDI reference of the loop.
* Note: mapped as the id of the first control construct reference. */
@DDI("getControlConstructReferenceArray(0).getIDArray(0).getStringValue()")
private String loopReference;

/** Boolean that describes if the completed occurrences should be locked or not.
* In DDI, this is modeled by the presence or not of a ComputationItem among the control construct references. */
@DDI("!getControlConstructReferenceList().?[#this.getTypeOfObject().toString() == 'ComputationItem'].isEmpty()")
@DDI("T(fr.insee.eno.core.model.sequence.RoundaboutSequence).ddiLockedProperty(#this, #index)")
private Boolean locked;

/**
Expand All @@ -41,4 +46,15 @@ public class RoundaboutSequence extends AbstractSequence {
*/
private List<Control> controls = new ArrayList<>();

public static boolean ddiLockedProperty(SequenceType ddiRoundaboutSequence, DDIIndex ddiIndex) {
return ddiRoundaboutSequence.getControlConstructReferenceList().stream()
.filter(reference -> "ComputationItem".equals(reference.getTypeOfObject().toString()))
.map(reference -> ddiIndex.get(reference.getIDArray(0).getStringValue()))
.filter(Objects::nonNull)
.filter(ComputationItemType.class::isInstance)
.map(ComputationItemType.class::cast)
.anyMatch(computationItem ->
DDI_LOCKED_CONTROL_TYPE.equals(computationItem.getTypeOfComputationItem().getStringValue()));
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.insee.eno.core.processing.out.steps.lunatic;

import fr.insee.eno.core.processing.ProcessingStep;
import fr.insee.eno.core.utils.VtlSyntaxUtils;
import fr.insee.lunatic.model.flat.*;

import java.util.Collection;
Expand All @@ -27,12 +28,13 @@ private void processComponents(List<ComponentType> components) {
.filter(control -> control.getTypeOfControl().equals(ControlTypeEnum.CONSISTENCY))
.forEach(control -> {
LabelType label = control.getControl();
label.setValue("not(" + label.getValue() + ")");
label.setValue(VtlSyntaxUtils.invertBooleanExpression(label.getValue()));
});

components.stream()
.filter(ComponentNestingType.class::isInstance)
.map(ComponentNestingType.class::cast)
.forEach(componentNesting -> processComponents(componentNesting.getComponents()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import fr.insee.eno.core.model.navigation.LinkedLoop;
import fr.insee.eno.core.model.sequence.RoundaboutSequence;
import fr.insee.eno.core.processing.ProcessingStep;
import fr.insee.eno.core.utils.VtlSyntaxUtils;
import fr.insee.lunatic.model.flat.*;
import fr.insee.lunatic.model.flat.variable.CollectedVariableType;
import fr.insee.lunatic.model.flat.variable.CollectedVariableValues;
Expand Down Expand Up @@ -167,6 +168,9 @@ private Roundabout createRoundabout(RoundaboutSequence roundaboutSequence, Loop
ControlType lunaticControl = new ControlType();
lunaticMapper.mapEnoObject(enoControl, lunaticControl);
lunaticRoundabout.getControls().add(lunaticControl);
// Control expressions have to be inverted in Lunatic
lunaticControl.getControl().setValue(
VtlSyntaxUtils.invertBooleanExpression(lunaticControl.getControl().getValue()));
});
//
Roundabout.Item lunaticRoundaboutItem = new Roundabout.Item();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

class ControlTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ void ddiToLunatic() throws DDIParsingException {
roundabout = roundabouts.getFirst();
}

@Test
void lockedPropertyTest() {
assertFalse(roundabout.getLocked());
}

@Test
void controlsCount() {
assertEquals(2, roundabout.getControls().size());
Expand All @@ -221,7 +226,7 @@ void roundaboutControlTest() {
.toList();
assertEquals(1, roundaboutControls.size());
ControlType roundaboutControl = roundaboutControls.getFirst();
assertEquals("count(Q2) < 3", roundaboutControl.getControl().getValue());
assertEquals("not(count(Q2) < 3)", roundaboutControl.getControl().getValue());
assertEquals(LabelTypeEnum.VTL, roundaboutControl.getControl().getType());
assertEquals("\"There is less than 3 answers in the roundabout.\"",
roundaboutControl.getErrorMessage().getValue());
Expand All @@ -237,7 +242,7 @@ void occurrenceControlTest() {
.toList();
assertEquals(1, occurrenceControls.size());
ControlType occurrenceControl = occurrenceControls.getFirst();
assertEquals("Q2 = \"bar\"", occurrenceControl.getControl().getValue());
assertEquals("not(Q2 = \"bar\")", occurrenceControl.getControl().getValue());
assertEquals(LabelTypeEnum.VTL, occurrenceControl.getControl().getType());
assertEquals("\"Occurrence with question 1 = '\" || Q1 || \"' answered 'bar' at question 2.\"",
occurrenceControl.getErrorMessage().getValue().stripTrailing());
Expand Down

0 comments on commit f8c6809

Please sign in to comment.