Search in sources :

Example 1 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO in project head by mifos.

the class ChkListAction method update.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ChkListActionForm chkListActionForm = (ChkListActionForm) form;
    Short stateId = getShortValue(chkListActionForm.getStateId());
    String checklistName = chkListActionForm.getChecklistName();
    Short checklistStatus = getShortValue(chkListActionForm.getChecklistStatus());
    List<String> details = chkListActionForm.getValidCheckListDetails();
    if (chkListActionForm.getIsCustomer()) {
        CustomerCheckListBO customerCheckList = (CustomerCheckListBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
        Short levelId = getShortValue(chkListActionForm.getMasterTypeId());
        this.checkListServiceFacade.updateCustomerChecklist(customerCheckList.getChecklistId(), levelId, stateId, checklistStatus, checklistName, details);
    } else {
        AccountCheckListBO accountCheckList = (AccountCheckListBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
        Short productId = getShortValue(chkListActionForm.getMasterTypeId());
        this.checkListServiceFacade.updateAccountChecklist(accountCheckList.getChecklistId(), productId, stateId, checklistStatus, checklistName, details);
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) ChkListActionForm(org.mifos.customers.checklist.struts.actionforms.ChkListActionForm) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO in project head by mifos.

the class ChkListAction method manage.

@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ChkListActionForm chkListActionForm = (ChkListActionForm) form;
    Short checklistId = getShortValue(chkListActionForm.getCheckListId());
    CheckListBO checkList = new CheckListPersistence().getCheckList(checklistId);
    if (checkList.getCheckListType().equals(CheckListType.CUSTOMER_CHECKLIST)) {
        chkListActionForm.setCheckListId(getStringValue(checkList.getChecklistId()));
        chkListActionForm.setChecklistName(checkList.getChecklistName());
        if (checkList.getCheckListType().equals(CheckListType.CUSTOMER_CHECKLIST)) {
            chkListActionForm.setMasterTypeId(getStringValue(((CustomerCheckListBO) checkList).getCustomerLevel().getId()));
            if (chkListActionForm.getMasterTypeId().equals(getStringValue(CustomerLevel.CENTER.getValue()))) {
                chkListActionForm.setType("0");
                chkListActionForm.setMasterTypeName(ConfigurationConstants.CENTER);
            } else if (chkListActionForm.getMasterTypeId().equals(getStringValue(CustomerLevel.GROUP.getValue()))) {
                chkListActionForm.setType("1");
                chkListActionForm.setMasterTypeName(ConfigurationConstants.GROUP);
            } else if (chkListActionForm.getMasterTypeId().equals(getStringValue(CustomerLevel.CLIENT.getValue()))) {
                chkListActionForm.setType("2");
                chkListActionForm.setMasterTypeName(ConfigurationConstants.CLIENT);
            }
            chkListActionForm.setStateName(((CustomerCheckListBO) checkList).getCustomerStatus().getName());
            chkListActionForm.setStateId(getStringValue(((CustomerCheckListBO) checkList).getCustomerStatus().getId()));
            chkListActionForm.setIsCustomer(true);
        } else {
            chkListActionForm.setMasterTypeId(getStringValue(((AccountCheckListBO) checkList).getProductTypeEntity().getProductTypeID()));
            if (chkListActionForm.getMasterTypeId().equals(getStringValue(ProductType.LOAN.getValue()))) {
                chkListActionForm.setType("3");
            } else {
                chkListActionForm.setType("4");
            }
            chkListActionForm.setMasterTypeName(((AccountCheckListBO) checkList).getProductTypeEntity().getName());
            chkListActionForm.setStateName(((AccountCheckListBO) checkList).getAccountStateEntity().getName());
            chkListActionForm.setStateId(getStringValue(((AccountCheckListBO) checkList).getAccountStateEntity().getId()));
            chkListActionForm.setIsCustomer(false);
        }
        if (checkList.getChecklistStatus().equals(CheckListConstants.STATUS_ACTIVE)) {
            chkListActionForm.setChecklistStatus(getStringValue(CheckListConstants.STATUS_ACTIVE));
        } else {
            chkListActionForm.setChecklistStatus(getStringValue(CheckListConstants.STATUS_INACTIVE));
        }
        List<String> details1 = new ArrayList<String>();
        for (CheckListDetailEntity checkListDetailEntity : checkList.getChecklistDetails()) {
            details1.add(checkListDetailEntity.getDetailText());
        }
        chkListActionForm.setDetailsList(details1);
        SessionUtils.setAttribute(Constants.BUSINESS_KEY, checkList, request);
        SessionUtils.setAttribute(CheckListConstants.TYPE, CheckListType.CUSTOMER_CHECKLIST.getValue(), request);
    } else {
        chkListActionForm.setCheckListId(getStringValue(checkList.getChecklistId()));
        chkListActionForm.setChecklistName(checkList.getChecklistName());
        if (checkList.getCheckListType().equals(CheckListType.CUSTOMER_CHECKLIST)) {
            chkListActionForm.setMasterTypeId(getStringValue(((CustomerCheckListBO) checkList).getCustomerLevel().getId()));
            if (chkListActionForm.getMasterTypeId().equals(getStringValue(CustomerLevel.CENTER.getValue()))) {
                chkListActionForm.setType("0");
                chkListActionForm.setMasterTypeName(ConfigurationConstants.CENTER);
            } else if (chkListActionForm.getMasterTypeId().equals(getStringValue(CustomerLevel.GROUP.getValue()))) {
                chkListActionForm.setType("1");
                chkListActionForm.setMasterTypeName(ConfigurationConstants.GROUP);
            } else if (chkListActionForm.getMasterTypeId().equals(getStringValue(CustomerLevel.CLIENT.getValue()))) {
                chkListActionForm.setType("2");
                chkListActionForm.setMasterTypeName(ConfigurationConstants.CLIENT);
            }
            chkListActionForm.setStateName(((CustomerCheckListBO) checkList).getCustomerStatus().getName());
            chkListActionForm.setStateId(getStringValue(((CustomerCheckListBO) checkList).getCustomerStatus().getId()));
            chkListActionForm.setIsCustomer(true);
        } else {
            chkListActionForm.setMasterTypeId(getStringValue(((AccountCheckListBO) checkList).getProductTypeEntity().getProductTypeID()));
            if (chkListActionForm.getMasterTypeId().equals(getStringValue(ProductType.LOAN.getValue()))) {
                chkListActionForm.setType("3");
            } else {
                chkListActionForm.setType("4");
            }
            chkListActionForm.setMasterTypeName(((AccountCheckListBO) checkList).getProductTypeEntity().getName());
            chkListActionForm.setStateName(((AccountCheckListBO) checkList).getAccountStateEntity().getName());
            chkListActionForm.setStateId(getStringValue(((AccountCheckListBO) checkList).getAccountStateEntity().getId()));
            chkListActionForm.setIsCustomer(false);
        }
        if (checkList.getChecklistStatus().equals(CheckListConstants.STATUS_ACTIVE)) {
            chkListActionForm.setChecklistStatus(getStringValue(CheckListConstants.STATUS_ACTIVE));
        } else {
            chkListActionForm.setChecklistStatus(getStringValue(CheckListConstants.STATUS_INACTIVE));
        }
        List<String> details1 = new ArrayList<String>();
        for (CheckListDetailEntity checkListDetailEntity : checkList.getChecklistDetails()) {
            details1.add(checkListDetailEntity.getDetailText());
        }
        chkListActionForm.setDetailsList(details1);
        SessionUtils.setAttribute(Constants.BUSINESS_KEY, checkList, request);
        SessionUtils.setAttribute(CheckListConstants.TYPE, CheckListType.ACCOUNT_CHECKLIST.getValue(), request);
    }
    List<CheckListMasterDto> masterData = this.checkListServiceFacade.retrieveChecklistMasterData();
    SessionUtils.setCollectionAttribute(CheckListConstants.CHECKLIST_MASTERDATA, masterData, request);
    List<CheckListStatesView> states = retrieveStates(chkListActionForm.getIsCustomer(), chkListActionForm.getMasterTypeId());
    deleteExistingStates(states, chkListActionForm.getIsCustomer(), chkListActionForm.getMasterTypeId(), Short.parseShort(chkListActionForm.getStateId()));
    SessionUtils.setCollectionAttribute(CheckListConstants.STATES, states, request);
    List<String> details = chkListActionForm.getValidCheckListDetails();
    SessionUtils.setCollectionAttribute(CheckListConstants.DETAILS, details, request);
    SessionUtils.setAttribute(CheckListConstants.OLDCHECKLISTNAME, checkList.getChecklistName(), request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) CheckListStatesView(org.mifos.dto.screen.CheckListStatesView) ChkListActionForm(org.mifos.customers.checklist.struts.actionforms.ChkListActionForm) ArrayList(java.util.ArrayList) CheckListDetailEntity(org.mifos.customers.checklist.business.CheckListDetailEntity) CheckListMasterDto(org.mifos.dto.domain.CheckListMasterDto) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CheckListBO(org.mifos.customers.checklist.business.CheckListBO) CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO in project head by mifos.

the class EditCustomerStatusAction method previewStatus.

@TransactionDemarcate(joinToken = true)
public ActionForward previewStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In EditCustomerStatusAction:preview()");
    CustomerBO customerBO = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    EditCustomerStatusActionForm statusActionForm = (EditCustomerStatusActionForm) form;
    statusActionForm.setCommentDate(DateUtils.getCurrentDate(getUserContext(request).getPreferredLocale()));
    if (StringUtils.isNotBlank(statusActionForm.getNewStatusId())) {
        CustomerStatusDetailDto customerStatusDetail = this.centerServiceFacade.retrieveCustomerStatusDetails(statusActionForm.getNewStatusIdValue(), statusActionForm.getFlagIdValue(), customerBO.getLevel().getValue());
        SessionUtils.setAttribute(SavingsConstants.NEW_STATUS_NAME, customerStatusDetail.getStatusName(), request);
        SessionUtils.setAttribute(SavingsConstants.FLAG_NAME, customerStatusDetail.getFlagName(), request);
    } else {
        SessionUtils.setAttribute(SavingsConstants.NEW_STATUS_NAME, null, request);
        SessionUtils.setAttribute(SavingsConstants.FLAG_NAME, null, request);
    }
    Short newStatusId = statusActionForm.getNewStatusIdValue();
    Short customerLevelId = statusActionForm.getLevelIdValue();
    List<CustomerCheckListBO> checklist = new CustomerPersistence().getStatusChecklist(newStatusId, customerLevelId);
    SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_CHECK_LIST, checklist, request);
    if (statusActionForm.getNewStatusIdValue().equals(CustomerStatus.CLIENT_CLOSED.getValue())) {
        return createClientQuestionnaire.fetchAppliedQuestions(mapping, statusActionForm, request, ActionForwards.previewStatus_success);
    }
    return mapping.findForward(ActionForwards.previewStatus_success.toString());
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) EditCustomerStatusActionForm(org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO in project head by mifos.

the class CustomerPersistenceIntegrationTest method testGetCustomerChecklist.

@Test
public void testGetCustomerChecklist() throws NumberFormatException, SystemException, ApplicationException, Exception {
    center = createCenter("center");
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    client = TestObjectFactory.createClient("client1", CustomerStatus.CLIENT_ACTIVE, group);
    CustomerCheckListBO checklistCenter = TestObjectFactory.createCustomerChecklist(center.getCustomerLevel().getId(), center.getCustomerStatus().getId(), CheckListConstants.STATUS_ACTIVE);
    CustomerCheckListBO checklistClient = TestObjectFactory.createCustomerChecklist(client.getCustomerLevel().getId(), client.getCustomerStatus().getId(), CheckListConstants.STATUS_INACTIVE);
    CustomerCheckListBO checklistGroup = TestObjectFactory.createCustomerChecklist(group.getCustomerLevel().getId(), group.getCustomerStatus().getId(), CheckListConstants.STATUS_ACTIVE);
    Assert.assertEquals(1, customerPersistence.getStatusChecklist(center.getCustomerStatus().getId(), center.getCustomerLevel().getId()).size());
    client = (ClientBO) StaticHibernateUtil.getSessionTL().get(ClientBO.class, Integer.valueOf(client.getCustomerId()));
    group = (GroupBO) StaticHibernateUtil.getSessionTL().get(GroupBO.class, Integer.valueOf(group.getCustomerId()));
    center = (CenterBO) StaticHibernateUtil.getSessionTL().get(CenterBO.class, Integer.valueOf(center.getCustomerId()));
    checklistCenter = (CustomerCheckListBO) StaticHibernateUtil.getSessionTL().get(CheckListBO.class, new Short(checklistCenter.getChecklistId()));
    checklistClient = (CustomerCheckListBO) StaticHibernateUtil.getSessionTL().get(CheckListBO.class, new Short(checklistClient.getChecklistId()));
    checklistGroup = (CustomerCheckListBO) StaticHibernateUtil.getSessionTL().get(CheckListBO.class, new Short(checklistGroup.getChecklistId()));
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) Test(org.junit.Test)

Example 5 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO in project head by mifos.

the class IntegrationTestObjectMother method createCustomerChecklist.

public static CustomerCheckListBO createCustomerChecklist(Short customerLevel, Short customerStatus, Short checklistStatus, List<String> details) {
    try {
        StaticHibernateUtil.startTransaction();
        CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.getLevel(customerLevel));
        CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(CustomerStatus.fromInt(customerStatus));
        CustomerCheckListBO customerChecklist = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, "productchecklist", checklistStatus, details, Short.valueOf("1"), PersonnelConstants.SYSTEM_USER);
        customerDao.save(customerChecklist);
        StaticHibernateUtil.commitTransaction();
        return customerChecklist;
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new RuntimeException(e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException) CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException)

Aggregations

CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)12 Test (org.junit.Test)4 AccountCheckListBO (org.mifos.customers.checklist.business.AccountCheckListBO)4 CheckListPersistence (org.mifos.customers.checklist.persistence.CheckListPersistence)4 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 CustomerLevelEntity (org.mifos.customers.business.CustomerLevelEntity)3 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)3 CheckListBO (org.mifos.customers.checklist.business.CheckListBO)3 ChkListActionForm (org.mifos.customers.checklist.struts.actionforms.ChkListActionForm)3 ArrayList (java.util.ArrayList)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)2 CheckListStatesView (org.mifos.dto.screen.CheckListStatesView)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 List (java.util.List)1 AccountException (org.mifos.accounts.exceptions.AccountException)1