@Override
  public SortedMap<LocalDate, BigDecimal> calculateBudgetedCostWorkPerformed(Interval interval) {
    Map<TaskElement, SortedMap<LocalDate, BigDecimal>> advanceCostPerTask =
        databaseSnapshots.snapshotAdvanceCostPerTask();
    Collection<TaskElement> tasks = filterTasksByDate(advanceCostPerTask.keySet(), interval);

    SortedMap<LocalDate, BigDecimal> result = new TreeMap<LocalDate, BigDecimal>();
    for (TaskElement each : tasks) {
      addCost(result, advanceCostPerTask.get(each));
    }
    return result;
  }
 private void searchInResources(String filter) {
   Map<Class<?>, List<Resource>> mapResources = databaseSnapshots.snapshotMapResources();
   for (Class<?> className : mapResources.keySet()) {
     for (Resource resource : mapResources.get(className)) {
       String name = StringUtils.deleteWhitespace(resource.getName().toLowerCase());
       if (name.contains(filter)) {
         addResource(className, resource);
         if ((filter.length() < 3) && (getListMatching().size() > 9)) {
           return;
         }
       }
     }
   }
 }
 private List<FilterPair> fillWithFirstTenFiltersResources() {
   Map<Class<?>, List<Resource>> mapResources = databaseSnapshots.snapshotMapResources();
   Iterator<Class<?>> iteratorClass = mapResources.keySet().iterator();
   while (iteratorClass.hasNext() && getListMatching().size() < 10) {
     Class<?> className = iteratorClass.next();
     for (int i = 0;
         getListMatching().size() < 10 && i < mapResources.get(className).size();
         i++) {
       Resource resource = mapResources.get(className).get(i);
       addResource(className, resource);
     }
   }
   return getListMatching();
 }
  @Override
  @Transactional(readOnly = true)
  public SortedMap<LocalDate, BigDecimal> calculateBudgetedCostWorkScheduled(
      AvailabilityTimeLine.Interval interval) {

    Map<TaskElement, SortedMap<LocalDate, BigDecimal>> estimatedCostPerTask =
        databaseSnapshots.snapshotEstimatedCostPerTask();

    Collection<TaskElement> list = filterTasksByDate(estimatedCostPerTask.keySet(), interval);
    SortedMap<LocalDate, BigDecimal> estimatedCost = new TreeMap<LocalDate, BigDecimal>();

    for (TaskElement each : list) {
      addCost(estimatedCost, estimatedCostPerTask.get(each));
    }
    return accumulateResult(estimatedCost);
  }
  @Override
  public SortedMap<LocalDate, BigDecimal> calculateActualCostWorkPerformed(Interval interval) {
    SortedMap<LocalDate, BigDecimal> result = new TreeMap<LocalDate, BigDecimal>();
    Collection<WorkReportLine> workReportLines =
        filterWorkReportLinesByDate(databaseSnapshots.snapshotWorkReportLines(), interval);

    if (workReportLines.isEmpty()) {
      return result;
    }

    for (WorkReportLine workReportLine : workReportLines) {
      LocalDate day = new LocalDate(workReportLine.getDate());
      BigDecimal cost = workReportLine.getEffort().toHoursAsDecimalWithScale(2);

      if (!result.containsKey(day)) {
        result.put(day, BigDecimal.ZERO);
      }
      result.put(day, result.get(day).add(cost));
    }
    return accumulateResult(result);
  }
 private SortedMap<CriterionType, List<Criterion>> getMapCriterions() {
   return databaseSnapshots.snapshotCriterionsMap();
 }
 private Map<LabelType, List<Label>> getLabelsMap() {
   return databaseSnapshots.snapshotLabelsMap();
 }