Search in sources :

Example 31 with ActionMessage

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

the class LoanAccountActionForm method validatePaymentDatesOrdering.

void validatePaymentDatesOrdering(List<PaymentDataHtmlBean> validPaymentBeans, ActionErrors errors) {
    List<java.util.Date> transactionDates = collect(validPaymentBeans, new Transformer<PaymentDataHtmlBean, java.util.Date>() {

        @Override
        public java.util.Date transform(PaymentDataHtmlBean input) {
            return input.getTransactionDate();
        }
    });
    int indexOutOfOrder = itemIndexOutOfAscendingOrder(transactionDates);
    if (indexOutOfOrder >= 0) {
        String installmentNumber = validPaymentBeans.get(indexOutOfOrder).getInstallmentNumber();
        String errorCode = LoanExceptionConstants.INVALIDTRANSACTIONDATEORDER;
        errors.add(errorCode, new ActionMessage(errorCode, installmentNumber));
    }
}
Also used : PaymentDataHtmlBean(org.mifos.accounts.loan.struts.uihelpers.PaymentDataHtmlBean) ActionMessage(org.apache.struts.action.ActionMessage) Date(java.sql.Date)

Example 32 with ActionMessage

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

the class LoanAccountActionForm method validate.

@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    String method = request.getParameter(Methods.method.toString());
    ActionErrors errors = new ActionErrors();
    if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
        request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
    }
    try {
        if (method.equals(Methods.getPrdOfferings.toString())) {
            checkValidationForGetPrdOfferings(errors);
        } else if (method.equals(Methods.load.toString())) {
            checkValidationForLoad(errors);
        } else if (method.equals(Methods.schedulePreview.toString())) {
            checkValidationForSchedulePreview(errors, getCurrencyFromLoanOffering(request), request);
        } else if (method.equals(Methods.managePreview.toString())) {
            checkValidationForManagePreview(errors, getCurrencyFromLoanOffering(request), request);
        } else if (method.equals(Methods.preview.toString())) {
            checkValidationForPreview(errors, getCurrencyFromLoanOffering(request), request);
        }
    } catch (ApplicationException ae) {
        // Discard other errors (is that right?)
        ae.printStackTrace();
        errors = new ActionErrors();
        errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
    }
    if (!errors.isEmpty()) {
        request.setAttribute(LoanConstants.METHODCALLED, method);
    }
    return errors;
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) ActionMessage(org.apache.struts.action.ActionMessage) ActionErrors(org.apache.struts.action.ActionErrors)

Example 33 with ActionMessage

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

the class ViewStageTransactionActionForm method mandatoryCheckForAudit.

private ActionErrors mandatoryCheckForAudit(UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
    String audit = resources.getString(SimpleAccountingConstants.AUDIT);
    String audit_comments = resources.getString(SimpleAccountingConstants.AUDIT_COMMENTS);
    ActionErrors errors = new ActionErrors();
    if (getAudit() == null || "".equals(getAudit())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, audit));
    } else if (getAuditComments() == null || "".equals(getAuditComments())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, audit_comments));
    }
    return errors;
}
Also used : Locale(java.util.Locale) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle) ActionErrors(org.apache.struts.action.ActionErrors)

Example 34 with ActionMessage

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

the class VoucherBranchMappingActionForm method trxnDateValidate.

private ActionErrors trxnDateValidate(ActionErrors errors, Locale locale) {
    if (StringUtils.isNotBlank(getTransactiondate()) && !DateUtils.isValidDate(getTransactiondate())) {
        ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
        String trxnDate = resources.getString(SimpleAccountingConstants.TRXNDATE);
        errors.add(SimpleAccountingConstants.INVALID_TRXN_DATE, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, trxnDate));
    }
    return errors;
}
Also used : ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle)

Example 35 with ActionMessage

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

the class VoucherBranchMappingActionForm method mandatoryCheck.

private ActionErrors mandatoryCheck(UserContext userContext) {
    Locale locale = userContext.getPreferredLocale();
    ResourceBundle resources = ResourceBundle.getBundle(FilePaths.SIMPLE_ACCOUNTING_RESOURCE, locale);
    ActionErrors errors = new ActionErrors();
    String branchname = resources.getString(SimpleAccountingConstants.BRANCH_NAME);
    String Amount = resources.getString(SimpleAccountingConstants.AMOUNT);
    String trxn_Type = resources.getString(SimpleAccountingConstants.TRXNTYPE);
    String main_Account = resources.getString(SimpleAccountingConstants.MAIN_ACCOUNT);
    String Notes = resources.getString(SimpleAccountingConstants.TRXN_NOTES);
    String trxn_Date = resources.getString(SimpleAccountingConstants.TRXNDATE);
    String[] amts = getAmount();
    String[] trannotes = getTransactionnotes();
    // String[] canames=getCoaname();
    List<CoaNamesDto> coaNamesDtolist = new ArrayList<CoaNamesDto>();
    if (amts.length < 0 || "".equals(amts)) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
    }
    for (int i = 0; i < amts.length; i++) {
        if (amts[i].equalsIgnoreCase("0")) {
            errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, Amount));
        }
    }
    if (trannotes == null || "".equals(trannotes)) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, Notes));
    }
    {
        for (int i = 0; i < getAmount().length; i++) {
            CoaNamesDto coanamesob = new CoaNamesDto();
            coanamesob.setAmount(amts[i]);
            coanamesob.setTrxnnotes(trannotes[i]);
            // coanamesob.setCoaName(canames[i]);
            coaNamesDtolist.add(coanamesob);
        }
    }
    java.sql.Date currentDate = null;
    try {
        currentDate = DateUtils.getLocaleDate(userContext.getPreferredLocale(), DateUtils.getCurrentDate(userContext.getPreferredLocale()));
    } catch (InvalidDateException ide) {
        errors.add(SimpleAccountingConstants.INVALIDDATE, new ActionMessage(SimpleAccountingConstants.INVALIDDATE));
    }
    java.sql.Date trxnDate = null;
    if (getTransactiondate() == null || "".equals(getTransactiondate())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, trxn_Date));
    } else if (getTransactiondate() != null && !getTransactiondate().equals("") && !DateUtils.isValidDate(getTransactiondate())) {
        errors = trxnDateValidate(errors, locale);
    } else if (DateUtils.isValidDate(getTransactiondate())) {
        try {
            trxnDate = DateUtils.getDateAsSentFromBrowser(getTransactiondate());
        } catch (InvalidDateException ide) {
            errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.INVALID_TRXN_DATE, trxn_Date));
        }
        if (trxnDate.compareTo(currentDate) > 0) {
            errors.add(SimpleAccountingConstants.INVALID_FUTURE, new ActionMessage(SimpleAccountingConstants.INVALID_FUTURE, trxn_Date));
        }
    }
    if (getBranch() == null || "".equals(getBranch())) {
        errors.add(SimpleAccountingConstants.MANDATORYENTER, new ActionMessage(SimpleAccountingConstants.MANDATORYENTER, branchname));
    }
    if (transactiontype == null || "".equals(transactiontype.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, trxn_Type));
    }
    if (mainAccount == null || "".equals(mainAccount.trim())) {
        errors.add(SimpleAccountingConstants.MANDATORYFIELDS, new ActionMessage(SimpleAccountingConstants.MANDATORYFIELDS, main_Account));
    }
    return errors;
}
Also used : Locale(java.util.Locale) ArrayList(java.util.ArrayList) ActionErrors(org.apache.struts.action.ActionErrors) CoaNamesDto(org.mifos.dto.domain.CoaNamesDto) InvalidDateException(org.mifos.application.admin.servicefacade.InvalidDateException) ActionMessage(org.apache.struts.action.ActionMessage) ResourceBundle(java.util.ResourceBundle)

Aggregations

ActionMessage (org.apache.struts.action.ActionMessage)166 ActionErrors (org.apache.struts.action.ActionErrors)70 ActionMessages (org.apache.struts.action.ActionMessages)45 ResourceBundle (java.util.ResourceBundle)29 JspException (javax.servlet.jsp.JspException)22 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)22 Iterator (java.util.Iterator)21 Locale (java.util.Locale)19 List (java.util.List)9 ActionForward (org.apache.struts.action.ActionForward)9 AbstractContest (cn.edu.zju.acm.onlinejudge.bean.AbstractContest)8 ArrayList (java.util.ArrayList)8 Problem (cn.edu.zju.acm.onlinejudge.bean.Problem)7 DoubleConversionResult (org.mifos.framework.util.helpers.DoubleConversionResult)7 UserProfile (cn.edu.zju.acm.onlinejudge.bean.UserProfile)6 IOException (java.io.IOException)6 Date (java.sql.Date)6 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)6 ApplicationException (org.mifos.framework.exceptions.ApplicationException)5 UserPersistence (cn.edu.zju.acm.onlinejudge.persistence.UserPersistence)4