Create client with datatable subentity type
This commit is contained in:
committed by
Arnold Gálovics
parent
29b900cccd
commit
804bdc28b9
+1
-1
@@ -73,7 +73,7 @@ public class BulkImportApiResource {
|
|||||||
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
|
this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSION);
|
||||||
Collection<ImportData> importData = new ArrayList<>();
|
Collection<ImportData> importData = new ArrayList<>();
|
||||||
if (entityType.equals(GlobalEntityType.CLIENT.getCode())) {
|
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);
|
final Collection<ImportData> importForClientPerson = this.bulkImportWorkbookService.getImports(GlobalEntityType.CLIENTS_PERSON);
|
||||||
if (importForClientEntity != null) {
|
if (importForClientEntity != null) {
|
||||||
importData.addAll(importForClientEntity);
|
importData.addAll(importForClientEntity);
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
public enum GlobalEntityType {
|
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,
|
"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,
|
"templates"), NOTES(11, "templates"), CALENDAR(12, "calendar"), MEETINGS(13, "meetings"), HOLIDAYS(14,
|
||||||
"holidays"), LOANS(15, "loans"), LOAN_PRODUCTS(16, "loancharges"), LOAN_TRANSACTIONS(18,
|
"holidays"), LOANS(15, "loans"), LOAN_PRODUCTS(16, "loancharges"), LOAN_TRANSACTIONS(18,
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ public class BulkImportEventListener implements ApplicationListener<BulkImportEv
|
|||||||
case CHART_OF_ACCOUNTS:
|
case CHART_OF_ACCOUNTS:
|
||||||
importHandler = this.applicationContext.getBean("chartOfAccountsImportHandler", ImportHandler.class);
|
importHandler = this.applicationContext.getBean("chartOfAccountsImportHandler", ImportHandler.class);
|
||||||
break;
|
break;
|
||||||
case CLIENTS_ENTTTY:
|
case CLIENTS_ENTITY:
|
||||||
importHandler = this.applicationContext.getBean("clientEntityImportHandler", ImportHandler.class);
|
importHandler = this.applicationContext.getBean("clientEntityImportHandler", ImportHandler.class);
|
||||||
break;
|
break;
|
||||||
case CLIENTS_PERSON:
|
case CLIENTS_PERSON:
|
||||||
|
|||||||
+2
-2
@@ -180,7 +180,7 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
|
|||||||
final Workbook workbook = new HSSFWorkbook();
|
final Workbook workbook = new HSSFWorkbook();
|
||||||
if (entityType != null) {
|
if (entityType != null) {
|
||||||
if (entityType.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_PERSON.toString())
|
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);
|
populator = populateClientWorkbook(entityType, officeId, staffId);
|
||||||
} else if (entityType.trim().equalsIgnoreCase(GlobalEntityType.CENTERS.toString())) {
|
} else if (entityType.trim().equalsIgnoreCase(GlobalEntityType.CENTERS.toString())) {
|
||||||
populator = populateCenterWorkbook(officeId, staffId);
|
populator = populateCenterWorkbook(officeId, staffId);
|
||||||
@@ -241,7 +241,7 @@ public class BulkImportWorkbookPopulatorServiceImpl implements BulkImportWorkboo
|
|||||||
return new ClientPersonWorkbookPopulator(new OfficeSheetPopulator(offices), new PersonnelSheetPopulator(staff, offices),
|
return new ClientPersonWorkbookPopulator(new OfficeSheetPopulator(offices), new PersonnelSheetPopulator(staff, offices),
|
||||||
clientTypeCodeValues, genderCodeValues, clientClassification, addressTypesCodeValues, stateProvinceCodeValues,
|
clientTypeCodeValues, genderCodeValues, clientClassification, addressTypesCodeValues, stateProvinceCodeValues,
|
||||||
countryCodeValues);
|
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> constitutionCodeValues = fetchCodeValuesByCodeName("Constitution");
|
||||||
List<CodeValueData> mainBusinessline = fetchCodeValuesByCodeName("Main Business Line");
|
List<CodeValueData> mainBusinessline = fetchCodeValuesByCodeName("Main Business Line");
|
||||||
return new ClientEntityWorkbookPopulator(new OfficeSheetPopulator(offices), new PersonnelSheetPopulator(staff, offices),
|
return new ClientEntityWorkbookPopulator(new OfficeSheetPopulator(offices), new PersonnelSheetPopulator(staff, offices),
|
||||||
|
|||||||
+2
-2
@@ -110,8 +110,8 @@ public class BulkImportWorkbookServiceImpl implements BulkImportWorkbookService
|
|||||||
if (entity.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_PERSON.toString())) {
|
if (entity.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_PERSON.toString())) {
|
||||||
entityType = GlobalEntityType.CLIENTS_PERSON;
|
entityType = GlobalEntityType.CLIENTS_PERSON;
|
||||||
primaryColumn = 0;
|
primaryColumn = 0;
|
||||||
} else if (entity.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_ENTTTY.toString())) {
|
} else if (entity.trim().equalsIgnoreCase(GlobalEntityType.CLIENTS_ENTITY.toString())) {
|
||||||
entityType = GlobalEntityType.CLIENTS_ENTTTY;
|
entityType = GlobalEntityType.CLIENTS_ENTITY;
|
||||||
primaryColumn = 0;
|
primaryColumn = 0;
|
||||||
} else if (entity.trim().equalsIgnoreCase(GlobalEntityType.CENTERS.toString())) {
|
} else if (entity.trim().equalsIgnoreCase(GlobalEntityType.CENTERS.toString())) {
|
||||||
entityType = GlobalEntityType.CENTERS;
|
entityType = GlobalEntityType.CENTERS;
|
||||||
|
|||||||
+2
-19
@@ -38,6 +38,7 @@ import javax.ws.rs.QueryParam;
|
|||||||
import javax.ws.rs.core.Context;
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import org.apache.fineract.commands.domain.CommandWrapper;
|
import org.apache.fineract.commands.domain.CommandWrapper;
|
||||||
import org.apache.fineract.commands.service.CommandWrapperBuilder;
|
import org.apache.fineract.commands.service.CommandWrapperBuilder;
|
||||||
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
|
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.EntityDataTableChecksTemplateData;
|
||||||
import org.apache.fineract.infrastructure.dataqueries.data.GenericResultsetData;
|
import org.apache.fineract.infrastructure.dataqueries.data.GenericResultsetData;
|
||||||
import org.apache.fineract.infrastructure.dataqueries.service.EntityDatatableChecksReadService;
|
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.context.annotation.Scope;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Path("/entityDatatableChecks")
|
@Path("/entityDatatableChecks")
|
||||||
|
@AllArgsConstructor
|
||||||
@Component
|
@Component
|
||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
@Tag(name = "Entity Data Table", description = "This defines Entity-Datatable Check.")
|
@Tag(name = "Entity Data Table", description = "This defines Entity-Datatable Check.")
|
||||||
public class EntityDatatableChecksApiResource {
|
public class EntityDatatableChecksApiResource {
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
|
||||||
private final GenericDataService genericDataService;
|
|
||||||
private final EntityDatatableChecksReadService readEntityDatatableChecksService;
|
private final EntityDatatableChecksReadService readEntityDatatableChecksService;
|
||||||
private final ToApiJsonSerializer<GenericResultsetData> toApiJsonSerializer;
|
private final ToApiJsonSerializer<GenericResultsetData> toApiJsonSerializer;
|
||||||
private final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService;
|
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
|
@GET
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
|
|||||||
+6
-28
@@ -21,12 +21,17 @@ package org.apache.fineract.infrastructure.dataqueries.domain;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
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.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Getter
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_entity_datatable_check")
|
@Table(name = "m_entity_datatable_check")
|
||||||
|
|
||||||
public class EntityDatatableChecks extends AbstractPersistableCustom {
|
public class EntityDatatableChecks extends AbstractPersistableCustom {
|
||||||
|
|
||||||
@Column(name = "application_table_name", nullable = false)
|
@Column(name = "application_table_name", nullable = false)
|
||||||
@@ -44,18 +49,6 @@ public class EntityDatatableChecks extends AbstractPersistableCustom {
|
|||||||
@Column(name = "product_id", nullable = true)
|
@Column(name = "product_id", nullable = true)
|
||||||
private Long productId;
|
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) {
|
public static EntityDatatableChecks fromJson(final JsonCommand command) {
|
||||||
|
|
||||||
final String entity = command.stringValueOfParameterNamed("entity");
|
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() {
|
public boolean isSystemDefined() {
|
||||||
return this.systemDefined;
|
return this.systemDefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getProductId() {
|
|
||||||
return productId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-1
@@ -27,7 +27,17 @@ import org.springframework.data.repository.query.Param;
|
|||||||
public interface EntityDatatableChecksRepository
|
public interface EntityDatatableChecksRepository
|
||||||
extends JpaRepository<EntityDatatableChecks, Long>, JpaSpecificationExecutor<EntityDatatableChecks> {
|
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 ")
|
@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") Long status,
|
||||||
|
|||||||
+50
@@ -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() {}
|
||||||
|
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
/**
|
||||||
|
* 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 org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
|
||||||
|
public interface RegisteredDatatableRepository
|
||||||
|
extends JpaRepository<RegisteredDatatable, Long>, JpaSpecificationExecutor<RegisteredDatatable> {
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -28,7 +28,7 @@ public interface EntityDatatableChecksWritePlatformService {
|
|||||||
|
|
||||||
CommandProcessingResult deleteCheck(Long entityDatatableCheckId);
|
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);
|
void runTheCheckForProduct(Long entityId, String entityName, Long statusCode, String foreignKeyColumn, long productLoanId);
|
||||||
|
|
||||||
|
|||||||
+17
-30
@@ -24,6 +24,8 @@ import com.google.gson.JsonObject;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
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.loanproduct.service.LoanProductReadPlatformService;
|
||||||
import org.apache.fineract.portfolio.savings.service.SavingsProductReadPlatformService;
|
import org.apache.fineract.portfolio.savings.service.SavingsProductReadPlatformService;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
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.dao.DataAccessException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@AllArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class EntityDatatableChecksWritePlatformServiceImpl implements EntityDatatableChecksWritePlatformService {
|
public class EntityDatatableChecksWritePlatformServiceImpl implements EntityDatatableChecksWritePlatformService {
|
||||||
|
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(EntityDatatableChecksWritePlatformServiceImpl.class);
|
|
||||||
|
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final EntityDatatableChecksDataValidator fromApiJsonDeserializer;
|
private final EntityDatatableChecksDataValidator fromApiJsonDeserializer;
|
||||||
private final EntityDatatableChecksRepository entityDatatableChecksRepository;
|
private final EntityDatatableChecksRepository entityDatatableChecksRepository;
|
||||||
@@ -67,24 +66,6 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
|||||||
private final FromJsonHelper fromApiJsonHelper;
|
private final FromJsonHelper fromApiJsonHelper;
|
||||||
private final ConfigurationDomainService configurationDomainService;
|
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
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult createCheck(final JsonCommand command) {
|
public CommandProcessingResult createCheck(final JsonCommand command) {
|
||||||
@@ -107,7 +88,7 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
|||||||
final String foreignKeyColumnName = EntityTables.getForeignKeyColumnNameOnDatatable(entity);
|
final String foreignKeyColumnName = EntityTables.getForeignKeyColumnNameOnDatatable(entity);
|
||||||
final boolean columnExist = datatableData.hasColumn(foreignKeyColumnName);
|
final boolean columnExist = datatableData.hasColumn(foreignKeyColumnName);
|
||||||
|
|
||||||
LOG.debug("{} has column {} ? {}", datatableData.getRegisteredTableName(), foreignKeyColumnName, columnExist);
|
log.debug("{} has column {} ? {}", datatableData.getRegisteredTableName(), foreignKeyColumnName, columnExist);
|
||||||
|
|
||||||
if (!columnExist) {
|
if (!columnExist) {
|
||||||
throw new EntityDatatableCheckNotSupportedException(datatableData.getRegisteredTableName(), entity);
|
throw new EntityDatatableCheckNotSupportedException(datatableData.getRegisteredTableName(), entity);
|
||||||
@@ -159,9 +140,15 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runTheCheck(final Long entityId, final String entityName, final Long statusCode, String foreignKeyColumn) {
|
public void runTheCheck(final Long entityId, final String entityName, final Integer statusCode, String foreignKeyColumn,
|
||||||
final List<EntityDatatableChecks> tableRequiredBeforeClientActivation = entityDatatableChecksRepository
|
final String entitySubtype) {
|
||||||
.findByEntityAndStatus(entityName, statusCode);
|
List<EntityDatatableChecks> tableRequiredBeforeClientActivation;
|
||||||
|
if (entitySubtype == null) {
|
||||||
|
tableRequiredBeforeClientActivation = entityDatatableChecksRepository.findByEntityAndStatus(entityName, statusCode);
|
||||||
|
} else {
|
||||||
|
tableRequiredBeforeClientActivation = entityDatatableChecksRepository.findByEntityAndStatusAndSubtype(entityName, statusCode,
|
||||||
|
entitySubtype.toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
if (tableRequiredBeforeClientActivation != null) {
|
if (tableRequiredBeforeClientActivation != null) {
|
||||||
List<String> reqDatatables = new ArrayList<>();
|
List<String> reqDatatables = new ArrayList<>();
|
||||||
@@ -170,7 +157,7 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
|||||||
final String datatableName = t.getDatatableName();
|
final String datatableName = t.getDatatableName();
|
||||||
final Long countEntries = readWriteNonCoreDataService.countDatatableEntries(datatableName, entityId, foreignKeyColumn);
|
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) {
|
if (countEntries.intValue() == 0) {
|
||||||
reqDatatables.add(datatableName);
|
reqDatatables.add(datatableName);
|
||||||
}
|
}
|
||||||
@@ -199,7 +186,7 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
|||||||
final String datatableName = t.getDatatableName();
|
final String datatableName = t.getDatatableName();
|
||||||
final Long countEntries = readWriteNonCoreDataService.countDatatableEntries(datatableName, entityId, foreignKeyColumn);
|
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) {
|
if (countEntries.intValue() == 0) {
|
||||||
reqDatatables.add(datatableName);
|
reqDatatables.add(datatableName);
|
||||||
}
|
}
|
||||||
@@ -281,7 +268,7 @@ public class EntityDatatableChecksWritePlatformServiceImpl implements EntityData
|
|||||||
throw new EntityDatatableCheckAlreadyExistsException(entity, status, datatableName, productId);
|
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",
|
throw new PlatformDataIntegrityException("error.msg.report.unknown.data.integrity.issue",
|
||||||
"Unknown data integrity issue with resource: " + realCause.getMessage());
|
"Unknown data integrity issue with resource: " + realCause.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
-30
@@ -66,7 +66,6 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
|
|||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final TellerLookupMapper lookupMapper = new TellerLookupMapper();
|
private final TellerLookupMapper lookupMapper = new TellerLookupMapper();
|
||||||
private final TellerInOfficeHierarchyMapper tellerInOfficeHierarchyMapper = new TellerInOfficeHierarchyMapper();
|
|
||||||
private final OfficeReadPlatformService officeReadPlatformService;
|
private final OfficeReadPlatformService officeReadPlatformService;
|
||||||
private final StaffReadPlatformService staffReadPlatformService;
|
private final StaffReadPlatformService staffReadPlatformService;
|
||||||
private final CurrencyReadPlatformService currencyReadPlatformService;
|
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 static final class TellerLookupMapper implements RowMapper<TellerData> {
|
||||||
|
|
||||||
private final String schemaSql;
|
private final String schemaSql;
|
||||||
@@ -378,8 +350,6 @@ public class TellerManagementReadPlatformServiceImpl implements TellerManagement
|
|||||||
tellerName = tellerData.getName();
|
tellerName = tellerData.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Collection<OfficeData> offices = this.officeReadPlatformService.retrieveAllOfficesForDropdown();
|
|
||||||
|
|
||||||
Collection<StaffData> staffOptions = null;
|
Collection<StaffData> staffOptions = null;
|
||||||
|
|
||||||
final boolean loanOfficersOnly = false;
|
final boolean loanOfficersOnly = false;
|
||||||
|
|||||||
+13
-11
@@ -18,29 +18,26 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.client.domain;
|
package org.apache.fineract.portfolio.client.domain;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Type used to differentiate the type of client
|
* Type used to differentiate the type of client
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public enum LegalForm {
|
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 Integer value;
|
||||||
private final String code;
|
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.value = value;
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
this.label = label;
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCode() {
|
|
||||||
return this.code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LegalForm fromInt(final Integer type) {
|
public static LegalForm fromInt(final Integer type) {
|
||||||
@@ -64,4 +61,9 @@ public enum LegalForm {
|
|||||||
public boolean isEntity() {
|
public boolean isEntity() {
|
||||||
return this.value.equals(LegalForm.ENTITY.getValue());
|
return this.value.equals(LegalForm.ENTITY.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.label;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-53
@@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.exception.ExceptionUtils;
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
||||||
import org.apache.fineract.commands.domain.CommandWrapper;
|
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.exception.SavingsProductNotFoundException;
|
||||||
import org.apache.fineract.portfolio.savings.service.SavingsApplicationProcessWritePlatformService;
|
import org.apache.fineract.portfolio.savings.service.SavingsApplicationProcessWritePlatformService;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.orm.jpa.JpaSystemException;
|
import org.springframework.orm.jpa.JpaSystemException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
|
public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWritePlatformService {
|
||||||
@@ -120,47 +121,6 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
private final BusinessEventNotifierService businessEventNotifierService;
|
private final BusinessEventNotifierService businessEventNotifierService;
|
||||||
private final EntityDatatableChecksWritePlatformService entityDatatableChecksWritePlatformService;
|
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
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult deleteClient(final Long clientId) {
|
public CommandProcessingResult deleteClient(final Long clientId) {
|
||||||
@@ -232,8 +192,6 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
|
|
||||||
final Boolean isAddressEnabled = configuration.isEnabled();
|
final Boolean isAddressEnabled = configuration.isEnabled();
|
||||||
|
|
||||||
final Boolean isStaff = command.booleanObjectValueOfParameterNamed(ClientApiConstants.isStaffParamName);
|
|
||||||
|
|
||||||
final Long officeId = command.longValueOfParameterNamed(ClientApiConstants.officeIdParamName);
|
final Long officeId = command.longValueOfParameterNamed(ClientApiConstants.officeIdParamName);
|
||||||
|
|
||||||
final Office clientOffice = this.officeRepositoryWrapper.findOneWithNotFoundDetection(officeId);
|
final Office clientOffice = this.officeRepositoryWrapper.findOneWithNotFoundDetection(officeId);
|
||||||
@@ -280,8 +238,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
final Integer legalFormParamValue = command.integerValueOfParameterNamed(ClientApiConstants.legalFormIdParamName);
|
final Integer legalFormParamValue = command.integerValueOfParameterNamed(ClientApiConstants.legalFormIdParamName);
|
||||||
boolean isEntity = false;
|
boolean isEntity = false;
|
||||||
Integer legalFormValue = null;
|
Integer legalFormValue = null;
|
||||||
|
LegalForm legalForm = LegalForm.PERSON;
|
||||||
if (legalFormParamValue != null) {
|
if (legalFormParamValue != null) {
|
||||||
LegalForm legalForm = LegalForm.fromInt(legalFormParamValue);
|
legalForm = LegalForm.fromInt(legalFormParamValue);
|
||||||
if (legalForm != null) {
|
if (legalForm != null) {
|
||||||
legalFormValue = legalForm.getValue();
|
legalFormValue = legalForm.getValue();
|
||||||
isEntity = legalForm.isEntity();
|
isEntity = legalForm.isEntity();
|
||||||
@@ -294,7 +253,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
boolean rollbackTransaction = false;
|
boolean rollbackTransaction = false;
|
||||||
if (newClient.isActive()) {
|
if (newClient.isActive()) {
|
||||||
validateParentGroupRulesBeforeClientActivation(newClient);
|
validateParentGroupRulesBeforeClientActivation(newClient);
|
||||||
runEntityDatatableCheck(newClient.getId());
|
runEntityDatatableCheck(newClient.getId(), newClient.getLegalForm());
|
||||||
final CommandWrapper commandWrapper = new CommandWrapperBuilder().activateClient(null).build();
|
final CommandWrapper commandWrapper = new CommandWrapperBuilder().activateClient(null).build();
|
||||||
rollbackTransaction = this.commandProcessingService.validateCommand(commandWrapper, currentUser);
|
rollbackTransaction = this.commandProcessingService.validateCommand(commandWrapper, currentUser);
|
||||||
}
|
}
|
||||||
@@ -332,8 +291,9 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
command.arrayOfParameterNamed(ClientApiConstants.datatables));
|
command.arrayOfParameterNamed(ClientApiConstants.datatables));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
legalForm = LegalForm.fromInt(newClient.getLegalForm());
|
||||||
entityDatatableChecksWritePlatformService.runTheCheck(newClient.getId(), EntityTables.CLIENT.getName(),
|
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));
|
businessEventNotifierService.notifyPostBusinessEvent(new ClientCreateBusinessEvent(newClient));
|
||||||
if (newClient.isActive()) {
|
if (newClient.isActive()) {
|
||||||
businessEventNotifierService.notifyPostBusinessEvent(new ClientActivateBusinessEvent(newClient));
|
businessEventNotifierService.notifyPostBusinessEvent(new ClientActivateBusinessEvent(newClient));
|
||||||
@@ -582,7 +542,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
|
final DateTimeFormatter fmt = DateTimeFormatter.ofPattern(command.dateFormat()).withLocale(locale);
|
||||||
final LocalDate activationDate = command.localDateValueOfParameterNamed("activationDate");
|
final LocalDate activationDate = command.localDateValueOfParameterNamed("activationDate");
|
||||||
|
|
||||||
runEntityDatatableCheck(clientId);
|
runEntityDatatableCheck(clientId, client.getLegalForm());
|
||||||
|
|
||||||
final AppUser currentUser = this.context.authenticatedUser();
|
final AppUser currentUser = this.context.authenticatedUser();
|
||||||
client.activate(currentUser, fmt, activationDate);
|
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,
|
throw new InvalidClientStateTransitionException("close", "date.cannot.before.client.actvation.date", errorMessage,
|
||||||
closureDate, client.getActivationLocalDate());
|
closureDate, client.getActivationLocalDate());
|
||||||
}
|
}
|
||||||
entityDatatableChecksWritePlatformService.runTheCheck(clientId, EntityTables.CLIENT.getName(),
|
final LegalForm legalForm = LegalForm.fromInt(client.getLegalForm());
|
||||||
StatusEnum.CLOSE.getCode().longValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable());
|
entityDatatableChecksWritePlatformService.runTheCheck(clientId, EntityTables.CLIENT.getName(), StatusEnum.CLOSE.getCode(),
|
||||||
|
EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(), legalForm.getLabel());
|
||||||
|
|
||||||
final List<Loan> clientLoans = this.loanRepositoryWrapper.findLoanByClientId(clientId);
|
final List<Loan> clientLoans = this.loanRepositoryWrapper.findLoanByClientId(clientId);
|
||||||
for (final Loan loan : clientLoans) {
|
for (final Loan loan : clientLoans) {
|
||||||
@@ -813,9 +774,10 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runEntityDatatableCheck(final Long clientId) {
|
private void runEntityDatatableCheck(final Long clientId, final Integer legalFormId) {
|
||||||
entityDatatableChecksWritePlatformService.runTheCheck(clientId, EntityTables.CLIENT.getName(),
|
final LegalForm legalForm = LegalForm.fromInt(legalFormId);
|
||||||
StatusEnum.ACTIVATE.getCode().longValue(), EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable());
|
entityDatatableChecksWritePlatformService.runTheCheck(clientId, EntityTables.CLIENT.getName(), StatusEnum.ACTIVATE.getCode(),
|
||||||
|
EntityTables.CLIENT.getForeignKeyColumnNameOnDatatable(), legalForm.getLabel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
-4
@@ -23,7 +23,6 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
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.organisation.staff.service.StaffReadPlatformService;
|
||||||
import org.apache.fineract.portfolio.calendar.data.CalendarData;
|
import org.apache.fineract.portfolio.calendar.data.CalendarData;
|
||||||
import org.apache.fineract.portfolio.calendar.service.CalendarEnumerations;
|
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.calendar.service.CalendarUtils;
|
||||||
import org.apache.fineract.portfolio.client.data.ClientData;
|
import org.apache.fineract.portfolio.client.data.ClientData;
|
||||||
import org.apache.fineract.portfolio.client.domain.ClientEnumerations;
|
import org.apache.fineract.portfolio.client.domain.ClientEnumerations;
|
||||||
@@ -86,8 +84,6 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
|
|||||||
private final StaffReadPlatformService staffReadPlatformService;
|
private final StaffReadPlatformService staffReadPlatformService;
|
||||||
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
||||||
private final ConfigurationDomainService configurationDomainService;
|
private final ConfigurationDomainService configurationDomainService;
|
||||||
private final CalendarReadPlatformService calendarReadPlatformService;
|
|
||||||
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
||||||
private final ColumnValidator columnValidator;
|
private final ColumnValidator columnValidator;
|
||||||
|
|
||||||
// data mappers
|
// data mappers
|
||||||
|
|||||||
+7
-7
@@ -207,7 +207,7 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.entityDatatableChecksWritePlatformService.runTheCheck(newGroup.getId(), EntityTables.GROUP.getName(),
|
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() //
|
return new CommandProcessingResultBuilder() //
|
||||||
@@ -323,8 +323,8 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
|
|||||||
if (!isGroupClientCountValid) {
|
if (!isGroupClientCountValid) {
|
||||||
throw new GroupMemberCountNotInPermissibleRangeException(group.getId(), minClients, maxClients);
|
throw new GroupMemberCountNotInPermissibleRangeException(group.getId(), minClients, maxClients);
|
||||||
}
|
}
|
||||||
entityDatatableChecksWritePlatformService.runTheCheck(group.getId(), EntityTables.GROUP.getName(),
|
entityDatatableChecksWritePlatformService.runTheCheck(group.getId(), EntityTables.GROUP.getName(), StatusEnum.ACTIVATE.getCode(),
|
||||||
StatusEnum.ACTIVATE.getCode().longValue(), EntityTables.GROUP.getForeignKeyColumnNameOnDatatable());
|
EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateGroupRulesBeforeClientAssociation(final Group group) {
|
public void validateGroupRulesBeforeClientAssociation(final Group group) {
|
||||||
@@ -595,8 +595,8 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
|
|||||||
|
|
||||||
validateLoansAndSavingsForGroupOrCenterClose(group, closureDate);
|
validateLoansAndSavingsForGroupOrCenterClose(group, closureDate);
|
||||||
|
|
||||||
entityDatatableChecksWritePlatformService.runTheCheck(groupId, EntityTables.GROUP.getName(), StatusEnum.CLOSE.getCode().longValue(),
|
entityDatatableChecksWritePlatformService.runTheCheck(groupId, EntityTables.GROUP.getName(), StatusEnum.CLOSE.getCode(),
|
||||||
EntityTables.GROUP.getForeignKeyColumnNameOnDatatable());
|
EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null);
|
||||||
|
|
||||||
group.close(currentUser, closureReason, closureDate);
|
group.close(currentUser, closureReason, closureDate);
|
||||||
|
|
||||||
@@ -670,8 +670,8 @@ public class GroupingTypesWritePlatformServiceJpaRepositoryImpl implements Group
|
|||||||
|
|
||||||
validateLoansAndSavingsForGroupOrCenterClose(center, closureDate);
|
validateLoansAndSavingsForGroupOrCenterClose(center, closureDate);
|
||||||
|
|
||||||
entityDatatableChecksWritePlatformService.runTheCheck(centerId, EntityTables.GROUP.getName(),
|
entityDatatableChecksWritePlatformService.runTheCheck(centerId, EntityTables.GROUP.getName(), StatusEnum.ACTIVATE.getCode(),
|
||||||
StatusEnum.ACTIVATE.getCode().longValue(), EntityTables.GROUP.getForeignKeyColumnNameOnDatatable());
|
EntityTables.GROUP.getForeignKeyColumnNameOnDatatable(), null);
|
||||||
|
|
||||||
center.close(currentUser, closureReason, closureDate);
|
center.close(currentUser, closureReason, closureDate);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -97,7 +97,7 @@ public class ClientEntityImportHandlerTest {
|
|||||||
CodeHelper.retrieveOrCreateCodeValue(25, requestSpec, responseSpec);
|
CodeHelper.retrieveOrCreateCodeValue(25, requestSpec, responseSpec);
|
||||||
|
|
||||||
ClientHelper clientHelper = new ClientHelper(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
|
// insert dummy data into client entity sheet
|
||||||
Sheet clientEntitySheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME);
|
Sheet clientEntitySheet = workbook.getSheet(TemplatePopulateImportConstants.CLIENT_ENTITY_SHEET_NAME);
|
||||||
|
|||||||
+1
-1
@@ -65,7 +65,7 @@ public class ClientEntityWorkbookPopulatorTest {
|
|||||||
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
|
Assertions.assertNotNull(outcome_office_creation, "Could not create office");
|
||||||
|
|
||||||
ClientHelper clientHelper = new ClientHelper(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");
|
||||||
Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
|
Sheet officeSheet = workbook.getSheet(TemplatePopulateImportConstants.OFFICE_SHEET_NAME);
|
||||||
Row firstOfficeRow = officeSheet.getRow(1);
|
Row firstOfficeRow = officeSheet.getRow(1);
|
||||||
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found for given OfficeId ");
|
Assertions.assertNotNull(firstOfficeRow.getCell(1), "No offices found for given OfficeId ");
|
||||||
|
|||||||
+30
-1
@@ -29,6 +29,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -156,6 +157,15 @@ public class ClientHelper extends IntegrationTest {
|
|||||||
"clientId");
|
"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) {
|
public static Integer createClientAsEntity(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
return createClientAsEntity(requestSpec, responseSpec, "04 March 2011");
|
return createClientAsEntity(requestSpec, responseSpec, "04 March 2011");
|
||||||
}
|
}
|
||||||
@@ -281,6 +291,25 @@ public class ClientHelper extends IntegrationTest {
|
|||||||
return GSON.toJson(map);
|
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,
|
public static String getTestEntityClientAsJSON(final String dateOfJoining, final String officeId,
|
||||||
final Integer soleProprietorCodeValueId) {
|
final Integer soleProprietorCodeValueId) {
|
||||||
final HashMap<String, Object> map = new HashMap<>();
|
final HashMap<String, Object> map = new HashMap<>();
|
||||||
@@ -665,7 +694,7 @@ public class ClientHelper extends IntegrationTest {
|
|||||||
public String importClientEntityTemplate(File file) {
|
public String importClientEntityTemplate(File file) {
|
||||||
String locale = "en";
|
String locale = "en";
|
||||||
String dateFormat = "dd MMMM yyyy";
|
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);
|
requestSpec.header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA);
|
||||||
return Utils.performServerTemplatePost(requestSpec, responseSpec, CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
|
return Utils.performServerTemplatePost(requestSpec, responseSpec, CLIENT_URL + "/uploadtemplate" + "?" + Utils.TENANT_IDENTIFIER,
|
||||||
legalFormType, file, locale, dateFormat);
|
legalFormType, file, locale, dateFormat);
|
||||||
|
|||||||
@@ -210,6 +210,7 @@ public final class Utils {
|
|||||||
|
|
||||||
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
public static <T> T performServerPost(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
|
||||||
final String postURL, final String jsonBodyToSend, final String jsonAttributeToGetBack) {
|
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)
|
final String json = given().spec(requestSpec).body(jsonBodyToSend).expect().spec(responseSpec).log().ifError().when().post(postURL)
|
||||||
.andReturn().asString();
|
.andReturn().asString();
|
||||||
if (jsonAttributeToGetBack == null) {
|
if (jsonAttributeToGetBack == null) {
|
||||||
|
|||||||
+12
@@ -22,6 +22,8 @@ import com.google.gson.Gson;
|
|||||||
import io.restassured.specification.RequestSpecification;
|
import io.restassured.specification.RequestSpecification;
|
||||||
import io.restassured.specification.ResponseSpecification;
|
import io.restassured.specification.ResponseSpecification;
|
||||||
import java.util.HashMap;
|
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.apache.fineract.integrationtests.common.Utils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
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 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) {
|
public EntityDatatableChecksHelper(final RequestSpecification requestSpec, final ResponseSpecification responseSpec) {
|
||||||
this.requestSpec = requestSpec;
|
this.requestSpec = requestSpec;
|
||||||
this.responseSpec = responseSpec;
|
this.responseSpec = responseSpec;
|
||||||
@@ -45,6 +49,14 @@ public class EntityDatatableChecksHelper {
|
|||||||
getTestEdcAsJSON(apptableName, datatableName, status, productId), "resourceId");
|
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) {
|
public Integer deleteEntityDatatableCheck(final Integer entityDatatableCheckId) {
|
||||||
return Utils.performServerDelete(requestSpec, responseSpec,
|
return Utils.performServerDelete(requestSpec, responseSpec,
|
||||||
DATATABLE_CHECK_URL + "/" + entityDatatableCheckId + "?" + Utils.TENANT_IDENTIFIER, "resourceId");
|
DATATABLE_CHECK_URL + "/" + entityDatatableCheckId + "?" + Utils.TENANT_IDENTIFIER, "resourceId");
|
||||||
|
|||||||
+74
@@ -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.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import io.restassured.builder.RequestSpecBuilder;
|
import io.restassured.builder.RequestSpecBuilder;
|
||||||
import io.restassured.builder.ResponseSpecBuilder;
|
import io.restassured.builder.ResponseSpecBuilder;
|
||||||
import io.restassured.http.ContentType;
|
import io.restassured.http.ContentType;
|
||||||
@@ -30,6 +31,8 @@ import java.math.BigDecimal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
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.ClientHelper;
|
||||||
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
|
import org.apache.fineract.integrationtests.common.CollateralManagementHelper;
|
||||||
import org.apache.fineract.integrationtests.common.CommonConstants;
|
import org.apache.fineract.integrationtests.common.CommonConstants;
|
||||||
@@ -549,4 +552,75 @@ public class EntityDatatableChecksIntegrationTest {
|
|||||||
datatablesListMap.add(datatableMap);
|
datatablesListMap.add(datatableMap);
|
||||||
return datatablesListMap;
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user