-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #363 from pagopa/develop
feat: [RTD-1983] update spring boot 3 (#362)
- Loading branch information
Showing
59 changed files
with
856 additions
and
795 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
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
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
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 |
---|---|---|
|
@@ -139,6 +139,7 @@ then | |
exit 2 | ||
fi | ||
|
||
exit 0 | ||
|
||
rm -rf cstar-cli | ||
rm -rf workdir | ||
|
||
exit 0 |
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 |
---|---|---|
|
@@ -51,4 +51,7 @@ else | |
exit 2 | ||
fi | ||
|
||
rm -rf cstar-cli | ||
rm -rf workdir | ||
|
||
exit 0 |
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
87 changes: 87 additions & 0 deletions
87
api/batch/src/main/java/it/gov/pagopa/rtd/transaction_filter/batch/BatchExecutor.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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package it.gov.pagopa.rtd.transaction_filter.batch; | ||
|
||
|
||
import it.gov.pagopa.rtd.transaction_filter.batch.step.PanReaderStep; | ||
import it.gov.pagopa.rtd.transaction_filter.batch.step.TransactionFilterStep; | ||
import it.gov.pagopa.rtd.transaction_filter.service.StoreService; | ||
import java.util.Date; | ||
import lombok.Data; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.SneakyThrows; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.JobExecution; | ||
import org.springframework.batch.core.JobParametersBuilder; | ||
import org.springframework.batch.core.launch.JobLauncher; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Component | ||
@Data | ||
public class BatchExecutor { | ||
|
||
private final Job job; | ||
private final JobLauncher jobLauncher; | ||
private final TransactionFilterStep transactionFilterStep; | ||
private final PanReaderStep panReaderStep; | ||
private final StoreService storeService; | ||
@Value("${batchConfiguration.TransactionFilterBatch.hpanListRecovery.enabled}") | ||
private Boolean hpanListRecoveryEnabled; | ||
private final PathMatchingResourcePatternResolver resolver; | ||
|
||
|
||
/** | ||
* | ||
* @return Method to start the execution of the transaction filter job | ||
* @param startDate starting date for the batch job execution | ||
*/ | ||
@SneakyThrows | ||
public JobExecution execute(Date startDate) { | ||
Resource[] transactionResources = resolver.getResources(transactionFilterStep.getTransactionDirectoryPath() + "/*.csv"); | ||
transactionResources = TransactionFilterStep.filterValidFilenames(transactionResources); | ||
|
||
String hpanPath = panReaderStep.getHpanDirectoryPath(); | ||
Resource[] hpanResources = resolver.getResources(hpanPath); | ||
|
||
JobExecution execution = null; | ||
|
||
/* | ||
The jobLauncher run method is called only if, based on the configured properties, a matching transaction | ||
resource is found, and either the remote pan list recovery is enabled, or a pan list file is available locally | ||
on the configured path | ||
*/ | ||
if (transactionResources.length == 0) { | ||
log.info("No transaction file has been found on configured path: {}", transactionFilterStep.getTransactionDirectoryPath()); | ||
} | ||
|
||
if (Boolean.FALSE.equals(hpanListRecoveryEnabled) && hpanResources.length == 0) { | ||
log.info("No hpan file has been found on configured path: {}", hpanPath); | ||
} | ||
|
||
if (transactionResources.length > 0 && | ||
(hpanListRecoveryEnabled || hpanResources.length > 0)) { | ||
|
||
log.info("Found {} {}. Starting filtering process", | ||
transactionResources.length, (transactionResources.length > 1 ? "resources" : "resource") | ||
); | ||
|
||
execution = jobLauncher.run(job, | ||
new JobParametersBuilder() | ||
.addDate("startDateTime", startDate) | ||
.toJobParameters()); | ||
clearStoreService(); | ||
|
||
} | ||
|
||
return execution; | ||
} | ||
|
||
public void clearStoreService() { | ||
storeService.clearAll(); | ||
} | ||
|
||
} |
Oops, something went wrong.