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);
}
}
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();
}
}
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());
}
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());
}
}
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());
}
}
Aggregations