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