FINERACT-2081: Support for string type primary keys - refactor existing enums

This commit is contained in:
Marta Jankovics
2024-06-26 17:08:24 +02:00
committed by Adam Saghy
parent 009e9ded01
commit b482fbd447
31 changed files with 169 additions and 261 deletions
@@ -20,16 +20,21 @@ package org.apache.fineract.accounting.common;
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<Integer, AccountingRuleType> intToEnumMap = new HashMap<>();
@@ -44,21 +49,22 @@ public enum AccountingRuleType {
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());
}
}
@@ -130,7 +130,7 @@ public enum EntityTables {
@NotNull
public static List<Integer> getCheckStatusCodes(String name) {
return getCheckStatuses(name).stream().map(StatusEnum::getCode).toList();
return getCheckStatuses(name).stream().map(StatusEnum::getValue).toList();
}
@NotNull
@@ -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<Integer, StatusEnum> BY_ID = Arrays.stream(VALUES).collect(Collectors.toMap(StatusEnum::getValue, v -> v));
public Integer getCode() {
return code;
private final String code;
private final Integer value;
public Integer getValue() {
return value;
}
StatusEnum(String name, Integer code) {
this.name = name;
StatusEnum(String code, Integer value) {
this.code = code;
this.value = value;
}
public static List<DatatableCheckStatusData> getStatusList() {
List<DatatableCheckStatusData> data = new ArrayList<DatatableCheckStatusData>();
for (StatusEnum status : StatusEnum.values()) {
data.add(new DatatableCheckStatusData(status.name, status.code));
}
return data;
public static StatusEnum fromInt(final Integer value) {
return BY_ID.get(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 EnumOptionData toEnumOptionData(final Integer id) {
return toEnumOptionData(StatusEnum.fromInt(id));
}
public static EnumOptionData statusTypeEnum(final Integer id) {
return statusType(StatusEnum.fromInt(id));
public static EnumOptionData toEnumOptionData(final StatusEnum statusType) {
return statusType == null ? null : statusType.toEnumOptionData();
}
public static EnumOptionData statusType(final StatusEnum statusType) {
final EnumOptionData optionData = new EnumOptionData(statusType.getCode().longValue(), statusType.name(), statusType.name());
return optionData;
public EnumOptionData toEnumOptionData() {
return new EnumOptionData(getValue().longValue(), code, name());
}
}
@@ -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;
@@ -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 enum TransactionEntryType {
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());
}
}
@@ -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;
@@ -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 enum AccountType {
return accountType;
}
public static List<EnumOptionData> toEnumOptionData() {
return Arrays.stream(values()).sequential().map(AccountEnumerations::loanType).toList();
}
public Integer getValue() {
return this.value;
}
@@ -75,6 +75,14 @@ public enum NoteType {
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());
}
@@ -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,
@@ -41,7 +41,7 @@ public class EntityDatatableChecks extends AbstractPersistableCustom<Long> {
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<Long> {
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;
}
}
@@ -41,20 +41,20 @@ public interface EntityDatatableChecksRepository
@Param("subtype") String subtype);
@Query("select t from EntityDatatableChecks t WHERE t.status =:status and t.entity=:entity and t.productId = :productId ")
List<EntityDatatableChecks> findByEntityStatusAndProduct(@Param("entity") String entity, @Param("status") Long status,
List<EntityDatatableChecks> 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<EntityDatatableChecks> findByEntityStatusAndNoProduct(@Param("entity") String entity, @Param("status") Long status);
List<EntityDatatableChecks> 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<EntityDatatableChecks> 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<EntityDatatableChecks> findByEntityStatusAndDatatableIdAndNoProduct(@Param("entity") String entityName,
@Param("status") Long status, @Param("datatableName") String datatableName);
@Param("status") Integer status, @Param("datatableName") String datatableName);
}
@@ -25,16 +25,16 @@ import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainR
*/
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);
}
}
@@ -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 class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
}
@Override
public Page<EntityDataTableChecksData> retrieveAll(SearchParameters searchParameters, final Long status, final String entity,
final Long productId) {
public Page<EntityDataTableChecksData> 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 class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
}
@Override
public List<DatatableData> retrieveTemplates(final Long status, final String entity, final Long productId) {
public List<DatatableData> retrieveTemplates(final Integer status, final String entity, final Long productId) {
List<EntityDatatableChecks> tableRequiredBeforeAction = null;
if (productId != null) {
tableRequiredBeforeAction = this.entityDatatableChecksRepository.findByEntityStatusAndProduct(entity, status, productId);
@@ -162,7 +161,7 @@ public class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
List<DatatableCheckStatusData> 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 @@ public class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
@Override
public EntityDataTableChecksData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
final Long id = JdbcSupport.getLong(rs, "id");
final String entity = rs.getString("entity");
final Long status = rs.getLong("status");
EnumOptionData statusEnum = null;
if (status != null) {
statusEnum = StatusEnum.statusTypeEnum(status.intValue());
}
final int status = rs.getInt("status");
EnumOptionData statusEnum = StatusEnum.toEnumOptionData(status);
final String datatableName = rs.getString("datatableName");
final boolean systemDefined = rs.getBoolean("systemDefined");
final Long productId = JdbcSupport.getLong(rs, "productId");
@@ -222,5 +217,4 @@ public class EntityDatatableChecksReadPlatformServiceImpl implements EntityDatat
+ "left join m_savings_product sp on sp.id = t.product_id and t.application_table_name = 'm_savings_account' ";
}
}
}
@@ -29,8 +29,7 @@ public interface EntityDatatableChecksReadService {
EntityDataTableChecksTemplateData retrieveTemplate();
List<DatatableData> retrieveTemplates(Long status, String entity, Long productId);
Page<EntityDataTableChecksData> retrieveAll(SearchParameters searchParameters, Long status, String entity, Long productLoanId);
List<DatatableData> retrieveTemplates(Integer status, String entity, Long productId);
Page<EntityDataTableChecksData> retrieveAll(SearchParameters searchParameters, Integer status, String entity, Long productId);
}
@@ -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);
}
@@ -94,9 +94,9 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
}
final Long productId = command.longValueOfParameterNamed("productId");
final Long status = command.longValueOfParameterNamed("status");
final Integer status = command.integerValueSansLocaleOfParameterNamed("status");
List<EntityDatatableChecks> entityDatatableCheck = null;
List<EntityDatatableChecks> entityDatatableCheck;
if (productId == null) {
entityDatatableCheck = this.entityDatatableChecksRepository.findByEntityStatusAndDatatableIdAndNoProduct(entity, status,
datatableName);
@@ -139,13 +139,13 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
}
@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<EntityDatatableChecks> 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 class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
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<EntityDatatableChecks> 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<String> reqDatatables = new ArrayList<>();
@@ -194,12 +193,11 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
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 class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
@Transactional
@Override
public CommandProcessingResult deleteCheck(final Long entityDatatableCheckId) {
final EntityDatatableChecks check = this.entityDatatableChecksRepository.findById(entityDatatableCheckId)
.orElseThrow(() -> new EntityDatatableChecksNotFoundException(entityDatatableCheckId));
@@ -265,9 +262,9 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
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";
@@ -155,8 +155,8 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
final List<EnumOptionData> clientLegalFormOptions = ClientEnumerations.legalForm(LegalForm.values());
final List<DatatableData> datatableTemplates = this.entityDatatableChecksReadService
.retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.CLIENT.getName(), null);
final List<DatatableData> 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,
@@ -324,14 +324,13 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
}
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 class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
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<Loan> clientLoans = this.loanRepositoryWrapper.findLoanByClientId(clientId);
@@ -955,7 +954,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
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());
}
@@ -139,8 +139,8 @@ public class CentersApiResource {
}
final CenterData template = this.centerReadPlatformService.retrieveTemplate(officeId, staffInSelectedOfficeOnly);
final List<DatatableData> datatableTemplates = this.entityDatatableChecksReadService
.retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.GROUP.getName(), null);
final List<DatatableData> datatableTemplates = this.entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(),
EntityTables.GROUP.getName(), null);
template.setDatatables(datatableTemplates);
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
@@ -159,8 +159,8 @@ public class GroupsApiResource {
GroupingTypesApiConstants.GROUP_RESPONSE_DATA_PARAMETERS);
}
final List<DatatableData> datatableTemplates = entityDatatableChecksReadService
.retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.GROUP.getName(), null);
final List<DatatableData> datatableTemplates = entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(),
EntityTables.GROUP.getName(), null);
if (centerId != null) {
final GroupGeneralData centerGroupTemplate = centerReadPlatformService.retrieveCenterGroupTemplate(centerId);
centerGroupTemplate.setDatatables(datatableTemplates);
@@ -200,13 +200,13 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
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 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements 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 class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
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 class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
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);
@@ -414,8 +414,8 @@ public class LoansApiResource {
newLoanAccount = LoanAccountData.associationsAndTemplate(newLoanAccount, productOptions, allowedLoanOfficers, calendarOptions,
accountLinkingOptions, isRatesEnabled);
}
final List<DatatableData> datatableTemplates = this.entityDatatableChecksReadService
.retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.LOAN.getName(), productId);
final List<DatatableData> datatableTemplates = this.entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(),
EntityTables.LOAN.getName(), productId);
newLoanAccount.setDatatables(datatableTemplates);
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
@@ -2004,7 +2004,7 @@ public final class LoanApplicationValidator {
}
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);
@@ -153,15 +153,14 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
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 class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
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 class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
// 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();
@@ -362,8 +362,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
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 class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
}
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);
@@ -247,8 +247,6 @@ public class NotesApiResource {
}
default -> resourceNameForPermissions = INVALIDNOTE;
}
return resourceDetails.withEntityName(resourceNameForPermissions).build();
}
}
@@ -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;
}
}
@@ -61,12 +61,8 @@ public class NoteReadPlatformServiceImpl implements NoteReadPlatformService {
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");
@@ -1154,8 +1154,8 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
charges, chargeOptions);
}
final List<DatatableData> datatableTemplates = this.entityDatatableChecksReadService
.retrieveTemplates(StatusEnum.CREATE.getCode().longValue(), EntityTables.SAVINGS.getName(), productId);
final List<DatatableData> datatableTemplates = this.entityDatatableChecksReadService.retrieveTemplates(StatusEnum.CREATE.getValue(),
EntityTables.SAVINGS.getName(), productId);
template.setDatatables(datatableTemplates);
return template;
@@ -208,7 +208,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
final Map<String, Object> 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 class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
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);
@@ -226,13 +226,11 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
// 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 class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
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<String, Object> changes = savingsAccount.approveApplication(currentUser, command);
if (!changes.isEmpty()) {
@@ -570,8 +567,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
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<String, Object> changes = savingsAccount.rejectApplication(currentUser, command);
if (!changes.isEmpty()) {
@@ -607,8 +603,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
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<String, Object> changes = savingsAccount.applicantWithdrawsFromApplication(currentUser, command);
if (!changes.isEmpty()) {