Skip to content

Commit d043f4c

Browse files
Satvik01000galovics
authored andcommitted
FINERACT-2415: Refactor InlineLoanCOBExecutorServiceImpl to reduce duplication
1 parent 36d779e commit d043f4c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

fineract-provider/src/main/java/org/apache/fineract/cob/service/InlineLoanCOBExecutorServiceImpl.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,17 @@ private List<LoanAccountLock> getLoanAccountLocks(List<Long> loanIds, LocalDate
200200
return loanAccountLocks;
201201
}
202202

203+
private Long saveCustomJobParameter(String paramName, String paramValue) {
204+
JobParameterDTO paramDTO = new JobParameterDTO(paramName, paramValue);
205+
Set<JobParameterDTO> paramSet = Collections.singleton(paramDTO);
206+
return customJobParameterRepository.save(paramSet);
207+
}
208+
203209
private Map<String, JobParameter<?>> getJobParametersMap(List<Long> loanIds, LocalDate businessDate) {
204-
// TODO: refactor for a more generic solution
205210
String parameterJson = gson.toJson(loanIds);
206-
JobParameterDTO loanIdsParameterDTO = new JobParameterDTO(LoanCOBConstant.LOAN_IDS_PARAMETER_NAME, parameterJson);
207-
Set<JobParameterDTO> loanIdJobParameter = Collections.singleton(loanIdsParameterDTO);
208-
Long loanIdsJobParameterId = customJobParameterRepository.save(loanIdJobParameter);
209-
JobParameterDTO businessDateParameterDTO = new JobParameterDTO(LoanCOBConstant.BUSINESS_DATE_PARAMETER_NAME,
211+
Long loanIdsJobParameterId = saveCustomJobParameter(LoanCOBConstant.LOAN_IDS_PARAMETER_NAME, parameterJson);
212+
Long businessDateJobParameterId = saveCustomJobParameter(LoanCOBConstant.BUSINESS_DATE_PARAMETER_NAME,
210213
businessDate.format(DateTimeFormatter.ISO_DATE));
211-
Set<JobParameterDTO> businessDateJobParameter = Collections.singleton(businessDateParameterDTO);
212-
Long businessDateJobParameterId = customJobParameterRepository.save(businessDateJobParameter);
213214
Map<String, JobParameter<?>> jobParameterMap = new HashMap<>();
214215
jobParameterMap.put(SpringBatchJobConstants.CUSTOM_JOB_PARAMETER_ID_KEY, new JobParameter<>(loanIdsJobParameterId, Long.class));
215216
jobParameterMap.put(LoanCOBConstant.BUSINESS_DATE_PARAMETER_NAME, new JobParameter<>(businessDateJobParameterId, Long.class));

0 commit comments

Comments
 (0)