This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 240a51eec1 FINERACT-2373: Fix backward compatibility issue of `Loan
COB`
240a51eec1 is described below
commit 240a51eec1ebac0ae6dc451b6d6a6a28656a40b7
Author: Adam Saghy <[email protected]>
AuthorDate: Fri Sep 5 16:38:32 2025 +0200
FINERACT-2373: Fix backward compatibility issue of `Loan COB`
---
.../cob/converter/COBParameterConverter.java | 36 +++++++++++++++++++
.../apache/fineract/cob/data/LoanCOBParameter.java | 40 ++++++++++++++++++++++
.../fineract/cob/loan/ApplyLoanLockTasklet.java | 3 +-
.../apache/fineract/cob/loan/LoanItemReader.java | 3 +-
4 files changed, 80 insertions(+), 2 deletions(-)
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/cob/converter/COBParameterConverter.java
b/fineract-provider/src/main/java/org/apache/fineract/cob/converter/COBParameterConverter.java
new file mode 100644
index 0000000000..70639d9fb4
--- /dev/null
+++
b/fineract-provider/src/main/java/org/apache/fineract/cob/converter/COBParameterConverter.java
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.converter;
+
+import org.apache.fineract.cob.data.COBParameter;
+import org.apache.fineract.cob.data.LoanCOBParameter;
+
+public final class COBParameterConverter {
+
+ private COBParameterConverter() {}
+
+ public static COBParameter convert(Object obj) {
+ if (obj instanceof COBParameter) {
+ return (COBParameter) obj;
+ } else if (obj instanceof LoanCOBParameter loanCOBParameter) {
+ return loanCOBParameter.toCOBParameter();
+ }
+ return null;
+ }
+}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/cob/data/LoanCOBParameter.java
b/fineract-provider/src/main/java/org/apache/fineract/cob/data/LoanCOBParameter.java
new file mode 100644
index 0000000000..a17c5a9bf7
--- /dev/null
+++
b/fineract-provider/src/main/java/org/apache/fineract/cob/data/LoanCOBParameter.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.data;
+
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import lombok.AllArgsConstructor;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+
+@AllArgsConstructor
+@Getter
+@NoArgsConstructor
+@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)
+@EqualsAndHashCode
+public class LoanCOBParameter {
+
+ private Long minLoanId;
+ private Long maxLoanId;
+
+ public COBParameter toCOBParameter() {
+ return new COBParameter(this.minLoanId, this.maxLoanId);
+ }
+}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/cob/loan/ApplyLoanLockTasklet.java
b/fineract-provider/src/main/java/org/apache/fineract/cob/loan/ApplyLoanLockTasklet.java
index dab46770dd..3d6a90793c 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/cob/loan/ApplyLoanLockTasklet.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/cob/loan/ApplyLoanLockTasklet.java
@@ -29,6 +29,7 @@ import java.util.Objects;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.cob.common.CustomJobParameterResolver;
+import org.apache.fineract.cob.converter.COBParameterConverter;
import org.apache.fineract.cob.data.COBParameter;
import org.apache.fineract.cob.domain.LoanAccountLock;
import org.apache.fineract.cob.domain.LockOwner;
@@ -61,7 +62,7 @@ public class ApplyLoanLockTasklet implements Tasklet {
throws LoanLockCannotBeAppliedException {
ExecutionContext executionContext =
contribution.getStepExecution().getExecutionContext();
long numberOfExecutions =
contribution.getStepExecution().getCommitCount();
- COBParameter loanCOBParameter = (COBParameter)
executionContext.get(LoanCOBConstant.LOAN_COB_PARAMETER);
+ COBParameter loanCOBParameter =
COBParameterConverter.convert(executionContext.get(LoanCOBConstant.LOAN_COB_PARAMETER));
List<Long> loanIds;
if (Objects.isNull(loanCOBParameter)
|| (Objects.isNull(loanCOBParameter.getMinAccountId()) &&
Objects.isNull(loanCOBParameter.getMaxAccountId()))
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanItemReader.java
b/fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanItemReader.java
index 933c656674..9ee7d325de 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanItemReader.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanItemReader.java
@@ -25,6 +25,7 @@ import java.util.Objects;
import java.util.concurrent.LinkedBlockingQueue;
import lombok.extern.slf4j.Slf4j;
import org.apache.fineract.cob.common.CustomJobParameterResolver;
+import org.apache.fineract.cob.converter.COBParameterConverter;
import org.apache.fineract.cob.data.COBParameter;
import org.apache.fineract.cob.domain.LoanAccountLock;
import org.apache.fineract.cob.domain.LockOwner;
@@ -53,7 +54,7 @@ public class LoanItemReader extends AbstractLoanItemReader {
@SuppressWarnings({ "unchecked" })
public void beforeStep(@NonNull StepExecution stepExecution) {
ExecutionContext executionContext =
stepExecution.getExecutionContext();
- COBParameter loanCOBParameter = (COBParameter)
executionContext.get(LoanCOBConstant.LOAN_COB_PARAMETER);
+ COBParameter loanCOBParameter =
COBParameterConverter.convert(executionContext.get(LoanCOBConstant.LOAN_COB_PARAMETER));
List<Long> loanIds;
if (Objects.isNull(loanCOBParameter)
|| (Objects.isNull(loanCOBParameter.getMinAccountId()) &&
Objects.isNull(loanCOBParameter.getMaxAccountId()))