Package org.projectforge.calendar

Examples of org.projectforge.calendar.DayHolder


  @Test
  public void calculateFromDate()
  {
    final GanttTaskImpl activity1 = createActivity(10).setTitle("activity1");
    final DayHolder day = new DayHolder();
    day.setDate(2010, Calendar.FEBRUARY, 5);
    activity1.setStartDate(day.getDate());
    assertDates("2010-02-05", "2010-02-19", activity1);
    activity1.setStartDate(null);
    day.addWorkingDays(10);
    activity1.setEndDate(day.getDate());
    assertDates("2010-02-05", "2010-02-19", activity1);

    final GanttTaskImpl activity2 = createActivity(5).setTitle("activity2");
    activity2.setPredecessor(activity1);
    assertDate(2010, Calendar.FEBRUARY, 19, GanttUtils.getCalculatedStartDate(activity2));
    activity2.setPredecessorOffset(2);
    assertDate(2010, Calendar.FEBRUARY, 19, GanttUtils.getCalculatedStartDate(activity2));
    activity2.recalculate();
    assertDate(2010, Calendar.FEBRUARY, 23, GanttUtils.getCalculatedStartDate(activity2));

    final GanttTaskImpl a1 = createActivity(1).setTitle("a1");
    day.setDate(2010, Calendar.FEBRUARY, 1);
    a1.setStartDate(day.getDate());
    final GanttTaskImpl a2 = createActivity(10).setTitle("a2");
    a2.setPredecessor(a1);
    final GanttTaskImpl a2_1 = createActivity(10).setTitle("a2_1");
    a2_1.setPredecessor(a2).setRelationType(GanttRelationType.START_START);
    a2.addChild(a2_1);
View Full Code Here


  }

  @Test
  public void subActivities()
  {
    final DayHolder day = new DayHolder();
    final GanttTaskImpl a1 = createActivity(1).setTitle("a1");
    day.setDate(2010, Calendar.SEPTEMBER, 1);
    a1.setStartDate(day.getDate());
    final GanttTaskImpl a2 = createActivity(-1).setTitle("a2");
    final GanttTaskImpl a2_1 = createActivity(2).setTitle("a2_1");
    a2_1.setPredecessor(a1);
    a2.addChild(a2_1);
    final GanttTaskImpl a2_2 = createActivity(2).setTitle("a2_2");
    a2_2.setPredecessor(a2_1);
    a2.addChild(a2_2);
    assertDates("2010-09-01", "2010-09-02", a1);
    assertDates("2010-09-02", "2010-09-06", a2_1); // 2010-09-04 to 2010-09-05 is a weekend.
    assertDates("2010-09-06", "2010-09-08", a2_2);
    assertDates("2010-09-02", "2010-09-08", a2);
    a2.setDuration(TWO);
    assertDates("Start date calculated from children and duration is fixed", "2010-09-02", "2010-09-06", a2);
    a2.setStartDate(day.getDate());
    assertDates("Start date and duration are fixed", "2010-09-01", "2010-09-03", a2);

    a2.setStartDate(null).setDuration(null).setPredecessor(a1).setPredecessorOffset(1);
    assertDates("Start date is calculated from predecessor.", "2010-09-03", "2010-09-08", a2);
    a2.setDuration(TWO);
View Full Code Here

    assertEquals(0, GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a1, a1)); // Same id
    a2 = new GanttTaskImpl(2).setTitle("A");
    assertTrue("Start date not given, use alphabetical order instead.", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a1, a2) > 0);
    assertTrue("Start date not given, use alphabetical order instead.", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a2, a1) < 0);

    final DayHolder day = new DayHolder();
    day.setDate(2010, Calendar.JUNE, 1);
    a1.setStartDate(day.getDate());
    assertTrue("a1.startDate before a2.startDate = null (now).", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a1, a2) < 0);
    assertTrue("a1.startDate before a2.startDate = null (now).", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a2, a1) > 0);
    day.addWorkingDays(2);
    a2.setStartDate(day.getDate());
    assertTrue("a1.startDate before a2.startDate.", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a1, a2) < 0);
    assertTrue("a1.startDate before a2.startDate.", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a2, a1) > 0);
    a1.setStartDate(day.getDate());
    assertTrue("Same start date -> alphabetical order", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a1, a2) > 0);
    assertTrue("Same start date -> alphabetical order", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a2, a1) < 0);
    day.addWorkingDays(2);
    a2.setEndDate(day.getDate());
    final Date a1StartDate = a1.getStartDate();
    a1.setStartDate(null);
    assertTrue("a1.endDate = null after a2.endDate", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a1, a2) > 0);
    assertTrue("a1.endDate = null before a2.endDate", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a2, a1) < 0);
    a1.setEndDate(day.getDate());
    a1.setStartDate(a1StartDate);
    assertTrue("Same start and end date -> alphabetical order", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a1, a2) > 0);
    assertTrue("Same start and end date -> alphabetical order", GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a2, a1) < 0);
  }
View Full Code Here

    return activity;
  }

  private void assertDate(final int year, final int month, final int day, final Date date)
  {
    final DayHolder dh = new DayHolder();
    dh.setDate(year, month, day);
    assertEquals(DateHelper.formatIsoDate(dh.getDate()), DateHelper.formatIsoDate(date));
  }
View Full Code Here

  {
    final GanttTask task = new GanttTaskImpl();
    assertFalse("duration should be 0.", task.hasDuration());
    task.setDuration(BigDecimal.TEN);
    assertTrue("duration should be 10.", task.hasDuration());
    final DayHolder day = new DayHolder();
    day.setDate(2010, Calendar.AUGUST, 13);
    task.setStartDate(day.getDate());
    assertTrue("duration should be 10.", task.hasDuration());
    task.setDuration(null);
    assertFalse("duration should be null.", task.hasDuration());
    day.add(Calendar.DAY_OF_MONTH, 1);
    task.setEndDate(day.getDate());
    assertTrue("duration expected.", task.hasDuration());
  }
View Full Code Here

  private RechnungCache rechnungCache;

  @Test
  public void baseTest()
  {
    final DayHolder today = new DayHolder();
    logon(getUser(TEST_FINANCE_USER));
    final AuftragDO auftrag = new AuftragDO();
    AuftragsPositionDO auftragsPosition = new AuftragsPositionDO();
    auftragsPosition.setTitel("Pos 1");
    auftrag.addPosition(auftragsPosition);
    auftragsPosition = new AuftragsPositionDO();
    auftragsPosition.setTitel("Pos 2");
    auftrag.addPosition(auftragsPosition);
    auftrag.setNummer(auftragDao.getNextNumber(auftrag));
    auftragDao.save(auftrag);

    final RechnungDO rechnung1 = new RechnungDO();
    RechnungsPositionDO position = new RechnungsPositionDO();
    position.setAuftragsPosition(auftrag.getPosition((short) 1)).setEinzelNetto(new BigDecimal("100")).setText("1.1");
    rechnung1.addPosition(position);
    position = new RechnungsPositionDO();
    position.setAuftragsPosition(auftrag.getPosition((short) 2)).setEinzelNetto(new BigDecimal("200")).setText("1.2");
    rechnung1.addPosition(position);
    rechnung1.setNummer(rechnungDao.getNextNumber(rechnung1)).setDatum(today.getSQLDate());
    rechnungDao.save(rechnung1);

    final RechnungDO rechnung2 = new RechnungDO();
    position = new RechnungsPositionDO();
    position.setAuftragsPosition(auftrag.getPosition((short) 1)).setEinzelNetto(new BigDecimal("400")).setText("2.1");
    rechnung2.addPosition(position);
    rechnung2.setNummer(rechnungDao.getNextNumber(rechnung2)).setDatum(today.getSQLDate());
    rechnungDao.save(rechnung2);

    Set<RechnungsPositionVO> set = rechnungCache.getRechnungsPositionVOSetByAuftragId(auftrag.getId());
    assertEquals("3 invoice positions expected.", 3, set.size());
    final Iterator<RechnungsPositionVO> it = set.iterator();
View Full Code Here

    initTestDB.addTask(prefix + "1.2.2", prefix + "1.2");
    initTestDB.addTask(prefix + "2", prefix);
    initTestDB.addTask(prefix + "2.1", prefix + "2");
    initTestDB.addTask(prefix + "2.2", prefix + "2");
    initTestDB.addTask(prefix + "2.3", prefix + "2");
    final DayHolder day = new DayHolder();
    day.setDate(2010, Calendar.AUGUST, 16);
    taskDao.update(getTask(prefix + "2.1").setStartDate(day.getDate()).setDuration(BigDecimal.TEN));
    taskDao.update(getTask(prefix + "2.2").setGanttPredecessor(getTask(prefix + "2.1")).setDuration(BigDecimal.TEN));

    taskDao.update(getTask(prefix + "1.1.1").setGanttPredecessor(getTask(prefix + "2.1")).setDuration(BigDecimal.TEN));
    taskDao.update(getTask(prefix + "1.1.2").setGanttPredecessor(getTask(prefix + "1.1.1")).setDuration(BigDecimal.TEN));
View Full Code Here

      sheet.addRow().setValues("DateHolder", "MINUTE_15", getDateHolder().setPrecision(DatePrecision.MINUTE_15));
      sheet.addRow().setValues("DateHolder", "MINUTE", getDateHolder().setPrecision(DatePrecision.MINUTE));
      sheet.addRow().setValues("DateHolder", "SECOND", getDateHolder().setPrecision(DatePrecision.SECOND));
      sheet.addRow().setValues("DateHolder", "MILLISECOND", getDateHolder().setPrecision(DatePrecision.MILLISECOND));
      sheet.addRow().setValues("DateHolder", "-", getDateHolder());
      sheet.addRow().setValues("DayHolder", "-", new DayHolder(getDate()));
      sheet.addRow().setValues("java.util.Date", "-", getDate());
      sheet.addRow().setValues("java.sql.Timestamp", "-", new Timestamp(getDate().getTime()));
      sheet.addRow().setValues("int", "-", 1234);
      sheet.addRow().setValues("BigDecimal", "-", new BigDecimal("123123123.123123123123"));
      final File file = TestConfiguration.getWorkFile(filename);
View Full Code Here

    assertDate("End date should have been calculated and set.", 2010, Calendar.SEPTEMBER, 13, externalGanttTask.getEndDate());
  }

  private void assertDate(final String message, final int year, final int month, final int dayOfMonth, final Date date)
  {
    final DayHolder dh = new DayHolder(date);
    assertEquals(message, year, dh.getYear());
    assertEquals(message, month, dh.getMonth());
    assertEquals(message, dayOfMonth, dh.getDayOfMonth());
  }
View Full Code Here

  @SuppressWarnings("serial")
  public List<IColumn<LiquidityEntryDO, String>> createColumns(final WebPage returnToPage, final boolean sortable)
  {
    final List<IColumn<LiquidityEntryDO, String>> columns = new ArrayList<IColumn<LiquidityEntryDO, String>>();
    final Date today = new DayHolder().getDate();
    final CellItemListener<LiquidityEntryDO> cellItemListener = new CellItemListener<LiquidityEntryDO>() {
      public void populateItem(final Item<ICellPopulator<LiquidityEntryDO>> item, final String componentId,
          final IModel<LiquidityEntryDO> rowModel)
      {
        final LiquidityEntryDO liquidityEntry = rowModel.getObject();
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.