-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename services and extract volumetrics
- Loading branch information
Showing
4 changed files
with
446 additions
and
232 deletions.
There are no files selected for viewing
This file contains 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
34 changes: 31 additions & 3 deletions
34
src/main/java/fr/insee/genesis/controller/rest/UtilsController.java
This file contains 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 |
---|---|---|
@@ -1,28 +1,56 @@ | ||
package fr.insee.genesis.controller.rest; | ||
|
||
import fr.insee.genesis.domain.ports.api.SurveyUnitApiPort; | ||
import fr.insee.genesis.domain.service.volumetry.VolumetryLogService; | ||
import fr.insee.genesis.domain.utils.XMLSplitter; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
@RequestMapping(path = "/utils") | ||
import java.io.IOException; | ||
|
||
@RequestMapping(path = "/") | ||
@Controller | ||
@Slf4j | ||
@Tag(name = "Technical services") | ||
public class UtilsController { | ||
|
||
private final VolumetryLogService volumetryLogService; | ||
private final SurveyUnitApiPort surveyUnitService; | ||
|
||
|
||
@Autowired | ||
public UtilsController(SurveyUnitApiPort surveyUnitService,VolumetryLogService volumetryLogService) { | ||
this.surveyUnitService = surveyUnitService; | ||
this.volumetryLogService = volumetryLogService; | ||
|
||
} | ||
|
||
|
||
|
||
@Operation(summary = "Split a XML file into smaller ones") | ||
@PutMapping(path = "/split/lunatic-xml") | ||
@PutMapping(path = "/utils/split/lunatic-xml") | ||
public ResponseEntity<Object> saveResponsesFromXmlFile(@RequestParam("inputFolder") String inputFolder, | ||
@RequestParam("outputFolder") String outputFolder, | ||
@RequestParam("filename") String filename, | ||
@RequestParam("nbResponsesByFile") int nbSU) | ||
throws Exception { | ||
log.info("Split XML file : {} into {} SU by file", filename, nbSU); | ||
XMLSplitter.split(inputFolder, filename, outputFolder, "SurveyUnit", nbSU); | ||
return ResponseEntity.ok("Test"); | ||
return ResponseEntity.ok("File split"); | ||
} | ||
|
||
@Operation(summary = "Record volumetrics of each campaign in a folder") | ||
@PutMapping(path = "/volumetrics/save-all-campaigns") | ||
public ResponseEntity<Object> saveVolumetry() throws IOException { | ||
volumetryLogService.writeVolumetries(surveyUnitService); | ||
volumetryLogService.cleanOldFiles(); | ||
return ResponseEntity.ok("Volumetric saved"); | ||
} | ||
} |
Oops, something went wrong.