Skip to content

Commit c3434d6

Browse files
committed
FINERACT-2455: Improved DTO and field value handling
1 parent 2f79e97 commit c3434d6

92 files changed

Lines changed: 1022 additions & 1156 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

fineract-accounting/src/main/resources/jpa/static-weaving/module/fineract-accounting/persistence.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<exclude-unlisted-classes>false</exclude-unlisted-classes>
8888
<properties>
8989
<property name="eclipselink.weaving" value="static" />
90+
<property name="eclipselink.weaving.internal" value="false"/>
9091
</properties>
9192
</persistence-unit>
9293
</persistence>

fineract-branch/src/main/resources/jpa/static-weaving/module/fineract-branch/persistence.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
<exclude-unlisted-classes>false</exclude-unlisted-classes>
9595
<properties>
9696
<property name="eclipselink.weaving" value="static" />
97+
<property name="eclipselink.weaving.internal" value="false"/>
9798
</properties>
9899
</persistence-unit>
99100
</persistence>

fineract-charge/src/main/resources/jpa/static-weaving/module/fineract-charge/persistence.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<exclude-unlisted-classes>false</exclude-unlisted-classes>
8888
<properties>
8989
<property name="eclipselink.weaving" value="static" />
90+
<property name="eclipselink.weaving.internal" value="false"/>
9091
</properties>
9192
</persistence-unit>
9293
</persistence>

fineract-cob/src/main/java/org/apache/fineract/cob/domain/AccountLock.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import jakarta.persistence.PrePersist;
2828
import jakarta.persistence.Transient;
2929
import jakarta.persistence.Version;
30+
import java.io.Serial;
3031
import java.io.Serializable;
3132
import java.time.LocalDate;
3233
import java.time.OffsetDateTime;
@@ -38,47 +39,41 @@
3839
import org.springframework.data.domain.Persistable;
3940

4041
@Getter
42+
@Setter
4143
@MappedSuperclass
4244
@NoArgsConstructor
4345
public abstract class AccountLock implements Persistable<Long>, Serializable {
4446

45-
protected static final long serialVersionUID = 2272591907035824317L;
47+
@Serial
48+
private static final long serialVersionUID = 1L;
4649

4750
@Id
48-
@Getter
4951
@Column(name = "loan_id", nullable = false)
50-
protected Long loanId;
52+
private Long loanId;
5153

5254
@Version
53-
@Getter
5455
@Column(name = "version")
55-
protected Long version;
56+
private Long version;
5657

5758
@Enumerated(EnumType.STRING)
58-
@Getter
5959
@Column(name = "lock_owner", nullable = false)
60-
protected LockOwner lockOwner;
60+
private LockOwner lockOwner;
6161

6262
@Column(name = "lock_placed_on", nullable = false)
63-
@Getter
64-
protected OffsetDateTime lockPlacedOn;
63+
private OffsetDateTime lockPlacedOn;
6564

6665
@Column(name = "error")
67-
@Getter
68-
protected String error;
66+
private String error;
6967

7068
@Column(name = "stacktrace")
71-
@Getter
72-
protected String stacktrace;
69+
private String stacktrace;
7370

7471
@Column(name = "lock_placed_on_cob_business_date")
75-
@Getter
76-
protected LocalDate lockPlacedOnCobBusinessDate;
72+
private LocalDate lockPlacedOnCobBusinessDate;
7773

7874
@Transient
7975
@Setter(value = AccessLevel.NONE)
80-
@Getter
81-
protected boolean isNew = true;
76+
private boolean isNew = true;
8277

8378
@PrePersist
8479
@PostLoad
@@ -88,7 +83,7 @@ void markNotNew() {
8883

8984
@Override
9085
public Long getId() {
91-
return getLoanId();
86+
return loanId;
9287
}
9388

9489
public AccountLock(Long loanId, LockOwner lockOwner, LocalDate lockPlacedOnCobBusinessDate) {

fineract-cob/src/main/java/org/apache/fineract/cob/service/BeforeStepLockingItemReaderHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ public LinkedBlockingQueue<Long> filterRemainingData(@NonNull StepExecution step
6464
private List<Long> getLoanIdsLockedWithChunkProcessingLock(List<Long> loanIds) {
6565
List<T> accountLocks = new ArrayList<>(
6666
loanLockingService.findAllByLoanIdInAndLockOwner(loanIds, LockOwner.LOAN_COB_CHUNK_PROCESSING));
67-
return accountLocks.stream().map(T::getLoanId).toList();
67+
return accountLocks.stream().map(T::getId).toList();
6868
}
6969
}

fineract-cob/src/main/java/org/apache/fineract/cob/tasklet/ApplyCommonLockTasklet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public RepeatStatus execute(@NonNull StepContribution contribution, @NonNull Chu
8383
loanIdPartitions.forEach(loanIdPartition -> accountLocks.addAll(loanLockingService.findAllByLoanIdIn(loanIdPartition)));
8484

8585
List<Long> toBeProcessedLoanIds = new ArrayList<>(loanIds);
86-
List<Long> alreadyLockedAccountIds = accountLocks.stream().map(AccountLock::getLoanId).toList();
86+
List<Long> alreadyLockedAccountIds = accountLocks.stream().map(AccountLock::getId).toList();
8787

8888
toBeProcessedLoanIds.removeAll(alreadyLockedAccountIds);
8989
try {

fineract-cob/src/main/resources/jpa/static-weaving/module/fineract-cob/persistence.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@
6666
<class>org.apache.fineract.infrastructure.codes.domain.CodeValue</class>
6767

6868
<!-- COB Module Entities -->
69-
69+
<class>org.apache.fineract.cob.domain.AccountLock</class>
70+
<class>org.apache.fineract.cob.domain.BatchBusinessStep</class>
7071
<exclude-unlisted-classes>false</exclude-unlisted-classes>
7172
<properties>
7273
<property name="eclipselink.weaving" value="static" />
74+
<property name="eclipselink.weaving.internal" value="false"/>
7375
</properties>
7476
</persistence-unit>
7577
</persistence>

fineract-core/src/main/java/org/apache/fineract/infrastructure/core/serialization/FromJsonHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,4 +329,8 @@ public <T extends Enum<T>> T enumValueOfParameterNamed(String parameterName, fin
329329
"Enum value not exists: ", enumType.getName(), value)), e);
330330
}
331331
}
332+
333+
public Integer extractIntegerNamed(String paramName, JsonObject element) {
334+
return extractIntegerNamed(paramName, element, new HashSet<>());
335+
}
332336
}

fineract-core/src/main/java/org/apache/fineract/portfolio/delinquency/domain/DelinquencyBucket.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import jakarta.persistence.CascadeType;
2222
import jakarta.persistence.Column;
2323
import jakarta.persistence.Entity;
24+
import jakarta.persistence.EnumType;
2425
import jakarta.persistence.Enumerated;
2526
import jakarta.persistence.FetchType;
2627
import jakarta.persistence.JoinColumn;
@@ -51,10 +52,10 @@ public class DelinquencyBucket extends AbstractAuditableWithUTCDateTimeCustom<Lo
5152
@JoinTable(name = "m_delinquency_bucket_mappings", joinColumns = @JoinColumn(name = "delinquency_bucket_id"), inverseJoinColumns = @JoinColumn(name = "delinquency_range_id"))
5253
private List<DelinquencyRange> ranges;
5354

54-
@OneToOne(mappedBy = "bucket", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
55+
@OneToOne(mappedBy = "bucket", cascade = CascadeType.ALL, orphanRemoval = true)
5556
private DelinquencyMinimumPaymentPeriodAndRule minimumPaymentPeriodAndRule;
5657

57-
@Enumerated
58+
@Enumerated(EnumType.STRING)
5859
@Column(name = "bucket_type")
5960
private DelinquencyBucketType bucketType;
6061

fineract-core/src/main/java/org/apache/fineract/portfolio/delinquency/domain/DelinquencyBucketType.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,27 @@
2020
package org.apache.fineract.portfolio.delinquency.domain;
2121

2222
import java.util.Arrays;
23+
import java.util.List;
2324
import lombok.Getter;
25+
import lombok.RequiredArgsConstructor;
26+
import org.apache.fineract.infrastructure.core.data.StringEnumOptionData;
2427

28+
@Getter
29+
@RequiredArgsConstructor
2530
public enum DelinquencyBucketType {
2631

27-
REGULAR(1L, "bucketType.regular"), //
28-
WORKING_CAPITAL(2L, "bucketType.workingCapital");
32+
REGULAR(1L, "bucketType.regular", "Reqular Loan Product"), //
33+
WORKING_CAPITAL(2L, "bucketType.workingCapital", "Working Capital Loan Product");
2934

30-
@Getter
31-
private final Long value;
32-
33-
@Getter
35+
private final Long id;
3436
private final String code;
37+
private final String description;
3538

36-
DelinquencyBucketType(Long value, String code) {
37-
this.value = value;
38-
this.code = code;
39+
public static List<StringEnumOptionData> toStringEnumOptions() {
40+
return Arrays.stream(values()).map(DelinquencyBucketType::toData).toList();
3941
}
4042

41-
public static DelinquencyBucketType fromLong(Long value) {
42-
if (value == null) {
43-
return null;
44-
}
45-
return Arrays.stream(DelinquencyBucketType.values()).filter(v -> v.getValue().equals(value)).findAny().orElse(REGULAR);
43+
public StringEnumOptionData toData() {
44+
return new StringEnumOptionData(name(), getCode(), getDescription());
4645
}
4746
}

0 commit comments

Comments
 (0)