use of org.mifos.customers.checklist.business.AccountCheckListBO in project head by mifos.
the class ChkListAction method update.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ChkListActionForm chkListActionForm = (ChkListActionForm) form;
Short stateId = getShortValue(chkListActionForm.getStateId());
String checklistName = chkListActionForm.getChecklistName();
Short checklistStatus = getShortValue(chkListActionForm.getChecklistStatus());
List<String> details = chkListActionForm.getValidCheckListDetails();
if (chkListActionForm.getIsCustomer()) {
CustomerCheckListBO customerCheckList = (CustomerCheckListBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Short levelId = getShortValue(chkListActionForm.getMasterTypeId());
this.checkListServiceFacade.updateCustomerChecklist(customerCheckList.getChecklistId(), levelId, stateId, checklistStatus, checklistName, details);
} else {
AccountCheckListBO accountCheckList = (AccountCheckListBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Short productId = getShortValue(chkListActionForm.getMasterTypeId());
this.checkListServiceFacade.updateAccountChecklist(accountCheckList.getChecklistId(), productId, stateId, checklistStatus, checklistName, details);
}
return mapping.findForward(ActionForwards.update_success.toString());
}
use of org.mifos.customers.checklist.business.AccountCheckListBO 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());
}
use of org.mifos.customers.checklist.business.AccountCheckListBO in project head by mifos.
the class CheckListActionStrutsTest method testUpdate_product.
@Test
public void testUpdate_product() throws Exception {
CheckListBO checkList = TestObjectFactory.createAccountChecklist(ProductType.LOAN.getValue(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, (short) 1);
StaticHibernateUtil.flushSession();
checkList = (CheckListBO) TestObjectFactory.getObject(AccountCheckListBO.class, checkList.getChecklistId());
setRequestPathInfo("/chkListAction");
addRequestParameter("method", "update");
addRequestParameter("checklistName", checkList.getChecklistName());
addRequestParameter("isCustomer", "false");
addRequestParameter("detailsList[0]", "newdetails");
addRequestParameter("masterTypeId", ((AccountCheckListBO) checkList).getProductTypeEntity().getProductTypeID().toString());
addRequestParameter("stateId", ((AccountCheckListBO) checkList).getAccountStateEntity().getId().toString());
addRequestParameter("checklistStatus", CheckListConstants.STATUS_INACTIVE.toString());
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, checkList, request);
actionPerform();
verifyNoActionErrors();
verifyForward(ActionForwards.update_success.toString());
Assert.assertNull(request.getAttribute(Constants.CURRENTFLOWKEY));
StaticHibernateUtil.flushSession();
checkList = (CheckListBO) TestObjectFactory.getObject(AccountCheckListBO.class, checkList.getChecklistId());
Assert.assertEquals(1, checkList.getChecklistDetails().size());
checkList = null;
}
use of org.mifos.customers.checklist.business.AccountCheckListBO in project head by mifos.
the class CheckListServiceFacadeWebTier method createAccountChecklist.
@Override
public void createAccountChecklist(Short productId, Short stateId, 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 accountCheckListBO = new AccountCheckListBO(productTypeEntity, accountStateEntity, checklistName, CheckListConstants.STATUS_ACTIVE, checklistDetails, userContext.getLocaleId(), userContext.getId());
customerDao.save(accountCheckListBO);
hibernateTransactionHelper.commitTransaction();
} catch (ServiceException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (CheckListException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.checklist.business.AccountCheckListBO in project head by mifos.
the class EditStatusAction method preview.
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
AccountBO accountBO = (AccountBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
// FIXME - ElsieF - KEITHW - is checklist functionality being removed from application?
List<AccountCheckListBO> checklist = new AccountBusinessService().getStatusChecklist(getShortValue(editStatusActionForm.getNewStatusId()), getShortValue(editStatusActionForm.getAccountTypeId()));
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_CHECK_LIST, checklist, request);
String newStatusId = editStatusActionForm.getNewStatusId();
String newStatusName = null;
if (StringUtils.isNotBlank(editStatusActionForm.getNewStatusId())) {
newStatusName = new AccountBusinessService().getStatusName(AccountState.fromShort(getShortValue(editStatusActionForm.getNewStatusId())), accountBO.getType());
}
SessionUtils.setAttribute(SavingsConstants.NEW_STATUS_NAME, newStatusName, request);
initializeLoanQuestionnaire(accountBO.getGlobalAccountNum(), newStatusId);
if (loanApproved(newStatusId) || loanClosed(newStatusId)) {
return loanQuestionnaire.fetchAppliedQuestions(mapping, editStatusActionForm, request, ActionForwards.preview_success);
}
return mapping.findForward(ActionForwards.preview_success.toString());
}
Aggregations