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);
|
||||
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);
|
||||
|
||||
+1
-1
@@ -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,
|
||||
|
||||
+1
-1
@@ -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:
|
||||
|
||||
+2
-2
@@ -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),
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
+2
-19
@@ -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 })
|
||||
|
||||
+6
-28
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -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,
|
||||
|
||||
+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);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
+17
-30
@@ -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());
|
||||
}
|
||||
|
||||
-30
@@ -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;
|
||||
|
||||
+13
-11
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+15
-53
@@ -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
|
||||
|
||||
-4
@@ -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
|
||||
|
||||
+7
-7
@@ -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);
|
||||
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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 ");
|
||||
|
||||
+30
-1
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
+12
@@ -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");
|
||||
|
||||
+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.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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user