Skip to content

Commit

Permalink
Merge pull request #90 from InseeFr/devMetadataParserLibIntegration
Browse files Browse the repository at this point in the history
 Use BPM to parse metadatas
  • Loading branch information
alexisszmundy authored Aug 21, 2024
2 parents ad70960 + ecc2a50 commit b07798e
Show file tree
Hide file tree
Showing 21 changed files with 124 additions and 1,306 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,27 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven

- name: Clone BPM
uses: actions/checkout@master
with:
repository: InseeFr/BPM
path: bpm

- name: Build BPM
run: |
cd bpm
mvn clean install
cd ..
- name: Build Genesis with Maven
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
Expand Down
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>

<!-- METADATA PARSER -->
<dependency>
<groupId>fr.insee.bpm</groupId>
<artifactId>bpm</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package fr.insee.genesis.controller.adapter;

import fr.insee.genesis.controller.sources.ddi.VariablesMap;
import fr.insee.genesis.controller.sources.xml.LunaticXmlCollectedData;
import fr.insee.genesis.controller.sources.xml.LunaticXmlSurveyUnit;
import fr.insee.genesis.controller.sources.xml.ValueType;
import fr.insee.genesis.controller.utils.LoopIdentifier;
import fr.insee.genesis.domain.dtos.*;

import fr.insee.genesis.domain.dtos.CollectedVariableDto;
import fr.insee.genesis.domain.dtos.DataState;
import fr.insee.genesis.domain.dtos.Mode;
import fr.insee.genesis.domain.dtos.SurveyUnitUpdateDto;
import fr.insee.genesis.domain.dtos.VariableDto;
import fr.insee.bpm.metadata.model.VariablesMap;
import lombok.experimental.UtilityClass;

import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import fr.insee.genesis.controller.responses.SurveyUnitUpdateSimplified;
import fr.insee.genesis.controller.service.SurveyUnitQualityService;
import fr.insee.genesis.controller.service.VolumetryLogService;
import fr.insee.genesis.controller.sources.ddi.DDIReader;
import fr.insee.genesis.controller.sources.ddi.VariablesMap;
import fr.insee.genesis.controller.sources.xml.LunaticXmlCampaign;
import fr.insee.genesis.controller.sources.xml.LunaticXmlDataParser;
import fr.insee.genesis.controller.sources.xml.LunaticXmlDataSequentialParser;
Expand All @@ -25,11 +23,16 @@
import fr.insee.genesis.exceptions.GenesisException;
import fr.insee.genesis.exceptions.NoDataError;
import fr.insee.genesis.infrastructure.utils.FileUtils;

import fr.insee.bpm.exceptions.MetadataParserException;
import fr.insee.bpm.metadata.model.VariablesMap;
import fr.insee.bpm.metadata.reader.ddi.DDIReader;

import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand Down Expand Up @@ -87,9 +90,11 @@ public ResponseEntity<Object> saveResponsesFromXmlFile(@RequestParam("pathLunati
Path ddiFilePath = Paths.get(ddiFile);
VariablesMap variablesMap;
try {
variablesMap = DDIReader.getVariablesFromDDI(ddiFilePath.toFile().toURI().toURL());
} catch (GenesisException e) {
return ResponseEntity.status(e.getStatus()).body(e.getMessage());
variablesMap =
DDIReader.getMetadataFromDDI(ddiFilePath.toFile().toURI().toURL().toString(),
new FileInputStream(ddiFilePath.toFile())).getVariables();
} catch (MetadataParserException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
}

log.info(String.format("Try to read Xml file : %s", xmlFile));
Expand Down Expand Up @@ -340,7 +345,8 @@ private void treatCampaignWithMode(String campaignName, Mode mode, List<GenesisE
VariablesMap variablesMap;
try {
Path ddiFilePath = fileUtils.findDDIFile(campaignName, mode.getModeName());
variablesMap = DDIReader.getVariablesFromDDI(ddiFilePath.toUri().toURL());
variablesMap = DDIReader.getMetadataFromDDI(ddiFilePath.toUri().toURL().toString(),
new FileInputStream(ddiFilePath.toFile())).getVariables();
} catch (Exception e) {
log.error(e.toString());
errors.add(new GenesisError(e.toString()));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.insee.genesis.controller.service;

import fr.insee.genesis.controller.sources.ddi.VariablesMap;
import fr.insee.genesis.controller.utils.DataVerifier;
import fr.insee.genesis.domain.dtos.SurveyUnitUpdateDto;
import fr.insee.bpm.metadata.model.VariablesMap;
import org.springframework.stereotype.Service;

import java.util.List;
Expand Down
210 changes: 0 additions & 210 deletions src/main/java/fr/insee/genesis/controller/sources/ddi/DDIReader.java

This file was deleted.

44 changes: 0 additions & 44 deletions src/main/java/fr/insee/genesis/controller/sources/ddi/Group.java

This file was deleted.

Loading

0 comments on commit b07798e

Please sign in to comment.