/**
  * Constructs the <code>TimeSeries</code> for the reference velocity.
  *
  * <p>Start point is at (startDate, originalEstimateSum). End point is at (endDate + 1, 0.0)
  *
  * @param timeDifferenceHours
  */
 protected TimeSeries getReferenceVelocityTimeSeries(
     DateTime startDate, DateTime endDate, ExactEstimate originalEstimateSum) {
   if (settingBusiness.isWeekendsInBurndown()) {
     return this.getReferenceVelocityWithWeekends(
         REFERENCE_SERIES_NAME, startDate, endDate, originalEstimateSum);
   } else {
     return this.getSeriesByStartAndEndPoints(
         REFERENCE_SERIES_NAME,
         startDate.minusMinutes(timeDifferenceMinutes),
         originalEstimateSum,
         endDate.minusMinutes(timeDifferenceMinutes).plusDays(1),
         new ExactEstimate(0));
   }
 }
 // TODO: write test
 public List<BacklogItem> getBacklogItemsByBacklog(Backlog backlog) {
   if (backlog != null) {
     List<BacklogItem> items = backlogItemDAO.getBacklogItemsByBacklog(backlog);
     Collections.sort(items, new BacklogItemComparator(new BacklogItemPriorityComparator()));
     // do we need to load spent effort sums
     if (settingBusiness.isHourReportingEnabled()) {
       Map<BacklogItem, AFTime> spentEffort = hourEntryBusiness.getSumsByBacklog(backlog);
       for (BacklogItem item : items) {
         if (spentEffort.containsKey(item)) {
           item.setEffortSpent(spentEffort.get(item));
         }
       }
     }
     return items;
   }
   return null;
 }
 /**
  * Calculate whether given hours can be fitted to the given week. Each day is assumed 8 hours
  * long.
  *
  * @param currentWeek
  * @param targetWeek
  * @param totalWorkload
  * @return
  */
 private boolean isAccommodableWorkload(
     int currentWeek, int targetWeek, AFTime totalWorkload, User user) {
   if (user == null) {
     return false;
   }
   long totalInWeek = 5;
   int daysLeft = 5;
   if (currentWeek == targetWeek) {
     Calendar cal = GregorianCalendar.getInstance();
     daysLeft = 1;
     while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.FRIDAY && daysLeft < 6) {
       cal.add(Calendar.DAY_OF_YEAR, 1);
       daysLeft++;
     }
   }
   totalInWeek =
       (long)
           (user.getWeekHours().getTime()
               * (1.0 * daysLeft * settingBusiness.getCriticalLow() / (5 * 100)));
   if (totalInWeek < totalWorkload.getTime()) {
     return false;
   }
   return true;
 }