Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b263024
Add unprocessed raw data endpoint
alexisszmundy Dec 19, 2024
ff82ef8
Add data processing
alexisszmundy Dec 20, 2024
e44151b
Add variable type storage
alexisszmundy Dec 20, 2024
c07fdea
Add exception management + fix after mongo tests
alexisszmundy Dec 20, 2024
65517c9
Merge branch 'main' into devRawDataProcessing
alexisszmundy Dec 23, 2024
265347c
refactors
alexisszmundy Dec 30, 2024
7a57e42
Removed unused
alexisszmundy Jan 6, 2025
80f2fdf
Store variablesmap in variabletype collection
alexisszmundy Jan 6, 2025
f5e3dbe
Merge branch 'main' into devRawDataProcessing
alicela Jan 9, 2025
61ca83f
fix: remove unused
alicela Jan 9, 2025
275fd5b
Merge branch 'main' into devRawDataProcessing
alexisszmundy Jan 9, 2025
0cf7a1d
fix: cucumber definitions with vartype
alexisszmundy Jan 9, 2025
6d19845
Merge branch 'devRawDataProcessing' of https://github.com/InseeFr/Gen…
alicela Jan 10, 2025
70d916d
Fix for sonar
alicela Jan 20, 2025
f3fd06b
build: refactors
alexisszmundy Jan 21, 2025
96881e0
feat: Disabled save Metadata when processing due to mapping problem
alexisszmundy Jan 21, 2025
1651366
Merge branch 'main' into devRawDataProcessing
alexisszmundy Feb 5, 2025
7257f87
fix: use VariableModel not CollectedVariable
alexisszmundy Feb 5, 2025
aeecb7c
fix: After merge fixes
alexisszmundy Feb 5, 2025
7bb7385
Merge branch 'main' into devRawDataProcessing
alexisszmundy Feb 20, 2025
23bf782
feat: input JSON raw data structure check and adaptations to lunatic …
alexisszmundy Feb 21, 2025
c5def6f
test: add raw data processing functional test
alexisszmundy Feb 24, 2025
3bdac3e
feat: add data verification on raw data processing
alexisszmundy Feb 24, 2025
2457ae9
Merge branch 'main' into devRawDataProcessing
alexisszmundy Feb 24, 2025
9f59a18
refactor: added refactors from Init raw response controller
alexisszmundy Feb 28, 2025
b8e342d
Merge branch 'main' into devRawDataProcessing
alexisszmundy Feb 28, 2025
70a2d69
fix: GroupUtils instead of LoopIdentifier
alexisszmundy Feb 28, 2025
aa25fed
fix: Mockito not creating mock
alexisszmundy Feb 28, 2025
6a9c22b
chore: remove unused imports
alexisszmundy Feb 28, 2025
f9f5504
fix: error on parentId (group parent) name
loichenninger Mar 5, 2025
fd5dff3
fix: can't see endpoints in swagger
loichenninger Mar 7, 2025
bfca7b5
fix: empty values should be send too
loichenninger Mar 7, 2025
64b5172
test: on fix empty values should be return too
loichenninger Mar 7, 2025
1d76bb1
chore: renaming raw controller services
loichenninger Mar 14, 2025
12e61f8
fix: remove code used for testing
loichenninger Mar 14, 2025
4baf785
fix: change mapper to read raw data in db
loichenninger Mar 18, 2025
b095e4e
test: update to take into account the changes
loichenninger Mar 18, 2025
216340c
refactor: RawData model change
loichenninger Mar 19, 2025
6035763
build: WIP on process data corresponding tests are deactivated
loichenninger Mar 19, 2025
2f4d79e
feat: forgot to add recordDate when saving the data
loichenninger Mar 19, 2025
602e107
chore: response message with more details
loichenninger Mar 19, 2025
7f8db99
chore: unnecessary code
loichenninger Mar 19, 2025
6804728
fix: test for saving raw data
alicela Mar 20, 2025
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
31 changes: 31 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"

#Specify inspection profile for code analysis
profile:
name: qodana.starter

#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>

#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>

projectJDK: 21 #(Applied in CI/CD pipeline)

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh

#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm-community:latest
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public ResponseEntity<Object> saveResponsesFromXmlFile(@RequestParam("pathLunati
log.info(String.format("Try to read Xml file : %s", xmlFile));
Path filepath = Paths.get(xmlFile);

if (filepath.toFile().length() / 1024 / 1024 <= Constants.MAX_FILE_SIZE_UNTIL_SEQUENTIAL) {
if (getFileSizeInMB(filepath) <= Constants.MAX_FILE_SIZE_UNTIL_SEQUENTIAL) {
return processXmlFileWithMemory(filepath, modeSpecified, variablesMap);
}
return processXmlFileSequentially(filepath, modeSpecified, variablesMap);
Expand Down Expand Up @@ -461,12 +461,12 @@ private void processCampaignWithMode(String campaignName, Mode currentMode, List
*/
private void processCampaignWithMode(String campaignName, Mode mode, List<GenesisError> errors, String rootDataFolder, boolean withDDI)
throws IOException, ParserConfigurationException, SAXException, XMLStreamException, NoDataException {
log.info("Try to import data for mode : {}", mode.getModeName());
log.info("Starting data import for mode: {}", mode.getModeName());
String dataFolder = rootDataFolder == null ?
fileUtils.getDataFolder(campaignName, mode.getFolder(), null)
: fileUtils.getDataFolder(campaignName, mode.getFolder(), rootDataFolder);
List<String> dataFiles = fileUtils.listFiles(dataFolder);
log.info("Numbers of files to load in folder {} : {}", dataFolder, dataFiles.size());
log.info("Number of files to load in folder {} : {}", dataFolder, dataFiles.size());
if (dataFiles.isEmpty()) {
throw new NoDataException("No data file found in folder %s".formatted(dataFolder));
}
Expand All @@ -478,31 +478,38 @@ private void processCampaignWithMode(String campaignName, Mode mode, List<Genesi

//For each XML data file
for (String fileName : dataFiles.stream().filter(s -> s.endsWith(".xml")).toList()) {
String filepathString = String.format(S_S, dataFolder, fileName);
Path filepath = Paths.get(filepathString);
//Check if file not in done folder, delete if true
if(isDataFileInDoneFolder(filepath, campaignName, mode.getFolder())){
log.warn("File {} already exists in DONE folder ! Deleting...", fileName);
Files.deleteIfExists(filepath);
continue; //Go to next file
}
//Read file
log.info("Try to read Xml file : {}", fileName);
ResponseEntity<Object> response;
if (filepath.toFile().length() / 1024 / 1024 <= Constants.MAX_FILE_SIZE_UNTIL_SEQUENTIAL) {
response = processXmlFileWithMemory(filepath, mode, variablesMap);
} else {
response = processXmlFileSequentially(filepath, mode, variablesMap);
}
log.debug("File {} saved", fileName);
if (response.getStatusCode() == HttpStatus.OK) {
fileUtils.moveDataFile(campaignName, mode.getFolder(),
filepath);
//Sonar is annoying when there is more than 1 continue
} else {
log.error("Error {} on file {} : {}", response.getStatusCode(), fileName, response.getBody());
}
processOneXmlFileForCampaign(campaignName, mode, fileName, dataFolder, variablesMap);
}
}

private void processOneXmlFileForCampaign(String campaignName, Mode mode, String fileName, String dataFolder, VariablesMap variablesMap) throws IOException, ParserConfigurationException, SAXException, XMLStreamException {
String filepathString = String.format(S_S, dataFolder, fileName);
Path filepath = Paths.get(filepathString);
//Check if file not in done folder, delete if true
if(isDataFileInDoneFolder(filepath, campaignName, mode.getFolder())){
log.warn("File {} already exists in DONE folder ! Deleting...", fileName);
Files.deleteIfExists(filepath);
return;
}
//Read file
log.info("Try to read Xml file : {}", fileName);
ResponseEntity<Object> response;
if (getFileSizeInMB(filepath) <= Constants.MAX_FILE_SIZE_UNTIL_SEQUENTIAL) {
response = processXmlFileWithMemory(filepath, mode, variablesMap);
} else {
response = processXmlFileSequentially(filepath, mode, variablesMap);
}
log.debug("File {} saved", fileName);
if (response.getStatusCode() == HttpStatus.OK) {
fileUtils.moveDataFile(campaignName, mode.getFolder(),filepath);
return;
}
log.error("Error {} on file {} : {}", response.getStatusCode(), fileName, response.getBody());

}

private static long getFileSizeInMB(Path filepath) {
return filepath.toFile().length() / 1024 / 1024;
}

private void processRawCampaignWithMode(String campaignName,
Expand Down Expand Up @@ -623,7 +630,7 @@ private ResponseEntity<Object> processRawXmlFile(Path filepath, Mode modeSpecifi
private ResponseEntity<Object> processXmlFileSequentially(Path filepath, Mode modeSpecified, VariablesMap variablesMap) throws IOException, XMLStreamException {
LunaticXmlCampaign campaign;
//Sequential method
log.warn("File size > " + Constants.MAX_FILE_SIZE_UNTIL_SEQUENTIAL + "MB! Parsing XML file using sequential method...");
log.warn("File size > {} MB! Parsing XML file using sequential method...", Constants.MAX_FILE_SIZE_UNTIL_SEQUENTIAL);
try (final InputStream stream = new FileInputStream(filepath.toFile())) {
LunaticXmlDataSequentialParser parser = new LunaticXmlDataSequentialParser(filepath, stream);
int suCount = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ spring.profiles.active=local
#--------------------------------------------------------------------------
# Global configuration
#--------------------------------------------------------------------------
fr.insee.genesis.authentication = OIDC
fr.insee.genesis.authentication = none
#OIDC

#--------------------------------------------------------------------------
# Configuration for springdoc / swagger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.http.ResponseEntity;

import java.time.LocalDateTime;
import java.time.Month;
import java.util.ArrayList;
import java.util.List;

class SurveyUnitServiceTest {




//Given
static SurveyUnitService surveyUnitServiceStatic;
Expand Down
Loading