Search in sources :

Example 6 with AccountCheckListBO

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

the class CheckListServiceFacadeWebTier method retreiveAllAccountCheckLists.

@Override
public List<AccountCheckBoxItemDto> retreiveAllAccountCheckLists() {
    try {
        List<AccountCheckListBO> accountCheckLists = new CheckListBusinessService().retreiveAllAccountCheckLists();
        List<AccountCheckBoxItemDto> dtoList = new ArrayList<AccountCheckBoxItemDto>();
        for (AccountCheckListBO bo : accountCheckLists) {
            String lookUpName = bo.getAccountStateEntity().getLookUpValue() != null ? bo.getAccountStateEntity().getLookUpValue().getLookUpName() : null;
            AccountCheckBoxItemDto dto = new AccountCheckBoxItemDto(bo.getChecklistId(), bo.getChecklistName(), bo.getChecklistStatus(), null, lookUpName, bo.getAccountStateEntity().getId(), bo.getProductTypeEntity().getProductTypeID());
            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 : ServiceException(org.mifos.framework.exceptions.ServiceException) AccountCheckBoxItemDto(org.mifos.dto.screen.AccountCheckBoxItemDto) ArrayList(java.util.ArrayList) CheckListBusinessService(org.mifos.customers.checklist.business.service.CheckListBusinessService) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with AccountCheckListBO

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

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

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

the class CheckListActionStrutsTest method testCreate_product.

@Test
public void testCreate_product() throws Exception {
    setRequestPathInfo("/chkListAction");
    addRequestParameter("method", "create");
    addRequestParameter("masterTypeId", "1");
    addRequestParameter("isCustomer", "false");
    addRequestParameter("stateId", "13");
    addRequestParameter("checklistName", "new checklistName");
    addRequestParameter("detailsList[0]", "newdetails");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.create_success.toString());
    List<AccountCheckListBO> accountCheckLists = new CheckListPersistence().retreiveAllAccountCheckLists();
    Assert.assertNotNull(accountCheckLists);
    Assert.assertEquals(1, accountCheckLists.size());
    Assert.assertNull(request.getAttribute(Constants.CURRENTFLOWKEY));
    for (AccountCheckListBO checkList : accountCheckLists) {
        Assert.assertEquals("new checklistName", checkList.getChecklistName());
        Assert.assertEquals("1", checkList.getProductTypeEntity().getProductTypeID().toString());
        Assert.assertEquals("1", checkList.getChecklistStatus().toString());
        Assert.assertEquals(1, checkList.getChecklistDetails().size());
    }
}
Also used : CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) Test(org.junit.Test)

Example 10 with AccountCheckListBO

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

the class CheckListActionStrutsTest method testGetStatesDuplicateForAccount.

@Test
public void testGetStatesDuplicateForAccount() throws Exception {
    AccountCheckListBO checkList = TestObjectFactory.createAccountChecklist(ProductType.LOAN.getValue(), AccountState.LOAN_APPROVED, (short) 1);
    StaticHibernateUtil.flushSession();
    setRequestPathInfo("/chkListAction");
    addRequestParameter("method", "getStates");
    addRequestParameter("masterTypeId", "1");
    addRequestParameter("isCustomer", "false");
    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.getAccountStateEntity().getId());
    }
}
Also used : CheckListStatesView(org.mifos.dto.screen.CheckListStatesView) List(java.util.List) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) Test(org.junit.Test)

Aggregations

AccountCheckListBO (org.mifos.customers.checklist.business.AccountCheckListBO)11 MifosRuntimeException (org.mifos.core.MifosRuntimeException)4 CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)4 CheckListPersistence (org.mifos.customers.checklist.persistence.CheckListPersistence)4 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 Test (org.junit.Test)3 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 ProductTypeEntity (org.mifos.accounts.productdefinition.business.ProductTypeEntity)3 CheckListBO (org.mifos.customers.checklist.business.CheckListBO)3 ChkListActionForm (org.mifos.customers.checklist.struts.actionforms.ChkListActionForm)3 ServiceException (org.mifos.framework.exceptions.ServiceException)3 ArrayList (java.util.ArrayList)2 ProductCategoryBusinessService (org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService)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