Search in sources :

Example 1 with CustomerPositionEntity

use of org.mifos.customers.business.CustomerPositionEntity in project head by mifos.

the class CenterServiceFacadeWebTier method generatePositionsFromExistingCustomerPositions.

private void generatePositionsFromExistingCustomerPositions(CustomerBO customer, List<PositionEntity> customerPositions, List<CustomerPositionDto> customerPositionDtos) {
    for (PositionEntity position : customerPositions) {
        for (CustomerPositionEntity entity : customer.getCustomerPositions()) {
            if (position.getId().equals(entity.getPosition().getId())) {
                CustomerPositionDto customerPosition;
                if (entity.getCustomer() != null) {
                    customerPosition = new CustomerPositionDto(entity.getCustomer().getCustomerId(), entity.getPosition().getId(), entity.getPosition().getName());
                } else {
                    customerPosition = new CustomerPositionDto(customer.getCustomerId(), entity.getPosition().getId(), entity.getPosition().getName());
                }
                customerPositionDtos.add(customerPosition);
            }
        }
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 2 with CustomerPositionEntity

use of org.mifos.customers.business.CustomerPositionEntity in project head by mifos.

the class GroupServiceFacadeWebTier method generatePositionsFromExistingCustomerPositions.

private void generatePositionsFromExistingCustomerPositions(CustomerBO customer, List<PositionEntity> customerPositions, List<CustomerPositionDto> customerPositionDtos) {
    for (PositionEntity position : customerPositions) {
        for (CustomerPositionEntity entity : customer.getCustomerPositions()) {
            if (position.getId().equals(entity.getPosition().getId())) {
                CustomerPositionDto customerPosition;
                if (entity.getCustomer() != null) {
                    customerPosition = new CustomerPositionDto(entity.getCustomer().getCustomerId(), entity.getPosition().getId(), entity.getPosition().getName());
                } else {
                    customerPosition = new CustomerPositionDto(customer.getCustomerId(), entity.getPosition().getId(), entity.getPosition().getName());
                }
                customerPositionDtos.add(customerPosition);
            }
        }
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 3 with CustomerPositionEntity

use of org.mifos.customers.business.CustomerPositionEntity in project head by mifos.

the class CustomerServiceImpl method assembleCustomerPostionsFromDto.

private void assembleCustomerPostionsFromDto(List<CustomerPositionDto> customerPositions, CustomerBO customer) {
    for (CustomerPositionDto positionView : customerPositions) {
        boolean isPositionFound = false;
        for (CustomerPositionEntity positionEntity : customer.getCustomerPositions()) {
            if (positionView.getPositionId().equals(positionEntity.getPosition().getId())) {
                CustomerBO customerInPosition = null;
                if (positionView.getCustomerId() != null) {
                    customerInPosition = customerDao.findCustomerById(positionView.getCustomerId());
                }
                positionEntity.setCustomer(customerInPosition);
                isPositionFound = true;
                break;
            }
        }
        if (!isPositionFound) {
            CustomerBO customerInPosition = null;
            if (positionView.getCustomerId() != null) {
                customerInPosition = customerDao.findCustomerById(positionView.getCustomerId());
            }
            CustomerPositionEntity customerPosition = new CustomerPositionEntity(new PositionEntity(positionView.getPositionId()), customerInPosition, customer);
            customer.addCustomerPosition(customerPosition);
        }
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPositionDto(org.mifos.dto.domain.CustomerPositionDto)

Example 4 with CustomerPositionEntity

use of org.mifos.customers.business.CustomerPositionEntity in project head by mifos.

the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsNotAssignedPosition.

@Test
public void testUIHelperWhenClientIsNotAssignedPosition() throws CustomerException, PageExpiredException {
    createInitialObjects();
    PositionEntity positionEntity = (PositionEntity) TestObjectFactory.getObject(PositionEntity.class, Short.valueOf("1"));
    CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(positionEntity, client, client.getParentCustomer());
    group.addCustomerPosition(customerPositionEntity);
    group.update();
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group.setUserContext(TestObjectFactory.getContext());
    CustomerDetailDto clientDetail = new CustomerDetailDto(client.getCustomerId(), client.getDisplayName(), client.getSearchId(), client.getGlobalCustNum());
    List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        customerPositions.add(new CustomerPositionOtherDto(customerPosition.getPosition().getName(), customerPosition.getCustomer().getCustomerId(), customerPosition.getCustomer().getDisplayName()));
    }
    String positionName = CustomerUIHelperFn.getClientPosition(customerPositions, clientDetail);
    Assert.assertEquals("(Center Leader)", positionName);
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.loadStatus.toString());
    addRequestParameter("customerId", client.getCustomerId().toString());
    actionPerform();
    verifyForward(ActionForwards.loadStatus_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
    Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.previewStatus.toString());
    addRequestParameter("notes", "Test");
    addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
    addRequestParameter("newStatusId", "6");
    addRequestParameter("flagId", "7");
    actionPerform();
    verifyForward(ActionForwards.previewStatus_success.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
    Assert.assertNotNull("Since new Status is Closed,so flag should be Duplicate.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request));
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNotNull(customerPosition.getCustomer());
        break;
    }
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.updateStatus.toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.client_detail_page.toString());
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    Assert.assertFalse(client.isActive());
    for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
        Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
        break;
    }
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNull(customerPosition.getCustomer());
        break;
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) ArrayList(java.util.ArrayList) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerFlagDetailEntity(org.mifos.customers.business.CustomerFlagDetailEntity) Test(org.junit.Test)

Example 5 with CustomerPositionEntity

use of org.mifos.customers.business.CustomerPositionEntity in project head by mifos.

the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsAssignedPosition.

@Test
public void testUIHelperWhenClientIsAssignedPosition() throws CustomerException, PageExpiredException {
    createInitialObjects();
    PositionEntity positionEntity = (PositionEntity) TestObjectFactory.getObject(PositionEntity.class, Short.valueOf("1"));
    CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(positionEntity, client, client.getParentCustomer());
    group.addCustomerPosition(customerPositionEntity);
    group.update();
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group.setUserContext(TestObjectFactory.getContext());
    CustomerDetailDto clientDetail = new CustomerDetailDto(client.getCustomerId(), client.getDisplayName(), client.getSearchId(), client.getGlobalCustNum());
    List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        customerPositions.add(new CustomerPositionOtherDto(customerPosition.getPosition().getName(), customerPosition.getCustomer().getCustomerId(), customerPosition.getCustomer().getDisplayName()));
    }
    String positionName = CustomerUIHelperFn.getClientPosition(customerPositions, clientDetail);
    Assert.assertEquals("(Center Leader)", positionName);
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.loadStatus.toString());
    addRequestParameter("customerId", client.getCustomerId().toString());
    actionPerform();
    verifyForward(ActionForwards.loadStatus_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
    Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.previewStatus.toString());
    addRequestParameter("notes", "Test");
    addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
    addRequestParameter("newStatusId", "6");
    addRequestParameter("flagId", "7");
    actionPerform();
    verifyForward(ActionForwards.previewStatus_success.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
    Assert.assertNotNull("Since new Status is Closed,so flag should be Duplicate.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request));
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNotNull(customerPosition.getCustomer());
        break;
    }
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.updateStatus.toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.client_detail_page.toString());
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    Assert.assertFalse(client.isActive());
    for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
        Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
        break;
    }
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNull(customerPosition.getCustomer());
        break;
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) ArrayList(java.util.ArrayList) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerFlagDetailEntity(org.mifos.customers.business.CustomerFlagDetailEntity) Test(org.junit.Test)

Aggregations

CustomerPositionEntity (org.mifos.customers.business.CustomerPositionEntity)8 PositionEntity (org.mifos.customers.business.PositionEntity)7 Test (org.junit.Test)4 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 CustomerFlagDetailEntity (org.mifos.customers.business.CustomerFlagDetailEntity)3 CustomerPositionDto (org.mifos.dto.domain.CustomerPositionDto)3 ArrayList (java.util.ArrayList)2 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)2 CustomerPositionOtherDto (org.mifos.dto.domain.CustomerPositionOtherDto)2 Ignore (org.junit.Ignore)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 GroupInformationDto (org.mifos.dto.screen.GroupInformationDto)1