Search in sources :

Example 1 with ActionForward

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

the class LoanAccountActionTest method captureQuestionResponses.

@Test
public void captureQuestionResponses() throws Exception {
    String redoLoan = "redoLoan";
    when(form.getPerspective()).thenReturn(redoLoan);
    ActionErrors errors = mock(ActionErrors.class);
    ActionForward forward = mock(ActionForward.class);
    when(createLoanQuestionnaire.validateResponses(request, form)).thenReturn(errors);
    when(errors.isEmpty()).thenReturn(true);
    when(createLoanQuestionnaire.rejoinFlow(mapping)).thenReturn(forward);
    loanAccountAction.captureQuestionResponses(mapping, form, request, response);
    verify(request, times(1)).setAttribute(eq(LoanConstants.METHODCALLED), eq("captureQuestionResponses"));
    verify(request, times(1)).setAttribute(PERSPECTIVE, redoLoan);
    verify(createLoanQuestionnaire).rejoinFlow(mapping);
}
Also used : ActionErrors(org.apache.struts.action.ActionErrors) ActionForward(org.apache.struts.action.ActionForward) Test(org.junit.Test)

Example 2 with ActionForward

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

the class LoanAccountActionTest method getLoanRepaymentScheduleShouldValidateViewDate.

@Test
public void getLoanRepaymentScheduleShouldValidateViewDate() throws Exception {
    ActionForward getLoanScheduleFailure = new ActionForward("getLoanRepaymentScheduleFailure");
    java.sql.Date extraInterestDate = TestUtils.getSqlDate(10, 7, 2010);
    Errors errors = new Errors();
    errors.addError(LoanConstants.CANNOT_VIEW_REPAYMENT_SCHEDULE, new String[] { extraInterestDate.toString() });
    when(loanBusinessService.computeExtraInterest(loanBO, extraInterestDate)).thenReturn(errors);
    when(form.getScheduleViewDateValue(Locale.US)).thenReturn(extraInterestDate);
    when(request.getParameter("accountId")).thenReturn("1");
    when(mapping.findForward("getLoanRepaymentScheduleFailure")).thenReturn(getLoanScheduleFailure);
    when(loanServiceFacade.retrieveOriginalLoanSchedule(Matchers.<Integer>any())).thenReturn(new OriginalScheduleInfoDto("100", new Date(), Collections.<RepaymentScheduleInstallment>emptyList()));
    ActionForward forward = loanAccountAction.getLoanRepaymentSchedule(mapping, form, request, response);
    assertThat(forward, is(getLoanScheduleFailure));
    verify(form).resetScheduleViewDate();
}
Also used : Errors(org.mifos.platform.validations.Errors) ActionErrors(org.apache.struts.action.ActionErrors) 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) Test(org.junit.Test)

Example 3 with ActionForward

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

the class AccountApplyGroupPaymentAction 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;
    String paymentType = request.getParameter(Constants.INPUT);
    Integer accountId;
    if (actionForm.getAccountId().isEmpty() || actionForm.getAccountId() == null) {
        accountId = loanDao.findByGlobalAccountNum(actionForm.getGlobalAccountNum()).getAccountId();
    } else {
        accountId = Integer.valueOf(actionForm.getAccountId());
    }
    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) || accountPaymentDto.getAccountType().equals(AccountTypeDto.GROUP_LOAN_ACCOUNT)) {
        paymentTypeDto = getLoanPaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
    } else {
        paymentTypeDto = getFeePaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
    }
    AccountPaymentParametersDto accountPaymentParametersDto;
    if (isGroupParentAccount(accountId)) {
        accountPaymentParametersDto = new AccountPaymentParametersDto(userReferenceDto, new AccountReferenceDto(accountId), new BigDecimal(amount), actionForm.getTrxnDateAsLocalDate(), paymentTypeDto, AccountConstants.NO_COMMENT, actionForm.getReceiptDateAsLocalDate(), actionForm.getReceiptId(), accountPaymentDto.getCustomerDto(), actionForm.getIndividualValues());
    } else if (isGroupMemberAccount(accountId)) {
        accountPaymentParametersDto = preparePaymentParametersDto(accountId, userReferenceDto, amount, actionForm, paymentTypeDto, userContext, paymentType);
    } else {
        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 4 with ActionForward

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

the class MifosRequestProcessor method processActionPerform.

/**
     * This method is overridden because in case of exception we need to
     * populate the request with the old values so that when the user goes back
     * to the previous page it has all the values in the request.For this we
     * create an object which will store the values of previous request in case
     * the request is successful and if there is an exception it reads values
     * from that object and context and dups all in the request.
     */
@Override
protected ActionForward processActionPerform(HttpServletRequest request, HttpServletResponse response, Action action, ActionForm form, ActionMapping mapping) throws IOException, ServletException {
    ActivityContext activityContext = null;
    ActionForward forward = null;
    HttpSession session = request.getSession();
    // gets the object where we will store values from request.
    PreviousRequestValues previousRequestValues = (PreviousRequestValues) session.getAttribute(Constants.PREVIOUS_REQUEST);
    if (null == previousRequestValues) {
        previousRequestValues = new PreviousRequestValues();
        session.setAttribute(Constants.PREVIOUS_REQUEST, previousRequestValues);
    }
    // getting the activity context from the session
    activityContext = (ActivityContext) session.getAttribute("ActivityContext");
    try {
        String currentFlowKey = request.getParameter(Constants.CURRENTFLOWKEY);
        if (currentFlowKey != null) {
            previousRequestValues.getPreviousRequestValueMap().put(Constants.CURRENTFLOWKEY, currentFlowKey);
        }
        forward = (action.execute(mapping, form, request, response));
        String method = request.getParameter("method");
        if (method.equals(ClientConstants.METHOD_RETRIEVE_PICTURE)) {
            forward = mapping.findForward("get_success");
        }
        // set the last forward in the activity context
        if (activityContext != null) {
            activityContext.setLastForward(forward);
        }
        // read the request and add the values to the PreviousRequestValues
        // object. this will set every thing in the request apart from
        // context and value object.
        Enumeration requestAttributes = request.getAttributeNames();
        while (requestAttributes.hasMoreElements()) {
            String nextName = (String) requestAttributes.nextElement();
            if (nextName.startsWith(Constants.STORE_ATTRIBUTE) || nextName.equalsIgnoreCase(Constants.CURRENTFLOWKEY)) {
                logger.debug(nextName + "=" + request.getAttribute(nextName));
                previousRequestValues.getPreviousRequestValueMap().put(nextName, request.getAttribute(nextName));
            }
        }
    } catch (Exception e) {
        // processException logs an error (see MifosExceptionHandler)
        forward = (processException(request, response, e, form, mapping));
        // set the last forward in the activity context
        if (activityContext != null) {
            activityContext.setLastForward(forward);
        }
        populateTheRequestFromPreviousValues(request, previousRequestValues);
    } finally {
        try {
            session.removeAttribute(SecurityConstants.SECURITY_PARAM);
        } catch (Exception e) {
        // FIXME: yikes, what is being swallowed here?
        }
    }
    if (null != forward) {
        logger.info("forward.path=" + forward.getPath());
    }
    return forward;
}
Also used : ActivityContext(org.mifos.security.util.ActivityContext) Enumeration(java.util.Enumeration) PreviousRequestValues(org.mifos.framework.util.helpers.PreviousRequestValues) HttpSession(javax.servlet.http.HttpSession) ActionForward(org.apache.struts.action.ActionForward) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 5 with ActionForward

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

the class LoanAccountAction method getDetails.

public ActionForward getDetails(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
    String globalAccountNum = request.getParameter(GLOBAL_ACCOUNT_NUM);
    ActionForward forward = null;
    if (loanDao.findByGlobalAccountNum(globalAccountNum).isParentGroupLoanAccount()) {
        forward = mapping.findForward("getGroupLoanAccountDetails");
    } else {
        forward = mapping.findForward("get");
    }
    return forward;
}
Also used : ActionForward(org.apache.struts.action.ActionForward)

Aggregations

ActionForward (org.apache.struts.action.ActionForward)117 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 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 Cookie (javax.servlet.http.Cookie)5 ActionMapping (org.apache.struts.action.ActionMapping)5 CloseSession (org.mifos.framework.util.helpers.CloseSession)5 Submission (cn.edu.zju.acm.onlinejudge.bean.Submission)4 IWantDocumentService (edu.cornell.kfs.module.purap.document.service.IWantDocumentService)4