use of org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm in project head by mifos.
the class EditCustomerStatusAction method getDetailAccountPage.
private String getDetailAccountPage(ActionForm form) {
EditCustomerStatusActionForm editStatusActionForm = (EditCustomerStatusActionForm) form;
String input = editStatusActionForm.getInput();
String forward = null;
if (input.equals("center")) {
forward = ActionForwards.center_detail_page.toString();
} else if (input.equals("group")) {
forward = ActionForwards.group_detail_page.toString();
} else if (input.equals("client")) {
forward = ActionForwards.client_detail_page.toString();
}
return forward;
}
use of org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm in project head by mifos.
the class EditCustomerStatusAction method loadStatus.
@TransactionDemarcate(joinToken = true)
public ActionForward loadStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In EditCustomerStatusAction:load()");
EditCustomerStatusActionForm editCustomerStatusActionForm = (EditCustomerStatusActionForm) form;
editCustomerStatusActionForm.clear();
UserContext userContext = getUserContext(request);
Integer customerId = editCustomerStatusActionForm.getCustomerIdValue();
CustomerBO customer = this.customerDao.findCustomerById(customerId);
customer.setUserContext(userContext);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, customer, request);
List<CustomerStatusEntity> statusList = new ArrayList<CustomerStatusEntity>();
switch(customer.getLevel()) {
case CENTER:
this.centerServiceFacade.initializeCenterStates(customer.getGlobalCustNum());
statusList = AccountStateMachines.getInstance().getCenterStatusList(customer.getCustomerStatus());
editCustomerStatusActionForm.setInput("center");
break;
case GROUP:
this.centerServiceFacade.initializeGroupStates(customer.getGlobalCustNum());
statusList = AccountStateMachines.getInstance().getGroupStatusList(customer.getCustomerStatus());
editCustomerStatusActionForm.setInput("group");
break;
case CLIENT:
this.centerServiceFacade.initializeClientStates(customer.getGlobalCustNum());
statusList = AccountStateMachines.getInstance().getClientStatusList(customer.getCustomerStatus());
editCustomerStatusActionForm.setInput("client");
break;
default:
break;
}
;
for (CustomerStatusEntity customerStatusEntity : statusList) {
for (CustomerStatusFlagEntity flag : customerStatusEntity.getFlagSet()) {
String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
flag.setStatusFlagMessageText(statusMessageText);
}
}
editCustomerStatusActionForm.setLevelId(customer.getCustomerLevel().getId().toString());
editCustomerStatusActionForm.setCurrentStatusId(customer.getCustomerStatus().getId().toString());
editCustomerStatusActionForm.setGlobalAccountNum(customer.getGlobalCustNum());
editCustomerStatusActionForm.setCustomerName(customer.getDisplayName());
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, statusList, request);
return mapping.findForward(ActionForwards.loadStatus_success.toString());
}
use of org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm in project head by mifos.
the class EditCustomerStatusAction method updateStatus.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
EditCustomerStatusActionForm editStatusActionForm = (EditCustomerStatusActionForm) form;
CustomerBO customerBOInSession = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
if (customerBOInSession.isBlackListed() && customerBOInSession.getStatus().getValue() == CustomerConstants.CLIENT_CLOSED) {
try {
this.clientServiceFacade.removeFromBlacklist(customerBOInSession.getCustomerId());
customerBOInSession.setVersionNo(customerBOInSession.getVersionNo() + 1);
} catch (AccessDeniedException e) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
try {
this.centerServiceFacade.updateCustomerStatus(customerBOInSession.getCustomerId(), customerBOInSession.getVersionNo(), editStatusActionForm.getFlagId(), editStatusActionForm.getNewStatusId(), editStatusActionForm.getNotes());
createClientQuestionnaire.saveResponses(request, editStatusActionForm, customerBOInSession.getCustomerId());
} catch (BusinessRuleException e) {
throw new ApplicationException(e.getMessageKey(), e);
}
return mapping.findForward(getDetailAccountPage(form));
}
use of org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm in project head by mifos.
the class EditCustomerStatusAction method previewStatus.
@TransactionDemarcate(joinToken = true)
public ActionForward previewStatus(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In EditCustomerStatusAction:preview()");
CustomerBO customerBO = (CustomerBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
EditCustomerStatusActionForm statusActionForm = (EditCustomerStatusActionForm) form;
statusActionForm.setCommentDate(DateUtils.getCurrentDate(getUserContext(request).getPreferredLocale()));
if (StringUtils.isNotBlank(statusActionForm.getNewStatusId())) {
CustomerStatusDetailDto customerStatusDetail = this.centerServiceFacade.retrieveCustomerStatusDetails(statusActionForm.getNewStatusIdValue(), statusActionForm.getFlagIdValue(), customerBO.getLevel().getValue());
SessionUtils.setAttribute(SavingsConstants.NEW_STATUS_NAME, customerStatusDetail.getStatusName(), request);
SessionUtils.setAttribute(SavingsConstants.FLAG_NAME, customerStatusDetail.getFlagName(), request);
} else {
SessionUtils.setAttribute(SavingsConstants.NEW_STATUS_NAME, null, request);
SessionUtils.setAttribute(SavingsConstants.FLAG_NAME, null, request);
}
Short newStatusId = statusActionForm.getNewStatusIdValue();
Short customerLevelId = statusActionForm.getLevelIdValue();
List<CustomerCheckListBO> checklist = new CustomerPersistence().getStatusChecklist(newStatusId, customerLevelId);
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_CHECK_LIST, checklist, request);
if (statusActionForm.getNewStatusIdValue().equals(CustomerStatus.CLIENT_CLOSED.getValue())) {
return createClientQuestionnaire.fetchAppliedQuestions(mapping, statusActionForm, request, ActionForwards.previewStatus_success);
}
return mapping.findForward(ActionForwards.previewStatus_success.toString());
}
Aggregations