@Test public void circularReferences() { final GanttTaskImpl a1 = createActivity(1).setTitle("a1"); final GanttTaskImpl a1_1 = createActivity(10).setTitle("a1_1"); a1_1.setPredecessor(a1); a1.addChild(a1_1); log.error("The two following error messages about circular reference detection are OK and part of this test."); assertNull(GanttUtils.getCalculatedStartDate(a1)); assertNull(GanttUtils.getCalculatedEndDate(a1)); assertNull(GanttUtils.getCalculatedStartDate(a1_1)); assertNull(GanttUtils.getCalculatedEndDate(a1_1)); }
@Test public void compareTo() final GanttTaskImpl a1 = new GanttTaskImpl(1).setTitle("B"); assertEquals(0, GanttUtils.GANTT_OBJECT_COMPARATOR.compare(a1, a1)); GanttTaskImpl a2 = new GanttTaskImpl(1).setTitle("A"); 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);
private GanttTaskImpl createGanttObject(final GanttTaskImpl parent, final String workpackageCode, final String title, final String durationDays, final GanttTask dependsOnGanttObject, final GanttRelationType type, final int dependDayOffset) { final GanttTaskImpl node = new GanttTaskImpl(); node.setTitle(title); node.setWorkpackageCode(workpackageCode); node.setDuration(new BigDecimal(durationDays)); node.setVisible(true); if (dependsOnGanttObject != null) { node.setPredecessor(dependsOnGanttObject); } if (type != null) { node.setRelationType(type); } if (dependDayOffset != 0) { node.setPredecessorOffset(dependDayOffset); } if (parent != null) { parent.addChild(node); } node.setPredecessor(dependsOnGanttObject); return node; }
@Test public void calculateFromDate() final GanttTaskImpl activity1 = createActivity(10).setTitle("activity1"); final DayHolder day = new DayHolder(); day.setDate(2010, Calendar.FEBRUARY, 5); 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)); 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); final GanttTaskImpl a2_2 = createActivity(2).setTitle("a2_2"); a2_2.setPredecessor(a2).setRelationType(GanttRelationType.START_START); a2.addChild(a2_2);
/** * Creates a new GanttTask and copies all fields from the given task (excluding the predecessor and any children). * @param task * @return */ public static final GanttTask convertToGanttObject(final TaskDO task) { final GanttTaskImpl ganttObject = new GanttTaskImpl(); ganttObject.setId(task.getId()); ganttObject.setPredecessorOffset(task.getGanttPredecessorOffset()); ganttObject.setRelationType(task.getGanttRelationType()); ganttObject.setDuration(task.getDuration()); ganttObject.setStartDate(task.getStartDate()); ganttObject.setEndDate(task.getEndDate()); ganttObject.setProgress(task.getProgress()); ganttObject.setType(task.getGanttObjectType()); ganttObject.setDescription(task.getDescription()); ganttObject.setTitle(task.getTitle()); return ganttObject; }
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);
findById(ganttObject, getTask(prefix + "1").getId()) .getStartDate()); findById(ganttObject, getTask(prefix + "1").getId()).addChild(new GanttTaskImpl(-1).setTitle("Child of 1")); findById(ganttObject, getTask(prefix + "1.1").getId()).addChild( new GanttTaskImpl(-2).setTitle("Child of 1.1").addChild(new GanttTaskImpl(-3).setTitle("Grand child of 1.1"))); ganttChartDao.writeGanttObjects(ganttChartDO, ganttObject); xml = transform(prefix, "<ganttObject id='{}'>"