Monday, May 21, 2018

Start date and End date validation at RowImpl class setter methods

public void setStartDate(Date value) {
        String errorMessage = "Start Date should be less than End Date.";
        oracle.jbo.domain.Date other = null;
        java.util.Date otherUtil = null;
        if (value == null) {
            setAttributeInternal(STARTDATE, value);
        } else {
            setAttributeInternal(STARTDATE, value);
            if (null != getAttributeInternal(ENDDATE)) {
                other = (Date)getAttributeInternal(ENDDATE);
                otherUtil = other.getValue();
            } else if (null != getAttributeInternal(ENDDATE)) {
                other = (Date)getAttributeInternal(ENDDATE);
                otherUtil = other.getValue();
            }
            java.util.Date valueUtil = value.getValue();
            if (null != otherUtil && otherUtil.before(valueUtil)) {
                throw new JboException(errorMessage);
            }
            setAttributeInternal(STARTDATE, value);
        }
    }



    public void setEndDate(Date value) {
        if (value == null) {
            setAttributeInternal(ENDDATE, value);
        } else {
            String errorMessage = "End Date should be greater than Start Date.";
            Date other = null;

            java.util.Date otherUtil = null;
            setAttributeInternal(ENDDATE, value);
            if (null != getAttributeInternal(STARTDATE)) {
                other = (Date)getAttributeInternal(STARTDATE);
                otherUtil = other.getValue();
            } else if (null != getAttributeInternal(STARTDATE)) {
                other = (Date)getAttributeInternal(STARTDATE);
                otherUtil = other.getValue();
            }
            java.util.Date valueUtil = value.getValue();
            if (null != otherUtil && otherUtil.after(valueUtil)) {
                throw new JboException(errorMessage);
            }
            setAttributeInternal(ENDDATE, value);
            //  setAttributeInternal(DATEFROM, other);
        }
    }

No comments:

Post a Comment