-
Notifications
You must be signed in to change notification settings - Fork 4
Raw lunatic XML & JSON data saving into database #139
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4e56908
Add raw data saving
alexisszmundy a1da64d
Some refactors
alexisszmundy 9bf21f0
We don't use specs to save raw data
alexisszmundy a79d4d5
add id
alexisszmundy 3fc6231
Add lunatic json raw import
alexisszmundy 2965b52
Test fixes + refactors
alexisszmundy 1fbdcc5
Removed some useless autowired
alexisszmundy ed8f777
Revert "Removed some useless autowired"
alexisszmundy 83ee8b5
removed useless autowired in controllers
alexisszmundy 4a3ca92
removed unused imports
alexisszmundy 3928b9b
Fix reset method
alexisszmundy 9bdb6fa
Add processDate to xml raw data
alexisszmundy 93585c7
Fixed error 400 when invalid json request + add test
alexisszmundy 56a3c32
Merge branch 'main' into devRawDataSave
alexisszmundy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/main/java/fr/insee/genesis/domain/model/surveyunit/rawdata/LunaticJsonDataModel.java
alexisszmundy marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| package fr.insee.genesis.domain.model.surveyunit.rawdata; | ||
|
|
||
| import fr.insee.genesis.domain.model.surveyunit.Mode; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import org.bson.types.ObjectId; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| @Data | ||
| @Builder | ||
| public class LunaticJsonDataModel { | ||
| private ObjectId id; | ||
| private String campaignId; | ||
| private Mode mode; | ||
| private String dataJson; | ||
| private LocalDateTime recordDate; | ||
| private LocalDateTime processDate; | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/main/java/fr/insee/genesis/domain/model/surveyunit/rawdata/LunaticXmlDataModel.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package fr.insee.genesis.domain.model.surveyunit.rawdata; | ||
|
|
||
| import fr.insee.genesis.controller.sources.xml.LunaticXmlCampaign; | ||
| import fr.insee.genesis.domain.model.surveyunit.Mode; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import org.bson.types.ObjectId; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| @Data | ||
| @Builder | ||
| public class LunaticXmlDataModel{ | ||
| private ObjectId id; | ||
| private Mode mode; | ||
| private LunaticXmlCampaign data; | ||
| private LocalDateTime recordDate; | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/fr/insee/genesis/domain/ports/api/LunaticJsonRawDataApiPort.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package fr.insee.genesis.domain.ports.api; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import fr.insee.genesis.domain.model.surveyunit.Mode; | ||
|
|
||
| public interface LunaticJsonRawDataApiPort { | ||
| void saveData(String campaignName, String dataJson, Mode mode) throws JsonProcessingException; | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/fr/insee/genesis/domain/ports/api/LunaticXmlRawDataApiPort.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package fr.insee.genesis.domain.ports.api; | ||
|
|
||
| import fr.insee.genesis.controller.sources.xml.LunaticXmlCampaign; | ||
| import fr.insee.genesis.domain.model.surveyunit.Mode; | ||
|
|
||
| public interface LunaticXmlRawDataApiPort { | ||
| void saveData(LunaticXmlCampaign data, Mode mode); | ||
| } |
7 changes: 7 additions & 0 deletions
7
src/main/java/fr/insee/genesis/domain/ports/spi/LunaticJsonPersistancePort.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package fr.insee.genesis.domain.ports.spi; | ||
|
|
||
| import fr.insee.genesis.domain.model.surveyunit.rawdata.LunaticJsonDataModel; | ||
|
|
||
| public interface LunaticJsonPersistancePort { | ||
| void save(LunaticJsonDataModel lunaticJsonDataModel); | ||
| } |
9 changes: 9 additions & 0 deletions
9
src/main/java/fr/insee/genesis/domain/ports/spi/LunaticXmlPersistancePort.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package fr.insee.genesis.domain.ports.spi; | ||
|
|
||
| import fr.insee.genesis.domain.model.surveyunit.rawdata.LunaticXmlDataModel; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface LunaticXmlPersistancePort { | ||
| void save(LunaticXmlDataModel lunaticXmlDataModels); | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/fr/insee/genesis/domain/service/rawdata/LunaticJsonRawDataService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package fr.insee.genesis.domain.service.rawdata; | ||
|
|
||
| import fr.insee.genesis.domain.model.surveyunit.Mode; | ||
| import fr.insee.genesis.domain.model.surveyunit.rawdata.LunaticJsonDataModel; | ||
| import fr.insee.genesis.domain.ports.api.LunaticJsonRawDataApiPort; | ||
| import fr.insee.genesis.domain.ports.spi.LunaticJsonPersistancePort; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| @Service | ||
| public class LunaticJsonRawDataService implements LunaticJsonRawDataApiPort { | ||
| @Qualifier("lunaticJsonMongoAdapter") | ||
| private final LunaticJsonPersistancePort lunaticJsonPersistancePort; | ||
|
|
||
| @Autowired | ||
| public LunaticJsonRawDataService(LunaticJsonPersistancePort lunaticJsonPersistancePort) { | ||
| this.lunaticJsonPersistancePort = lunaticJsonPersistancePort; | ||
| } | ||
|
|
||
| @Override | ||
| public void saveData(String campaignName, String dataJson, Mode mode){ | ||
| LunaticJsonDataModel lunaticJsonDataModel = LunaticJsonDataModel.builder() | ||
| .campaignId(campaignName) | ||
| .mode(mode) | ||
| .dataJson(dataJson) | ||
| .recordDate(LocalDateTime.now()) | ||
| .build(); | ||
|
|
||
| lunaticJsonPersistancePort.save(lunaticJsonDataModel); | ||
| } | ||
| } |
34 changes: 34 additions & 0 deletions
34
src/main/java/fr/insee/genesis/domain/service/rawdata/LunaticXmlRawDataService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package fr.insee.genesis.domain.service.rawdata; | ||
|
|
||
| import fr.insee.genesis.controller.sources.xml.LunaticXmlCampaign; | ||
| import fr.insee.genesis.domain.model.surveyunit.Mode; | ||
| import fr.insee.genesis.domain.model.surveyunit.rawdata.LunaticXmlDataModel; | ||
| import fr.insee.genesis.domain.ports.api.LunaticXmlRawDataApiPort; | ||
| import fr.insee.genesis.domain.ports.spi.LunaticXmlPersistancePort; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.beans.factory.annotation.Qualifier; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| @Service | ||
| public class LunaticXmlRawDataService implements LunaticXmlRawDataApiPort { | ||
| @Qualifier("lunaticXmlMongoAdapter") | ||
| private final LunaticXmlPersistancePort lunaticXmlPersistancePort; | ||
|
|
||
| @Autowired | ||
| public LunaticXmlRawDataService(LunaticXmlPersistancePort lunaticXmlPersistancePort) { | ||
| this.lunaticXmlPersistancePort = lunaticXmlPersistancePort; | ||
| } | ||
|
|
||
| @Override | ||
| public void saveData(LunaticXmlCampaign campaign, Mode mode) { | ||
| LunaticXmlDataModel lunaticXmlDataModel = LunaticXmlDataModel.builder() | ||
| .mode(mode) | ||
| .data(campaign) | ||
| .recordDate(LocalDateTime.now()) | ||
| .build(); | ||
|
|
||
| lunaticXmlPersistancePort.save(lunaticXmlDataModel); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.