diff --git a/src/main/java/org/mifos/processor/bulk/camel/config/CamelProperties.java b/src/main/java/org/mifos/processor/bulk/camel/config/CamelProperties.java index 0f3ffb1e..665af581 100644 --- a/src/main/java/org/mifos/processor/bulk/camel/config/CamelProperties.java +++ b/src/main/java/org/mifos/processor/bulk/camel/config/CamelProperties.java @@ -7,4 +7,8 @@ private CamelProperties() {} public static final String AUTH_TYPE = "authType"; public static final String IS_BATCH_READY = "isBatchReady"; // camel property to check if batch is ready for sampling + public static final String SERVER_FILE_NAME = "serverFileNam"; + + public static final String LOCAL_FILE_PATH = "localFilePath"; + } diff --git a/src/main/java/org/mifos/processor/bulk/camel/routes/FileDownloadingRoute.java b/src/main/java/org/mifos/processor/bulk/camel/routes/FileDownloadingRoute.java new file mode 100644 index 00000000..353545ad --- /dev/null +++ b/src/main/java/org/mifos/processor/bulk/camel/routes/FileDownloadingRoute.java @@ -0,0 +1,41 @@ +package org.mifos.processor.bulk.camel.routes; + +import org.mifos.processor.bulk.file.FileTransferService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.io.FileOutputStream; + +import static org.mifos.processor.bulk.camel.config.CamelProperties.LOCAL_FILE_PATH; +import static org.mifos.processor.bulk.camel.config.CamelProperties.SERVER_FILE_NAME; + +@Component +public class FileDownloadingRoute extends BaseRouteBuilder{ + + @Autowired + @Qualifier("awsStorage") + private FileTransferService fileTransferService; + + @Value("${application.bucket-name}") + private String bucketName; + + @Override + public void configure() throws Exception { + from("direct:download-file") + .id("download-file") + .log("Started download-file route") + .process(exchange -> { + String filename = exchange.getProperty(SERVER_FILE_NAME, String.class); + + byte[] csvFile = fileTransferService.downloadFile(filename, bucketName); + File file = new File(filename); + try (FileOutputStream fos = new FileOutputStream(file)) { + fos.write(csvFile); + } + exchange.setProperty(LOCAL_FILE_PATH, file.getAbsolutePath()); + }); + } +} diff --git a/src/main/java/org/mifos/processor/bulk/zeebe/worker/WorkerConfig.java b/src/main/java/org/mifos/processor/bulk/zeebe/worker/WorkerConfig.java index 1c0235fb..0eab8ecd 100644 --- a/src/main/java/org/mifos/processor/bulk/zeebe/worker/WorkerConfig.java +++ b/src/main/java/org/mifos/processor/bulk/zeebe/worker/WorkerConfig.java @@ -6,22 +6,22 @@ @Component public class WorkerConfig { - @Value("${config.partylookup}") + @Value("${config.partylookup.enable}") public boolean isPartyLookUpWorkerEnabled; - @Value("${config.approval}") + @Value("${config.approval.enable}") public boolean isApprovalWorkerEnabled; - @Value("${config.ordering}") + @Value("${config.ordering.enable}") public boolean isOrderingWorkerEnabled; - @Value("${config.splitting}") + @Value("${config.splitting.enable}") public boolean isSplittingWorkerEnabled; - @Value("${config.formatting}") + @Value("${config.formatting.enable}") public boolean isFormattingWorkerEnabled; - @Value("${config.mergeback}") + @Value("${config.mergeback.enable}") public boolean isMergeBackWorkerEnabled; diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 2f7be99c..3a9bd630 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -59,10 +59,18 @@ bpmn: config: minimum-successful-tx-ratio: 0.90 - partylookup: false - approval: false - ordering: true - splitting: false - formatting: true - mergeback: false - backpressure: false + partylookup: + enable: false + approval: + enable: false + ordering: + enable: true + splitting: + enable: false + batch-size: 10 + formatting: + enable: true + mergeback: + enable: false + backpressure: + enable: false