コード例 #1
0
 @Test
 @Transactional
 public void testSaveWorkReportLine() {
   WorkReportLine workReportLine = createValidWorkReportLine();
   workReportLineDAO.save(workReportLine);
   assertTrue(workReportLineDAO.exists(workReportLine.getId()));
 }
コード例 #2
0
 @Test
 @Transactional
 public void testRemoveWorkReportLine() throws InstanceNotFoundException {
   WorkReportLine workReportLine = createValidWorkReportLine();
   workReportLineDAO.save(workReportLine);
   workReportLine.getWorkReport().removeWorkReportLine(workReportLine);
   workReportLineDAO.remove(workReportLine.getId());
   assertFalse(workReportLineDAO.exists(workReportLine.getId()));
 }
コード例 #3
0
 private List<WorkReportLine> filterWorkReportLinesByDate(
     Collection<WorkReportLine> lines, AvailabilityTimeLine.Interval interval) {
   List<WorkReportLine> result = new ArrayList<WorkReportLine>();
   for (WorkReportLine line : lines) {
     if (interval.includes(line.getLocalDate())) {
       result.add(line);
     }
   }
   return result;
 }
コード例 #4
0
  @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);
  }