Skip to content

Commit

Permalink
fli-iam#2488 : better sorting + path naming update
Browse files Browse the repository at this point in the history
  • Loading branch information
DuckflipXYZ committed Dec 9, 2024
1 parent 0095849 commit a79c0e8
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void massiveDownload(List<DatasetProcessing> processingList, boolean resu

private void manageProcessingsDownload(List<DatasetProcessing> processingList, Map<Long, DatasetDownloadError> downloadResults, ZipOutputStream zipOutputStream, String format, boolean withManifest, Map<Long, List<String>> filesByAcquisitionId, Long converterId) throws RestServiceException, IOException {
for (DatasetProcessing processing : processingList) {
String processingFilePath = getExecFilepath(processing.getId(), getExaminationDatas(processing.getInputDatasets()));
String processingFilePath = getExecFilepath(processing, getExaminationDatas(processing.getInputDatasets()));
String subjectName = getProcessingSubject(processing);
for (Dataset dataset : processing.getInputDatasets()) {
manageDatasetDownload(dataset, downloadResults, zipOutputStream, subjectName, processingFilePath + "/" + shapeForPath(dataset.getName()), format, withManifest, filesByAcquisitionId, converterId);
Expand Down Expand Up @@ -141,17 +141,27 @@ private Pair<Long, String> getExaminationDatas(List<Dataset> inputs) {
return new Pair<>(0L, "");
}

private String getExecFilepath(Long processingId, Pair<Long, String> examDatas) {
private String getExecFilepath(DatasetProcessing processing, Pair<Long, String> examDatas) {
String execFilePath = "";
if(Objects.equals(processing.getComment(), "comete_moelle/0.1")){
if(!processing.getOutputDatasets().stream().filter(it -> Objects.equals(it.getName(), "results.yaml")).toList().isEmpty()) {
execFilePath = "result/";
} else if(!processing.getOutputDatasets().stream().filter(it -> Objects.equals(it.getName(), "error.yaml")).toList().isEmpty()) {
execFilePath = "error/";
} else {
execFilePath = "unknown";
}

String execFilePath = "processing_" + processingId + "_exam_" + examDatas.first();
if (!Objects.equals(examDatas.second(), "")) {
}
execFilePath += "processing_" + processing.getId() + "_exam_" + examDatas.first();
if (Objects.nonNull(examDatas.second()) && !Objects.equals(examDatas.second(), "")) {
execFilePath += "_" + examDatas.second();
}
return shapeForPath(execFilePath);
}

private String shapeForPath(String path){
path = path.replaceAll("[^a-zA-Z0-9_\\-]", "_");
path = path.replaceAll("[^a-zA-Z0-9_]", "_").replaceAll("_+$", "").replaceAll("_+", "_");
if (path.length() > 255) {
path = path.substring(0, 254);
}
Expand Down

0 comments on commit a79c0e8

Please sign in to comment.