Search in sources :

Example 6 with CustomerCheckListBO

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

the class CheckListServiceFacadeWebTier method createCustomerChecklist.

@Override
public void createCustomerChecklist(Short levelId, Short stateId, String checklistName, List<String> checklistDetails) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    CustomerLevel level = CustomerLevel.getLevel(levelId);
    CustomerLevelEntity customerLevelEntity = new CustomerLevelEntity(level);
    CustomerStatusEntity customerStatusEntity = new CustomerStatusEntity(stateId);
    try {
        hibernateTransactionHelper.startTransaction();
        CustomerCheckListBO customerCheckListBO = new CustomerCheckListBO(customerLevelEntity, customerStatusEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
        customerDao.save(customerCheckListBO);
        hibernateTransactionHelper.commitTransaction();
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : CustomerLevel(org.mifos.customers.api.CustomerLevel) CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) BusinessRuleException(org.mifos.service.BusinessRuleException) UserContext(org.mifos.security.util.UserContext) CustomerLevelEntity(org.mifos.customers.business.CustomerLevelEntity) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException)

Example 7 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO 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 8 with CustomerCheckListBO

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

the class CheckListServiceFacadeWebTier method retreiveAllCustomerCheckLists.

@Override
public List<CustomerCheckBoxItemDto> retreiveAllCustomerCheckLists() {
    try {
        List<CustomerCheckListBO> customerCheckLists = new CheckListBusinessService().retreiveAllCustomerCheckLists();
        List<CustomerCheckBoxItemDto> dtoList = new ArrayList<CustomerCheckBoxItemDto>();
        for (CustomerCheckListBO bo : customerCheckLists) {
            String lookUpName = bo.getCustomerStatus().getLookUpValue() != null ? bo.getCustomerStatus().getLookUpValue().getLookUpName() : null;
            CustomerCheckBoxItemDto dto = new CustomerCheckBoxItemDto(bo.getChecklistId(), bo.getChecklistName(), bo.getChecklistStatus(), null, lookUpName, bo.getCustomerStatus().getId(), bo.getCustomerLevel().getId());
            if (dto.getLookUpName() != null) {
                dto.setName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(dto.getLookUpName()));
            }
            dtoList.add(dto);
        }
        return dtoList;
    } catch (ServiceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) ServiceException(org.mifos.framework.exceptions.ServiceException) ArrayList(java.util.ArrayList) CheckListBusinessService(org.mifos.customers.checklist.business.service.CheckListBusinessService) CustomerCheckBoxItemDto(org.mifos.dto.screen.CustomerCheckBoxItemDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 9 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO 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)

Example 10 with CustomerCheckListBO

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

the class CheckListActionStrutsTest method testGetStatesDuplicateForCustomer.

@Test
public void testGetStatesDuplicateForCustomer() throws Exception {
    CustomerCheckListBO checkList = TestObjectFactory.createCustomerChecklist(CustomerLevel.GROUP.getValue(), CustomerStatus.GROUP_ACTIVE.getValue(), (short) 1);
    StaticHibernateUtil.flushSession();
    setRequestPathInfo("/chkListAction");
    addRequestParameter("method", "getStates");
    addRequestParameter("masterTypeId", "2");
    addRequestParameter("isCustomer", "true");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.load_success.toString());
    Assert.assertNotNull(request.getAttribute(Constants.CURRENTFLOWKEY));
    List<CheckListStatesView> states = (List<CheckListStatesView>) SessionUtils.getAttribute(CheckListConstants.STATES, request);
    for (CheckListStatesView state : states) {
        Assert.assertNotSame(state.getStateId(), checkList.getCustomerStatus().getId());
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) CheckListStatesView(org.mifos.dto.screen.CheckListStatesView) List(java.util.List) Test(org.junit.Test)

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