protected final void setReportFormDateRangeAndInterval(final F report) {
        // Determine default interval based on the intervals available for this aggregation
        if (report.getInterval() == null) {
            report.setInterval(AggregationInterval.DAY);
            final Set<AggregationInterval> intervals = this.getIntervals();
            for (final AggregationInterval preferredInterval : PREFERRED_INTERVAL_ORDER) {
                if (intervals.contains(preferredInterval)) {
                    report.setInterval(preferredInterval);
                    break;
                }
            }
        }

        // Set the report end date as today
        final DateMidnight reportEnd;
        if (report.getEnd() == null) {
            reportEnd = new DateMidnight();
            report.setEnd(reportEnd);
        } else {
            reportEnd = report.getEnd();
        }

        // Determine the best start date based on the selected interval
        if (report.getStart() == null) {
            final DateMidnight start;
            switch (report.getInterval()) {
                case MINUTE:
                    {
                        start = reportEnd.minusDays(1);
                        break;
                    }
                case FIVE_MINUTE:
                    {
                        start = reportEnd.minusDays(2);
                        break;
                    }
                case HOUR:
                    {
                        start = reportEnd.minusWeeks(1);
                        break;
                    }
                case DAY:
                    {
                        start = reportEnd.minusMonths(1);
                        break;
                    }
                case WEEK:
                    {
                        start = reportEnd.minusMonths(3);
                        break;
                    }
                case MONTH:
                    {
                        start = reportEnd.minusYears(1);
                        break;
                    }
                case ACADEMIC_TERM:
                    {
                        start = reportEnd.minusYears(2);
                        break;
                    }
                case CALENDAR_QUARTER:
                    {
                        start = reportEnd.minusYears(2);
                        break;
                    }
                case YEAR:
                    {
                        start = reportEnd.minusYears(10);
                        break;
                    }
                default:
                    {
                        start = reportEnd.minusWeeks(1);
                    }
            }

            report.setStart(start);
        }
    }
protected final void setReportFormDateRangeAndInterval ( final F report ) { if ( report . getInterval ( ) == null ) { report . setInterval ( AggregationInterval . DAY ) ; final Set < AggregationInterval > intervals = this . getIntervals ( ) ; for ( final AggregationInterval preferredInterval : PREFERRED_INTERVAL_ORDER ) { if ( intervals . contains ( preferredInterval ) ) { report . setInterval ( preferredInterval ) ; break ; } } } final DateMidnight reportEnd ; if ( report . getEnd ( ) == null ) { reportEnd = new DateMidnight ( ) ; report . setEnd ( reportEnd ) ; } else { reportEnd = report . getEnd ( ) ; } if ( report . getStart ( ) == null ) { final DateMidnight start ; switch ( report . getInterval ( ) ) { case MINUTE : { start = reportEnd . minusDays ( 1 ) ; break ; } case FIVE_MINUTE : { start = reportEnd . minusDays ( 2 ) ; break ; } case HOUR : { start = reportEnd . minusWeeks ( 1 ) ; break ; } case DAY : { start = reportEnd . minusMonths ( 1 ) ; break ; } case WEEK : { start = reportEnd . minusMonths ( 3 ) ; break ; } case MONTH : { start = reportEnd . minusYears ( 1 ) ; break ; } case ACADEMIC_TERM : { start = reportEnd . minusYears ( 2 ) ; break ; } case CALENDAR_QUARTER : { start = reportEnd . minusYears ( 2 ) ; break ; } case YEAR : { start = reportEnd . minusYears ( 10 ) ; break ; } default : { start = reportEnd . minusWeeks ( 1 ) ; } } report . setStart ( start ) ; } }
Set the start/end date and the interval to have selected by default if they are not already
set