@Test public void testConvertingTaskTree() { logon(AbstractTestBase.TEST_ADMIN_USER); final String prefix = "task2Gantt"; initTestDB.addTask(prefix, "root"); initTestDB.addTask(prefix + "1", prefix); initTestDB.addTask(prefix + "1.1", prefix + "1"); initTestDB.addTask(prefix + "1.1.1", prefix + "1.1"); initTestDB.addTask(prefix + "1.1.2", prefix + "1.1"); initTestDB.addTask(prefix + "1.2", prefix + "1"); initTestDB.addTask(prefix + "1.2.1", prefix + "1.2"); 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 PFDateTime day = PFDateTime.withDate(2010, Month.AUGUST, 16); TaskDO task = getTask(prefix + "2.1"); task.setStartDate(day.getLocalDate()); task.setDuration(BigDecimal.TEN); taskDao.update(task); task = getTask(prefix + "2.2"); task.setGanttPredecessor(getTask(prefix + "2.1")); task.setDuration(BigDecimal.TEN); taskDao.update(task); task = getTask(prefix + "1.1.1"); task.setGanttPredecessor(getTask(prefix + "2.1")); task.setDuration(BigDecimal.TEN); taskDao.update(task); task = getTask(prefix + "1.1.2"); task.setGanttPredecessor(getTask(prefix + "1.1.1")); task.setDuration(BigDecimal.TEN); taskDao.update(task); task = getTask(prefix + "1.2.1"); task.setGanttPredecessor(getTask(prefix + "2.2")); task.setDuration(BigDecimal.TEN); taskDao.update(task); task = getTask(prefix + "1.2.2"); task.setGanttPredecessor(getTask(prefix + "1.2.1")); task.setDuration(BigDecimal.TEN); taskDao.update(task); final GanttChartData ganttChartData = Task2GanttTaskConverter.convertToGanttObjectTree(taskDao.getTaskTree(), getTask(prefix + "1")); assertEquals(2, ganttChartData.getExternalObjects().size(), "Two external objects (2.1 and 2.2) exptected."); assertExternalTasks(ganttChartData, prefix); final GanttChartDO ganttChartDO = new GanttChartDO(); ganttChartDO.setTask(getTask(prefix + "1")); ganttChartDao.writeGanttObjects(ganttChartDO, ganttChartData.getRootObject()); assertEquals("", ganttChartDO.getGanttObjectsAsXml(), "No output because there is no further information in the GanttObject tree."); GanttChartData data = ganttChartDao.readGanttObjects(ganttChartDO); assertExternalTasks(data, prefix); final GanttTask external2_1 = ganttChartData.getExternalObject(getTask(prefix + "2.1").getId()); findById(ganttChartData, prefix, "1.2") .setPredecessor(ganttChartData.ensureAndGetExternalGanttObject(getTask(prefix + "2.3"))); findById(ganttChartData, prefix, "1.1.1").setPredecessor(null); findById(ganttChartData, prefix, "1.2.1").setPredecessor(external2_1); findById(ganttChartData, prefix, "1.1.2").setPredecessor(findById(ganttChartData, prefix, "1.2.2")); findById(ganttChartData, prefix, "1.2.2").setPredecessor(null); ganttChartDao.writeGanttObjects(ganttChartDO, ganttChartData.getRootObject()); final String xml = transform(prefix, "<ganttObject id='{1}'>" + "<children>" + "<ganttObject id='{1.1}'>" + "<children>" + "<ganttObject id='{1.1.1}' predecessor='null'/>" + "<ganttObject id='{1.1.2}'><predecessor id='{1.2.2}' predecessor='null' o-id='0'/></ganttObject>" + "</children>" + "</ganttObject>" + "<ganttObject id='{1.2}'><predecessor id='{2.3}'/>" + "<children>" + "<ganttObject id='{1.2.1}'><predecessor id='{2.1}'/></ganttObject>" + "<ganttObject ref-id='0'/>" + "</children>" + "</ganttObject>" + "</children>" + "</ganttObject>"); assertEquals(xml, ganttChartDO.getGanttObjectsAsXml(), "Gantt objects as xml."); data = ganttChartDao.readGanttObjects(ganttChartDO); ganttChartDao.writeGanttObjects(ganttChartDO, data.getRootObject()); assertEquals(xml, ganttChartDO.getGanttObjectsAsXml(), "Gantt objects as xml."); assertNull(findById(data, prefix, "1.2.2").getPredecessor(), "Predecessor was set to null."); assertEquals(prefix + "2.3", findById(data, prefix, "1.2").getPredecessor().getTitle(), "External predecessor expected."); }
public static final GanttChartData convertToGanttObjectTree(final TaskTree taskTree, final TaskDO rootTask) { final GanttChartData ganttChartData = new GanttChartData(); convertToGanttObject(ganttChartData, taskTree, rootTask); processPredecessor(ganttChartData, taskTree, ganttChartData.getRootObject()); return ganttChartData; }
Task2GanttTaskConverter { public static final GanttChartData convertToGanttObjectTree(final TaskTree taskTree, final TaskDO rootTask) { final GanttChartData ganttChartData = new GanttChartData(); convertToGanttObject(ganttChartData, taskTree, rootTask); processPredecessor(ganttChartData, taskTree, ganttChartData.getRootObject()); return ganttChartData; } }
Task2GanttTaskConverter { public static final GanttChartData convertToGanttObjectTree(final TaskTree taskTree, final TaskDO rootTask) { final GanttChartData ganttChartData = new GanttChartData(); convertToGanttObject(ganttChartData, taskTree, rootTask); processPredecessor(ganttChartData, taskTree, ganttChartData.getRootObject()); return ganttChartData; }  }
Task2GanttTaskConverter { public static final GanttChartData convertToGanttObjectTree(final TaskTree taskTree, final TaskDO rootTask) { final GanttChartData ganttChartData = new GanttChartData(); convertToGanttObject(ganttChartData, taskTree, rootTask); processPredecessor(ganttChartData, taskTree, ganttChartData.getRootObject()); return ganttChartData; }  static final GanttChartData convertToGanttObjectTree(final TaskTree taskTree, final TaskDO rootTask); static final GanttTask convertToGanttObject(final TaskDO task); static final TaskDO convertToTask(final GanttTask ganttObject); }
Task2GanttTaskConverter { public static final GanttChartData convertToGanttObjectTree(final TaskTree taskTree, final TaskDO rootTask) { final GanttChartData ganttChartData = new GanttChartData(); convertToGanttObject(ganttChartData, taskTree, rootTask); processPredecessor(ganttChartData, taskTree, ganttChartData.getRootObject()); return ganttChartData; }  static final GanttChartData convertToGanttObjectTree(final TaskTree taskTree, final TaskDO rootTask); static final GanttTask convertToGanttObject(final TaskDO task); static final TaskDO convertToTask(final GanttTask ganttObject);  }