Skip to content

Commit

Permalink
chore: merge commit for release 3.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nsenave authored Dec 11, 2024
2 parents bbda349 + 1c7fde8 commit ef01275
Show file tree
Hide file tree
Showing 19 changed files with 238 additions and 96 deletions.
24 changes: 12 additions & 12 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: nsenave

---

## Describe the bug

A clear and concise description of what the bug is.
A clear and concise description of the bug.

- [ ] I tested it on the storybook, which leads me to believe that it's a lunatic bug.
Please indicate which formats are concerned:

- Input : Pogues / DDI (if you don't knwo, leave both)
- Output : Lunatic / Xforms / Paper / Specifications / All formats

## To Reproduce

Steps to reproduce the behavior:
Please provide a clear description of the case where the generation is wrong, including:

1. With the survey available here/uploaded in issue
2. Go to '...'
3. Click on '....'
4. See error ...
- Context: DEFAULT / HOUSEHOLD / BUSINESS
- Mode: CAPI / CATI / CAWI / PAPI

## Expected behavior
or a parameters file if the error occurs with specific parameters.

A clear and concise description of what you expected to happen.
If the case is not precisely identified, please provide a Pogues json questionnaire, or eventually a DDI.

## Screenshots
## Expected output

If applicable, add screenshots to help explain your problem.
A clear and concise description of what should be generated.

## Version where the bug appeared

Expand Down
7 changes: 0 additions & 7 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: nsenave

---

Expand All @@ -27,12 +26,6 @@ Have you considered any alternative solutions or workarounds? If yes, please des

Provide any additional information or context that might help in understanding the feature request.

## Priority

- [ ] Low
- [ ] Medium
- [ ] High

## Attachments

If applicable, include any mockups, diagrams, or additional files that help illustrate the feature.
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ jobs:
exit 1
fi
# if ! [[ "${{ steps.version-step.outputs.version }}" =~ ^[0-9]+.[0-9]+.[0-9]+(-hotfix\.\d+)?$ ]]; then
# echo "Nothing to tag/release, the tag ${{ steps.version-step.outputs.version }} is not in correct format X.Y.Z"
# exit 1
# fi
if ! [[ "${{ steps.version-step.outputs.version }}" =~ ^[0-9]+.[0-9]+.[0-9]+$ ]]; then
echo "Nothing to tag/release, the tag ${{ steps.version-step.outputs.version }} is not in correct format X.Y.Z"
exit 1
fi
sonar:
name: Sonar analysis
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:

- name: Get previous final release tag
id: previousTag
run: echo "previousTag=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | grep "^[3-9]\.[0-9]+\.[0-9]+(-hotfix\.\d+)?$" | tail -1)" >> $GITHUB_OUTPUT
run: echo "previousTag=$(git --no-pager tag --sort=creatordate --merged ${{ github.ref_name }} | grep "^[0-9]+.[0-9]+.[0-9]+$" | tail -1)" >> $GITHUB_OUTPUT
# Note: the regex works for single digit major version, to be updated if the version goes 10.0.0 or more

- name: Create tag
Expand Down
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.1"
version = "3.30.0"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,11 @@ private void computeHorizontalSizes(CodeItem codeItem) {
}
}

@Override
public String toString() {
return "CodeList[" +
"id='" + this.getId() + '\'' +
", name='" + name + '\'' +
']';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public abstract class Question extends EnoIdentifiableObject implements EnoCompo

@Override
public String toString() {
return this.getClass() + "[id="+this.getId()+", name="+getName()+"]";
return this.getClass().getSimpleName() + "[id="+this.getId()+", name="+getName()+"]";
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.insee.eno.core.processing.in.steps.ddi;

import fr.insee.eno.core.exceptions.business.IllegalDDIElementException;
import fr.insee.eno.core.model.EnoQuestionnaire;
import fr.insee.eno.core.model.code.CodeItem;
import fr.insee.eno.core.model.code.CodeList;
Expand Down Expand Up @@ -37,7 +38,14 @@ public void apply(EnoQuestionnaire enoQuestionnaire) {

private void insertModalityLabels(SimpleMultipleChoiceQuestion simpleMultipleChoiceQuestion) {
CodeList codeList = codeListMap.get(simpleMultipleChoiceQuestion.getCodeListReference());
for (int i = 0; i < codeList.size(); i ++) {
int codeListSize = codeList.size();
int responsesSize = simpleMultipleChoiceQuestion.getCodeResponses().size();
if (codeListSize != responsesSize)
throw new IllegalDDIElementException(String.format(
"Code list '%s' (id=%s) has %s codes, and is used in multiple choice question '%s' (id=%s) that has %s responses.",
codeList.getName(), codeList.getId(), codeListSize,
simpleMultipleChoiceQuestion.getName(), simpleMultipleChoiceQuestion.getId(), responsesSize));
for (int i = 0; i < codeListSize; i ++) {
CodeItem codeItem = codeList.getCodeItems().get(i);
CodeResponse codeResponse = simpleMultipleChoiceQuestion.getCodeResponses().get(i);
codeResponse.setLabel(codeItem.getLabel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fr.insee.eno.core.processing.ProcessingStep;
import fr.insee.lunatic.model.flat.*;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;
import java.math.RoundingMode;
Expand All @@ -14,6 +15,7 @@
* Processing adding format controls to components
* Format controls are controls generated by the min/max/decimals attributes of the Datepicker/InputNumber components
*/
@Slf4j
public class LunaticAddControlFormat implements ProcessingStep<Questionnaire> {
/**
*
Expand Down Expand Up @@ -114,21 +116,21 @@ private List<ControlType> getFormatControlsFromInputNumberAttributes(String id,
String maxValue = formatDoubleValue(max, decimalsCount);
String controlExpression = String.format("not(not(isnull(%s)) and (%s>%s or %s<%s))", responseName, minValue, responseName, maxValue, responseName);
String controlErrorMessage = String.format("\" La valeur doit être comprise entre %s et %s.\"", minValue, maxValue);
controls.add(0, createFormatControl(controlIdPrefix+"-borne-inf-sup", controlExpression, controlErrorMessage));
controls.addFirst(createFormatControl(controlIdPrefix+"-borne-inf-sup", controlExpression, controlErrorMessage));
}

if(min == null && max != null) {
String maxValue = formatDoubleValue(max, decimalsCount);
String controlExpression = String.format("not(not(isnull(%s)) and %s<%s)", responseName, maxValue, responseName);
String controlErrorMessage = String.format("\" La valeur doit être inférieure à %s.\"", maxValue);
controls.add(0, createFormatControl(controlIdPrefix+"-borne-sup", controlExpression, controlErrorMessage));
controls.addFirst(createFormatControl(controlIdPrefix+"-borne-sup", controlExpression, controlErrorMessage));
}

if(min != null && max == null) {
String minValue = formatDoubleValue(min, decimalsCount);
String controlExpression = String.format("not(not(isnull(%s)) and %s>%s)", responseName, minValue, responseName);
String controlErrorMessage = String.format("\" La valeur doit être supérieure à %s.\"", minValue);
controls.add(0, createFormatControl(controlIdPrefix+"-borne-inf", controlExpression, controlErrorMessage));
controls.addFirst(createFormatControl(controlIdPrefix+"-borne-inf", controlExpression, controlErrorMessage));
}

controls.add(createDecimalsFormatControl(controlIdPrefix, responseName, decimalsCount));
Expand All @@ -148,9 +150,12 @@ private void createFormatControlsForDatepicker(Datepicker datepicker) {

List<ControlType> controls = datepicker.getControls();

Optional<ControlType> control = getFormatControlFromDatepickerAttributes(id, minValue, maxValue, format, responseName);

control.ifPresent(controlType -> controls.add(0, controlType));
Optional<ControlType> controlYearFormat = generateDatepickerYearControl(id, format, responseName);
Optional<ControlType> controlBounds = getFormatControlFromDatepickerAttributes(id, minValue, maxValue, format, responseName);
controlBounds.ifPresent(controls::addFirst);
controlYearFormat.ifPresent(controls::addFirst);
// Note: it's important that the year format is added in first position, since in some cases only the message
// of the first control is displayed.
}

/**
Expand Down Expand Up @@ -188,6 +193,20 @@ private Optional<ControlType> getFormatControlFromDatepickerAttributes(String id
}
return Optional.empty();
}
private Optional<ControlType> generateDatepickerYearControl(String id, String format, String responseName) {
if (format == null || !format.contains("YYYY")) {
log.warn("Datepicker '{}' (id={}) format is {} which doesn't have the year (YYYY).",
responseName, id, format);
return Optional.empty();
}
String controlId = id + "-format-year";
String expression = String.format("not(not(isnull(%s)) and (" +
"cast(cast(cast(%s, date, \"%s\"), string, \"YYYY\"), integer) <= 999 or " +
"cast(cast(cast(%s, date, \"%s\"), string, \"YYYY\"), integer) > 9999))",
responseName, responseName, format, responseName, format);
String message = "\"L'année doit être saisie avec 4 chiffres.\"";
return Optional.of(createFormatControl(controlId, expression, message));
}

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,51 @@

import fr.insee.ddi.lifecycle33.instance.DDIInstanceDocument;
import fr.insee.eno.core.exceptions.business.DDIParsingException;
import fr.insee.eno.core.exceptions.business.IllegalDDIElementException;
import fr.insee.eno.core.mappers.DDIMapper;
import fr.insee.eno.core.model.EnoQuestionnaire;
import fr.insee.eno.core.model.code.CodeItem;
import fr.insee.eno.core.model.code.CodeList;
import fr.insee.eno.core.model.question.SimpleMultipleChoiceQuestion;
import fr.insee.eno.core.model.response.CodeResponse;
import fr.insee.eno.core.serialize.DDIDeserializer;
import org.junit.jupiter.api.Test;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;

class DDIInsertMultipleChoiceLabelsTest {

@Test
void failingCase_tooManyCodes() {
// Given
EnoQuestionnaire enoQuestionnaire = new EnoQuestionnaire();
//
CodeList codeList = new CodeList();
codeList.setId("code-list-id");
codeList.setName("CODE_LIST_NAME");
codeList.getCodeItems().add(new CodeItem());
codeList.getCodeItems().add(new CodeItem());
enoQuestionnaire.getCodeLists().add(codeList);
//
SimpleMultipleChoiceQuestion simpleMCQ = new SimpleMultipleChoiceQuestion();
simpleMCQ.setId("question-id");
simpleMCQ.setName("QUESTION_NAME");
simpleMCQ.setCodeListReference("code-list-id");
simpleMCQ.getCodeResponses().add(new CodeResponse());
enoQuestionnaire.getMultipleResponseQuestions().add(simpleMCQ);
// When + Then
DDIInsertMultipleChoiceLabels processing = new DDIInsertMultipleChoiceLabels();
assertThatThrownBy(() -> processing.apply(enoQuestionnaire))
.isInstanceOf(IllegalDDIElementException.class)
.hasMessageContaining("code-list-id")
.hasMessageContaining("CODE_LIST_NAME")
.hasMessageContaining("question-id")
.hasMessageContaining("QUESTION_NAME");
}

@Test
void integrationTest() throws DDIParsingException {
//
Expand Down
Loading

0 comments on commit ef01275

Please sign in to comment.