Skip to content

Commit

Permalink
Update MainService.java
Browse files Browse the repository at this point in the history
  • Loading branch information
alexisszmundy committed Nov 12, 2024
1 parent 31e7117 commit a30a3c8
Showing 1 changed file with 26 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,7 @@ public ResponseEntity<String> mainService(
) {
boolean fileByFile = false;
boolean withDDI = true;
FileUtilsInterface fileUtilsInterface = getFileUtilsInterface();

MainProcessing mp = new MainProcessing(inDirectoryParam, fileByFile,withAllReportingData,withDDI, defaultDirectory, limitSize, fileUtilsInterface);
try {
mp.runMain();
} catch (KraftwerkException e) {
return ResponseEntity.status(e.getStatus()).body(e.getMessage());
}

/* Step 4.3- 4.4 : Archive */
if (Boolean.TRUE.equals(archiveAtEnd)) archive(inDirectoryParam,fileUtilsInterface);

return ResponseEntity.ok(inDirectoryParam);
return runWithoutGenesis(inDirectoryParam, archiveAtEnd, fileByFile, withAllReportingData, withDDI);
}

@PutMapping(value = "/main/file-by-file")
Expand All @@ -84,18 +72,7 @@ public ResponseEntity<String> mainFileByFile(
boolean fileByFile = true;
boolean withAllReportingData = false;
boolean withDDI = true;
FileUtilsInterface fileUtilsInterface = getFileUtilsInterface();

MainProcessing mp = new MainProcessing(inDirectoryParam, fileByFile,withAllReportingData,withDDI, defaultDirectory, limitSize, fileUtilsInterface);
try {
mp.runMain();
} catch (KraftwerkException e) {
return ResponseEntity.status(e.getStatus()).body(e.getMessage());
}
/* Step 4.3- 4.4 : Archive */
if (Boolean.TRUE.equals(archiveAtEnd)) archive(inDirectoryParam, fileUtilsInterface);

return ResponseEntity.ok(inDirectoryParam);
return runWithoutGenesis(inDirectoryParam, archiveAtEnd, fileByFile, withAllReportingData, withDDI);
}

@PutMapping(value = "/main/lunatic-only")
Expand All @@ -107,36 +84,15 @@ public ResponseEntity<String> mainLunaticOnly(
boolean withDDI = false;
boolean fileByFile = false;
boolean withAllReportingData = false;
FileUtilsInterface fileUtilsInterface = getFileUtilsInterface();

MainProcessing mp = new MainProcessing(inDirectoryParam, fileByFile,withAllReportingData,withDDI, defaultDirectory, limitSize, fileUtilsInterface);
try {
mp.runMain();
} catch (KraftwerkException e) {
return ResponseEntity.status(e.getStatus()).body(e.getMessage());
}
/* Step 4.3- 4.4 : Archive */
if (Boolean.TRUE.equals(archiveAtEnd)) archive(inDirectoryParam, fileUtilsInterface);

return ResponseEntity.ok(inDirectoryParam);
return runWithoutGenesis(inDirectoryParam, archiveAtEnd, fileByFile, withAllReportingData, withDDI);
}

@PutMapping(value = "/main/genesis")
@Operation(operationId = "mainGenesis", summary = "${summary.mainGenesis}", description = "${description.mainGenesis}")
public ResponseEntity<String> mainGenesis(
@Parameter(description = "${param.idCampaign}", required = true, example = INDIRECTORY_EXAMPLE) @RequestBody String idCampaign) {
FileUtilsInterface fileUtilsInterface = getFileUtilsInterface();

MainProcessingGenesis mpGenesis = new MainProcessingGenesis(configProperties, fileUtilsInterface);

try {
mpGenesis.runMain(idCampaign);
} catch (KraftwerkException e) {
return ResponseEntity.status(e.getStatus()).body(e.getMessage());
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
}
return ResponseEntity.ok(idCampaign);
boolean withDDI = true;
return runWithGenesis(idCampaign, withDDI);
}


Expand All @@ -145,6 +101,27 @@ public ResponseEntity<String> mainGenesis(
public ResponseEntity<String> mainGenesisLunaticOnly(
@Parameter(description = "${param.idCampaign}", required = true, example = INDIRECTORY_EXAMPLE) @RequestBody String idCampaign) {
boolean withDDI = false;
return runWithGenesis(idCampaign, withDDI);
}

@NotNull
private ResponseEntity<String> runWithoutGenesis(String inDirectoryParam, boolean archiveAtEnd, boolean fileByFile, boolean withAllReportingData, boolean withDDI) {
FileUtilsInterface fileUtilsInterface = getFileUtilsInterface();

MainProcessing mp = new MainProcessing(inDirectoryParam, fileByFile, withAllReportingData, withDDI, defaultDirectory, limitSize, fileUtilsInterface);
try {
mp.runMain();
} catch (KraftwerkException e) {
return ResponseEntity.status(e.getStatus()).body(e.getMessage());
}
/* Step 4.3- 4.4 : Archive */
if (Boolean.TRUE.equals(archiveAtEnd)) archive(inDirectoryParam, fileUtilsInterface);

return ResponseEntity.ok(inDirectoryParam);
}

@NotNull
private ResponseEntity<String> runWithGenesis(String idCampaign, boolean withDDI) {
FileUtilsInterface fileUtilsInterface = getFileUtilsInterface();

MainProcessingGenesis mpGenesis = new MainProcessingGenesis(configProperties, fileUtilsInterface, withDDI);
Expand All @@ -168,5 +145,4 @@ public ResponseEntity<String> mainGenesisLunaticOnly(
}
return fileUtilsInterface;
}

}

0 comments on commit a30a3c8

Please sign in to comment.