Search in sources :

Example 71 with ActionForward

use of org.apache.struts.action.ActionForward in project head by mifos.

the class AccountApplyGroupIndividualAction method applyPayment.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward applyPayment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    AccountApplyPaymentActionForm actionForm = (AccountApplyPaymentActionForm) form;
    Integer accountId = Integer.valueOf(actionForm.getAccountId());
    String paymentType = request.getParameter(Constants.INPUT);
    UserReferenceDto userReferenceDto = new UserReferenceDto(userContext.getId());
    AccountPaymentDto accountPaymentDto = accountServiceFacade.getAccountPaymentInformation(accountId, paymentType, userContext.getLocaleId(), userReferenceDto, actionForm.getTrxnDate());
    validateAccountPayment(accountPaymentDto, accountId, request);
    validateAmount(accountPaymentDto, actionForm.getAmount());
    PaymentTypeDto paymentTypeDto;
    String amount = actionForm.getAmount();
    if (accountPaymentDto.getAccountType().equals(AccountTypeDto.LOAN_ACCOUNT)) {
        paymentTypeDto = getLoanPaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
    } else {
        paymentTypeDto = getFeePaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
    }
    AccountPaymentParametersDto accountPaymentParametersDto = new AccountPaymentParametersDto(userReferenceDto, new AccountReferenceDto(accountId), new BigDecimal(amount), actionForm.getTrxnDateAsLocalDate(), paymentTypeDto, AccountConstants.NO_COMMENT, actionForm.getReceiptDateAsLocalDate(), actionForm.getReceiptId(), accountPaymentDto.getCustomerDto());
    if (paymentTypeDto.getValue().equals(this.legacyAcceptedPaymentTypeDao.getSavingsTransferId())) {
        this.accountServiceFacade.makePaymentFromSavingsAcc(accountPaymentParametersDto, actionForm.getAccountForTransfer());
    } else {
        this.accountServiceFacade.makePayment(accountPaymentParametersDto);
    }
    request.getSession().setAttribute("globalAccountNum", ((AccountApplyPaymentActionForm) form).getGlobalAccountNum());
    ActionForward findForward;
    if (actionForm.getPrintReceipt()) {
        findForward = mapping.findForward(getForward("PRINT"));
    } else {
        findForward = mapping.findForward(getForward(((AccountApplyPaymentActionForm) form).getInput()));
    }
    return findForward;
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) UserContext(org.mifos.security.util.UserContext) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) PaymentTypeDto(org.mifos.dto.domain.PaymentTypeDto) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) AccountPaymentDto(org.mifos.accounts.servicefacade.AccountPaymentDto) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) BigDecimal(java.math.BigDecimal) ActionForward(org.apache.struts.action.ActionForward) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 72 with ActionForward

use of org.apache.struts.action.ActionForward in project head by mifos.

the class MifosExceptionHandler method execute.

/**
     * Figures the type of exception and thus gets the page to which it should
     * be forwarded. If the exception is of type {@link SystemException} it is
     * forwarded to standard page which is obtained using Exception Config. If
     * the exception is of type {@link ApplicationException} the page to which
     * the request is forwarded is figured out using the string
     * <method_invoked>+failure which should be defined in the ActionConfig.
     */
@Override
public ActionForward execute(Exception ex, ExceptionConfig ae, ActionMapping mapping, ActionForm formInstance, HttpServletRequest request, HttpServletResponse response) throws ServletException {
    ActionForward forwardToBeReturned = null;
    String input = null;
    String parameter = null;
    ActionMessage error = null;
    if (ex instanceof ServiceUnavailableException) {
        forwardToBeReturned = new ActionForward(ae.getPath());
        error = new ActionMessage(((ServiceUnavailableException) ex).getKey(), ((ServiceUnavailableException) ex).getValues());
    }
    if (ex instanceof ConnectionNotFoundException) {
        forwardToBeReturned = new ActionForward(ae.getPath());
        error = new ActionMessage(((ConnectionNotFoundException) ex).getKey(), ((ConnectionNotFoundException) ex).getValues());
    }
    if (ex instanceof SystemException) {
        forwardToBeReturned = new ActionForward(ae.getPath());
        error = new ActionMessage(((SystemException) ex).getKey(), ((SystemException) ex).getValues());
    } else if (ex instanceof PageExpiredException) {
        forwardToBeReturned = new ActionForward(ae.getPath());
        error = new ActionMessage(((PageExpiredException) ex).getKey(), ((PageExpiredException) ex).getValues());
    } else if (ex instanceof ApplicationException || ex instanceof BusinessRuleException) {
        String key = ex instanceof ApplicationException ? ((ApplicationException) ex).getKey() : ((BusinessRuleException) ex).getMessageKey();
        Object[] values = ex instanceof ApplicationException ? ((ApplicationException) ex).getValues() : ((BusinessRuleException) ex).getMessageValues();
        error = new ActionMessage(key, values);
        parameter = request.getParameter("method");
        // jsp to which the user should be returned is identified by
        // methodname_failure e.g. if there is an exception in create the
        // failure forward would be create_failure if input is not null it
        // also tries to append that to parameter to find the action
        // forward.If that is not availablee it still tries to find the
        // forward with the actionforward being parameter_failure
        input = request.getParameter("input");
        if (null != input) {
            parameter = parameter + "_" + input;
        }
        forwardToBeReturned = mapping.findForward(parameter + "_failure");
        if (null == forwardToBeReturned) {
            forwardToBeReturned = mapping.findForward(request.getParameter("method") + "_failure");
        }
        // is coming
        if (null == forwardToBeReturned) {
            input = mapping.getInput();
            if (null != input) {
                forwardToBeReturned = new ActionForward("ExceptionForward", input, false, null);
            } else {
                forwardToBeReturned = super.execute(ex, ae, mapping, formInstance, request, response);
                // further statements
                return forwardToBeReturned;
            }
        }
    }
    logException(ex);
    // This will store the exception in the scope mentioned so that
    // it can be displayed on the UI
    this.storeException(request, error.getKey(), error, forwardToBeReturned, ae.getScope());
    return forwardToBeReturned;
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ActionMessage(org.apache.struts.action.ActionMessage) ActionForward(org.apache.struts.action.ActionForward)

Example 73 with ActionForward

use of org.apache.struts.action.ActionForward in project head by mifos.

the class GroupCustAction method search.

@Override
@TransactionDemarcate(joinToken = true)
public ActionForward search(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    GroupCustActionForm actionForm = (GroupCustActionForm) form;
    UserContext userContext = getUserContext(request);
    ActionForward actionForward = super.search(mapping, form, request, response);
    String searchString = actionForm.getSearchString();
    if (searchString == null) {
        if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
            request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
        } else {
            request.setAttribute(Constants.INPUT, null);
        }
        throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
    }
    addSeachValues(searchString, userContext.getBranchId().toString(), new OfficeBusinessService().getOffice(userContext.getBranchId()).getOfficeName(), request);
    final String normalizedSearchString = SearchUtils.normalizeSearchString(searchString);
    if (normalizedSearchString.equals("")) {
        if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
            request.setAttribute(Constants.INPUT, CenterConstants.INPUT_SEARCH_TRANSFERGROUP);
        } else {
            request.setAttribute(Constants.INPUT, null);
        }
        throw new CustomerException(CenterConstants.NO_SEARCH_STRING);
    }
    boolean searchForAddingClientsToGroup = (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_ADD_CLIENTS_TO_GROUPS));
    GroupSearchResultsDto searchResult = this.customerServiceFacade.searchGroups(searchForAddingClientsToGroup, normalizedSearchString, userContext.getId());
    SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchResults(), request);
    if (actionForm.getInput() != null && actionForm.getInput().equals(GroupConstants.GROUP_SEARCH_CLIENT_TRANSFER)) {
        return mapping.findForward(ActionForwards.transferSearch_success.toString());
    } else if (searchForAddingClientsToGroup) {
        SessionUtils.setQueryResultAttribute(Constants.SEARCH_RESULTS, searchResult.getSearchForAddingClientToGroupResults(), request);
        return mapping.findForward(ActionForwards.addGroupSearch_success.toString());
    } else {
        return actionForward;
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) OfficeBusinessService(org.mifos.customers.office.business.service.OfficeBusinessService) UserContext(org.mifos.security.util.UserContext) GroupCustActionForm(org.mifos.customers.group.struts.actionforms.GroupCustActionForm) ActionForward(org.apache.struts.action.ActionForward) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 74 with ActionForward

use of org.apache.struts.action.ActionForward in project head by mifos.

the class CustomerNotesAction method create.

@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    logger.debug("In CustomerNotesAction::create()");
    ActionForward forward = null;
    CustomerNotesActionForm notesActionForm = (CustomerNotesActionForm) form;
    Integer customerId = Integer.valueOf(((CustomerNotesActionForm) form).getCustomerId());
    CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
    UserContext uc = getUserContext(request);
    if (customerBO.getPersonnel() != null) {
        checkPermissionForAddingNotes(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), uc, customerBO.getOffice().getOfficeId(), customerBO.getPersonnel().getPersonnelId());
    } else {
        checkPermissionForAddingNotes(AccountTypes.CUSTOMER_ACCOUNT, customerBO.getLevel(), uc, customerBO.getOffice().getOfficeId(), uc.getId());
    }
    CustomerNoteFormDto customerNoteForm = new CustomerNoteFormDto(customerBO.getGlobalCustNum(), customerBO.getDisplayName(), customerBO.getCustomerLevel().getId().intValue(), new LocalDate(), "", notesActionForm.getComment());
    this.centerServiceFacade.createCustomerNote(customerNoteForm);
    forward = mapping.findForward(getDetailCustomerPage(notesActionForm));
    return forward;
}
Also used : CustomerNotesActionForm(org.mifos.customers.struts.actionforms.CustomerNotesActionForm) UserContext(org.mifos.security.util.UserContext) CustomerBO(org.mifos.customers.business.CustomerBO) CustomerNoteFormDto(org.mifos.dto.screen.CustomerNoteFormDto) LocalDate(org.joda.time.LocalDate) ActionForward(org.apache.struts.action.ActionForward) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 75 with ActionForward

use of org.apache.struts.action.ActionForward in project head by mifos.

the class LoanAccountActionTest method shouldViewOriginalSchedule.

@SuppressWarnings("unchecked")
@Test
public void shouldViewOriginalSchedule() throws Exception {
    ActionForward viewOriginalScheduleForward = new ActionForward("viewOriginalSchedule");
    int loanId = 1;
    String loanAmount = "123";
    List<RepaymentScheduleInstallment> installments = Collections.EMPTY_LIST;
    java.sql.Date disbursementDate = new java.sql.Date(new DateTime().toDate().getTime());
    OriginalScheduleInfoDto dto = mock(OriginalScheduleInfoDto.class);
    when(dto.getOriginalLoanScheduleInstallment()).thenReturn(installments);
    when(dto.getLoanAmount()).thenReturn(loanAmount);
    when(dto.getDisbursementDate()).thenReturn(disbursementDate);
    when(request.getParameter(LoanAccountAction.ACCOUNT_ID)).thenReturn(String.valueOf(loanId));
    when(loanServiceFacade.retrieveOriginalLoanSchedule(loanId)).thenReturn(dto);
    when(mapping.findForward("viewOriginalSchedule")).thenReturn(viewOriginalScheduleForward);
    ActionForward forward = loanAccountAction.viewOriginalSchedule(mapping, form, request, response);
    assertThat(forward, is(viewOriginalScheduleForward));
    verify(request).getParameter(LoanAccountAction.ACCOUNT_ID);
    verify(loanServiceFacade).retrieveOriginalLoanSchedule(loanId);
    verify(dto).getOriginalLoanScheduleInstallment();
    verify(dto).getLoanAmount();
    verify(dto).getDisbursementDate();
    verify(mapping).findForward("viewOriginalSchedule");
}
Also used : RepaymentScheduleInstallment(org.mifos.accounts.loan.util.helpers.RepaymentScheduleInstallment) OriginalScheduleInfoDto(org.mifos.accounts.loan.business.service.OriginalScheduleInfoDto) ActionForward(org.apache.struts.action.ActionForward) Date(java.util.Date) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

ActionForward (org.apache.struts.action.ActionForward)125 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)16 ActionMessages (org.apache.struts.action.ActionMessages)14 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)11 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)11 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)9 ActionMessage (org.apache.struts.action.ActionMessage)9 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)8 IWantDocument (edu.cornell.kfs.module.purap.document.IWantDocument)7 PurApFavoriteAccountLineBuilderForIWantDocument (edu.cornell.kfs.module.purap.util.PurApFavoriteAccountLineBuilderForIWantDocument)7 ActionMapping (org.apache.struts.action.ActionMapping)7 UserContext (org.mifos.security.util.UserContext)7 IOException (java.io.IOException)6 Date (java.util.Date)6 AuthorizationPersistence (cn.edu.zju.acm.onlinejudge.persistence.AuthorizationPersistence)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)5 Cookie (javax.servlet.http.Cookie)5 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)4