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; }
/** * 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; }
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); a2.setDuration(TWO); assertDates("Start date is calculated from predecessor and duration is fixed.", "2010-09-02", "2010-09-06", a2); a2.setRelationType(GanttRelationType.START_FINISH).setDuration(null).setPredecessorOffset(4); assertDates("End date is calculated from predecessor.", "2010-09-02", "2010-09-07", a2); a2.setDuration(TWO);
activity2.setPredecessor(activity1); assertDate(2010, Calendar.FEBRUARY, 19, GanttUtils.getCalculatedStartDate(activity2)); activity2.setPredecessorOffset(2); assertDate(2010, Calendar.FEBRUARY, 19, GanttUtils.getCalculatedStartDate(activity2)); activity2.recalculate();
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);