Search in sources :

Example 1 with EditCustomerStatusActionForm

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;
}
Also used : EditCustomerStatusActionForm(org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm)

Example 2 with EditCustomerStatusActionForm

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());
}
Also used : EditCustomerStatusActionForm(org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm) UserContext(org.mifos.security.util.UserContext) MessageLookup(org.mifos.application.master.MessageLookup) ArrayList(java.util.ArrayList) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerStatusFlagEntity(org.mifos.customers.business.CustomerStatusFlagEntity) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with EditCustomerStatusActionForm

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));
}
Also used : AccessDeniedException(org.springframework.security.access.AccessDeniedException) CustomerException(org.mifos.customers.exceptions.CustomerException) BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) EditCustomerStatusActionForm(org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm) CustomerBO(org.mifos.customers.business.CustomerBO) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with EditCustomerStatusActionForm

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());
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) CustomerStatusDetailDto(org.mifos.dto.screen.CustomerStatusDetailDto) EditCustomerStatusActionForm(org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerPersistence(org.mifos.customers.persistence.CustomerPersistence) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

EditCustomerStatusActionForm (org.mifos.customers.struts.actionforms.EditCustomerStatusActionForm)4 CustomerBO (org.mifos.customers.business.CustomerBO)3 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)3 ArrayList (java.util.ArrayList)1 MessageLookup (org.mifos.application.master.MessageLookup)1 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)1 CustomerStatusFlagEntity (org.mifos.customers.business.CustomerStatusFlagEntity)1 CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)1 CustomerException (org.mifos.customers.exceptions.CustomerException)1 CustomerPersistence (org.mifos.customers.persistence.CustomerPersistence)1 CustomerStatusDetailDto (org.mifos.dto.screen.CustomerStatusDetailDto)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1 UserContext (org.mifos.security.util.UserContext)1 BusinessRuleException (org.mifos.service.BusinessRuleException)1 AccessDeniedException (org.springframework.security.access.AccessDeniedException)1