This is an automated email from the ASF dual-hosted git repository.
arnold pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new 804bdc28b Create client with datatable subentity type
804bdc28b is described below
commit 804bdc28b9ede9cb20ee3cfecb78b66e2362672e
Author: Jose Alberto Hernandez <[email protected]>
AuthorDate: Mon Nov 21 22:58:16 2022 -0600
Create client with datatable subentity type
---
.../bulkimport/api/BulkImportApiResource.java | 2 +-
.../bulkimport/data/GlobalEntityType.java | 2 +-
.../service/BulkImportEventListener.java | 2 +-
.../BulkImportWorkbookPopulatorServiceImpl.java | 4 +-
.../service/BulkImportWorkbookServiceImpl.java | 4 +-
.../api/EntityDatatableChecksApiResource.java | 21 +-----
.../dataqueries/domain/EntityDatatableChecks.java | 34 ++--------
.../domain/EntityDatatableChecksRepository.java | 12 +++-
.../dataqueries/domain/RegisteredDatatable.java | 50 +++++++++++++++
.../RegisteredDatatableRepository.java} | 20 ++----
.../EntityDatatableChecksWritePlatformService.java | 2 +-
...ityDatatableChecksWritePlatformServiceImpl.java | 47 +++++---------
.../TellerManagementReadPlatformServiceImpl.java | 30 ---------
.../portfolio/client/domain/LegalForm.java | 24 +++----
...lientWritePlatformServiceJpaRepositoryImpl.java | 68 +++++---------------
.../service/CenterReadPlatformServiceImpl.java | 4 --
...TypesWritePlatformServiceJpaRepositoryImpl.java | 14 ++--
.../client/ClientEntityImportHandlerTest.java | 2 +-
.../client/ClientEntityWorkbookPopulatorTest.java | 2 +-
.../integrationtests/common/ClientHelper.java | 31 ++++++++-
.../fineract/integrationtests/common/Utils.java | 1 +
.../organisation/EntityDatatableChecksHelper.java | 12 ++++
.../EntityDatatableChecksIntegrationTest.java | 74 ++++++++++++++++++++++
23 files changed, 253 insertions(+), 209 deletions(-)
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/api/BulkImportApiResource.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/api/BulkImportApiResource.java
index bf18b74a7..a2a5cb7ac 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/api/BulkImportApiResource.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/api/BulkImportApiResource.java
@@ -73,7 +73,7 @@ public class BulkImportApiResource {
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
Collection<ImportData> importData = new ArrayList<>();
if (entityType.equals(GlobalEntityType.CLIENT.getCode())) {
- final Collection<ImportData> importForClientEntity =
this.bulkImportWorkbookService.getImports(GlobalEntityType.CLIENTS_ENTTTY);
+ final Collection<ImportData> importForClientEntity =
this.bulkImportWorkbookService.getImports(GlobalEntityType.CLIENTS_ENTITY);
final Collection<ImportData> importForClientPerson =
this.bulkImportWorkbookService.getImports(GlobalEntityType.CLIENTS_PERSON);
if (importForClientEntity != null) {
importData.addAll(importForClientEntity);
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/data/GlobalEntityType.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/data/GlobalEntityType.java
index cab690cac..6f2fa8fbc 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/data/GlobalEntityType.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/data/GlobalEntityType.java
@@ -23,7 +23,7 @@ import java.util.Map;
public enum GlobalEntityType {
- INVALID(0, "invalid"), CLIENTS_PERSON(1, "clients.person"),
CLIENTS_ENTTTY(2, "clients.entity"), GROUPS(3, "groups"), CENTERS(4,
+ INVALID(0, "invalid"), CLIENTS_PERSON(1, "clients.person"),
CLIENTS_ENTITY(2, "clients.entity"), GROUPS(3, "groups"), CENTERS(4,
"centers"), OFFICES(5, "offices"), STAFF(6, "staff"), USERS(7,
"users"), SMS(8, "sms"), DOCUMENTS(9, "documents"), TEMPLATES(10,
"templates"), NOTES(11, "templates"), CALENDAR(12,
"calendar"), MEETINGS(13, "meetings"), HOLIDAYS(14,
"holidays"), LOANS(15, "loans"), LOAN_PRODUCTS(16,
"loancharges"), LOAN_TRANSACTIONS(18,
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportEventListener.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportEventListener.java
index 595834b13..a82b7fedf 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportEventListener.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportEventListener.java
@@ -80,7 +80,7 @@ public class BulkImportEventListener implements
ApplicationListener<BulkImportEv
case CHART_OF_ACCOUNTS:
importHandler =
this.applicationContext.getBean("chartOfAccountsImportHandler",
ImportHandler.class);
break;
- case CLIENTS_ENTTTY:
+ case CLIENTS_ENTITY:
importHandler =
this.applicationContext.getBean("clientEntityImportHandler",
ImportHandler.class);
break;
case CLIENTS_PERSON:
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookPopulatorServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookPopulatorServiceImpl.java
index a636bbdb4..2458fb495 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookPopulatorServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookPopulatorServiceImpl.java
@@ -180,7 +180,7 @@ public class BulkImportWorkbookPopulatorServiceImpl
implements BulkImportWorkboo
final Workbook workbook = new HSSFWorkbook();
if (entityType != null) {
if
(entityType.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_PERSON.toString())
- ||
entityType.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_ENTTTY.toString()))
{
+ ||
entityType.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_ENTITY.toString()))
{
populator = populateClientWorkbook(entityType, officeId,
staffId);
} else if
(entityType.trim().equalsIgnoreCase(GlobalEntityType.CENTERS.toString())) {
populator = populateCenterWorkbook(officeId, staffId);
@@ -241,7 +241,7 @@ public class BulkImportWorkbookPopulatorServiceImpl
implements BulkImportWorkboo
return new ClientPersonWorkbookPopulator(new
OfficeSheetPopulator(offices), new PersonnelSheetPopulator(staff, offices),
clientTypeCodeValues, genderCodeValues,
clientClassification, addressTypesCodeValues, stateProvinceCodeValues,
countryCodeValues);
- } else if
(entityType.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_ENTTTY.toString()))
{
+ } else if
(entityType.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_ENTITY.toString()))
{
List<CodeValueData> constitutionCodeValues =
fetchCodeValuesByCodeName("Constitution");
List<CodeValueData> mainBusinessline =
fetchCodeValuesByCodeName("Main Business Line");
return new ClientEntityWorkbookPopulator(new
OfficeSheetPopulator(offices), new PersonnelSheetPopulator(staff, offices),
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookServiceImpl.java
index 26af6968d..5e4bdda42 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/bulkimport/service/BulkImportWorkbookServiceImpl.java
@@ -110,8 +110,8 @@ public class BulkImportWorkbookServiceImpl implements
BulkImportWorkbookService
if
(entity.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_PERSON.toString())) {
entityType = GlobalEntityType.CLIENTS_PERSON;
primaryColumn = 0;
- } else if
(entity.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_ENTTTY.toString())) {
- entityType = GlobalEntityType.CLIENTS_ENTTTY;
+ } else if
(entity.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_ENTITY.toString())) {
+ entityType = GlobalEntityType.CLIENTS_ENTITY;
primaryColumn = 0;
} else if
(entity.trim().equalsIgnoreCase(GlobalEntityType.CENTERS.toString())) {
entityType = GlobalEntityType.CENTERS;
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 0c973fd45..85aa01359 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
@@ -38,6 +38,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
+import lombok.AllArgsConstructor;
import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder;
import
org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
@@ -50,37 +51,19 @@ import
org.apache.fineract.infrastructure.dataqueries.data.EntityDataTableChecks
import
org.apache.fineract.infrastructure.dataqueries.data.EntityDataTableChecksTemplateData;
import
org.apache.fineract.infrastructure.dataqueries.data.GenericResultsetData;
import
org.apache.fineract.infrastructure.dataqueries.service.EntityDatatableChecksReadService;
-import
org.apache.fineract.infrastructure.dataqueries.service.GenericDataService;
-import
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Path("/entityDatatableChecks")
+@AllArgsConstructor
@Component
@Scope("singleton")
@Tag(name = "Entity Data Table", description = "This defines Entity-Datatable
Check.")
public class EntityDatatableChecksApiResource {
- private final PlatformSecurityContext context;
- private final GenericDataService genericDataService;
private final EntityDatatableChecksReadService
readEntityDatatableChecksService;
private final ToApiJsonSerializer<GenericResultsetData>
toApiJsonSerializer;
private final PortfolioCommandSourceWritePlatformService
commandsSourceWritePlatformService;
- private static final org.slf4j.Logger LOG =
LoggerFactory.getLogger(EntityDatatableChecksApiResource.class);
-
- @Autowired
- public EntityDatatableChecksApiResource(final PlatformSecurityContext
context, final GenericDataService genericDataService,
- final EntityDatatableChecksReadService
readEntityDatatableChecksService,
- final ToApiJsonSerializer<GenericResultsetData>
toApiJsonSerializer,
- final PortfolioCommandSourceWritePlatformService
commandsSourceWritePlatformService) {
- this.context = context;
- this.genericDataService = genericDataService;
- this.readEntityDatatableChecksService =
readEntityDatatableChecksService;
- this.toApiJsonSerializer = toApiJsonSerializer;
- this.commandsSourceWritePlatformService =
commandsSourceWritePlatformService;
- }
@GET
@Consumes({ MediaType.APPLICATION_JSON })
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 84ef4eaf6..4d661555e 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
@@ -21,12 +21,17 @@ package
org.apache.fineract.infrastructure.dataqueries.domain;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
+@AllArgsConstructor
+@NoArgsConstructor
+@Getter
@Entity
@Table(name = "m_entity_datatable_check")
-
public class EntityDatatableChecks extends AbstractPersistableCustom {
@Column(name = "application_table_name", nullable = false)
@@ -44,18 +49,6 @@ public class EntityDatatableChecks extends
AbstractPersistableCustom {
@Column(name = "product_id", nullable = true)
private Long productId;
- public EntityDatatableChecks() {}
-
- public EntityDatatableChecks(final String entity, final String
datatableName, final Long status, final boolean systemDefined,
- final Long productId) {
-
- this.entity = entity;
- this.status = status;
- this.datatableName = datatableName;
- this.systemDefined = systemDefined;
- this.productId = productId;
- }
-
public static EntityDatatableChecks fromJson(final JsonCommand command) {
final String entity = command.stringValueOfParameterNamed("entity");
@@ -78,23 +71,8 @@ public class EntityDatatableChecks extends
AbstractPersistableCustom {
}
- public String getEntity() {
- return this.entity;
- }
-
- public Long getStatus() {
- return this.status;
- }
-
- public String getDatatableName() {
- return this.datatableName;
- }
-
public boolean isSystemDefined() {
return this.systemDefined;
}
- public Long getProductId() {
- return productId;
- }
}
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 5b08ae304..fa92b24bd 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
@@ -27,7 +27,17 @@ import org.springframework.data.repository.query.Param;
public interface EntityDatatableChecksRepository
extends JpaRepository<EntityDatatableChecks, Long>,
JpaSpecificationExecutor<EntityDatatableChecks> {
- List<EntityDatatableChecks> findByEntityAndStatus(String entityName, Long
status);
+ List<EntityDatatableChecks> findByEntityAndStatus(String entityName,
Integer status);
+
+ @Query("""
+ SELECT dt
+ FROM EntityDatatableChecks dt
+ INNER JOIN RegisteredDatatable rdt ON rdt.datatableName =
dt.datatableName
+ WHERE dt.entity = :entity
+ AND dt.status = :status
+ AND rdt.subtype = :subtype
+ """)
+ List<EntityDatatableChecks> findByEntityAndStatusAndSubtype(String entity,
Integer status, 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,
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/RegisteredDatatable.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/RegisteredDatatable.java
new file mode 100644
index 000000000..c29d593a6
--- /dev/null
+++
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/RegisteredDatatable.java
@@ -0,0 +1,50 @@
+/**
+ * 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.infrastructure.dataqueries.domain;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Table;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+import
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
+
+@Getter
+@Setter
+@AllArgsConstructor
+@Entity
+@Table(name = "x_registered_table")
+public class RegisteredDatatable extends AbstractPersistableCustom {
+
+ @Column(name = "registered_table_name", nullable = false)
+ private String datatableName;
+
+ @Column(name = "application_table_name", nullable = false)
+ private String entity;
+
+ @Column(name = "entity_subtype", nullable = true)
+ private String subtype;
+
+ @Column(name = "category", nullable = false)
+ private int category;
+
+ public RegisteredDatatable() {}
+
+}
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/domain/RegisteredDatatableRepository.java
similarity index 51%
copy from
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/EntityDatatableChecksWritePlatformService.java
copy to
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/domain/RegisteredDatatableRepository.java
index 0bb309e42..44d0a17f2 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/domain/RegisteredDatatableRepository.java
@@ -16,22 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.fineract.infrastructure.dataqueries.service;
+package org.apache.fineract.infrastructure.dataqueries.domain;
-import com.google.gson.JsonArray;
-import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-public interface EntityDatatableChecksWritePlatformService {
-
- CommandProcessingResult createCheck(JsonCommand command);
-
- CommandProcessingResult deleteCheck(Long entityDatatableCheckId);
-
- void runTheCheck(Long entityId, String entityName, Long statusCode, String
foreignKeyColumn);
-
- void runTheCheckForProduct(Long entityId, String entityName, Long
statusCode, String foreignKeyColumn, long productLoanId);
-
- boolean saveDatatables(Long status, String entity, Long entityId, Long
productId, JsonArray data);
+public interface RegisteredDatatableRepository
+ extends JpaRepository<RegisteredDatatable, Long>,
JpaSpecificationExecutor<RegisteredDatatable> {
}
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 0bb309e42..def42a3b9 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,7 +28,7 @@ public interface EntityDatatableChecksWritePlatformService {
CommandProcessingResult deleteCheck(Long entityDatatableCheckId);
- void runTheCheck(Long entityId, String entityName, Long statusCode, String
foreignKeyColumn);
+ void runTheCheck(Long entityId, String entityName, Integer statusCode,
String foreignKeyColumn, String entitySubtype);
void runTheCheckForProduct(Long entityId, String entityName, Long
statusCode, String foreignKeyColumn, long productLoanId);
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 5e4e7c929..8ea58dcf5 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
@@ -24,6 +24,8 @@ import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.PersistenceException;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import
org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
@@ -46,18 +48,15 @@ import
org.apache.fineract.infrastructure.security.service.PlatformSecurityConte
import
org.apache.fineract.portfolio.loanproduct.service.LoanProductReadPlatformService;
import
org.apache.fineract.portfolio.savings.service.SavingsProductReadPlatformService;
import org.apache.fineract.useradministration.domain.AppUser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+@Slf4j
+@AllArgsConstructor
@Service
public class EntityDatatableChecksWritePlatformServiceImpl implements
EntityDatatableChecksWritePlatformService {
- private static final Logger LOG =
LoggerFactory.getLogger(EntityDatatableChecksWritePlatformServiceImpl.class);
-
private final PlatformSecurityContext context;
private final EntityDatatableChecksDataValidator fromApiJsonDeserializer;
private final EntityDatatableChecksRepository
entityDatatableChecksRepository;
@@ -67,24 +66,6 @@ public class EntityDatatableChecksWritePlatformServiceImpl
implements EntityData
private final FromJsonHelper fromApiJsonHelper;
private final ConfigurationDomainService configurationDomainService;
- @Autowired
- public EntityDatatableChecksWritePlatformServiceImpl(final
PlatformSecurityContext context,
- final EntityDatatableChecksDataValidator fromApiJsonDeserializer,
- final EntityDatatableChecksRepository
entityDatatableChecksRepository,
- final ReadWriteNonCoreDataService readWriteNonCoreDataService,
- final LoanProductReadPlatformService
loanProductReadPlatformService,
- final SavingsProductReadPlatformService
savingsProductReadPlatformService, final FromJsonHelper fromApiJsonHelper,
- final ConfigurationDomainService configurationDomainService) {
- this.context = context;
- this.fromApiJsonDeserializer = fromApiJsonDeserializer;
- this.entityDatatableChecksRepository = entityDatatableChecksRepository;
- this.readWriteNonCoreDataService = readWriteNonCoreDataService;
- this.loanProductReadPlatformService = loanProductReadPlatformService;
- this.savingsProductReadPlatformService =
savingsProductReadPlatformService;
- this.fromApiJsonHelper = fromApiJsonHelper;
- this.configurationDomainService = configurationDomainService;
- }
-
@Transactional
@Override
public CommandProcessingResult createCheck(final JsonCommand command) {
@@ -107,7 +88,7 @@ public class EntityDatatableChecksWritePlatformServiceImpl
implements EntityData
final String foreignKeyColumnName =
EntityTables.getForeignKeyColumnNameOnDatatable(entity);
final boolean columnExist =
datatableData.hasColumn(foreignKeyColumnName);
- LOG.debug("{} has column {} ? {}",
datatableData.getRegisteredTableName(), foreignKeyColumnName, columnExist);
+ log.debug("{} has column {} ? {}",
datatableData.getRegisteredTableName(), foreignKeyColumnName, columnExist);
if (!columnExist) {
throw new
EntityDatatableCheckNotSupportedException(datatableData.getRegisteredTableName(),
entity);
@@ -159,9 +140,15 @@ public class EntityDatatableChecksWritePlatformServiceImpl
implements EntityData
}
@Override
- public void runTheCheck(final Long entityId, final String entityName,
final Long statusCode, String foreignKeyColumn) {
- final List<EntityDatatableChecks> tableRequiredBeforeClientActivation
= entityDatatableChecksRepository
- .findByEntityAndStatus(entityName, statusCode);
+ public void runTheCheck(final Long entityId, final String entityName,
final Integer statusCode, String foreignKeyColumn,
+ final String entitySubtype) {
+ List<EntityDatatableChecks> tableRequiredBeforeClientActivation;
+ if (entitySubtype == null) {
+ tableRequiredBeforeClientActivation =
entityDatatableChecksRepository.findByEntityAndStatus(entityName, statusCode);
+ } else {
+ tableRequiredBeforeClientActivation =
entityDatatableChecksRepository.findByEntityAndStatusAndSubtype(entityName,
statusCode,
+ entitySubtype.toUpperCase());
+ }
if (tableRequiredBeforeClientActivation != null) {
List<String> reqDatatables = new ArrayList<>();
@@ -170,7 +157,7 @@ public class EntityDatatableChecksWritePlatformServiceImpl
implements EntityData
final String datatableName = t.getDatatableName();
final Long countEntries =
readWriteNonCoreDataService.countDatatableEntries(datatableName, entityId,
foreignKeyColumn);
- LOG.debug("The are {} entries in the table {}", countEntries,
datatableName);
+ log.debug("The are {} entries in the table {}", countEntries,
datatableName);
if (countEntries.intValue() == 0) {
reqDatatables.add(datatableName);
}
@@ -199,7 +186,7 @@ public class EntityDatatableChecksWritePlatformServiceImpl
implements EntityData
final String datatableName = t.getDatatableName();
final Long countEntries =
readWriteNonCoreDataService.countDatatableEntries(datatableName, entityId,
foreignKeyColumn);
- LOG.debug("The are {} entries in the table {}", countEntries,
datatableName);
+ log.debug("The are {} entries in the table {}", countEntries,
datatableName);
if (countEntries.intValue() == 0) {
reqDatatables.add(datatableName);
}
@@ -281,7 +268,7 @@ public class EntityDatatableChecksWritePlatformServiceImpl
implements EntityData
throw new EntityDatatableCheckAlreadyExistsException(entity,
status, datatableName, productId);
}
- LOG.error("Error occured.", dae);
+ log.error("Error occured.", dae);
throw new
PlatformDataIntegrityException("error.msg.report.unknown.data.integrity.issue",
"Unknown data integrity issue with resource: " +
realCause.getMessage());
}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java
index da4cabcff..0a40087b4 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/organisation/teller/service/TellerManagementReadPlatformServiceImpl.java
@@ -66,7 +66,6 @@ public class TellerManagementReadPlatformServiceImpl
implements TellerManagement
private final JdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context;
private final TellerLookupMapper lookupMapper = new TellerLookupMapper();
- private final TellerInOfficeHierarchyMapper tellerInOfficeHierarchyMapper
= new TellerInOfficeHierarchyMapper();
private final OfficeReadPlatformService officeReadPlatformService;
private final StaffReadPlatformService staffReadPlatformService;
private final CurrencyReadPlatformService currencyReadPlatformService;
@@ -113,33 +112,6 @@ public class TellerManagementReadPlatformServiceImpl
implements TellerManagement
}
}
- private static final class TellerInOfficeHierarchyMapper implements
RowMapper<TellerData> {
-
- @Override
- public TellerData mapRow(final ResultSet rs, final int rowNum) throws
SQLException {
-
- final Long id = rs.getLong("id");
- final String tellerName = rs.getString("teller_name");
- final String description = rs.getString("description");
- final String officeName = rs.getString("office_name");
- final Long officeId = rs.getLong("office_id");
- TellerStatus tellerStatus = null;
- final Integer status = rs.getInt("status");
- if (status != null) {
- tellerStatus = TellerStatus.fromInt(status);
- }
- final Long debitAccountId = rs.getLong("debit_account_id");
- final Long creditAccountId = rs.getLong("credit_account_id");
-
- final LocalDate startDate = JdbcSupport.getLocalDate(rs,
"start_date");
- final LocalDate endDate = JdbcSupport.getLocalDate(rs, "end_date");
-
- return TellerData.instance(id, officeId, debitAccountId,
creditAccountId, tellerName, description, startDate, endDate,
- tellerStatus, officeName, null, null);
-
- }
- }
-
private static final class TellerLookupMapper implements
RowMapper<TellerData> {
private final String schemaSql;
@@ -378,8 +350,6 @@ public class TellerManagementReadPlatformServiceImpl
implements TellerManagement
tellerName = tellerData.getName();
}
- final Collection<OfficeData> offices =
this.officeReadPlatformService.retrieveAllOfficesForDropdown();
-
Collection<StaffData> staffOptions = null;
final boolean loanOfficersOnly = false;
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/LegalForm.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/LegalForm.java
index bd29d5741..3415ec9da 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/LegalForm.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/domain/LegalForm.java
@@ -18,29 +18,26 @@
*/
package org.apache.fineract.portfolio.client.domain;
+import lombok.Getter;
+
/**
* Type used to differentiate the type of client
*/
+@Getter
public enum LegalForm {
- PERSON(1, "legalFormType.person"),
+ PERSON(1, "legalFormType.person", "Person"),
- ENTITY(2, "legalFormType.entity");
+ ENTITY(2, "legalFormType.entity", "Entity");
private final Integer value;
private final String code;
+ private final String label;
- LegalForm(final Integer value, final String code) {
+ LegalForm(final Integer value, final String code, final String label) {
this.value = value;
this.code = code;
- }
-
- public Integer getValue() {
- return this.value;
- }
-
- public String getCode() {
- return this.code;
+ this.label = label;
}
public static LegalForm fromInt(final Integer type) {
@@ -64,4 +61,9 @@ public enum LegalForm {
public boolean isEntity() {
return this.value.equals(LegalForm.ENTITY.getValue());
}
+
+ @Override
+ public String toString() {
+ return this.label;
+ }
}
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 e7e7740fe..6268e9e74 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
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import javax.persistence.PersistenceException;
+import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.fineract.commands.domain.CommandWrapper;
@@ -86,12 +87,12 @@ import
org.apache.fineract.portfolio.savings.domain.SavingsProductRepository;
import
org.apache.fineract.portfolio.savings.exception.SavingsProductNotFoundException;
import
org.apache.fineract.portfolio.savings.service.SavingsApplicationProcessWritePlatformService;
import org.apache.fineract.useradministration.domain.AppUser;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.orm.jpa.JpaSystemException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+@AllArgsConstructor
@Service
@Slf4j
public class ClientWritePlatformServiceJpaRepositoryImpl implements
ClientWritePlatformService {
@@ -120,47 +121,6 @@ public class ClientWritePlatformServiceJpaRepositoryImpl
implements ClientWriteP
private final BusinessEventNotifierService businessEventNotifierService;
private final EntityDatatableChecksWritePlatformService
entityDatatableChecksWritePlatformService;
- @Autowired
- public ClientWritePlatformServiceJpaRepositoryImpl(final
PlatformSecurityContext context,
- final ClientRepositoryWrapper clientRepository, final
ClientNonPersonRepositoryWrapper clientNonPersonRepository,
- final OfficeRepositoryWrapper officeRepositoryWrapper, final
NoteRepository noteRepository,
- final ClientDataValidator fromApiJsonDeserializer, final
AccountNumberGenerator accountNumberGenerator,
- final GroupRepository groupRepository, final
StaffRepositoryWrapper staffRepository,
- final CodeValueRepositoryWrapper codeValueRepository, final
LoanRepositoryWrapper loanRepositoryWrapper,
- final SavingsAccountRepositoryWrapper savingsRepositoryWrapper,
final SavingsProductRepository savingsProductRepository,
- final SavingsApplicationProcessWritePlatformService
savingsApplicationProcessWritePlatformService,
- final CommandProcessingService commandProcessingService, final
ConfigurationDomainService configurationDomainService,
- final AccountNumberFormatRepositoryWrapper
accountNumberFormatRepository, final FromJsonHelper fromApiJsonHelper,
- final ConfigurationReadPlatformService
configurationReadPlatformService,
- final AddressWritePlatformService addressWritePlatformService,
- final ClientFamilyMembersWritePlatformService
clientFamilyMembersWritePlatformService,
- final BusinessEventNotifierService businessEventNotifierService,
- final EntityDatatableChecksWritePlatformService
entityDatatableChecksWritePlatformService) {
- this.context = context;
- this.clientRepository = clientRepository;
- this.clientNonPersonRepository = clientNonPersonRepository;
- this.officeRepositoryWrapper = officeRepositoryWrapper;
- this.noteRepository = noteRepository;
- this.fromApiJsonDeserializer = fromApiJsonDeserializer;
- this.accountNumberGenerator = accountNumberGenerator;
- this.groupRepository = groupRepository;
- this.staffRepository = staffRepository;
- this.codeValueRepository = codeValueRepository;
- this.loanRepositoryWrapper = loanRepositoryWrapper;
- this.savingsRepositoryWrapper = savingsRepositoryWrapper;
- this.savingsProductRepository = savingsProductRepository;
- this.savingsApplicationProcessWritePlatformService =
savingsApplicationProcessWritePlatformService;
- this.commandProcessingService = commandProcessingService;
- this.configurationDomainService = configurationDomainService;
- this.accountNumberFormatRepository = accountNumberFormatRepository;
- this.fromApiJsonHelper = fromApiJsonHelper;
- this.configurationReadPlatformService =
configurationReadPlatformService;
- this.addressWritePlatformService = addressWritePlatformService;
- this.clientFamilyMembersWritePlatformService =
clientFamilyMembersWritePlatformService;
- this.businessEventNotifierService = businessEventNotifierService;
- this.entityDatatableChecksWritePlatformService =
entityDatatableChecksWritePlatformService;
- }
-
@Transactional
@Override
public CommandProcessingResult deleteClient(final Long clientId) {
@@ -232,8 +192,6 @@ public class ClientWritePlatformServiceJpaRepositoryImpl
implements ClientWriteP
final Boolean isAddressEnabled = configuration.isEnabled();
- final Boolean isStaff =
command.booleanObjectValueOfParameterNamed(ClientApiConstants.isStaffParamName);
-
final Long officeId =
command.longValueOfParameterNamed(ClientApiConstants.officeIdParamName);
final Office clientOffice =
this.officeRepositoryWrapper.findOneWithNotFoundDetection(officeId);
@@ -280,8 +238,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl
implements ClientWriteP
final Integer legalFormParamValue =
command.integerValueOfParameterNamed(ClientApiConstants.legalFormIdParamName);
boolean isEntity = false;
Integer legalFormValue = null;
+ LegalForm legalForm = LegalForm.PERSON;
if (legalFormParamValue != null) {
- LegalForm legalForm = LegalForm.fromInt(legalFormParamValue);
+ legalForm = LegalForm.fromInt(legalFormParamValue);
if (legalForm != null) {
legalFormValue = legalForm.getValue();
isEntity = legalForm.isEntity();
@@ -294,7 +253,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl
implements ClientWriteP
boolean rollbackTransaction = false;
if (newClient.isActive()) {
validateParentGroupRulesBeforeClientActivation(newClient);
- runEntityDatatableCheck(newClient.getId());
+ runEntityDatatableCheck(newClient.getId(),
newClient.getLegalForm());
final CommandWrapper commandWrapper = new
CommandWrapperBuilder().activateClient(null).build();
rollbackTransaction =
this.commandProcessingService.validateCommand(commandWrapper, currentUser);
}
@@ -332,8 +291,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl
implements ClientWriteP
command.arrayOfParameterNamed(ClientApiConstants.datatables));
}
+ legalForm = LegalForm.fromInt(newClient.getLegalForm());
entityDatatableChecksWritePlatformService.runTheCheck(newClient.getId(),
EntityTables.CLIENT.getName(),
- StatusEnum.CREATE.getCode().longValue(),
EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable());
+ StatusEnum.CREATE.getCode(),
EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(), legalForm.getLabel());
businessEventNotifierService.notifyPostBusinessEvent(new
ClientCreateBusinessEvent(newClient));
if (newClient.isActive()) {
businessEventNotifierService.notifyPostBusinessEvent(new
ClientActivateBusinessEvent(newClient));
@@ -582,7 +542,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl
implements ClientWriteP
final DateTimeFormatter fmt =
DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
final LocalDate activationDate =
command.localDateValueOfParameterNamed("activationDate");
- runEntityDatatableCheck(clientId);
+ runEntityDatatableCheck(clientId, client.getLegalForm());
final AppUser currentUser = this.context.authenticatedUser();
client.activate(currentUser, fmt, activationDate);
@@ -718,8 +678,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl
implements ClientWriteP
throw new InvalidClientStateTransitionException("close",
"date.cannot.before.client.actvation.date", errorMessage,
closureDate, client.getActivationLocalDate());
}
- entityDatatableChecksWritePlatformService.runTheCheck(clientId,
EntityTables.CLIENT.getName(),
- StatusEnum.CLOSE.getCode().longValue(),
EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable());
+ final LegalForm legalForm =
LegalForm.fromInt(client.getLegalForm());
+ entityDatatableChecksWritePlatformService.runTheCheck(clientId,
EntityTables.CLIENT.getName(), StatusEnum.CLOSE.getCode(),
+ EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(),
legalForm.getLabel());
final List<Loan> clientLoans =
this.loanRepositoryWrapper.findLoanByClientId(clientId);
for (final Loan loan : clientLoans) {
@@ -813,9 +774,10 @@ public class ClientWritePlatformServiceJpaRepositoryImpl
implements ClientWriteP
}
}
- private void runEntityDatatableCheck(final Long clientId) {
- entityDatatableChecksWritePlatformService.runTheCheck(clientId,
EntityTables.CLIENT.getName(),
- StatusEnum.ACTIVATE.getCode().longValue(),
EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable());
+ private void runEntityDatatableCheck(final Long clientId, final Integer
legalFormId) {
+ final LegalForm legalForm = LegalForm.fromInt(legalFormId);
+ entityDatatableChecksWritePlatformService.runTheCheck(clientId,
EntityTables.CLIENT.getName(), StatusEnum.ACTIVATE.getCode(),
+ EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(),
legalForm.getLabel());
}
@Override
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
index 5c459f828..d1119a457 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/service/CenterReadPlatformServiceImpl.java
@@ -23,7 +23,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.LocalTime;
-import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -55,7 +54,6 @@ import org.apache.fineract.organisation.staff.data.StaffData;
import org.apache.fineract.organisation.staff.service.StaffReadPlatformService;
import org.apache.fineract.portfolio.calendar.data.CalendarData;
import org.apache.fineract.portfolio.calendar.service.CalendarEnumerations;
-import
org.apache.fineract.portfolio.calendar.service.CalendarReadPlatformService;
import org.apache.fineract.portfolio.calendar.service.CalendarUtils;
import org.apache.fineract.portfolio.client.data.ClientData;
import org.apache.fineract.portfolio.client.domain.ClientEnumerations;
@@ -86,8 +84,6 @@ public class CenterReadPlatformServiceImpl implements
CenterReadPlatformService
private final StaffReadPlatformService staffReadPlatformService;
private final CodeValueReadPlatformService codeValueReadPlatformService;
private final ConfigurationDomainService configurationDomainService;
- private final CalendarReadPlatformService calendarReadPlatformService;
- private final DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("yyyy-MM-dd");
private final ColumnValidator columnValidator;
// data mappers
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 b72e69d3c..c90bf1898 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
@@ -207,7 +207,7 @@ public class
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
}
this.entityDatatableChecksWritePlatformService.runTheCheck(newGroup.getId(),
EntityTables.GROUP.getName(),
- StatusEnum.CREATE.getCode().longValue(),
EntityTables.GROUP.getForeignKeyColumnNameOnDatatable());
+ StatusEnum.CREATE.getCode(),
EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null);
}
return new CommandProcessingResultBuilder() //
@@ -323,8 +323,8 @@ public class
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
if (!isGroupClientCountValid) {
throw new
GroupMemberCountNotInPermissibleRangeException(group.getId(), minClients,
maxClients);
}
- entityDatatableChecksWritePlatformService.runTheCheck(group.getId(),
EntityTables.GROUP.getName(),
- StatusEnum.ACTIVATE.getCode().longValue(),
EntityTables.GROUP.getForeignKeyColumnNameOnDatatable());
+ entityDatatableChecksWritePlatformService.runTheCheck(group.getId(),
EntityTables.GROUP.getName(), StatusEnum.ACTIVATE.getCode(),
+ EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null);
}
public void validateGroupRulesBeforeClientAssociation(final Group group) {
@@ -595,8 +595,8 @@ public class
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
validateLoansAndSavingsForGroupOrCenterClose(group, closureDate);
- entityDatatableChecksWritePlatformService.runTheCheck(groupId,
EntityTables.GROUP.getName(), StatusEnum.CLOSE.getCode().longValue(),
- EntityTables.GROUP.getForeignKeyColumnNameOnDatatable());
+ entityDatatableChecksWritePlatformService.runTheCheck(groupId,
EntityTables.GROUP.getName(), StatusEnum.CLOSE.getCode(),
+ EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null);
group.close(currentUser, closureReason, closureDate);
@@ -670,8 +670,8 @@ public class
GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
validateLoansAndSavingsForGroupOrCenterClose(center, closureDate);
- entityDatatableChecksWritePlatformService.runTheCheck(centerId,
EntityTables.GROUP.getName(),
- StatusEnum.ACTIVATE.getCode().longValue(),
EntityTables.GROUP.getForeignKeyColumnNameOnDatatable());
+ entityDatatableChecksWritePlatformService.runTheCheck(centerId,
EntityTables.GROUP.getName(), StatusEnum.ACTIVATE.getCode(),
+ EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null);
center.close(currentUser, closureReason, closureDate);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
index 28f01a5b8..16753405a 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/importhandler/client/ClientEntityImportHandlerTest.java
@@ -97,7 +97,7 @@ public class ClientEntityImportHandlerTest {
CodeHelper.retrieveOrCreateCodeValue(25, requestSpec, responseSpec);
ClientHelper clientHelper = new ClientHelper(requestSpec,
responseSpec);
- Workbook workbook =
clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY, "dd MMMM
yyyy");
+ Workbook workbook =
clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTITY, "dd MMMM
yyyy");
// insert dummy data into client entity sheet
Sheet clientEntitySheet =
workbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/client/ClientEntityWorkbookPopulatorTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/client/ClientEntityWorkbookPopulatorTest.java
index 1fe82f5ae..0a6cd1b07 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/client/ClientEntityWorkbookPopulatorTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/bulkimport/populator/client/ClientEntityWorkbookPopulatorTest.java
@@ -65,7 +65,7 @@ public class ClientEntityWorkbookPopulatorTest {
Assertions.assertNotNull(outcome_office_creation, "Could not create
office");
ClientHelper clientHelper = new ClientHelper(requestSpec,
responseSpec);
- Workbook workbook =
clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTTTY, "dd MMMM
yyyy");
+ Workbook workbook =
clientHelper.getClientEntityWorkbook(GlobalEntityType.CLIENTS_ENTITY, "dd MMMM
yyyy");
Sheet officeSheet =
workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
Row firstOfficeRow = officeSheet.getRow(1);
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found
for given OfficeId ");
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ClientHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ClientHelper.java
index 7b696d733..00b51347a 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ClientHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/ClientHelper.java
@@ -29,6 +29,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -156,6 +157,15 @@ public class ClientHelper extends IntegrationTest {
"clientId");
}
+ public static PostClientsResponse createClientAsPersonWithDatatable(final
RequestSpecification requestSpec,
+ final ResponseSpecification responseSpec, final String
activationDate, final String officeId,
+ final HashMap<String, Object> datatables) {
+ log.info("---------------------------------CREATING A CLIENT PERSON
WITH DATATABLE---------------------------------------------");
+ final String response = Utils.performServerPost(requestSpec,
responseSpec, CREATE_CLIENT_URL,
+ getTestPersonClientAsJSON(activationDate, officeId,
datatables), null);
+ return GSON.fromJson(response, PostClientsResponse.class);
+ }
+
public static Integer createClientAsEntity(final RequestSpecification
requestSpec, final ResponseSpecification responseSpec) {
return createClientAsEntity(requestSpec, responseSpec, "04 March
2011");
}
@@ -281,6 +291,25 @@ public class ClientHelper extends IntegrationTest {
return GSON.toJson(map);
}
+ public static String getTestPersonClientAsJSON(final String dateOfJoining,
final String officeId,
+ final HashMap<String, Object> datatables) {
+ final HashMap<String, Object> map = new HashMap<>();
+ map.put("officeId", officeId);
+ map.put("fullname", Utils.randomNameGenerator("Client_FullName_", 5));
+ map.put("externalId", randomIDGenerator("ID_", 7));
+ map.put("dateFormat", Utils.DATE_FORMAT);
+ map.put("locale", "en");
+ map.put("active", "true");
+ map.put("activationDate", dateOfJoining);
+ map.put("legalFormId", 1);
+ if (datatables != null) {
+ map.put("datatables", Arrays.asList(datatables));
+ }
+
+ log.info("map : {}", map);
+ return GSON.toJson(map);
+ }
+
public static String getTestEntityClientAsJSON(final String dateOfJoining,
final String officeId,
final Integer soleProprietorCodeValueId) {
final HashMap<String, Object> map = new HashMap<>();
@@ -665,7 +694,7 @@ public class ClientHelper extends IntegrationTest {
public String importClientEntityTemplate(File file) {
String locale = "en";
String dateFormat = "dd MMMM yyyy";
- String legalFormType = GlobalEntityType.CLIENTS_ENTTTY.toString();
+ String legalFormType = GlobalEntityType.CLIENTS_ENTITY.toString();
requestSpec.header(HttpHeaders.CONTENT_TYPE,
MediaType.MULTIPART_FORM_DATA);
return Utils.performServerTemplatePost(requestSpec, responseSpec,
CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
legalFormType, file, locale, dateFormat);
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/Utils.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/Utils.java
index 858d13db3..035e2cadf 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/Utils.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/Utils.java
@@ -210,6 +210,7 @@ public final class Utils {
public static <T> T performServerPost(final RequestSpecification
requestSpec, final ResponseSpecification responseSpec,
final String postURL, final String jsonBodyToSend, final String
jsonAttributeToGetBack) {
+ LOG.info("JSON {}", jsonBodyToSend);
final String json =
given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
.andReturn().asString();
if (jsonAttributeToGetBack == null) {
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksHelper.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksHelper.java
index bce369f68..79ae47a22 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksHelper.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksHelper.java
@@ -22,6 +22,8 @@ import com.google.gson.Gson;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.HashMap;
+import
org.apache.fineract.client.models.PostEntityDatatableChecksTemplateResponse;
+import org.apache.fineract.client.util.JSON;
import org.apache.fineract.integrationtests.common.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,6 +36,8 @@ public class EntityDatatableChecksHelper {
private static final String DATATABLE_CHECK_URL =
"/fineract-provider/api/v1/entityDatatableChecks";
+ private static final Gson GSON = new JSON().getGson();
+
public EntityDatatableChecksHelper(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec) {
this.requestSpec = requestSpec;
this.responseSpec = responseSpec;
@@ -45,6 +49,14 @@ public class EntityDatatableChecksHelper {
getTestEdcAsJSON(apptableName, datatableName, status,
productId), "resourceId");
}
+ public PostEntityDatatableChecksTemplateResponse
addEntityDatatableCheck(final String apptableName, final String datatableName,
+ final int status, final Integer productId) {
+ final String response = Utils.performServerPost(this.requestSpec,
this.responseSpec,
+ DATATABLE_CHECK_URL + "?" + Utils.TENANT_IDENTIFIER,
getTestEdcAsJSON(apptableName, datatableName, status, productId),
+ null);
+ return GSON.fromJson(response,
PostEntityDatatableChecksTemplateResponse.class);
+ }
+
public Integer deleteEntityDatatableCheck(final Integer
entityDatatableCheckId) {
return Utils.performServerDelete(requestSpec, responseSpec,
DATATABLE_CHECK_URL + "/" + entityDatatableCheckId + "?" +
Utils.TENANT_IDENTIFIER, "resourceId");
diff --git
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksIntegrationTest.java
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksIntegrationTest.java
index 190416d34..d439c82f5 100644
---
a/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksIntegrationTest.java
+++
b/integration-tests/src/test/java/org/apache/fineract/integrationtests/common/organisation/EntityDatatableChecksIntegrationTest.java
@@ -21,6 +21,7 @@ package
org.apache.fineract.integrationtests.common.organisation;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import com.google.gson.Gson;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
@@ -30,6 +31,8 @@ import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import org.apache.fineract.client.models.PostClientsResponse;
+import
org.apache.fineract.client.models.PostEntityDatatableChecksTemplateResponse;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
import org.apache.fineract.integrationtests.common.CommonConstants;
@@ -549,4 +552,75 @@ public class EntityDatatableChecksIntegrationTest {
datatablesListMap.add(datatableMap);
return datatablesListMap;
}
+
+ @Test
+ public void createClientWithDatatableUsingEntitySubtype() {
+ // creating datatable for client entity person subentity
+ HashMap<String, Object> columnMap = new HashMap<>();
+ final List<HashMap<String, Object>> datatableColumnsList = new
ArrayList<>();
+ final String datatableNamePerson =
Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_person_",
5).toLowerCase().toLowerCase();
+ final String datatableNameEntity =
Utils.randomNameGenerator(CLIENT_APP_TABLE_NAME + "_entity_",
5).toLowerCase().toLowerCase();
+
+ String itsAString = "itsastring";
+ DatatableHelper.addDatatableColumns(datatableColumnsList, itsAString,
"String", true, 10, null);
+
+ // Person Subtype
+ columnMap.put("datatableName", datatableNamePerson);
+ columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+ columnMap.put("entitySubType", "PERSON");
+ columnMap.put("multiRow", false);
+ String dateFormat = "dateFormat";
+
+ columnMap.put("columns", datatableColumnsList);
+ String datatabelRequestJsonString = new Gson().toJson(columnMap);
+ LOG.info("map : {}", datatabelRequestJsonString);
+
+ datatableHelper.createDatatable(datatabelRequestJsonString, "");
+
+ PostEntityDatatableChecksTemplateResponse
entityDatatableChecksResponse = entityDatatableChecksHelper
+ .addEntityDatatableCheck(CLIENT_APP_TABLE_NAME,
datatableNamePerson, 100, null);
+ assertNotNull(entityDatatableChecksResponse);
+ final Long personDatatableCheck =
entityDatatableChecksResponse.getResourceId();
+ LOG.info("entityDatatableChecksResponse Person: {}",
entityDatatableChecksResponse.getResourceId());
+
+ // Entity Subtype
+ columnMap = new HashMap<>();
+ columnMap.put("datatableName", datatableNameEntity);
+ columnMap.put("apptableName", CLIENT_APP_TABLE_NAME);
+ columnMap.put("entitySubType", "ENTITY");
+ columnMap.put("multiRow", false);
+
+ columnMap.put("columns", datatableColumnsList);
+ datatabelRequestJsonString = new Gson().toJson(columnMap);
+ LOG.info("map : {}", datatabelRequestJsonString);
+
+ datatableHelper.createDatatable(datatabelRequestJsonString, "");
+
+ entityDatatableChecksResponse =
entityDatatableChecksHelper.addEntityDatatableCheck(CLIENT_APP_TABLE_NAME,
datatableNameEntity, 100,
+ null);
+ assertNotNull(entityDatatableChecksResponse);
+ final Long entityDatatableCheck =
entityDatatableChecksResponse.getResourceId();
+ LOG.info("entityDatatableChecksResponse Entity: {}",
entityDatatableChecksResponse.getResourceId());
+
+ final HashMap<String, Object> datatableEntryMap = new HashMap<>();
+ datatableEntryMap.put(itsAString, Utils.randomStringGenerator("", 8));
+ datatableEntryMap.put("locale", "en");
+
+ final HashMap<String, Object> datatablesMap = new HashMap<>();
+ datatablesMap.put("registeredTableName", datatableNamePerson);
+ datatablesMap.put("data", datatableEntryMap);
+
+ String datatablesJsonString = new Gson().toJson(datatablesMap);
+ LOG.info("map : {}", datatablesJsonString);
+
+ PostClientsResponse postClientsResponse =
ClientHelper.createClientAsPersonWithDatatable(requestSpec, responseSpec, "04
March 2011",
+ "1", datatablesMap);
+ assertNotNull(postClientsResponse);
+ assertNotNull(postClientsResponse.getResourceId());
+
+ // Remove the Entity Datatable checks for others tests
+
entityDatatableChecksHelper.deleteEntityDatatableCheck(personDatatableCheck.intValue());
+
entityDatatableChecksHelper.deleteEntityDatatableCheck(entityDatatableCheck.intValue());
+ }
+
}