-
Notifications
You must be signed in to change notification settings - Fork 4
usualSurveyUnitId bug fix + json export modele filiere fix + unit tests fix for modele filiere #361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devModeleFiliere
Are you sure you want to change the base?
Changes from all commits
1f6e684
36dd2ab
26b5a2a
283e31d
c307047
99b44aa
9b0e690
d2af7ea
3fe8905
e1a5afb
332dc12
4d1e88b
5d902fa
41602ae
4023687
7cdeb02
78afbfe
10b45fb
fdae91f
111af1e
62e400a
c889181
b1efc20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <component name="ProjectRunConfigurationManager"> | ||
| <configuration default="false" name="Unit tests GENESIS" type="JUnit" factoryName="JUnit"> | ||
| <module name="genesis-api" /> | ||
| <option name="PACKAGE_NAME" value="fr.insee.genesis" /> | ||
| <option name="MAIN_CLASS_NAME" value="" /> | ||
| <option name="METHOD_NAME" value="" /> | ||
| <option name="TEST_OBJECT" value="directory" /> | ||
| <dir value="$PROJECT_DIR$/src/test/java/fr/insee/genesis" /> | ||
| <method v="2"> | ||
| <option name="Make" enabled="true" /> | ||
| </method> | ||
| </configuration> | ||
| </component> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| # Changelog | ||
| ## 2.0.0 [TODO] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that with all the breaking changes the major should get incremented |
||
| ### Changed | ||
| - Use filière model | ||
|
|
||
| ## 1.13.0 [2025-12-04] | ||
| ### Changed | ||
| - New raw data process endpoint | ||
|
|
||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Simple refactor to use the correct field |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Branch bug fix : we get the first non null usual survey unit id for interrogation |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hajar devs on filter result bug adaptation |
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seemed to not care about what we find in the database, I changed that, probably a merge conflit issue |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,17 +50,11 @@ public MetadataModel loadAndSaveIfNotExists(String campaignName, String collecti | |
| List<QuestionnaireMetadataModel> questionnaireMetadataModels = | ||
| questionnaireMetadataPersistencePort.find(collectionInstrumentId.toUpperCase(), mode); | ||
| if(questionnaireMetadataModels.isEmpty() || questionnaireMetadataModels.getFirst().metadataModel() == null){ | ||
| MetadataModel metadataModel = readMetadatas(campaignName, mode.getModeName(), fileUtils, errors); | ||
| MetadataModel metadataModel = readMetadatas(collectionInstrumentId, mode.getModeName(), fileUtils, errors); | ||
| saveMetadata(collectionInstrumentId.toUpperCase(), mode, metadataModel); | ||
| return metadataModel; | ||
| } | ||
|
|
||
| MetadataModel metadataModel = | ||
| readMetadatas(campaignName, mode.getModeName(), fileUtils, errors); | ||
|
|
||
| saveMetadata(questionnaireId.toUpperCase(), mode, metadataModel); | ||
|
|
||
| return metadataModel; | ||
| return questionnaireMetadataModels.getFirst().metadataModel(); | ||
| } | ||
|
|
||
| private void saveMetadata(String collectionInstrumentId, Mode mode, MetadataModel metadataModel) { | ||
|
|
@@ -87,11 +81,12 @@ private MetadataModel readMetadatas(String campaignName, String modeName, FileUt | |
| List<GenesisError> errors) throws GenesisException{ | ||
|
|
||
| Path ddiFilePath; | ||
| Path lunaticFilePath; | ||
| MetadataModel metadataModel = null; | ||
| try { | ||
| ddiFilePath = fileUtils.findFile(String.format("%s/%s", fileUtils.getSpecFolder(campaignName), modeName), DDI_FILE_PATTERN); | ||
| metadataModel = parseMetadata(ddiFilePath.toString(), true); | ||
|
|
||
| lunaticFilePath = fileUtils.findFile(String.format("%s/%s", fileUtils.getSpecFolder(campaignName), modeName), LUNATIC_FILE_PATTERN); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. filter_result bug fix adaptation |
||
| metadataModel = parseMetadata(lunaticFilePath, ddiFilePath); | ||
| } catch (RuntimeException e) { | ||
| //DDI file not found and already log - Go to next step | ||
| } catch (IOException e) { | ||
|
|
@@ -100,8 +95,8 @@ private MetadataModel readMetadatas(String campaignName, String modeName, FileUt | |
| if(metadataModel == null ){ | ||
| log.warn("DDI not found or error occurred. Trying Lunatic metadata...for {}, {} mode", campaignName, modeName); | ||
| try { | ||
| Path lunaticFilePath = fileUtils.findFile(String.format("%s/%s", fileUtils.getSpecFolder(campaignName), modeName), LUNATIC_FILE_PATTERN); | ||
| return parseMetadata(lunaticFilePath.toString(), false); | ||
| lunaticFilePath = fileUtils.findFile(String.format("%s/%s", fileUtils.getSpecFolder(campaignName), modeName), LUNATIC_FILE_PATTERN); | ||
| return parseMetadata(lunaticFilePath, null); | ||
| } catch (Exception ex) { | ||
| log.error("Error reading Lunatic metadata file", ex); | ||
| errors.add(new GenesisError(ex.toString())); | ||
|
|
@@ -116,32 +111,33 @@ private MetadataModel readMetadatas(String campaignName, String modeName, FileUt | |
| } | ||
|
|
||
| /** | ||
| * Parse metadata file, either DDI or Lunatic, depending on the withDDI flag. | ||
| * Parse metadata file | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to read lunatic after the filter_result bugfix, so I changed it to always need a lunatic file and the ddi if it's not null |
||
| * | ||
| * @param metadataFilePath path to the metadata file | ||
| * @param withDDI true for DDI parsing, false for Lunatic parsing | ||
| * @param lunaticFilePath path to the DDI metadata file | ||
| * @param ddiFilePath path to the DDI metadata file, will parse only lunatic if null | ||
| * @return VariablesMap or null if an error occurs | ||
| */ | ||
| private MetadataModel parseMetadata(String metadataFilePath, boolean withDDI) { | ||
| private MetadataModel parseMetadata(Path lunaticFilePath, Path ddiFilePath) { | ||
| try { | ||
| log.info("Try to read {} file: {}", withDDI ? "DDI" : "Lunatic", metadataFilePath); | ||
| if (withDDI) { | ||
| InputStream metadataInputStream = new FileInputStream(metadataFilePath); | ||
| log.info("Try to read {} file: {}", ddiFilePath != null ? "DDI" : "Lunatic", ddiFilePath); | ||
|
|
||
| if (ddiFilePath != null) { | ||
| InputStream metadataInputStream = new FileInputStream(ddiFilePath.toFile()); | ||
| InputStream lunaticInputStream = new FileInputStream(lunaticFilePath.toFile()); | ||
| MetadataModel metadataModel = ReaderUtils.getMetadataFromDDIAndLunatic( | ||
| Path.of(metadataFilePath).toFile().toURI().toURL().toString(), | ||
| metadataInputStream,metadataInputStream); | ||
| ddiFilePath.toFile().toURI().toURL().toString(), | ||
| metadataInputStream, | ||
| lunaticInputStream | ||
| ); | ||
| // Temporary solution | ||
| // the logic of adding variables from lunatic to the ones present in the DDI needs to be implemented in BPM | ||
| // (only in Kraftwerk for the moment) | ||
| for (String enoVar : Constants.getEnoVariables()){ | ||
| metadataModel.getVariables().putVariable(new Variable(enoVar, metadataModel.getRootGroup(), VariableType.STRING)); | ||
| } | ||
| return metadataModel; | ||
|
|
||
| } else { | ||
| return LunaticReader.getMetadataFromLunatic( | ||
| new FileInputStream(metadataFilePath)); | ||
| } | ||
| return LunaticReader.getMetadataFromLunatic(new FileInputStream(lunaticFilePath.toFile())); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed useless else { |
||
| } catch (MetadataParserException | IOException e) { | ||
| log.error("Error reading metadata file", e); | ||
| return null; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,7 +248,7 @@ public SurveyUnitDto findLatestValuesByStateByIdAndByCollectionInstrumentId( | |
| for (SurveyUnitModel surveyUnitModel : suByMode) { | ||
| if (variablesMap == null) { | ||
| variablesMap = metadataService.loadAndSaveIfNotExists( | ||
| surveyUnitModel.getCampaignId(), | ||
| surveyUnitModel.getCollectionInstrumentId(), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. campaignId is deprecated so we use collectionInstrumentId to look for specs
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After farid devs for modele filiere 2.1.0, campaignId won't be deprecated anymore |
||
| surveyUnitModel.getCollectionInstrumentId(), | ||
| surveyUnitModel.getMode(), | ||
| fileUtils, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -161,8 +161,10 @@ public List<SurveyUnitModel> findInterrogationIdsByCollectionInstrumentId(String | |
|
|
||
| @Override | ||
| public List<SurveyUnitModel> findInterrogationIdsByQuestionnaireIdAndDateAfter(String questionnaireId, LocalDateTime since) { | ||
| List<SurveyUnitDocument> surveyUnits = mongoRepository.findInterrogationIdsByQuestionnaireIdAndDateAfter(questionnaireId, since); | ||
| return surveyUnits.isEmpty() ? Collections.emptyList() : SurveyUnitDocumentMapper.INSTANCE.listDocumentToListModel(surveyUnits); | ||
| List<SurveyUnitDocument> results = new ArrayList<>(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's why the JSON extraction didn't work, it only searched with questionnaireId from old model, so now it will include collectionInstrumentId search |
||
| results.addAll(mongoRepository.findInterrogationIdsByQuestionnaireIdAndDateAfter(questionnaireId, since)); | ||
| results.addAll(mongoRepository.findInterrogationIdsByCollectionInstrumentIdAndDateAfter(questionnaireId, since)); | ||
| return results.isEmpty() ? Collections.emptyList() : SurveyUnitDocumentMapper.INSTANCE.listDocumentToListModel(results); | ||
| } | ||
|
|
||
| //========== OPTIMISATIONS PERFS (START) =========== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,8 @@ public interface SurveyUnitDocumentMapper { | |
| List<SurveyUnitDocument> listModelToListDocument(List<SurveyUnitModel> surveyUnitModels); | ||
|
|
||
| @AfterMapping | ||
| default void fillModelAfterRead(SurveyUnitDocument doc, | ||
| @SuppressWarnings("deprecation") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We handle deprecated fields, so we don't care of those warnings |
||
| default void handleDeprecatedFields(SurveyUnitDocument doc, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more explicit name |
||
| @MappingTarget SurveyUnitModel model) { | ||
|
|
||
| if (model.getUsualSurveyUnitId() == null) { | ||
|
|
@@ -34,5 +35,4 @@ default void fillModelAfterRead(SurveyUnitDocument doc, | |
| } | ||
|
|
||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,9 @@ public interface SurveyUnitMongoDBRepository extends MongoRepository<SurveyUnitD | |
| @Query(value = "{ 'questionnaireId' : ?0, 'recordDate': { $gte: ?1 } }", fields = "{ 'interrogationId' : 1, 'mode' : 1 }") | ||
| List<SurveyUnitDocument> findInterrogationIdsByQuestionnaireIdAndDateAfter(String questionnaireId, LocalDateTime since); | ||
|
|
||
| @Query(value = "{ 'collectionInstrumentId' : ?0, 'recordDate': { $gte: ?1 } }", fields = "{ 'interrogationId' : 1, 'mode' : 1 }") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for JSON extraction fix |
||
| List<SurveyUnitDocument> findInterrogationIdsByCollectionInstrumentIdAndDateAfter(String collectionInstrumentId, LocalDateTime since); | ||
|
|
||
| //========= OPTIMISATIONS PERFS (START) ========== | ||
| /** | ||
| * @author Adrien Marchal | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,7 +34,7 @@ Feature: Do we extract data ? | |
| Examples: | ||
| | CampaignId | QuestionnaireId | InterrogationId | ExpectedCollectedVariablesCount | ExpectedExternalVariablesCount | ExpectedVariableType | ExpectedVariableName | ExpectedValue | | ||
| | TEST-TABLEAUX | TEST-TABLEAUX | AUTO11000 | 49 | 4 | Integer | TABLEAUTIC21 | 5 | | ||
| | SAMPLETEST-PARADATA-v2 | quest_model_famille_AD_ttp | 0000007 | 96 | 17 | Boolean | AVIS_SUPPORT1 | true | | ||
| | SAMPLETEST-PARADATA-V2 | quest_model_famille_AD_ttp | 0000007 | 96 | 17 | Boolean | AVIS_SUPPORT1 | true | | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to adapt the cucumber test to make them work with the filière model (I failed miserabily), it became too costly so I moved the cucumber features into a folder where it won't launch with my tests shortcut |
||
|
|
||
| Scenario Outline: Multiple different Contexts for one partitionId | ||
| Given We have data in directory "<CampaignId>" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically a shortcut to run tests in intelliJ