[FINERACT-1678] all Loan COB steps are completed if there is no loan to be processed

This commit is contained in:
taskain7
2023-03-17 10:18:58 +01:00
committed by Arnold Gálovics
parent 3b337c96ee
commit 4e52bd3a02
5 changed files with 17 additions and 27 deletions
@@ -21,6 +21,7 @@ package org.apache.fineract.cob.loan;
import com.google.common.collect.Lists;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import lombok.RequiredArgsConstructor;
@@ -54,6 +55,7 @@ public class FetchAndLockLoanTasklet implements Tasklet {
LocalDate businessDate = LocalDate.parse(Objects.requireNonNull(businessDateParameter));
List<Long> allNonClosedLoanIds = retrieveLoanIdService.retrieveLoanIdsNDaysBehind(NUMBER_OF_DAYS_BEHIND, businessDate);
if (allNonClosedLoanIds.isEmpty()) {
contribution.getStepExecution().getJobExecution().getExecutionContext().put(LoanCOBConstant.LOAN_IDS, Collections.emptyList());
return RepeatStatus.FINISHED;
}
List<Long> remainingIds = new ArrayList<>(allNonClosedLoanIds);
@@ -37,7 +37,6 @@ import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.core.launch.NoSuchJobExecutionException;
import org.springframework.batch.core.partition.support.Partitioner;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.util.CollectionUtils;
@Slf4j
@RequiredArgsConstructor
@@ -58,17 +57,12 @@ public class LoanCOBPartitioner implements Partitioner {
int partitionSize = propertyService.getPartitionSize(LoanCOBConstant.JOB_NAME);
Set<BusinessStepNameAndOrder> cobBusinessSteps = cobBusinessStepService.getCOBBusinessSteps(LoanCOBBusinessStep.class,
LoanCOBConstant.LOAN_COB_JOB_NAME);
if (cobBusinessSteps.isEmpty()) {
stopJobExecution();
return Map.of();
}
return getPartitions(partitionSize, cobBusinessSteps);
}
private Map<String, ExecutionContext> getPartitions(int partitionSize, Set<BusinessStepNameAndOrder> cobBusinessSteps) {
Map<String, ExecutionContext> partitions = new HashMap<>();
if (CollectionUtils.isEmpty(loanIds)) {
if (cobBusinessSteps.isEmpty()) {
stopJobExecution();
return Map.of();
}
@@ -35,7 +35,6 @@ public class LoanItemReader extends AbstractLoanItemReader {
@BeforeStep
@SuppressWarnings({ "unchecked" })
public void beforeStep(@NotNull StepExecution stepExecution) {
ExecutionContext executionContext = stepExecution.getExecutionContext();
ExecutionContext jobExecutionContext = stepExecution.getJobExecution().getExecutionContext();
List<Long> loanIds = (List<Long>) executionContext.get(LoanCOBConstant.LOAN_IDS);