Package org.projectforge.common

Examples of org.projectforge.common.DateHolder


  public String toString(Object obj)
  {
    if (obj == null) {
      return null;
    }
    final DateHolder dh = new DateHolder((Date) obj);
    final String format;
    if (dh.getMilliSecond() == 0) {
      if (dh.getSecond() == 0) {
        if (dh.getMinute() == 0 && dh.getHourOfDay() == 0) {
          format = FORMAT_ISO_DATE;
        } else {
          format = FORMAT_ISO_TIMESTAMP_MINUTES;
        }
      } else {
View Full Code Here


    getInitTestDB().addTask(prefix + "1.2", prefix + "1");

    final TaskDO t2 = getInitTestDB().addTask(prefix + "2", "root");
    projektDao.setTask(projekt2, t2.getId());
    projektDao.update(projekt2);
    final DateHolder dh = new DateHolder();
    dh.setDate(2009, 11, 31);
    t2.setProtectTimesheetsUntil(dh.getDate());
    taskDao.update(t2);
    getInitTestDB().addTask(prefix + "2.1", prefix + "2");
    getInitTestDB().addTask(prefix + "2.2", prefix + "2");
    getInitTestDB().addUser(prefix + "user");
    final TimesheetDO ts1 = createTimesheet(prefix, "1.1", "user", 2009, 10, 21, 3, 0, 3, 15, "Office", "A lot of stuff done and more.", 5,
View Full Code Here

  {
    if (from == null) {
      this.from = null;
      return;
    }
    final DateHolder day = new DateHolder(from);
    day.setBeginOfMonth();
    this.from = day.getDate();
  }
View Full Code Here

  {
    if (to == null) {
      this.to = null;
      return;
    }
    final DateHolder day = new DateHolder(to);
    day.setEndOfMonth();
    this.to = day.getDate();
  }
View Full Code Here

    auftrag2 = auftragDao.getById(id2);

    AuftragDO auftrag3 = new AuftragDO();
    auftrag3.setNummer(auftragDao.getNextNumber(auftrag3));
    auftragDao.setContactPerson(auftrag3, getUserId(TEST_PROJECT_MANAGER_USER));
    final DateHolder date = new DateHolder();
    date.add(Calendar.YEAR, -6); // 6 years old.
    auftrag3.setAngebotsDatum(date.getSQLDate());
    auftrag3.setAuftragsStatus(AuftragsStatus.ABGESCHLOSSEN);
    final AuftragsPositionDO position = new AuftragsPositionDO();
    position.setVollstaendigFakturiert(true);
    position.setStatus(AuftragsPositionsStatus.ABGESCHLOSSEN);
    auftrag3.addPosition(position);
View Full Code Here

  }

  private FooDO createFooDO(final int createdDayOfMonth, final int lastUpdateDateOfMonth, final boolean deleted, final boolean testBoolean, final String testString)
  {
    final FooDO obj = new FooDO();
    final DateHolder dateHolder = new DateHolder(DatePrecision.SECOND, Locale.GERMAN);
    obj.setId(42);
    dateHolder.setDate(1970, Calendar.NOVEMBER, createdDayOfMonth, 4, 50, 0);
    obj.setCreated(dateHolder.getDate());
    dateHolder.setDate(1970, Calendar.NOVEMBER, lastUpdateDateOfMonth, 4, 50, 0);
    obj.setLastUpdate(dateHolder.getDate());
    obj.setDeleted(deleted);
    obj.setTestBoolean(testBoolean);
    obj.setTestString(testString);
    return obj;
  }
View Full Code Here

  {
    logon(TEST_ADMIN_USER);
    final String prefix = "GantChartTest";
    final TaskTree taskTree = taskDao.getTaskTree();
    final TaskDO rootTask = initTestDB.addTask(prefix, "root");
    final DateHolder dh = new DateHolder();
    dh.setDate(2010, Calendar.AUGUST, 3);
    taskDao.update(initTestDB.addTask(prefix + "1", prefix).setStartDate(dh.getDate()).setDuration(BigDecimal.TEN));
    initTestDB.addTask(prefix + "1.1", prefix + "1");
    taskDao.update(initTestDB.addTask(prefix + "2", prefix).setGanttPredecessor(getTask(prefix + "1")).setDuration(BigDecimal.ONE));
    taskDao.update(initTestDB.addTask(prefix + "3", prefix).setGanttPredecessor(getTask(prefix + "2")).setGanttPredecessorOffset(10)
        .setDuration(BigDecimal.TEN));
    final GanttChartData data = Task2GanttTaskConverter.convertToGanttObjectTree(taskTree, rootTask);
    final GanttTask rootObject = data.getRootObject();
    final GanttChartDO ganttChartDO = new GanttChartDO().setTask(rootTask);
    ganttChartDao.writeGanttObjects(ganttChartDO, rootObject);
    assertEquals("No output because there is no further information in the GanttObject tree.", "", ganttChartDO.getGanttObjectsAsXml());
    findById(rootObject, getTask(prefix + "2").getId()).setPredecessorOffset(5).setDuration(new BigDecimal("12"));
    findById(rootObject, getTask(prefix + "1.1").getId()).setDuration(new BigDecimal("2"));
    ganttChartDao.writeGanttObjects(ganttChartDO, rootObject);
    String xml = transform(prefix, "<ganttObject id='{}'>"
        + "<children>"
        + "<ganttObject id='{1}'>"
        + "<children>"
        + "<ganttObject id='{1.1}' duration='2'/>"
        + "</children>"
        + "</ganttObject>"
        + "<ganttObject id='{2}' predecessorOffset='5' duration='12'/></children></ganttObject>");
    assertEquals("3 has no further information.", xml, ganttChartDO.getGanttObjectsAsXml());

    GanttTask ganttObject = ganttChartDao.readGanttObjects(ganttChartDO).getRootObject();
    ganttChartDao.writeGanttObjects(ganttChartDO, ganttObject);
    assertEquals(xml, ganttChartDO.getGanttObjectsAsXml());
    assertEquals("duration", BigDecimal.TEN, findById(ganttObject, getTask(prefix + "1").getId()).getDuration());
    assertEquals("startDate", dh.getDate(), findById(ganttObject, getTask(prefix + "1").getId()).getStartDate());

    initTestDB.addTask(prefix + "II", "root");
    taskDao.update(getTask(prefix + "1.1").setParentTask(getTask(prefix))); // One level higher
    taskDao.update(getTask(prefix + "2").setParentTask(getTask(prefix + "II"))); // Moved anywhere.
    taskDao.update(getTask(prefix + "3").setParentTask(getTask(prefix + "II"))); // Moved anywhere.
View Full Code Here

  @Test
  public void testWrite()
  {
    final XmlObjectWriter writer = new XmlObjectWriter();
    TestObject obj = new TestObject();
    final DateHolder dh = new DateHolder();
    dh.setDate(2010, Calendar.AUGUST, 29, 23, 8, 17, 123);
    obj.date = dh.getDate();
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"1283116097123\"/>", writer.writeToXml(obj));
    final XmlRegistry reg = new XmlRegistry();
    reg.registerConverter(Date.class, new ISODateConverter());
    writer.setXmlRegistry(reg);
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:08:17.123\"/>", writer.writeToXml(obj));
    obj.date = dh.setMilliSecond(0).getDate();
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:08:17\"/>", writer.writeToXml(obj));
    obj.date = dh.setSecond(0).getDate();
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:08\"/>", writer.writeToXml(obj));
    obj.date = dh.setMinute(0).getDate();
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29 23:00\"/>", writer.writeToXml(obj));
    obj.date = dh.setHourOfDay(0).getDate();
    assertEquals("<test d1=\"0.0\" i1=\"0\" date=\"2010-08-29\"/>", writer.writeToXml(obj));
  }
View Full Code Here

    }
  }

  private DateHolder getDateHolder()
  {
    return new DateHolder(getDate(), DateHelper.UTC);
  }
View Full Code Here

    logon(getUser(TEST_ADMIN_USER));
    final TaskDO task = initTestDB.addTask("totalDurationTask", "root");
    final TaskDO subTask1 = initTestDB.addTask("totalDurationTask.subtask1", "totalDurationTask");
    final TaskDO subTask2 = initTestDB.addTask("totalDurationTask.subtask2", "totalDurationTask");
    assertEquals(0, taskDao.readTotalDuration(task.getId()));
    final DateHolder dh = new DateHolder();
    dh.setDate(2010, Calendar.APRIL, 20, 8, 0);
    TimesheetDO ts = new TimesheetDO().setUser(getUser(TEST_USER)).setStartDate(dh.getDate()).setStopTime(
        dh.add(Calendar.HOUR_OF_DAY, 4).getTimestamp()).setTask(task);
    timesheetDao.save(ts);
    assertEquals(4 * 3600, taskDao.readTotalDuration(task.getId()));
    assertEquals(4 * 3600, getTotalDuration(task.getId()));
    ts = new TimesheetDO().setUser(getUser(TEST_USER)).setStartDate(dh.add(Calendar.HOUR_OF_DAY, 1).getDate()).setStopTime(
        dh.add(Calendar.HOUR_OF_DAY, 4).getTimestamp()).setTask(task);
    timesheetDao.save(ts);
    assertEquals(8 * 3600, taskDao.readTotalDuration(task.getId()));
    assertEquals(8 * 3600, getTotalDuration(task.getId()));
    ts = new TimesheetDO().setUser(getUser(TEST_USER)).setStartDate(dh.add(Calendar.HOUR_OF_DAY, 1).getDate()).setStopTime(
        dh.add(Calendar.HOUR_OF_DAY, 4).getTimestamp()).setTask(subTask1);
    timesheetDao.save(ts);
    final List<Object[]> list = taskDao.readTotalDurations();
    boolean taskFound = false;
    boolean subtask1Found = false;
    for (final Object[] oa : list) {
View Full Code Here

TOP

Related Classes of org.projectforge.common.DateHolder

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.