Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/create-release.yaml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: régression modèle filière

Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
java-version: '25'

- name: install model filiere
run: mvn install:install-file -Dfile="$(pwd)/libs/modelefiliere-2.2.2-springboot4.jar" -DgroupId=fr.insee -DartifactId=modelefiliere -Dversion=2.2.2-springboot4 -Dpackaging=jar -DgeneratePom=true
run: mvn install:install-file -Dfile="$(pwd)/libs/modelefiliere-2.1.0.jar" -DgroupId=fr.insee -DartifactId=modelefiliere -Dversion=2.1.0 -Dpackaging=jar -DgeneratePom=true

- name: Clone BPM
uses: actions/checkout@v7
Expand Down Expand Up @@ -182,4 +182,4 @@ jobs:
password: ${{ secrets.DOCKERHUB_TOKEN }}
default_branch: ${{ github.ref }}
tags: ${{ needs.check-version.outputs.release-tag }}
workdir: .
workdir: .
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
java-version: "25"

- name: install model filiere
run: mvn install:install-file -Dfile="$(pwd)/libs/modelefiliere-2.2.2-springboot4.jar" -DgroupId=fr.insee -DartifactId=modelefiliere -Dversion=2.2.2-springboot4 -Dpackaging=jar -DgeneratePom=true
run: mvn install:install-file -Dfile="$(pwd)/libs/modelefiliere-2.1.0.jar" -DgroupId=fr.insee -DartifactId=modelefiliere -Dversion=2.1.0 -Dpackaging=jar -DgeneratePom=true

- name: Clone BPM
uses: actions/checkout@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
cache: maven

- name: install model filiere
run: mvn install:install-file -Dfile="$(pwd)/libs/modelefiliere-2.2.2-springboot4.jar" -DgroupId=fr.insee -DartifactId=modelefiliere -Dversion=2.2.2-springboot4 -Dpackaging=jar -DgeneratePom=true
run: mvn install:install-file -Dfile="$(pwd)/libs/modelefiliere-2.1.0.jar" -DgroupId=fr.insee -DartifactId=modelefiliere -Dversion=2.1.0 -Dpackaging=jar -DgeneratePom=true

- name: Clone BPM
uses: actions/checkout@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scheduled-version-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:

- name: install model filiere
run: |
mvn install:install-file -Dfile="$(pwd)/genesis/libs/modelefiliere-2.2.2-springboot4.jar" -DgroupId=fr.insee -DartifactId=modelefiliere -Dversion=2.2.2-springboot4 -Dpackaging=jar -DgeneratePom=true
mvn install:install-file -Dfile="$(pwd)/genesis/libs/modelefiliere-2.1.0.jar" -DgroupId=fr.insee -DartifactId=modelefiliere -Dversion=2.1.0 -Dpackaging=jar -DgeneratePom=true

- name: Clone BPM
uses: actions/checkout@master
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ src/bin/

# Package Files #
*.jar
!libs/*.jar
*.war
*.nar
*.ear
Expand Down
Binary file added libs/modelefiliere-2.1.0.jar
Binary file not shown.
Binary file removed libs/modelefiliere-2.2.2-springboot4.jar
Binary file not shown.
19 changes: 6 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@
<!-- (!!!) Dependency versions temporary overwritten for security reasons -->
<tomcat.version>10.1.55</tomcat.version>
<commons-lang3.version>3.20.0</commons-lang3.version>
<junit-jupiter.version>5.13.4</junit-jupiter.version>
<jackson-bom.version>2.21.1</jackson-bom.version>

<!-- Dependency versions not managed by Spring -->
<bpm.version>1.2.1</bpm.version>
<springdoc.version>3.0.3</springdoc.version>
<mapstruct.version>1.6.3</mapstruct.version>
<pitest.version>1.25.5</pitest.version>
<pitest.version>1.25.3</pitest.version>
<pitest.junit.version>1.2.3</pitest.junit.version>

<!-- Sonar properties -->
Expand Down Expand Up @@ -73,19 +75,10 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- AssertJ -->
<!-- https://www.baeldung.com/introduction-to-assertj -->
<!-- https://mvnrepository.com/artifact/org.assertj/assertj-core -->
Expand Down Expand Up @@ -113,7 +106,7 @@
<dependency>
<groupId>fr.insee</groupId>
<artifactId>modelefiliere</artifactId>
<version>2.2.2-springboot4</version>
<version>2.1.0</version>
</dependency>
<!-- XML libraries -->
<!-- XML-XSLT with Saxon -->
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/fr/insee/genesis/configuration/MongoConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fr.insee.genesis.configuration;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.MongoTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;

@Configuration
public class MongoConfig {

@Bean
@ConditionalOnMissingBean(PlatformTransactionManager.class)
MongoTransactionManager transactionManager(MongoDatabaseFactory dbFactory) {
return new MongoTransactionManager(dbFactory);
}

}
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package fr.insee.genesis.controller.dto;

import fr.insee.genesis.domain.model.surveyunit.Mode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class SurveyUnitInputDto {
private String questionnaireId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.insee.genesis.controller.rest;

import tools.jackson.core.JacksonException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.insee.genesis.domain.model.lunaticmodel.LunaticModelModel;
import fr.insee.genesis.domain.ports.api.LunaticModelApiPort;
import fr.insee.genesis.exceptions.GenesisException;
Expand All @@ -14,7 +15,6 @@
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import tools.jackson.databind.json.JsonMapper;

import java.util.Map;

Expand Down Expand Up @@ -45,12 +45,10 @@ public ResponseEntity<String> saveRawResponsesFromJsonBody(
@PreAuthorize("hasRole('READER')")
public ResponseEntity<String> getLunaticModelFromQuestionnaireId(
@RequestParam("questionnaireId") String questionnaireId
) throws JacksonException, GenesisException {
) throws JsonProcessingException, GenesisException {

LunaticModelModel lunaticModelModel = lunaticModelApiPort.get(questionnaireId);
JsonMapper objectMapper = JsonMapper.builder()
.findAndAddModules()
.build();
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
return ResponseEntity.ok(objectMapper.writeValueAsString(lunaticModelModel.lunaticModel()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private static void setValues(LunaticXmlCollectedData varData, Node value, List<
varData.setPrevious(valueTypes);
break;
default:
throw new GenesisException(HttpStatus.LOCKED, "Tag not recognized: " + valueElement.getTagName());
throw new GenesisException(HttpStatus.DESTINATION_LOCKED, "Tag not recognized: " + valueElement.getTagName());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.insee.genesis.controller.utils;

import tools.jackson.databind.node.StringNode;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.node.ArrayNode;
import tools.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.TextNode;
public class ExtendedJsonNormalizer {

public static final String $_DATE = "$date";
Expand All @@ -23,20 +23,18 @@ public static JsonNode normalize(JsonNode node) {
ObjectNode obj = (ObjectNode) node;

if (obj.size() == 1) {
if (obj.has($_DATE) && obj.get($_DATE).isString()) {
return StringNode.valueOf(obj.get($_DATE).asString());
if (obj.has($_DATE) && obj.get($_DATE).isTextual()) {
return TextNode.valueOf(obj.get($_DATE).asText());
}
// if (obj.has("$oid") && obj.get("$oid").isTextual()) {
// return TextNode.valueOf(obj.get("$oid").asText());
// }
}

ObjectNode copy = obj.objectNode();

obj.properties().forEach(e ->
obj.fields().forEachRemaining(e ->
copy.set(e.getKey(), normalize(e.getValue()))
);

return copy;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,16 @@ private static void convertListVar(
VariablesMap variablesMap,
List<VariableModel> destination
) {
if (!(valuesForState instanceof List<?> values)) {
throw new IllegalArgumentException("Object is not a List");
}

int iteration = 1;
for (Object rawValue : values) {
String value = rawValue == null ? null : getValueString(rawValue);
List<String> values = JsonUtils.asStringList(valuesForState);

if (value != null && !value.isEmpty()) {
convertOneVar(variableEntry, value, variablesMap, iteration, destination);
if (!values.isEmpty()) {
int iteration = 1;
for (String value : values) {
if (value != null && !value.isEmpty()) {
convertOneVar(variableEntry, value, variablesMap, iteration, destination);
}
iteration++;
}

iteration++;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fr.insee.genesis.domain.service.context;

import tools.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import fr.insee.genesis.Constants;
import fr.insee.genesis.controller.dto.KraftwerkExecutionScheduleInput;
import fr.insee.genesis.controller.dto.rawdata.ScheduleResponseDto;
Expand Down Expand Up @@ -282,9 +283,8 @@ public void deleteExpiredSchedules(String logFolder) throws GenesisException {
scheduleName + ".json"
);

JsonMapper objectMapper = JsonMapper.builder()
.findAndAddModules()
.build();
ObjectMapper objectMapper = new ObjectMapper().findAndRegisterModules();
objectMapper.registerModule(new JavaTimeModule());

String jsonToWrite = objectMapper.writeValueAsString(deletedSchedules);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package fr.insee.genesis.domain.service.contextualvariable.external;

import fr.insee.genesis.exceptions.JsonParsingException;
import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonParser;
import tools.jackson.core.json.JsonFactory;
import tools.jackson.core.JsonToken;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import fr.insee.genesis.domain.model.contextualvariable.ContextualExternalVariableModel;
import fr.insee.genesis.domain.ports.api.ContextualExternalVariableApiPort;
import fr.insee.genesis.domain.ports.spi.ContextualExternalVariablePersistancePort;
Expand Down Expand Up @@ -75,7 +74,7 @@ public boolean readContextualExternalFile(String collectionInstrumentId, String
contextualExternalVariablePersistancePort.deleteBackup(collectionInstrumentId);
return true;
}
}catch (JacksonException jpe){
}catch (JsonParseException jpe){
contextualExternalVariablePersistancePort.restoreBackup(collectionInstrumentId);
throw new GenesisException(HttpStatus.BAD_REQUEST, "JSON Parsing exception : %s".formatted(jpe.toString()));
}catch (IOException ioe){
Expand All @@ -91,7 +90,7 @@ public ContextualExternalVariableModel findByCollectionInstrumentIdAndInterrogat

private static boolean goToContextualExternalToken(JsonParser jsonParser) throws IOException {
while (jsonParser.nextToken() != null) {
if (jsonParser.currentToken() == JsonToken.PROPERTY_NAME
if (jsonParser.currentToken() == JsonToken.FIELD_NAME
&& "editedExternal".equals(jsonParser.currentName())) {
return true;
}
Expand Down Expand Up @@ -128,15 +127,15 @@ private ContextualExternalVariableModel readNextContextualExternal(JsonParser js
String collectionInstrumentId
) throws IOException {
if(jsonParser.currentToken() != JsonToken.START_OBJECT){
throw new JsonParsingException("Expected { on line %d, got token %s".formatted(jsonParser.currentLocation().getLineNr(), jsonParser.currentToken()));
throw new JsonParseException("Expected { on line %d, got token %s".formatted(jsonParser.currentLocation().getLineNr(), jsonParser.currentToken()));
}
ContextualExternalVariableModel contextualExternalVariableModel = ContextualExternalVariableModel.builder()
.collectionInstrumentId(collectionInstrumentId)
.variables(new HashMap<>())
.build();
jsonParser.nextToken();
while (!jsonParser.currentToken().equals(JsonToken.END_OBJECT)){
if(jsonParser.currentToken().equals(JsonToken.PROPERTY_NAME) && jsonParser.currentName().equals("interrogationId")){
if(jsonParser.currentToken().equals(JsonToken.FIELD_NAME) && jsonParser.currentName().equals("interrogationId")){
jsonParser.nextToken();
contextualExternalVariableModel.setInterrogationId(jsonParser.getText());
jsonParser.nextToken();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package fr.insee.genesis.domain.service.contextualvariable.previous;

import tools.jackson.core.JacksonException;
import tools.jackson.core.json.JsonFactory;
import fr.insee.genesis.exceptions.JsonParsingException;
import tools.jackson.core.JsonParser;
import tools.jackson.core.JsonToken;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import fr.insee.genesis.domain.model.contextualvariable.ContextualPreviousVariableModel;
import fr.insee.genesis.domain.ports.api.ContextualPreviousVariableApiPort;
import fr.insee.genesis.domain.ports.spi.ContextualPreviousVariablePersistancePort;
Expand Down Expand Up @@ -42,7 +41,7 @@ public boolean readContextualPreviousFile(String collectionInstrumentId,
try(FileInputStream inputStream = new FileInputStream(filePath)){
checkSourceStateLength(sourceState);

JsonFactory jsonFactory = JsonFactory.builder().build();
JsonFactory jsonFactory = new JsonFactory();
try (JsonParser jsonParser = jsonFactory.createParser(inputStream)) {
if (!goToEditedPreviousToken(jsonParser)) {
log.warn("No EditedPrevious part found in file {}", filePath);
Expand Down Expand Up @@ -80,7 +79,7 @@ public boolean readContextualPreviousFile(String collectionInstrumentId,
contextualPreviousVariablePersistancePort.deleteBackup(collectionInstrumentId);
return true;
}
}catch (JacksonException jpe){
}catch (JsonParseException jpe){
contextualPreviousVariablePersistancePort.restoreBackup(collectionInstrumentId);
throw new GenesisException(HttpStatus.BAD_REQUEST, "JSON Parsing exception : %s".formatted(jpe.toString()));
}catch (IOException _){
Expand Down Expand Up @@ -117,8 +116,8 @@ private static void checkSourceStateLength(String sourceState) throws GenesisExc

private boolean goToEditedPreviousToken(JsonParser jsonParser) throws IOException {
while (jsonParser.nextToken() != null) {
if (jsonParser.currentToken() == JsonToken.PROPERTY_NAME
&& "editedPrevious".equals(jsonParser.currentName())) {
if (jsonParser.currentToken() == JsonToken.FIELD_NAME
&& "editedPrevious".equals(jsonParser.getCurrentName())) {
return true;
}
}
Expand All @@ -130,7 +129,7 @@ private ContextualPreviousVariableModel readNextContextualPrevious(JsonParser js
String sourceState
) throws IOException {
if(jsonParser.currentToken() != JsonToken.START_OBJECT){
throw new JsonParsingException("Expected { on line %d, got token %s".formatted(jsonParser.currentLocation().getLineNr(), jsonParser.currentToken()));
throw new JsonParseException("Expected { on line %d, got token %s".formatted(jsonParser.currentLocation().getLineNr(), jsonParser.currentToken()));
}
ContextualPreviousVariableModel contextualPreviousVariableModel = ContextualPreviousVariableModel.builder()
.collectionInstrumentId(collectionInstrumentId)
Expand All @@ -139,7 +138,7 @@ private ContextualPreviousVariableModel readNextContextualPrevious(JsonParser js
.build();
jsonParser.nextToken();
while (!jsonParser.currentToken().equals(JsonToken.END_OBJECT)){
if(jsonParser.currentToken().equals(JsonToken.PROPERTY_NAME) && jsonParser.currentName().equals("interrogationId")){
if(jsonParser.currentToken().equals(JsonToken.FIELD_NAME) && jsonParser.currentName().equals("interrogationId")){
jsonParser.nextToken();
contextualPreviousVariableModel.setInterrogationId(jsonParser.getText());
jsonParser.nextToken();
Expand Down Expand Up @@ -175,7 +174,7 @@ private Object readValue(JsonParser jsonParser) throws IOException{
case START_ARRAY -> {
return readArray(jsonParser);
}
case null, default -> throw new JsonParsingException("Unexpected token %s on line %d".formatted(
case null, default -> throw new JsonParseException("Unexpected token %s on line %d".formatted(
jsonParser.currentToken(), jsonParser.currentLocation().getLineNr())
);
}
Expand Down
Loading
Loading