Package org.projectforge.calendar

Examples of org.projectforge.calendar.DayHolder


  @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
  public HRViewData getResources(final HRFilter filter)
  {
    final HRViewData data = new HRViewData(filter);
    if (filter.getStartTime() == null) {
      final DayHolder day = new DayHolder();
      day.setBeginOfWeek();
      filter.setStartTime(day.getDate());
    }
    if (filter.getStopTime() == null) {
      final DayHolder day = new DayHolder(filter.getStartTime());
      day.setEndOfWeek();
      filter.setStopTime(day.getDate());
    }
    if (filter.isShowBookedTimesheets() == true) {
      final TimesheetFilter tsFilter = new TimesheetFilter();
      tsFilter.setStartTime(filter.getStartTime());
      tsFilter.setStopTime(filter.getStopTime());
View Full Code Here


    if (label != null) {
      g1.appendChild(SVGHelper.createText(doc, diagramWidth / 2, 0, label));
    }
    final Element ticks = SVGHelper.createElement(doc, "g", "stroke", SVGColor.BLACK.getName(), "stroke-width", "1", "transform", "translate(0,10)");
    g1.appendChild(ticks);
    final DayHolder day = new DayHolder(fromDate);
    final DayHolder toDay = new DayHolder(toDate);
    int dayCounter = 0;
    int weekCounter = 0;
    int monthCounter = 0;
    int quarterCounter = 0;
    int lastDateLabel = 0;
    boolean nonWorkingDayDisplayed = false;
    while (day.before(toDay) == true) {
      if (dayCounter > 0) {
        if (showNonWorkingDays == true && xGridHeight > 0) {
          if (day.isWorkingDay() == true) {
            nonWorkingDayDisplayed = false;
          } else if (nonWorkingDayDisplayed == false) {
            // Non-working day:
            showNonWorkingDays(doc, grid, day.getDate(), toDay.getDate(), xGridHeight);
            nonWorkingDayDisplayed = true;
          }
        }
        int wc = -1;
        if (day.getDayOfWeek() == day.getCalendar().getFirstDayOfWeek()) {
View Full Code Here

  private void showNonWorkingDays(final Document doc, final Element g, final Date day, final Date toDate, final double height)
  {
    if (g == null) {
      return;
    }
    final DayHolder dh = new DayHolder(day);
    final double x1 = getXValue(day);
    for (int i = 0; i < 100; i++) { // End-less loop protection.
      dh.add(Calendar.DAY_OF_MONTH, 1);
      if (dh.isWorkingDay() == true || dh.before(toDate) == false) {
        break;
      }
    }
    final double x2 = getXValue(dh.getDate());
    g.appendChild(SVGHelper.createRect(doc, x1, 0, x2 - x1, height, SVGColor.LIGHT_GRAY, SVGColor.NONE));
  }
View Full Code Here

   * @return
   */
  public JFreeChart create(final TimesheetDao timesheetDao, final Integer userId, final double workingHoursPerDay,
      final short forLastNDays, final boolean showAxisValues)
  {
    final DayHolder dh = new DayHolder();
    final TimesheetFilter filter = new TimesheetFilter();
    filter.setStopTime(dh.getDate());
    dh.add(Calendar.DATE, -forLastNDays);
    filter.setStartTime(dh.getDate());
    filter.setUserId(userId);
    filter.setOrderType(OrderDirection.ASC);
    final List<TimesheetDO> list = timesheetDao.getList(filter);
    final TimeSeries sollSeries = new TimeSeries("Soll");
    final TimeSeries istSeries = new TimeSeries("Ist");
    planWorkingHours = 0;
    actualWorkingHours = 0;
    final Iterator<TimesheetDO> it = list.iterator();
    TimesheetDO current = null;
    if (it.hasNext() == true) {
      current = it.next();
    }
    for (int i = 0; i <= forLastNDays; i++) {
      while (current != null && (dh.isSameDay(current.getStartTime()) == true || current.getStartTime().before(dh.getDate()) == true)) {
        actualWorkingHours += ((double) current.getWorkFractionDuration()) / 3600000;
        if (it.hasNext() == true) {
          current = it.next();
        } else {
          current = null;
          break;
        }
      }
      if (dh.isWorkingDay() == true) {
        final BigDecimal workFraction = dh.getWorkFraction();
        if (workFraction != null) {
          planWorkingHours += workFraction.doubleValue() * workingHoursPerDay;
        } else {
          planWorkingHours += workingHoursPerDay;
        }
      }
      final Day day = new Day(dh.getDayOfMonth(), dh.getMonth() + 1, dh.getYear());
      sollSeries.add(day, planWorkingHours);
      istSeries.add(day, actualWorkingHours);
      dh.add(Calendar.DATE, 1);
    }
    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(sollSeries);
    dataset.addSeries(istSeries);
    final XYChartBuilder cb = new XYChartBuilder(null,  null,  null,  dataset, false);
View Full Code Here

   * @param showAxisValues
   * @return
   */
  public JFreeChart create(final TimesheetDao timesheetDao, final Integer userId, final short forLastNDays, final boolean showAxisValues)
  {
    final DayHolder dh = new DayHolder();
    final TimesheetFilter filter = new TimesheetFilter();
    filter.setStopTime(dh.getDate());
    dh.add(Calendar.DATE, -forLastNDays);
    filter.setStartTime(dh.getDate());
    filter.setUserId(userId);
    filter.setOrderType(OrderDirection.ASC);
    final List<TimesheetDO> list = timesheetDao.getList(filter);
    final TimeSeries planSeries = new TimeSeries("Soll");
    final TimeSeries actualSeries = new TimeSeries("Ist");
    final Iterator<TimesheetDO> it = list.iterator();
    TimesheetDO current = null;
    if (it.hasNext() == true) {
      current = it.next();
    }
    long numberOfBookedDays = 0;
    long totalDifference = 0;
    for (int i = 0; i <= forLastNDays; i++) {
      long difference = 0;
      long totalDuration = 0; // Weight for average.
      while (current != null && (dh.isSameDay(current.getStartTime()) == true || current.getStartTime().before(dh.getDate()) == true)) {
        final long duration = current.getWorkFractionDuration();
        difference += (current.getCreated().getTime() - current.getStartTime().getTime()) * duration;
        totalDuration += duration;
        if (it.hasNext() == true) {
          current = it.next();
        } else {
          current = null;
          break;
        }
      }
      final double averageDifference = difference > 0 ? ((double) difference) / totalDuration / 86400000 : 0; // In days.
      final Day day = new Day(dh.getDayOfMonth(), dh.getMonth() + 1, dh.getYear());
      if (averageDifference > 0) {
        planSeries.add(day, PLANNED_AVERAGE_DIFFERENCE_BETWEEN_TIMESHEET_AND_BOOKING); // plan average
        // (PLANNED_AVERAGE_DIFFERENCE_BETWEEN_TIMESHEET_AND_BOOKING
        // days).
        actualSeries.add(day, averageDifference);
        totalDifference += averageDifference;
        numberOfBookedDays++;
      }
      dh.add(Calendar.DATE, 1);
    }
    averageDifferenceBetweenTimesheetAndBooking = numberOfBookedDays > 0 ? new BigDecimal(totalDifference).divide(new BigDecimal(
        numberOfBookedDays), 1, RoundingMode.HALF_UP) : BigDecimal.ZERO;

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
View Full Code Here

    // Add a default calendar called "Standard"
    //
    final ProjectCalendar calendar = file.addDefaultBaseCalendar();
    calendar.setWorkingDay(Day.SATURDAY, false);
    calendar.setWorkingDay(Day.SUNDAY, false);
    final DayHolder dh = new DayHolder(ganttChart.getCalculatedStartDate());
    for (int i = 0; i < 3000; i++) { // Endless loop protection (paranoia)
      dh.add(Calendar.DAY_OF_MONTH, 1);
      if (dh.isWorkingDay() == false && dh.isHoliday() == true && dh.isWeekend() == false) {
        // Add this holiday to the calendar:
        final Date date = dh.getSQLDate();
        calendar.addCalendarException(date, date);
        if (log.isDebugEnabled() == true) {
          log.debug("Add holiday: " + date);
        }
      }
      if (dh.before(ganttChart.getCalculatedEndDate()) == false) {
        break;
      }
    }

    final List<GanttTask> children = ganttChart.getRootNode().getChildren();
View Full Code Here

   *         the week.
   * @see DayHolder#setBeginOfWeek()
   */
  public static final Date getFirstDayOfWeek(final Date date)
  {
    final DayHolder day = new DayHolder(date, DateHelper.UTC, Locale.GERMAN);
    day.setBeginOfWeek();
    return day.getSQLDate();
  }
View Full Code Here

   *         the week.
   * @see DayHolder#setBeginOfWeek()
   */
  public static final Date getFirstDayOfWeek(final java.util.Date date)
  {
    final DayHolder day = new DayHolder(date, DateHelper.UTC, Locale.GERMAN);
    day.setBeginOfWeek();
    return day.getSQLDate();
  }
View Full Code Here

    } while (dh.getDate().before(toDate));
  }

  public void addTimesheet(final TimesheetDO sheet)
  {
    final DayHolder day = new DayHolder(sheet.getStartTime());
    bookedDays.add(day.getDayOfMonth());
    for (final MonthlyEmployeeReportWeek week : weeks) {
      if (week.matchWeek(sheet) == true) {
        week.addEntry(sheet);
        return;
      }
View Full Code Here

   * @return
   */
  public static ReindexSettings createReindexSettings(final boolean onlyNewest)
  {
    if (onlyNewest == true) {
      final DayHolder day = new DayHolder();
      day.add(Calendar.DAY_OF_MONTH, -1); // Since yesterday:
      return new ReindexSettings(day.getDate(), 1000); // Maximum 1,000 newest entries.
    } else {
      return new ReindexSettings();
    }
  }
View Full Code Here

TOP

Related Classes of org.projectforge.calendar.DayHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.