Search in sources :

Example 1 with CheckListPersistence

use of org.mifos.customers.checklist.persistence.CheckListPersistence 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 2 with CheckListPersistence

use of org.mifos.customers.checklist.persistence.CheckListPersistence in project head by mifos.

the class CheckListServiceFacadeWebTier method updateCustomerChecklist.

@Override
public void updateCustomerChecklist(Short checklistId, Short levelId, Short stateId, Short checklistStatus, String checklistName, List<String> details) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(CustomerLevel.getLevel(levelId));
    CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(stateId);
    try {
        hibernateTransactionHelper.startTransaction();
        CustomerCheckListBO customerCheckList = (CustomerCheckListBO) new CheckListPersistence().getCheckList(checklistId);
        customerCheckList.update(customerLevelEntity, customerStatusEntity, checklistName, checklistStatus, details, userContext.getLocaleId(), userContext.getId());
        customerDao.save(customerCheckList);
        hibernateTransactionHelper.commitTransaction();
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } catch (PersistenceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with CheckListPersistence

use of org.mifos.customers.checklist.persistence.CheckListPersistence in project head by mifos.

the class CheckListServiceFacadeWebTier method retrieveChecklistMasterData.

@Override
public List<CheckListMasterDto> retrieveChecklistMasterData() {
    try {
        Short localeIdNotUsed = null;
        List<CheckListMasterDto> masterData = new CheckListPersistence().getCheckListMasterData(localeIdNotUsed);
        for (CheckListMasterDto checkListMasterDto : masterData) {
            if (checkListMasterDto.isCustomer()) {
                checkListMasterDto.setMasterTypeName(ApplicationContextProvider.getBean(MessageLookup.class).lookupLabel(checkListMasterDto.getLookupKey()));
            } else {
                checkListMasterDto.setMasterTypeName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(checkListMasterDto.getLookupKey()));
            }
        }
        return masterData;
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) PersistenceException(org.mifos.framework.exceptions.PersistenceException) CheckListMasterDto(org.mifos.dto.domain.CheckListMasterDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 4 with CheckListPersistence

use of org.mifos.customers.checklist.persistence.CheckListPersistence in project head by mifos.

the class CheckListServiceFacadeWebTier method updateAccountChecklist.

@Override
public void updateAccountChecklist(Short checklistId, Short productId, Short stateId, Short checklistStatus, String checklistName, List<String> checklistDetails) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    try {
        ProductTypeEntity productTypeEntity = null;
        for (ProductTypeEntity prdTypeEntity : new ProductCategoryBusinessService().getProductTypes()) {
            if (productId.equals(prdTypeEntity.getProductTypeID())) {
                productTypeEntity = prdTypeEntity;
                break;
            }
        }
        hibernateTransactionHelper.startTransaction();
        AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.fromShort(stateId));
        AccountCheckListBO accountCheckList = (AccountCheckListBO) new CheckListPersistence().getCheckList(checklistId);
        accountCheckList.update(productTypeEntity, accountStateEntity, checklistName, checklistStatus, checklistDetails, userContext.getLocaleId(), userContext.getId());
        customerDao.save(accountCheckList);
        hibernateTransactionHelper.commitTransaction();
    } catch (ServiceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } catch (PersistenceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) BusinessRuleException(org.mifos.service.BusinessRuleException) ServiceException(org.mifos.framework.exceptions.ServiceException) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 5 with CheckListPersistence

use of org.mifos.customers.checklist.persistence.CheckListPersistence in project head by mifos.

the class ChkListAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ChkListActionForm chkListActionForm = (ChkListActionForm) form;
    Short localeId = getUserContext(request).getLocaleId();
    Short checklistId = getShortValue(chkListActionForm.getCheckListId());
    CheckListBO checkList = new CheckListPersistence().getCheckList(checklistId);
    if (checkList.getCheckListType().equals(CheckListType.CUSTOMER_CHECKLIST)) {
        CustomerCheckListBO customerCheckList = (CustomerCheckListBO) checkList;
        SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerCheckList, request);
        SessionUtils.setAttribute(CheckListConstants.TYPE, CheckListType.CUSTOMER_CHECKLIST.getValue(), request);
    } else {
        AccountCheckListBO accountCheckList = (AccountCheckListBO) checkList;
        SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountCheckList, request);
        SessionUtils.setAttribute(CheckListConstants.TYPE, CheckListType.ACCOUNT_CHECKLIST.getValue(), request);
    }
    SessionUtils.setAttribute(CheckListConstants.CREATED_BY_NAME, new PersonnelBusinessService().getPersonnel(checkList.getCreatedBy()).getDisplayName(), request);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) PersonnelBusinessService(org.mifos.customers.personnel.business.service.PersonnelBusinessService) ChkListActionForm(org.mifos.customers.checklist.struts.actionforms.ChkListActionForm) 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)

Aggregations

CheckListPersistence (org.mifos.customers.checklist.persistence.CheckListPersistence)7 AccountCheckListBO (org.mifos.customers.checklist.business.AccountCheckListBO)4 CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 Test (org.junit.Test)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 CheckListBO (org.mifos.customers.checklist.business.CheckListBO)2 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)2 ChkListActionForm (org.mifos.customers.checklist.struts.actionforms.ChkListActionForm)2 CheckListMasterDto (org.mifos.dto.domain.CheckListMasterDto)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 ArrayList (java.util.ArrayList)1 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)1 ProductTypeEntity (org.mifos.accounts.productdefinition.business.ProductTypeEntity)1 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)1 CustomerLevelEntity (org.mifos.customers.business.CustomerLevelEntity)1