Skip to content

Commit 0697dd6

Browse files
committed
Merge branch 'devNullVariables' of https://github.com/InseeFr/Genesis-API into devNullVariables
2 parents d5a7f35 + ba959a6 commit 0697dd6

25 files changed

Lines changed: 793 additions & 161 deletions

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
## 2.6.9 [2026-06-11]
3+
### Fixed
4+
- Delete only expired V2 schedules from dataProcessingContext
25
## 2.6.6 [2026-05-26]
36
### Fixed
47
- Compound index names

pom.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>fr.insee.genesis</groupId>
66
<artifactId>genesis-api</artifactId>
7-
<version>2.6.7</version>
7+
<version>2.6.9</version>
88
<packaging>jar</packaging>
99
<name>genesis-api</name>
1010

@@ -24,14 +24,14 @@
2424
<jackson-bom.version>2.21.1</jackson-bom.version>
2525

2626
<!-- Dependency versions not managed by Spring -->
27-
<bpm.version>1.1.4</bpm.version>
27+
<bpm.version>1.1.5</bpm.version>
2828
<springdoc.version>2.8.17</springdoc.version>
2929
<mapstruct.version>1.6.3</mapstruct.version>
30-
<pitest.version>1.25.1</pitest.version>
30+
<pitest.version>1.25.3</pitest.version>
3131
<pitest.junit.version>1.2.3</pitest.junit.version>
3232

3333
<!-- Sonar properties -->
34-
<jacoco.version>0.8.14</jacoco.version>
34+
<jacoco.version>0.8.15</jacoco.version>
3535
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
3636
<sonar.language>java</sonar.language>
3737
<sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
@@ -113,14 +113,14 @@
113113
<dependency>
114114
<groupId>net.sf.saxon</groupId>
115115
<artifactId>Saxon-HE</artifactId>
116-
<version>12.9</version>
116+
<version>13.0</version>
117117
</dependency>
118118

119119
<!-- JSON -->
120120
<dependency>
121121
<groupId>com.networknt</groupId>
122122
<artifactId>json-schema-validator</artifactId>
123-
<version>3.0.2</version>
123+
<version>3.0.3</version>
124124
</dependency>
125125

126126
<!-- generate implementation auto -->
@@ -164,7 +164,7 @@
164164
<plugin>
165165
<groupId>org.sonarsource.scanner.maven</groupId>
166166
<artifactId>sonar-maven-plugin</artifactId>
167-
<version>5.6.0.6792</version>
167+
<version>5.7.0.6970</version>
168168
</plugin>
169169
<plugin>
170170
<groupId>org.jacoco</groupId>

src/main/java/fr/insee/genesis/controller/adapter/LunaticXmlAdapter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ private static SurveyUnitModel getStateDataFromSurveyUnit(LunaticXmlSurveyUnit s
7272
.state(dataState)
7373
.mode(mode)
7474
.recordDate(Instant.now())
75-
.fileDate(su.getFileDate())
76-
.rawRecordDate(su.getFileDate())
75+
.rawRecordDate(su.getRawRecordDate())
7776
.build();
7877

7978
return getCollectedDataFromSurveyUnit(su, surveyUnitModel, variablesMap, dataState);

src/main/java/fr/insee/genesis/controller/rest/responses/ResponseController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import fr.insee.genesis.exceptions.ReviewDisabledException;
3535
import fr.insee.genesis.infrastructure.utils.FileUtils;
3636
import fr.insee.modelefiliere.RawResponseDto;
37+
import io.swagger.v3.oas.annotations.Hidden;
3738
import io.swagger.v3.oas.annotations.Operation;
3839
import io.swagger.v3.oas.annotations.Parameter;
3940
import io.swagger.v3.oas.annotations.media.Schema;
@@ -333,7 +334,7 @@ public ResponseEntity<SurveyUnitSimplifiedDto> getLatestByInterrogationOneObject
333334
@Operation(summary = "Returns the response with the latest variables for a collectionInstrument, mode and " +
334335
"interrogation")
335336
@GetMapping(path = "/{collectionInstrumentId}/{mode}/{interrogationId}")
336-
@PreAuthorize("hasRole('USER_KRAFTWERK')")
337+
@PreAuthorize("hasRole('ADMIN')")
337338
public ResponseEntity<SurveyUnitSimplifiedDto> getResponseByCollectionInstrumentAndInterrogation(
338339
@PathVariable("collectionInstrumentId") String collectionInstrumentId,
339340
@PathVariable("interrogationId") String interrogationId,
@@ -407,6 +408,7 @@ public ResponseEntity<List<SurveyUnitSimplifiedDto>> getLatestForInterrogationLi
407408
return ResponseEntity.ok(results);
408409
}
409410

411+
//Kraftwerk uses this
410412
@Operation(summary = "Retrieve responses for a collection instrument and a list of interrogations",
411413
description = "Return the latest state for each variable for the given interrogationIds and a given collection instrument (formerly questionnaire).<br>" +
412414
"For a given id, the endpoint returns a document by collection mode (if there is more than one)<br>" +
@@ -696,6 +698,7 @@ private static String getSuccessMessage(boolean isAnyDataSaved) {
696698
*/
697699
//TODO Unused for now, reuse code for optimizations, also move it to service
698700
@Deprecated
701+
@Hidden
699702
@Operation(summary = "Retrieve all responses for a questionnaire and a list of UE",
700703
description = "Return the latest state for each variable for the given ids and a given questionnaire.<br>" +
701704
"For a given id, the endpoint returns a document by collection mode (if there is more than one).")

src/main/java/fr/insee/genesis/controller/sources/xml/LunaticXmlDataParser.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private Document readXmlFile(Path filePath) throws IOException, SAXException, Ge
4747
return document;
4848
}
4949

50-
private LocalDateTime getFileDate(Path filePath) throws IOException {
50+
private LocalDateTime getRawRecordDate(Path filePath) throws IOException {
5151
BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class);
5252
return LocalDateTime.ofInstant(attr.lastModifiedTime().toInstant(), ZoneId.of("Europe/Paris"));
5353
}
@@ -68,9 +68,8 @@ public LunaticXmlCampaign parseDataFile(Path filePath) throws GenesisException,
6868
if (surveyUnit.getNodeType() == Node.ELEMENT_NODE) {
6969
Element surveyUnitElement = (Element) surveyUnit;
7070
LunaticXmlSurveyUnit lunaticXmlSurveyUnit = new LunaticXmlSurveyUnit();
71-
LocalDateTime rawRecordDate = getFileDate(filePath);
71+
LocalDateTime rawRecordDate = getRawRecordDate(filePath);
7272
lunaticXmlSurveyUnit.setRawRecordDate(rawRecordDate);
73-
lunaticXmlSurveyUnit.setFileDate(rawRecordDate);
7473
lunaticXmlSurveyUnit.setId(surveyUnitElement.getElementsByTagName("Id").item(0).getFirstChild().getNodeValue());
7574
lunaticXmlSurveyUnit.setQuestionnaireModelId(surveyUnitElement.getElementsByTagName("QuestionnaireModelId").item(0).getFirstChild().getNodeValue());
7675
Node data = surveyUnitElement.getElementsByTagName("Data").item(0);

src/main/java/fr/insee/genesis/controller/sources/xml/LunaticXmlDataSequentialParser.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class LunaticXmlDataSequentialParser{
2929

3030

3131
public LunaticXmlDataSequentialParser(final Path filePath, final InputStream stream) throws IOException, XMLStreamException {
32-
this.rawRecordDate = getFileDate(filePath);
32+
this.rawRecordDate = getRawRecordDate(filePath);
3333

3434
XMLInputFactory factory = XMLInputFactory.newInstance();
3535
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
@@ -90,7 +90,6 @@ public LunaticXmlSurveyUnit readNextSurveyUnit() throws XMLStreamException {
9090
*/
9191
private LunaticXmlSurveyUnit parseSurveyUnit(final XMLEventReader reader) throws XMLStreamException {
9292
LunaticXmlSurveyUnit xmlSurveyUnit = new LunaticXmlSurveyUnit();
93-
xmlSurveyUnit.setFileDate(this.rawRecordDate);
9493
xmlSurveyUnit.setRawRecordDate(this.rawRecordDate);
9594

9695
LunaticXmlData data = new LunaticXmlData();
@@ -276,7 +275,7 @@ private List<LunaticXmlOtherData> readCalculatedOrExternal(XMLEventReader reader
276275
return lunaticXmlOtherDataList;
277276
}
278277

279-
private LocalDateTime getFileDate(Path filePath) throws IOException {
278+
private LocalDateTime getRawRecordDate(Path filePath) throws IOException {
280279
BasicFileAttributes attr = Files.readAttributes(filePath, BasicFileAttributes.class);
281280
return LocalDateTime.ofInstant(attr.lastModifiedTime().toInstant(), ZoneId.of("Europe/Paris"));
282281
}

src/main/java/fr/insee/genesis/domain/converter/rawdata/LunaticJsonRawDataConverter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public List<SurveyUnitModel> convertRawDataAndCollectEmptyModels(
7373
.validationDate(payloadParser.getValidationDate(rawData))
7474
.isCapturedIndirectly(payloadParser.getIsCapturedIndirectly(rawData))
7575
.state(dataState)
76-
.fileDate(rawData.recordDate())
7776
.rawRecordDate(rawData.recordDate())
7877
.recordDate(Instant.now())
7978
.collectedVariables(new ArrayList<>())

src/main/java/fr/insee/genesis/domain/converter/rawdata/RawDataConverter.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import fr.insee.genesis.domain.utils.JsonUtils;
1313
import jakarta.validation.constraints.NotNull;
1414
import lombok.extern.slf4j.Slf4j;
15+
import org.jspecify.annotations.Nullable;
1516
import org.springframework.beans.factory.annotation.Autowired;
16-
import org.springframework.lang.Nullable;
1717
import org.springframework.stereotype.Component;
1818

1919
import java.math.BigDecimal;
@@ -268,10 +268,14 @@ protected void convertCollectedVariables(
268268
) {
269269
//Get data map from payload
270270
Map<String, Object> dataMap = dataOrPayloadMap;
271-
if (rawDataModelType == RawDataModelType.FILIERE) {
271+
if (rawDataModelType == RawDataModelType.FILIERE && dataOrPayloadMap.containsKey("data")) {
272272
dataMap = JsonUtils.asMap(dataOrPayloadMap.get("data"));
273273
}
274-
Map<String, Object> collectedMap = new HashMap<>(JsonUtils.asMap(dataMap.get("COLLECTED")));
274+
275+
Map<String, Object> collectedMap = new HashMap<>();
276+
if(dataMap.containsKey("COLLECTED")) {
277+
collectedMap = new HashMap<>(JsonUtils.asMap(dataMap.get("COLLECTED")));
278+
}
275279

276280
if(lastSurveyUnitModel != null && lastSurveyUnitModel.getState().equals(dataState)) {
277281
fillRawDataMapWithAbsentVariables(lastSurveyUnitModel, collectedMap, dataState);
@@ -491,18 +495,18 @@ protected void convertExternalVariables(
491495
) {
492496
//Get data map from payload if filiere model
493497
Map<String, Object> dataMap = dataOrPayloadMap;
494-
if (rawDataModelType == RawDataModelType.FILIERE) {
498+
if (rawDataModelType == RawDataModelType.FILIERE && dataOrPayloadMap.containsKey("data")) {
495499
dataMap = JsonUtils.asMap(dataOrPayloadMap.get("data"));
496500
}
497-
Map<String, Object> externalMap = null;
501+
Map<String, Object> externalMap = new HashMap<>();
498502
if(dataMap.containsKey("EXTERNAL")) {
499503
externalMap = new HashMap<>(JsonUtils.asMap(dataMap.get("EXTERNAL")));
500504
}
501505

502506
if(lastSurveyUnitModel != null){
503507
fillRawDataMapWithAbsentVariables(lastSurveyUnitModel, externalMap, null);
504508
}
505-
if(externalMap == null){
509+
if(externalMap.isEmpty()){
506510
return;
507511
}
508512

src/main/java/fr/insee/genesis/domain/converter/rawdata/RawResponseRawDataConverter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import fr.insee.genesis.domain.model.surveyunit.rawdata.RawResponseModel;
88
import fr.insee.genesis.domain.parser.rawdata.RawResponsePayloadParser;
99
import fr.insee.genesis.domain.ports.api.SurveyUnitApiPort;
10-
import fr.insee.genesis.domain.service.surveyunit.SurveyUnitService;
1110
import fr.insee.modelefiliere.RawResponseDto;
1211
import lombok.extern.slf4j.Slf4j;
1312
import org.springframework.stereotype.Component;
@@ -141,7 +140,7 @@ private SurveyUnitModel buildSurveyUnitModel(RawResponseModel rawResponseModel,
141140
.validationDate(rawResponsePayloadParser.getValidationDate(rawResponseModel))
142141
.isCapturedIndirectly(rawResponsePayloadParser.getIsCapturedIndirectly(rawResponseModel))
143142
.state(dataState)
144-
.fileDate(rawResponseModel.recordDate())
143+
.rawRecordDate(rawResponseModel.recordDate())
145144
.recordDate(Instant.now())
146145
.collectedVariables(new ArrayList<>())
147146
.externalVariables(new ArrayList<>())
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package fr.insee.genesis.domain.model.context.schedule;
2+
3+
import java.util.List;
4+
5+
public record DeletedExpiredSchedules(
6+
List<KraftwerkExecutionSchedule> v1Schedules,
7+
List<KraftwerkExecutionScheduleV2> v2Schedules
8+
) {
9+
public boolean isEmpty() {
10+
return v1Schedules.isEmpty() && v2Schedules.isEmpty();
11+
}
12+
}

0 commit comments

Comments
 (0)