From b482fbd44728bf78dd68a4f130a7ced497526607 Mon Sep 17 00:00:00 2001 From: Marta Jankovics Date: Wed, 26 Jun 2024 13:31:57 +0200 Subject: [PATCH] FINERACT-2081: Support for string type primary keys - refactor existing enums --- .../accounting/common/AccountingRuleType.java | 26 +++-- .../dataqueries/data/EntityTables.java | 2 +- .../dataqueries/data/StatusEnum.java | 97 ++++++------------- .../infrastructure/jobs/service/JobName.java | 3 +- .../portfolio/TransactionEntryType.java | 29 +++--- .../account/PortfolioAccountType.java | 3 +- .../accountdetails/domain/AccountType.java | 12 ++- .../portfolio/note/domain/NoteType.java | 8 ++ .../api/EntityDatatableChecksApiResource.java | 2 +- .../domain/EntityDatatableChecks.java | 16 +-- .../EntityDatatableChecksRepository.java | 8 +- ...yDatatableCheckAlreadyExistsException.java | 14 +-- ...atatableChecksReadPlatformServiceImpl.java | 22 ++--- .../EntityDatatableChecksReadService.java | 5 +- ...tyDatatableChecksWritePlatformService.java | 6 +- ...tatableChecksWritePlatformServiceImpl.java | 27 +++--- .../ClientReadPlatformServiceImpl.java | 4 +- ...WritePlatformServiceJpaRepositoryImpl.java | 11 +-- .../group/api/CentersApiResource.java | 4 +- .../group/api/GroupsApiResource.java | 4 +- ...WritePlatformServiceJpaRepositoryImpl.java | 10 +- .../loanaccount/api/LoansApiResource.java | 4 +- .../LoanApplicationValidator.java | 2 +- ...WritePlatformServiceJpaRepositoryImpl.java | 13 ++- ...WritePlatformServiceJpaRepositoryImpl.java | 6 +- .../portfolio/note/api/NotesApiResource.java | 2 - .../note/service/NoteEnumerations.java | 59 ----------- .../service/NoteReadPlatformServiceImpl.java | 6 +- ...SavingsAccountReadPlatformServiceImpl.java | 4 +- ...WritePlatformServiceJpaRepositoryImpl.java | 4 +- ...WritePlatformServiceJpaRepositoryImpl.java | 17 ++-- 31 files changed, 169 insertions(+), 261 deletions(-) delete mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/note/service/NoteEnumerations.java diff --git a/fineract-core/src/main/java/org/apache/fineract/accounting/common/AccountingRuleType.java b/fineract-core/src/main/java/org/apache/fineract/accounting/common/AccountingRuleType.java index 5457736cfce..456eb12f0f7 100644 --- a/fineract-core/src/main/java/org/apache/fineract/accounting/common/AccountingRuleType.java +++ b/fineract-core/src/main/java/org/apache/fineract/accounting/common/AccountingRuleType.java @@ -20,16 +20,21 @@ import java.util.HashMap; import java.util.Map; +import lombok.Getter; +import org.apache.fineract.infrastructure.core.data.EnumOptionData; +import org.apache.fineract.infrastructure.core.data.StringEnumOptionData; +@Getter public enum AccountingRuleType { - NONE(1, "accountingRuleType.none"), // - CASH_BASED(2, "accountingRuleType.cash"), // - ACCRUAL_PERIODIC(3, "accountingRuleType.accrual.periodic"), // - ACCRUAL_UPFRONT(4, "accountingRuleType.accrual.upfront"); // + NONE(1, "accountingRuleType.none", "No accounting"), // + CASH_BASED(2, "accountingRuleType.cash", "Cash based accounting"), // + ACCRUAL_PERIODIC(3, "accountingRuleType.accrual.periodic", "Periodic accrual accounting"), // + ACCRUAL_UPFRONT(4, "accountingRuleType.accrual.upfront", "Upfront accrual accounting"); // private final Integer value; private final String code; + private final String description; private static final Map intToEnumMap = new HashMap<>(); @@ -44,21 +49,22 @@ public static AccountingRuleType fromInt(final Integer ruleTypeValue) { return type; } - AccountingRuleType(final Integer value, final String code) { + AccountingRuleType(final Integer value, final String code, final String description) { this.value = value; this.code = code; + this.description = description; } @Override public String toString() { - return name().toString().replaceAll("_", " "); + return name().replaceAll("_", " "); } - public Integer getValue() { - return this.value; + public EnumOptionData toEnumOptionData() { + return new EnumOptionData((long) getValue(), getCode(), getDescription()); } - public String getCode() { - return this.code; + public StringEnumOptionData toStringEnumOptionData() { + return new StringEnumOptionData(name(), getCode(), getDescription()); } } diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/EntityTables.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/EntityTables.java index 2db319073df..0a924cf1939 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/EntityTables.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/EntityTables.java @@ -130,7 +130,7 @@ public static List getCheckStatuses(String name) { @NotNull public static List getCheckStatusCodes(String name) { - return getCheckStatuses(name).stream().map(StatusEnum::getCode).toList(); + return getCheckStatuses(name).stream().map(StatusEnum::getValue).toList(); } @NotNull diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/StatusEnum.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/StatusEnum.java index 6c848f467cc..6a7add1823d 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/StatusEnum.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/dataqueries/data/StatusEnum.java @@ -18,88 +18,55 @@ */ package org.apache.fineract.infrastructure.dataqueries.data; -import java.util.ArrayList; -import java.util.List; +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; import org.apache.fineract.infrastructure.core.data.EnumOptionData; public enum StatusEnum { - CREATE("create", 100), APPROVE("approve", 200), ACTIVATE("activate", 300), WITHDRAWN("withdraw", 400), REJECTED("reject", 500), CLOSE( - "close", 600), WRITE_OFF("write off", 601), RESCHEDULE("reschedule", 602), OVERPAY("overpay", 700), DISBURSE("disburse", 800); + CREATE("statusEnum.create", 100), // + APPROVE("statusEnum.approve", 200), // + ACTIVATE("statusEnum.activate", 300), // + WITHDRAWN("statusEnum.withdraw", 400), // + REJECTED("statusEnum.reject", 500), // + CLOSE("statusEnum.close", 600), // + WRITE_OFF("statusEnum.write off", 601), // + RESCHEDULE("statusEnum.reschedule", 602), // + OVERPAY("statusEnum.overpay", 700), // + DISBURSE("statusEnum.disburse", 800), // + ; - private final String name; + private static final StatusEnum[] VALUES = values(); - private final Integer code; + private static final Map BY_ID = Arrays.stream(VALUES).collect(Collectors.toMap(StatusEnum::getValue, v -> v)); - public Integer getCode() { - return code; - } - - StatusEnum(String name, Integer code) { + private final String code; - this.name = name; - this.code = code; + private final Integer value; + public Integer getValue() { + return value; } - public static List getStatusList() { - - List data = new ArrayList(); - - for (StatusEnum status : StatusEnum.values()) { - data.add(new DatatableCheckStatusData(status.name, status.code)); - } - - return data; - + StatusEnum(String code, Integer value) { + this.code = code; + this.value = value; } - public static StatusEnum fromInt(final Integer code) { - StatusEnum ret = null; - switch (code) { - case 100: - ret = StatusEnum.CREATE; - break; - case 200: - ret = StatusEnum.APPROVE; - break; - case 300: - ret = StatusEnum.ACTIVATE; - break; - case 400: - ret = StatusEnum.WITHDRAWN; - break; - case 500: - ret = StatusEnum.REJECTED; - break; - case 600: - ret = StatusEnum.CLOSE; - break; - case 601: - ret = StatusEnum.WRITE_OFF; - break; - case 602: - ret = StatusEnum.RESCHEDULE; - break; - case 700: - ret = StatusEnum.OVERPAY; - break; - case 800: - ret = StatusEnum.DISBURSE; - break; - default: - break; - } - return ret; + public static StatusEnum fromInt(final Integer value) { + return BY_ID.get(value); } - public static EnumOptionData statusTypeEnum(final Integer id) { - return statusType(StatusEnum.fromInt(id)); + public static EnumOptionData toEnumOptionData(final Integer id) { + return toEnumOptionData(StatusEnum.fromInt(id)); } - public static EnumOptionData statusType(final StatusEnum statusType) { - final EnumOptionData optionData = new EnumOptionData(statusType.getCode().longValue(), statusType.name(), statusType.name()); - return optionData; + public static EnumOptionData toEnumOptionData(final StatusEnum statusType) { + return statusType == null ? null : statusType.toEnumOptionData(); } + public EnumOptionData toEnumOptionData() { + return new EnumOptionData(getValue().longValue(), code, name()); + } } diff --git a/fineract-core/src/main/java/org/apache/fineract/infrastructure/jobs/service/JobName.java b/fineract-core/src/main/java/org/apache/fineract/infrastructure/jobs/service/JobName.java index 2f9e5fb44bc..678f4858e7e 100644 --- a/fineract-core/src/main/java/org/apache/fineract/infrastructure/jobs/service/JobName.java +++ b/fineract-core/src/main/java/org/apache/fineract/infrastructure/jobs/service/JobName.java @@ -56,7 +56,8 @@ public enum JobName { LOAN_DELINQUENCY_CLASSIFICATION("Loan Delinquency Classification"), // SEND_ASYNCHRONOUS_EVENTS("Send Asynchronous Events"), // PURGE_EXTERNAL_EVENTS("Purge External Events"), // - PURGE_PROCESSED_COMMANDS("Purge Processed Commands"); + PURGE_PROCESSED_COMMANDS("Purge Processed Commands"), // + ; private final String name; diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/TransactionEntryType.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/TransactionEntryType.java index dc517ec6993..bf782535ac4 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/TransactionEntryType.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/TransactionEntryType.java @@ -18,26 +18,25 @@ */ package org.apache.fineract.portfolio; +import lombok.Getter; +import org.apache.fineract.infrastructure.core.data.EnumOptionData; +import org.apache.fineract.infrastructure.core.data.StringEnumOptionData; + +@Getter public enum TransactionEntryType { - CREDIT(1, "transactionEntryType.credit"), // - DEBIT(2, "transactionEntryType.debit"), // + CREDIT(1, "transactionEntryType.credit", "Credit transaction"), // + DEBIT(2, "transactionEntryType.debit", "Debit transaction"), // ; private final Integer value; private final String code; + private final String description; - TransactionEntryType(final Integer value, final String code) { + TransactionEntryType(final Integer value, final String code, final String description) { this.value = value; this.code = code; - } - - public Integer getValue() { - return this.value; - } - - public String getCode() { - return this.code; + this.description = description; } public boolean isCredit() { @@ -51,4 +50,12 @@ public boolean isDebit() { public TransactionEntryType getReversal() { return this == CREDIT ? DEBIT : CREDIT; } + + public EnumOptionData toEnumOptionData() { + return new EnumOptionData((long) getValue(), getCode(), getDescription()); + } + + public StringEnumOptionData toStringEnumOptionData() { + return new StringEnumOptionData(name(), getCode(), getDescription()); + } } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/account/PortfolioAccountType.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/account/PortfolioAccountType.java index e70dfab5498..3a81a147c10 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/account/PortfolioAccountType.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/account/PortfolioAccountType.java @@ -22,7 +22,8 @@ public enum PortfolioAccountType { INVALID(0, "accountType.invalid"), // LOAN(1, "accountType.loan"), // - SAVINGS(2, "accountType.savings"); + SAVINGS(2, "accountType.savings"), // + ; private final Integer value; private final String code; diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/accountdetails/domain/AccountType.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/accountdetails/domain/AccountType.java index 10da640e3e0..f5d4d77b4f7 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/accountdetails/domain/AccountType.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/accountdetails/domain/AccountType.java @@ -18,6 +18,11 @@ */ package org.apache.fineract.portfolio.accountdetails.domain; +import java.util.Arrays; +import java.util.List; +import org.apache.fineract.infrastructure.core.data.EnumOptionData; +import org.apache.fineract.portfolio.accountdetails.service.AccountEnumerations; + /** * Enum representation of account types . */ @@ -27,7 +32,8 @@ public enum AccountType { INDIVIDUAL(1, "accountType.individual"), // GROUP(2, "accountType.group"), // JLG(3, "accountType.jlg"), // JLG account given in group context - GLIM(4, "accountType.glim"), GSIM(5, "accountType.gsim"); + GLIM(4, "accountType.glim"), // + GSIM(5, "accountType.gsim"); private final Integer value; private final String code; @@ -71,6 +77,10 @@ public static AccountType fromName(final String name) { return accountType; } + public static List toEnumOptionData() { + return Arrays.stream(values()).sequential().map(AccountEnumerations::loanType).toList(); + } + public Integer getValue() { return this.value; } diff --git a/fineract-core/src/main/java/org/apache/fineract/portfolio/note/domain/NoteType.java b/fineract-core/src/main/java/org/apache/fineract/portfolio/note/domain/NoteType.java index a50c8e660ca..19710b3bbca 100644 --- a/fineract-core/src/main/java/org/apache/fineract/portfolio/note/domain/NoteType.java +++ b/fineract-core/src/main/java/org/apache/fineract/portfolio/note/domain/NoteType.java @@ -75,6 +75,14 @@ public static NoteType fromApiUrl(final String url) { return BY_API.get(url); } + public static EnumOptionData toEnumOptionData(final Integer id) { + return toEnumOptionData(NoteType.fromInt(id)); + } + + public static EnumOptionData toEnumOptionData(final NoteType noteType) { + return noteType == null ? null : noteType.toEnumOptionData(); + } + public EnumOptionData toEnumOptionData() { return new EnumOptionData(getValue().longValue(), getCode(), getDescription()); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/EntityDatatableChecksApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/EntityDatatableChecksApiResource.java index 0a54f3eb8ae..649a94d5a93 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/EntityDatatableChecksApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/EntityDatatableChecksApiResource.java @@ -72,7 +72,7 @@ public class EntityDatatableChecksApiResource { + "Example Request:\n" + "\n" + "entityDatatableChecks?offset=0&limit=15") @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK", content = @Content(array = @ArraySchema(schema = @Schema(implementation = EntityDatatableChecksApiResourceSwagger.GetEntityDatatableChecksResponse.class)))) }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("status") @Parameter(description = "status") final Long status, + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("status") @Parameter(description = "status") final Integer status, @QueryParam("entity") @Parameter(description = "entity") final String entity, @QueryParam("productId") @Parameter(description = "productId") final Long productId, @QueryParam("offset") @Parameter(description = "offset") final Integer offset, diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/EntityDatatableChecks.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/EntityDatatableChecks.java index 50aeba4d42f..6129dff9c81 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/EntityDatatableChecks.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/EntityDatatableChecks.java @@ -41,7 +41,7 @@ public class EntityDatatableChecks extends AbstractPersistableCustom { private String datatableName; @Column(name = "status_enum", nullable = false) - private Long status; + private Integer status; @Column(name = "system_defined") private boolean systemDefined = false; @@ -50,29 +50,19 @@ public class EntityDatatableChecks extends AbstractPersistableCustom { private Long productId; public static EntityDatatableChecks fromJson(final JsonCommand command) { - final String entity = command.stringValueOfParameterNamed("entity"); - final Long status = command.longValueOfParameterNamed("status"); + final Integer status = command.integerValueSansLocaleOfParameterNamed("status"); final String datatableName = command.stringValueOfParameterNamed("datatableName"); - boolean systemDefined = false; - if (command.parameterExists("systemDefined")) { - systemDefined = command.booleanObjectValueOfParameterNamed("systemDefined"); - } else { - systemDefined = false; - } - + boolean systemDefined = command.booleanPrimitiveValueOfParameterNamed("systemDefined"); Long productId = null; if (command.parameterExists("productId")) { productId = command.longValueOfParameterNamed("productId"); } - return new EntityDatatableChecks(entity, datatableName, status, systemDefined, productId); - } public boolean isSystemDefined() { return this.systemDefined; } - } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/EntityDatatableChecksRepository.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/EntityDatatableChecksRepository.java index eec7e0eff9d..28b4b4c8729 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/EntityDatatableChecksRepository.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/EntityDatatableChecksRepository.java @@ -41,20 +41,20 @@ List findByEntityAndStatusAndSubtype(@Param("entity") Str @Param("subtype") String subtype); @Query("select t from EntityDatatableChecks t WHERE t.status =:status and t.entity=:entity and t.productId = :productId ") - List findByEntityStatusAndProduct(@Param("entity") String entity, @Param("status") Long status, + List findByEntityStatusAndProduct(@Param("entity") String entity, @Param("status") Integer status, @Param("productId") Long productId); @Query("select t from EntityDatatableChecks t WHERE t.status =:status and t.entity=:entity and t.productId IS NULL ") - List findByEntityStatusAndNoProduct(@Param("entity") String entity, @Param("status") Long status); + List findByEntityStatusAndNoProduct(@Param("entity") String entity, @Param("status") Integer status); @Query("select t from EntityDatatableChecks t WHERE t.status =:status " + "and t.entity=:entity and t.datatableName = :datatableName AND t.productId = :productId") List findByEntityStatusAndDatatableIdAndProductId(@Param("entity") String entityName, - @Param("status") Long status, @Param("datatableName") String datatableName, @Param("productId") Long productId); + @Param("status") Integer status, @Param("datatableName") String datatableName, @Param("productId") Long productId); @Query("select t from EntityDatatableChecks t WHERE t.status =:status and t.entity=:entity " + " and t.datatableName = :datatableName AND t.productId IS NULL") List findByEntityStatusAndDatatableIdAndNoProduct(@Param("entity") String entityName, - @Param("status") Long status, @Param("datatableName") String datatableName); + @Param("status") Integer status, @Param("datatableName") String datatableName); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/exception/EntityDatatableCheckAlreadyExistsException.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/exception/EntityDatatableCheckAlreadyExistsException.java index 2b2534dfc0b..7b13866728c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/exception/EntityDatatableCheckAlreadyExistsException.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/exception/EntityDatatableCheckAlreadyExistsException.java @@ -25,16 +25,16 @@ */ public class EntityDatatableCheckAlreadyExistsException extends AbstractPlatformDomainRuleException { - public EntityDatatableCheckAlreadyExistsException(final String entityName, final Long status, final String datatableName) { + public EntityDatatableCheckAlreadyExistsException(final String entityName, final Integer status, final String datatable) { super("error.msg.entityDatatableCheck.duplicate.entry", "the entity datatable check for status: '" + status - + "' and datatable name '" + datatableName + "' on entity '" + entityName + "' already exist", "status", "datatableName", - "entity", status, datatableName, entityName); + + "' and datatable name '" + datatable + "' on entity '" + entityName + "' already exist", "status", "datatable", "entity", + status, datatable, entityName); } - public EntityDatatableCheckAlreadyExistsException(final String entityName, long status, String datatableName, long productId) { + public EntityDatatableCheckAlreadyExistsException(final String entityName, Integer status, String datatable, Long productId) { super("error.msg.entityDatatableCheck.duplicate.entry", - "the entity datatable check for status: '" + status + "' and datatable name '" + datatableName + "' on entity '" - + entityName + "' and product id '" + productId + "' already exist", - "status", "datatableName", "entity", "productId", status, datatableName, entityName, productId); + "the entity datatable check for status: '" + status + "' and datatable name '" + datatable + "' on entity '" + entityName + + "' and product id '" + productId + "' already exist", + "status", "datatable", "entity", "productId", status, datatable, entityName, productId); } } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksReadPlatformServiceImpl.java index 495713c00e1..1192e74f305 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksReadPlatformServiceImpl.java @@ -18,6 +18,7 @@ */ package org.apache.fineract.infrastructure.dataqueries.service; +import jakarta.validation.constraints.NotNull; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -84,11 +85,10 @@ public EntityDatatableChecksReadPlatformServiceImpl(final JdbcTemplate jdbcTempl } @Override - public Page retrieveAll(SearchParameters searchParameters, final Long status, final String entity, - final Long productId) { + public Page retrieveAll(@NotNull SearchParameters searchParameters, final Integer status, + final String entity, final Long productId) { final StringBuilder sqlBuilder = new StringBuilder(200); - sqlBuilder.append("select " + sqlGenerator.calcFoundRows() + " "); - sqlBuilder.append(this.entityDataTableChecksMapper.schema()); + sqlBuilder.append("select ").append(sqlGenerator.calcFoundRows()).append(" ").append(this.entityDataTableChecksMapper.schema()); if (status != null || entity != null || productId != null) { sqlBuilder.append(" where "); @@ -122,8 +122,7 @@ public Page retrieveAll(SearchParameters searchParame } @Override - public List retrieveTemplates(final Long status, final String entity, final Long productId) { - + public List retrieveTemplates(final Integer status, final String entity, final Long productId) { List tableRequiredBeforeAction = null; if (productId != null) { tableRequiredBeforeAction = this.entityDatatableChecksRepository.findByEntityStatusAndProduct(entity, status, productId); @@ -162,7 +161,7 @@ private List getStatusList(List statuses) List ret = new ArrayList<>(); if (statuses != null) { for (StatusEnum status : statuses) { - ret.add(new DatatableCheckStatusData(status.name(), status.getCode())); + ret.add(new DatatableCheckStatusData(status.name(), status.getValue())); } } return ret; @@ -196,14 +195,10 @@ protected static final class EntityDataTableChecksMapper implements RowMapper retrieveTemplates(Long status, String entity, Long productId); - - Page retrieveAll(SearchParameters searchParameters, Long status, String entity, Long productLoanId); + List retrieveTemplates(Integer status, String entity, Long productId); + Page retrieveAll(SearchParameters searchParameters, Integer status, String entity, Long productId); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformService.java index def42a3b9d6..d690214c753 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformService.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformService.java @@ -28,10 +28,10 @@ public interface EntityDatatableChecksWritePlatformService { CommandProcessingResult deleteCheck(Long entityDatatableCheckId); - void runTheCheck(Long entityId, String entityName, Integer statusCode, String foreignKeyColumn, String entitySubtype); + void runTheCheck(Long entityId, String entityName, Integer status, String foreignKeyColumn, String entitySubtype); - void runTheCheckForProduct(Long entityId, String entityName, Long statusCode, String foreignKeyColumn, long productLoanId); + void runTheCheckForProduct(Long entityId, String entityName, Integer status, String foreignKeyColumn, long productLoanId); - boolean saveDatatables(Long status, String entity, Long entityId, Long productId, JsonArray data); + boolean saveDatatables(Integer status, String entity, Long entityId, Long productId, JsonArray data); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformServiceImpl.java index e5bbc6384c8..99f006da622 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformServiceImpl.java @@ -94,9 +94,9 @@ public CommandProcessingResult createCheck(final JsonCommand command) { } final Long productId = command.longValueOfParameterNamed("productId"); - final Long status = command.longValueOfParameterNamed("status"); + final Integer status = command.integerValueSansLocaleOfParameterNamed("status"); - List entityDatatableCheck = null; + List entityDatatableCheck; if (productId == null) { entityDatatableCheck = this.entityDatatableChecksRepository.findByEntityStatusAndDatatableIdAndNoProduct(entity, status, datatableName); @@ -139,13 +139,13 @@ public CommandProcessingResult createCheck(final JsonCommand command) { } @Override - public void runTheCheck(final Long entityId, final String entityName, final Integer statusCode, String foreignKeyColumn, + public void runTheCheck(final Long entityId, final String entityName, final Integer status, String foreignKeyColumn, final String entitySubtype) { List tableRequiredBeforeClientActivation; if (entitySubtype == null) { - tableRequiredBeforeClientActivation = entityDatatableChecksRepository.findByEntityAndStatus(entityName, statusCode); + tableRequiredBeforeClientActivation = entityDatatableChecksRepository.findByEntityAndStatus(entityName, status); } else { - tableRequiredBeforeClientActivation = entityDatatableChecksRepository.findByEntityAndStatusAndSubtype(entityName, statusCode, + tableRequiredBeforeClientActivation = entityDatatableChecksRepository.findByEntityAndStatusAndSubtype(entityName, status, entitySubtype.toUpperCase()); } @@ -161,22 +161,21 @@ public void runTheCheck(final Long entityId, final String entityName, final Inte reqDatatables.add(datatableName); } } - if (reqDatatables.size() > 0) { + if (!reqDatatables.isEmpty()) { throw new DatatableEntryRequiredException(reqDatatables.toString()); } } - } @Transactional(readOnly = true) @Override - public void runTheCheckForProduct(final Long entityId, final String entityName, final Long statusCode, String foreignKeyColumn, + public void runTheCheckForProduct(final Long entityId, final String entityName, final Integer status, String foreignKeyColumn, long productId) { List tableRequiredBeforAction = entityDatatableChecksRepository.findByEntityStatusAndProduct(entityName, - statusCode, productId); + status, productId); if (tableRequiredBeforAction == null || tableRequiredBeforAction.isEmpty()) { - tableRequiredBeforAction = entityDatatableChecksRepository.findByEntityStatusAndNoProduct(entityName, statusCode); + tableRequiredBeforAction = entityDatatableChecksRepository.findByEntityStatusAndNoProduct(entityName, status); } if (tableRequiredBeforAction != null) { List reqDatatables = new ArrayList<>(); @@ -194,12 +193,11 @@ public void runTheCheckForProduct(final Long entityId, final String entityName, throw new DatatableEntryRequiredException(reqDatatables.toString()); } } - } @Transactional @Override - public boolean saveDatatables(final Long status, final String entity, final Long entityId, final Long productId, + public boolean saveDatatables(final Integer status, final String entity, final Long entityId, final Long productId, final JsonArray datatableDatas) { final AppUser user = this.context.authenticatedUser(); boolean isMakerCheckerEnabled = false; @@ -237,7 +235,6 @@ public boolean saveDatatables(final Long status, final String entity, final Long @Transactional @Override public CommandProcessingResult deleteCheck(final Long entityDatatableCheckId) { - final EntityDatatableChecks check = this.entityDatatableChecksRepository.findById(entityDatatableCheckId) .orElseThrow(() -> new EntityDatatableChecksNotFoundException(entityDatatableCheckId)); @@ -265,9 +262,9 @@ private void handleReportDataIntegrityIssues(final JsonCommand command, final Th msgArgs = new Object[] { datatableName, dae }; } else if (checkEx.getMessage().contains("unique_entity_check")) { final String datatableName = command.stringValueOfParameterNamed("datatableName"); - final long status = command.longValueOfParameterNamed("status"); + final Integer status = command.integerValueSansLocaleOfParameterNamed("status"); final String entity = command.stringValueOfParameterNamed("entity"); - final long productId = command.longValueOfParameterNamed("productId"); + final Long productId = command.longValueOfParameterNamed("productId"); throw new EntityDatatableCheckAlreadyExistsException(entity, status, datatableName, productId); } else { msgCode += ".unknown.data.integrity.issue"; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java index 13906e92260..7f747b78e72 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientReadPlatformServiceImpl.java @@ -155,8 +155,8 @@ public ClientData retrieveTemplate(final Long officeId, final boolean staffInSel final List clientLegalFormOptions = ClientEnumerations.legalForm(LegalForm.values()); - final List datatableTemplates = this.entityDatatableChecksReadService - .retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.CLIENT.getName(), null); + final List datatableTemplates = this.entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(), + EntityTables.CLIENT.getName(), null); return ClientData.template(defaultOfficeId, LocalDate.now(DateUtils.getDateTimeZoneOfTenant()), offices, staffOptions, null, genderOptions, savingsProductDatas, clientTypeOptions, clientClassificationOptions, clientNonPersonConstitutionOptions, diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java index 5f98977437c..74b53fd87b9 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/service/ClientWritePlatformServiceJpaRepositoryImpl.java @@ -324,14 +324,13 @@ public CommandProcessingResult createClient(final JsonCommand command) { } if (command.parameterExists(ClientApiConstants.datatables)) { - this.entityDatatableChecksWritePlatformService.saveDatatables(StatusEnum.CREATE.getCode().longValue(), - EntityTables.CLIENT.getName(), newClient.getId(), null, - command.arrayOfParameterNamed(ClientApiConstants.datatables)); + this.entityDatatableChecksWritePlatformService.saveDatatables(StatusEnum.CREATE.getValue(), EntityTables.CLIENT.getName(), + newClient.getId(), null, command.arrayOfParameterNamed(ClientApiConstants.datatables)); } legalForm = LegalForm.fromInt(newClient.getLegalForm()); entityDatatableChecksWritePlatformService.runTheCheck(newClient.getId(), EntityTables.CLIENT.getName(), - StatusEnum.CREATE.getCode(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(), legalForm.getLabel()); + StatusEnum.CREATE.getValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(), legalForm.getLabel()); businessEventNotifierService.notifyPostBusinessEvent(new ClientCreateBusinessEvent(newClient)); if (newClient.isActive()) { businessEventNotifierService.notifyPostBusinessEvent(new ClientActivateBusinessEvent(newClient)); @@ -856,7 +855,7 @@ public CommandProcessingResult closeClient(final Long clientId, final JsonComman closureDate, client.getActivationDate()); } final LegalForm legalForm = LegalForm.fromInt(client.getLegalForm()); - entityDatatableChecksWritePlatformService.runTheCheck(clientId, EntityTables.CLIENT.getName(), StatusEnum.CLOSE.getCode(), + entityDatatableChecksWritePlatformService.runTheCheck(clientId, EntityTables.CLIENT.getName(), StatusEnum.CLOSE.getValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(), legalForm.getLabel()); final List clientLoans = this.loanRepositoryWrapper.findLoanByClientId(clientId); @@ -955,7 +954,7 @@ private void validateParentGroupRulesBeforeClientActivation(Client client) { private void runEntityDatatableCheck(final Long clientId, final Integer legalFormId) { final LegalForm legalForm = LegalForm.fromInt(legalFormId); - entityDatatableChecksWritePlatformService.runTheCheck(clientId, EntityTables.CLIENT.getName(), StatusEnum.ACTIVATE.getCode(), + entityDatatableChecksWritePlatformService.runTheCheck(clientId, EntityTables.CLIENT.getName(), StatusEnum.ACTIVATE.getValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(), legalForm.getLabel()); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java index 7e4ff0ac38b..3c64e7e0894 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java @@ -139,8 +139,8 @@ public String retrieveTemplate(@Context final UriInfo uriInfo, } final CenterData template = this.centerReadPlatformService.retrieveTemplate(officeId, staffInSelectedOfficeOnly); - final List datatableTemplates = this.entityDatatableChecksReadService - .retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.GROUP.getName(), null); + final List datatableTemplates = this.entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(), + EntityTables.GROUP.getName(), null); template.setDatatables(datatableTemplates); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java index 82608b0f965..3338dd88f7f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java @@ -159,8 +159,8 @@ public String retrieveTemplate(@Context final UriInfo uriInfo, GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS); } - final List datatableTemplates = entityDatatableChecksReadService - .retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.GROUP.getName(), null); + final List datatableTemplates = entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(), + EntityTables.GROUP.getName(), null); if (centerId != null) { final GroupGeneralData centerGroupTemplate = centerReadPlatformService.retrieveCenterGroupTemplate(centerId); centerGroupTemplate.setDatatables(datatableTemplates); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java index cda35f7ccdf..65c1b05844f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/GroupingTypesWritePlatformServiceJpaRepositoryImpl.java @@ -200,13 +200,13 @@ private CommandProcessingResult createGroupingType(final JsonCommand command, fi if (newGroup.isGroup()) { if (command.parameterExists(GroupingTypesApiConstants.datatables)) { - this.entityDatatableChecksWritePlatformService.saveDatatables(StatusEnum.CREATE.getCode().longValue(), + this.entityDatatableChecksWritePlatformService.saveDatatables(StatusEnum.CREATE.getValue(), EntityTables.GROUP.getName(), newGroup.getId(), null, command.arrayOfParameterNamed(GroupingTypesApiConstants.datatables)); } this.entityDatatableChecksWritePlatformService.runTheCheck(newGroup.getId(), EntityTables.GROUP.getName(), - StatusEnum.CREATE.getCode(), EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null); + StatusEnum.CREATE.getValue(), EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null); } return new CommandProcessingResultBuilder() // @@ -322,7 +322,7 @@ private void validateGroupRulesBeforeActivation(final Group group) { if (!isGroupClientCountValid) { throw new GroupMemberCountNotInPermissibleRangeException(group.getId(), minClients, maxClients); } - entityDatatableChecksWritePlatformService.runTheCheck(group.getId(), EntityTables.GROUP.getName(), StatusEnum.ACTIVATE.getCode(), + entityDatatableChecksWritePlatformService.runTheCheck(group.getId(), EntityTables.GROUP.getName(), StatusEnum.ACTIVATE.getValue(), EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null); } @@ -594,7 +594,7 @@ public CommandProcessingResult closeGroup(final Long groupId, final JsonCommand validateLoansAndSavingsForGroupOrCenterClose(group, closureDate); - entityDatatableChecksWritePlatformService.runTheCheck(groupId, EntityTables.GROUP.getName(), StatusEnum.CLOSE.getCode(), + entityDatatableChecksWritePlatformService.runTheCheck(groupId, EntityTables.GROUP.getName(), StatusEnum.CLOSE.getValue(), EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null); group.close(currentUser, closureReason, closureDate); @@ -669,7 +669,7 @@ public CommandProcessingResult closeCenter(final Long centerId, final JsonComman validateLoansAndSavingsForGroupOrCenterClose(center, closureDate); - entityDatatableChecksWritePlatformService.runTheCheck(centerId, EntityTables.GROUP.getName(), StatusEnum.ACTIVATE.getCode(), + entityDatatableChecksWritePlatformService.runTheCheck(centerId, EntityTables.GROUP.getName(), StatusEnum.ACTIVATE.getValue(), EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null); center.close(currentUser, closureReason, closureDate); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java index 684f458a6f1..8fd7316cb22 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java @@ -414,8 +414,8 @@ public String template(@QueryParam("clientId") @Parameter(description = "clientI newLoanAccount = LoanAccountData.associationsAndTemplate(newLoanAccount, productOptions, allowedLoanOfficers, calendarOptions, accountLinkingOptions, isRatesEnabled); } - final List datatableTemplates = this.entityDatatableChecksReadService - .retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.LOAN.getName(), productId); + final List datatableTemplates = this.entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(), + EntityTables.LOAN.getName(), productId); newLoanAccount.setDatatables(datatableTemplates); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationValidator.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationValidator.java index 0d21be1cc50..c908df94aed 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationValidator.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationValidator.java @@ -2004,7 +2004,7 @@ public void validateApproval(JsonCommand command, Long loanId) { } entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), - StatusEnum.APPROVE.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); + StatusEnum.APPROVE.getValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); if (loan.isTopup() && loan.getClientId() != null) { validateTopupLoan(loan, expectedDisbursementDate); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java index b61f0357696..783873b2086 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java @@ -153,15 +153,14 @@ public CommandProcessingResult submitApplication(final JsonCommand command) { createSavingsAccountAssociation(savingsAccountId, loan); // Save related datatable entries if (command.parameterExists(LoanApiConstants.datatables)) { - this.entityDatatableChecksWritePlatformService.saveDatatables(StatusEnum.CREATE.getCode().longValue(), - EntityTables.LOAN.getName(), loan.getId(), loan.productId(), - command.arrayOfParameterNamed(LoanApiConstants.datatables)); + this.entityDatatableChecksWritePlatformService.saveDatatables(StatusEnum.CREATE.getValue(), EntityTables.LOAN.getName(), + loan.getId(), loan.productId(), command.arrayOfParameterNamed(LoanApiConstants.datatables)); } // TODO: review whether we really need this loanRepositoryWrapper.flush(); // Check mandatory datatable entries were created this.entityDatatableChecksWritePlatformService.runTheCheckForProduct(loan.getId(), EntityTables.LOAN.getName(), - StatusEnum.CREATE.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); + StatusEnum.CREATE.getValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); // Trigger business event businessEventNotifierService.notifyPostBusinessEvent(new LoanCreatedBusinessEvent(loan)); // Building response @@ -691,8 +690,8 @@ public CommandProcessingResult rejectApplication(final Long loanId, final JsonCo loanApplicationTransitionValidator.validateRejection(command, loan); // check for mandatory entities - entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), - StatusEnum.REJECTED.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); + entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), StatusEnum.REJECTED.getValue(), + EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); // loan application rejection final AppUser currentUser = getAppUserIfPresent(); @@ -730,7 +729,7 @@ public CommandProcessingResult applicantWithdrawsFromApplication(final Long loan // check for mandatory entities entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), - StatusEnum.WITHDRAWN.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); + StatusEnum.WITHDRAWN.getValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); // loan application withdrawal final AppUser currentUser = getAppUserIfPresent(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java index 590d66d26a2..2eaa893db50 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java @@ -362,8 +362,8 @@ public CommandProcessingResult disburseLoan(final Long loanId, final JsonCommand final LocalDate nextPossibleRepaymentDate = loan.getNextPossibleRepaymentDateForRescheduling(); final LocalDate rescheduledRepaymentDate = command.localDateValueOfParameterNamed("adjustRepaymentDate"); - entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), - StatusEnum.DISBURSE.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); + entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), StatusEnum.DISBURSE.getValue(), + EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); LocalDate recalculateFrom = null; if (!loan.isMultiDisburmentLoan()) { @@ -1786,7 +1786,7 @@ public CommandProcessingResult writeOff(final Long loanId, final JsonCommand com } businessEventNotifierService.notifyPreBusinessEvent(new LoanWrittenOffPreBusinessEvent(loan)); entityDatatableChecksWritePlatformService.runTheCheckForProduct(loanId, EntityTables.LOAN.getName(), - StatusEnum.WRITE_OFF.getCode().longValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); + StatusEnum.WRITE_OFF.getValue(), EntityTables.LOAN.getForeignKeyColumnNameOnDatatable(), loan.productId()); removeLoanCycle(loan); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java index 9c2d1763800..27a77f4ef30 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java @@ -247,8 +247,6 @@ private CommandWrapper getResourceDetails(final NoteType type, final Long resour } default -> resourceNameForPermissions = INVALIDNOTE; } - return resourceDetails.withEntityName(resourceNameForPermissions).build(); } - } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/service/NoteEnumerations.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/service/NoteEnumerations.java deleted file mode 100644 index 6661f096e87..00000000000 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/service/NoteEnumerations.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * 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.portfolio.note.service; - -import org.apache.fineract.infrastructure.core.data.EnumOptionData; -import org.apache.fineract.portfolio.note.domain.NoteType; - -public final class NoteEnumerations { - - private NoteEnumerations() { - - } - - public static EnumOptionData noteType(final Integer id) { - return noteType(NoteType.fromInt(id)); - } - - public static EnumOptionData noteType(final NoteType type) { - EnumOptionData optionData = null; - switch (type) { - case CLIENT: - optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), "Client note"); - break; - case LOAN: - optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), "Loan note"); - break; - case LOAN_TRANSACTION: - optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), "Loan transaction note"); - break; - case SAVING_ACCOUNT: - optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), "Saving account note"); - break; - case GROUP: - optionData = new EnumOptionData(type.getValue().longValue(), type.getCode(), "Group note"); - break; - default: - break; - - } - return optionData; - } - -} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/service/NoteReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/service/NoteReadPlatformServiceImpl.java index 29bc1422675..99217482f41 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/service/NoteReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/service/NoteReadPlatformServiceImpl.java @@ -61,12 +61,8 @@ public NoteData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int final Long groupId = JdbcSupport.getLong(rs, "groupId"); final Long loanId = JdbcSupport.getLong(rs, "loanId"); final Long transactionId = JdbcSupport.getLong(rs, "transactionId"); - // final Long depositAccountId = JdbcSupport.getLong(rs, - // "depositAccountId"); - // final Long savingAccountId = JdbcSupport.getLong(rs, - // "savingAccountId"); final Integer noteTypeId = JdbcSupport.getInteger(rs, "noteTypeEnum"); - final EnumOptionData noteType = NoteEnumerations.noteType(noteTypeId); + final EnumOptionData noteType = NoteType.toEnumOptionData(noteTypeId); final String note = rs.getString("note"); final OffsetDateTime createdDateLocal = JdbcSupport.getOffsetDateTime(rs, "createdDate"); final OffsetDateTime createdDateUtc = JdbcSupport.getOffsetDateTime(rs, "createdDateUtc"); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java index f40ca425140..7480918b3e9 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java @@ -1154,8 +1154,8 @@ public SavingsAccountData retrieveTemplate(final Long clientId, final Long group charges, chargeOptions); } - final List datatableTemplates = this.entityDatatableChecksReadService - .retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.SAVINGS.getName(), productId); + final List datatableTemplates = this.entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(), + EntityTables.SAVINGS.getName(), productId); template.setDatatables(datatableTemplates); return template; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java index bb7aaf80dd7..76b34916bbf 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountWritePlatformServiceJpaRepositoryImpl.java @@ -208,7 +208,7 @@ public CommandProcessingResult activate(final Long savingsId, final JsonCommand final Map changes = account.activate(user, command); entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVINGS.getName(), - StatusEnum.ACTIVATE.getCode().longValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), account.productId()); + StatusEnum.ACTIVATE.getValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), account.productId()); if (!changes.isEmpty()) { final Locale locale = command.extractLocale(); @@ -904,7 +904,7 @@ public CommandProcessingResult close(final Long savingsId, final JsonCommand com } entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVINGS.getName(), - StatusEnum.CLOSE.getCode().longValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), account.productId()); + StatusEnum.CLOSE.getValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), account.productId()); final boolean isWithdrawBalance = command.booleanPrimitiveValueOfParameterNamed(withdrawBalanceParamName); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl.java index 06881b00550..2645cfccae5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl.java @@ -226,13 +226,11 @@ public CommandProcessingResult submitApplication(final JsonCommand command) { // end of gsim final Long savingsId = account.getId(); if (command.parameterExists(SavingsApiConstants.datatables)) { - this.entityDatatableChecksWritePlatformService.saveDatatables(StatusEnum.CREATE.getCode().longValue(), - EntityTables.SAVINGS.getName(), savingsId, account.productId(), - command.arrayOfParameterNamed(SavingsApiConstants.datatables)); + this.entityDatatableChecksWritePlatformService.saveDatatables(StatusEnum.CREATE.getValue(), EntityTables.SAVINGS.getName(), + savingsId, account.productId(), command.arrayOfParameterNamed(SavingsApiConstants.datatables)); } this.entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVINGS.getName(), - StatusEnum.CREATE.getCode().longValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), - account.productId()); + StatusEnum.CREATE.getValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), account.productId()); businessEventNotifierService.notifyPostBusinessEvent(new SavingsCreateBusinessEvent(account)); @@ -447,8 +445,7 @@ public CommandProcessingResult approveApplication(final Long savingsId, final Js checkClientOrGroupActive(savingsAccount); entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVINGS.getName(), - StatusEnum.APPROVE.getCode().longValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), - savingsAccount.productId()); + StatusEnum.APPROVE.getValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), savingsAccount.productId()); final Map changes = savingsAccount.approveApplication(currentUser, command); if (!changes.isEmpty()) { @@ -570,8 +567,7 @@ public CommandProcessingResult rejectApplication(final Long savingsId, final Jso checkClientOrGroupActive(savingsAccount); entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVINGS.getName(), - StatusEnum.REJECTED.getCode().longValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), - savingsAccount.productId()); + StatusEnum.REJECTED.getValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), savingsAccount.productId()); final Map changes = savingsAccount.rejectApplication(currentUser, command); if (!changes.isEmpty()) { @@ -607,8 +603,7 @@ public CommandProcessingResult applicantWithdrawsFromApplication(final Long savi checkClientOrGroupActive(savingsAccount); entityDatatableChecksWritePlatformService.runTheCheckForProduct(savingsId, EntityTables.SAVINGS.getName(), - StatusEnum.WITHDRAWN.getCode().longValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), - savingsAccount.productId()); + StatusEnum.WITHDRAWN.getValue(), EntityTables.SAVINGS.getForeignKeyColumnNameOnDatatable(), savingsAccount.productId()); final Map changes = savingsAccount.applicantWithdrawsFromApplication(currentUser, command); if (!changes.isEmpty()) {