protected TimeSeries getPredictedVelocityTimeSeries(
     LocalDate iterationStart,
     LocalDate iterationEnd,
     IterationHistoryEntry yesterdayEntry,
     IterationHistoryEntry todayEntry) {
   LocalDate today = new LocalDate();
   ExactEstimate startValue = getTodaysStartValueWithScoping(yesterdayEntry, todayEntry);
   ExactEstimate velocity =
       iterationBusiness.calculateDailyVelocity(iterationStart, yesterdayEntry);
   LocalDate startDate = (iterationEnd.isBefore(today)) ? iterationEnd : today;
   LocalDate endDate =
       iterationHistoryEntryBusiness.calculateExpectedEffortDoneDate(
           startDate, startValue, velocity);
   if (endDate == null) return null;
   endDate = endDate.plusDays(1);
   if (startDate.isEqual(endDate)) return null;
   return this.getSeriesByStartAndEndPoints(
       EXPECTED_SERIES_NAME,
       today
           .toDateTimeAtCurrentTime()
           .minusMinutes(timeDifferenceMinutes)
           .toLocalDate()
           .toDateTimeAtStartOfDay(),
       startValue,
       endDate
           .toDateTimeAtCurrentTime()
           .minusMinutes(timeDifferenceMinutes)
           .toLocalDate()
           .toDateTimeAtStartOfDay(),
       ExactEstimate.ZERO);
 }
  /** Assembles all the needed <code>TimeSeries</code>. */
  protected TimeSeriesCollection getDataset(Iteration iteration) {
    TimeSeriesCollection chartDataset = new TimeSeriesCollection();

    List<IterationHistoryEntry> iterationEntries =
        iterationHistoryEntryBusiness.getHistoryEntriesForIteration(iteration);

    LocalDate yesterday = new LocalDate().minusDays(1);
    LocalDate today = new LocalDate();
    IterationHistoryEntry yesterdayEntry = getHistoryEntryForDate(iterationEntries, yesterday);
    IterationHistoryEntry todayEntry = getHistoryEntryForDate(iterationEntries, today);
    DateTime iterationStartDate = new DateTime(iteration.getStartDate());
    DateTime iterationEndDate = new DateTime(iteration.getEndDate());

    chartDataset.addSeries(
        getBurndownTimeSeries(
            iterationEntries,
            new LocalDate(iteration.getStartDate()),
            determineEndDate(new LocalDate(iteration.getEndDate()))));

    chartDataset.addSeries(getCurrentDayTimeSeries(yesterdayEntry, todayEntry));

    chartDataset.addSeries(
        getScopingTimeSeries(
            iterationEntries, iterationStartDate.toLocalDate(), iterationEndDate.toLocalDate()));

    chartDataset.addSeries(
        getReferenceVelocityTimeSeries(
            iterationStartDate,
            iterationEndDate,
            new ExactEstimate(todayEntry.getOriginalEstimateSum())));

    TimeSeries predictedVelocity =
        getPredictedVelocityTimeSeries(
            iterationStartDate.toLocalDate(),
            iterationEndDate.toLocalDate(),
            yesterdayEntry,
            todayEntry);
    if (predictedVelocity != null) {
      chartDataset.addSeries(predictedVelocity);
    }

    return chartDataset;
  }
 protected List<IterationHistoryEntry> getIterationHistoryEntries(Iteration iteration) {
   return iterationHistoryEntryBusiness.getHistoryEntriesForIteration(iteration);
 }