public void insertSessions(String eventId, LocalDate date) {
    LocalDateTime dateTime = date.toLocalDateTime(LocalTime.MIDNIGHT);

    dateTime = dateTime.plusHours(9);

    Session session1 = new Session();
    session1.setEventId(eventId);
    session1.setTitle("Session 1");
    session1.setTimeslot(new Interval(dateTime.toDateTime(), Minutes.minutes(60)));
    session1.setRoom(room1);
    sessionDao.saveSession(session1);

    dateTime = dateTime.plusHours(1);

    Session session2 = new Session();
    session2.setEventId(eventId);
    session2.setTitle("Session 2");
    session2.setTimeslot(new Interval(dateTime.toDateTime(), Minutes.minutes(60)));
    session2.setRoom(room2);
    sessionDao.saveSession(session2);

    dateTime = dateTime.plusHours(1);

    Session session3 = new Session();
    session3.setEventId(eventId);
    session3.setTitle("Session 3");
    session3.setTimeslot(new Interval(dateTime.toDateTime(), Minutes.minutes(60)));
    session3.setRoom(room3);
    sessionDao.saveSession(session3);
  }
Esempio n. 2
0
  // should be private, but public because of unit test visibility
  public void detachWeekdaysFromWeekends(List<ParkingEvent> parkingEvents) {

    totalHours = 0; // for weekday hours

    weekends = new HashSet<String>(); // storing weekend days

    // iterating over events
    for (ParkingEvent parkingEvent : parkingEvents) {

      LocalDateTime startDateTime = new LocalDateTime(parkingEvent.getStartTime());
      LocalDateTime endDateTime = new LocalDateTime(parkingEvent.getEndTime());

      // iterating over event hours
      for (LocalDateTime date = startDateTime;
          date.isBefore(endDateTime);
          date = date.plusHours(1)) {
        if (date.getDayOfWeek() == DateTimeConstants.SATURDAY
            || date.getDayOfWeek() == DateTimeConstants.SUNDAY) {
          weekends.add(date.toLocalDate().toString());
        } else {
          totalHours++;
        }
      }
    }
  }
  @Override
  public List<UnidadeIndiceOEE> gerarUnidadesIndiceOEE(
      IndiceOEEPorHoraFilter filter, LocalDateTime dtHrInicio, LocalDateTime dtHrFim) {
    if (dtHrFim == null) {
      LocalTime horaAtual = new LocalTime();
      dtHrFim =
          new LocalDate()
              .toLocalDateTime(
                  new LocalTime(horaAtual.getHourOfDay(), horaAtual.getMinuteOfHour(), 0, 0));
    }
    List<UnidadeIndiceOEE> result = new ArrayList<UnidadeIndiceOEE>();

    int year = dtHrInicio.getYear();
    int month = dtHrInicio.getMonthOfYear();
    int day = dtHrInicio.getDayOfMonth();
    int hour = dtHrInicio.getHourOfDay();

    LocalDateTime dtHr = new LocalDateTime(year, month, day, hour, 0, 0, 0);

    while (dtHr.isBefore(dtHrFim)) {
      if (dtHr.toLocalDate().equals(filter.getDt())) {

        UnidadeIndiceOEE unidade = new UnidadeIndiceOEE();
        unidade.setInicio(dtHr);
        unidade.setFim(dtHr.plusMinutes(59));
        updateId(unidade);

        LocalDateTime inicio = dtHrInicio.isAfter(dtHr) ? dtHrInicio : unidade.getInicio();
        LocalDateTime fim = dtHr.plusHours(1);
        fim = dtHrFim.isAfter(fim) ? fim : dtHrFim;
        Integer tempoUtilMinutos = DateUtils.getDiferencaEmMinutos(inicio, fim);
        unidade.setTempoUtilMinutos(tempoUtilMinutos);

        result.add(unidade);
      }
      dtHr = dtHr.plusHours(1);
    }

    return result;
  }
 @Test
 public void should_pass_if_actual_is_equal_to_other_ignoring_hour_fields() {
   assertThat(refLocalDateTime).isEqualToIgnoringHours(refLocalDateTime.plusHours(1));
 }