Search in sources :

Example 11 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class AddGroupMembershipAction method updateParent.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward updateParent(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    AddGroupMembershipForm actionForm = (AddGroupMembershipForm) form;
    Integer parentGroupId = actionForm.getParentGroupIdValue();
    ClientBO clientInSession = (ClientBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    String globalCustNum = this.clientServiceFacade.transferClientToGroup(parentGroupId, clientInSession.getGlobalCustNum(), clientInSession.getVersionNo());
    ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
    return mapping.findForward(ActionForwards.view_client_details_page.toString());
}
Also used : ClientBO(org.mifos.customers.client.business.ClientBO) AddGroupMembershipForm(org.mifos.customers.group.struts.actionforms.AddGroupMembershipForm) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 12 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class GroupCustAction method update.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    GroupBO group = (GroupBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    boolean trained = false;
    if (actionForm.getTrainedValue() != null && actionForm.getTrainedValue().equals(Short.valueOf("1"))) {
        trained = true;
    }
    AddressDto address = null;
    if (actionForm.getAddress() != null) {
        address = Address.toDto(actionForm.getAddress());
    }
    GroupUpdate groupUpdate = new GroupUpdate(group.getCustomerId(), group.getGlobalCustNum(), group.getVersionNo(), actionForm.getDisplayName(), actionForm.getLoanOfficerIdValue(), actionForm.getExternalId(), trained, actionForm.getTrainedDate(), address, actionForm.getCustomFields(), actionForm.getCustomerPositions());
    try {
        this.groupServiceFacade.updateGroup(groupUpdate);
    } catch (BusinessRuleException e) {
        throw new ApplicationException(e.getMessageKey(), e);
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) GroupBO(org.mifos.customers.group.business.GroupBO) AddressDto(org.mifos.dto.domain.AddressDto) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) GroupUpdate(org.mifos.dto.domain.GroupUpdate) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 13 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class OffAction method update.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    OffActionForm offActionForm = (OffActionForm) form;
    ActionForward forward = null;
    OfficeDto sessionOffice = (OfficeDto) SessionUtils.getAttribute(OfficeConstants.OFFICE_DTO, request);
    Short officeId = sessionOffice.getOfficeId();
    Integer versionNum = sessionOffice.getVersionNum();
    OfficeUpdateRequest officeUpdateRequest = officeUpdateRequestFrom(offActionForm);
    boolean isParentOfficeChanged = this.officeServiceFacade.updateOffice(officeId, versionNum, officeUpdateRequest);
    if (isParentOfficeChanged) {
        forward = mapping.findForward(ActionForwards.update_cache_success.toString());
    } else {
        forward = mapping.findForward(ActionForwards.update_success.toString());
    }
    return forward;
}
Also used : OfficeDto(org.mifos.dto.domain.OfficeDto) OffActionForm(org.mifos.customers.office.struts.actionforms.OffActionForm) ActionForward(org.apache.struts.action.ActionForward) OfficeUpdateRequest(org.mifos.dto.domain.OfficeUpdateRequest) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 14 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.

the class CustomerApplyAdjustmentAction method applyAdjustment.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward applyAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    String forward = null;
    request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_APPLY_ADJUSTMENT);
    CustomerApplyAdjustmentActionForm applyAdjustmentActionForm = (CustomerApplyAdjustmentActionForm) form;
    String globalCustNum = applyAdjustmentActionForm.getGlobalCustNum();
    CustomerBO customerBO = this.customerDao.findCustomerBySystemId(globalCustNum);
    SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, customerBO, request);
    if (null == customerBO.getCustomerAccount().findMostRecentNonzeroPaymentByPaymentDate()) {
        request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_PREVIEW_ADJUSTMENT);
        throw new ApplicationException(AccountExceptionConstants.ZEROAMNTADJUSTMENT);
    }
    try {
        this.centerServiceFacade.revertLastChargesPayment(globalCustNum, applyAdjustmentActionForm.getAdjustmentNote());
    } catch (BusinessRuleException e) {
        request.setAttribute(CustomerConstants.METHOD, CustomerConstants.METHOD_PREVIEW_ADJUSTMENT);
        throw e;
    }
    String inputPage = applyAdjustmentActionForm.getInput();
    resetActionFormFields(applyAdjustmentActionForm);
    if (inputPage != null) {
        if (inputPage.equals(CustomerConstants.VIEW_GROUP_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_GROUP_SUCCESS;
        } else if (inputPage.equals(CustomerConstants.VIEW_CENTER_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_CENTER_SUCCESS;
        } else if (inputPage.equals(CustomerConstants.VIEW_CLIENT_CHARGES)) {
            forward = CustomerConstants.APPLY_ADJUSTMENT_CLIENT_SUCCESS;
        }
    }
    return mapping.findForward(forward);
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerApplyAdjustmentActionForm(org.mifos.customers.struts.actionforms.CustomerApplyAdjustmentActionForm) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 15 with CloseSession

use of org.mifos.framework.util.helpers.CloseSession 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)

Aggregations

CloseSession (org.mifos.framework.util.helpers.CloseSession)35 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)35 UserContext (org.mifos.security.util.UserContext)13 ClientBO (org.mifos.customers.client.business.ClientBO)7 BusinessRuleException (org.mifos.service.BusinessRuleException)7 CustomerBO (org.mifos.customers.business.CustomerBO)6 BigDecimal (java.math.BigDecimal)5 ActionForward (org.apache.struts.action.ActionForward)5 LocalDate (org.joda.time.LocalDate)5 AccountBO (org.mifos.accounts.business.AccountBO)5 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)4 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)4 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)4 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Locale (java.util.Locale)3 AccountBusinessService (org.mifos.accounts.business.service.AccountBusinessService)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)3