public GanttTask findById(final Serializable id) { if (rootObject == null) { return null; } return rootObject.findById(id); }
private GanttTask getExternalGanttObject(final TaskDO task) { final GanttTask ganttObject = convertToGanttObject(task); if (ganttObject.getStartDate() == null) { ganttObject.setStartDate(GanttUtils.getCalculatedStartDate(ganttObject)); } if (ganttObject.getEndDate() == null) { ganttObject.setEndDate(GanttUtils.getCalculatedEndDate(ganttObject)); } // Remove any existing predecessor chain: ganttObject.setPredecessor(null); return ganttObject; }
private static void setPredecessors(final Map<Serializable, Task> taskMap, final GanttTask ganttTask) { if (ganttTask.getPredecessor() != null) { final Task task = taskMap.get(ganttTask.getId()); final Task predecessor = taskMap.get(ganttTask.getPredecessorId()); if (task == null) { log.error("Oups, task with id '" + ganttTask.getId() + "' not found."); } else if (predecessor == null) { log.error("Oups, predecessor task with id '" + ganttTask.getPredecessorId() + "' not found."); } else { final Integer predecessorOffset = ganttTask.getPredecessorOffset(); final int value; if (predecessorOffset == null) { value = 0; } else { value = predecessorOffset.intValue(); } task.addPredecessor(predecessor, getRelationType(ganttTask.getRelationType()), Duration.getInstance(value, TimeUnit.DAYS)); } } final List<GanttTask> children = ganttTask.getChildren(); if (children == null) { return; } for (final GanttTask child : children) { setPredecessors(taskMap, child); } }
@Override public String getObject() { final GanttTask predecessor = ganttObject.getPredecessor(); return predecessor != null ? predecessor.getTitle() : ""; } });
if (node.getEndDate() != null) { return node.getEndDate(); if (node.isEndDateCalculated() == true) { return node.getCalculatedEndDate(); final int durationDays = node.getDuration() != null ? node.getDuration().setScale(0, RoundingMode.HALF_UP).intValue() : 0; if (node.getDuration() != null && node.getStartDate() != null) { final Date endDate = calculateDate(node.getStartDate(), durationDays); node.setCalculatedEndDate(endDate).setEndDateCalculated(true); if (log.isDebugEnabled() == true) { log.debug("calculated end date=" + endDate + " for: " + node); if (endDateSet.contains(node.getId()) == true) { log.error("Circular reference detection (couldn't calculate end date: " + node); return null; } else { endDateSet.add(node.getId()); final GanttTask predecessor = node.getPredecessor(); if (predecessor != null) { endDate = getPredecessorRelDate(node.getRelationType(), predecessor, startDateSet, endDateSet); if (endDate != null) { if (NumberHelper.isNotZero(node.getPredecessorOffset()) == true) { endDate = calculateDate(endDate, node.getPredecessorOffset()); if (node.getRelationType() != GanttRelationType.START_FINISH && node.getRelationType() != GanttRelationType.FINISH_FINISH) { if (durationDays > 0) { endDate = calculateDate(endDate, durationDays);
if (node.getStartDate() != null) { return node.getStartDate(); if (node.isStartDateCalculated() == true) { return node.getCalculatedStartDate(); final int durationDays = node.getDuration() != null ? node.getDuration().setScale(0, RoundingMode.HALF_UP).intValue() : 0; if (node.getDuration() != null && node.getEndDate() != null) { final Date startDate = calculateDate(node.getEndDate(), -durationDays); node.setCalculatedStartDate(startDate).setStartDateCalculated(true); if (log.isDebugEnabled() == true) { log.debug("calculated start date=" + startDate + " for: " + node); if (startDateSet.contains(node.getId()) == true) { log.error("Circular reference detection (couldn't calculate start date: " + node); return null; } else { startDateSet.add(node.getId()); final GanttTask predecessor = node.getPredecessor(); if (predecessor != null) { startDate = getPredecessorRelDate(node.getRelationType(), predecessor, startDateSet, endDateSet); if (startDate != null) { if (NumberHelper.isNotZero(node.getPredecessorOffset()) == true) { startDate = calculateDate(startDate, node.getPredecessorOffset()); if (node.getRelationType() == GanttRelationType.START_FINISH || node.getRelationType() == GanttRelationType.FINISH_FINISH) { if (durationDays > 0) { startDate = calculateDate(startDate, -durationDays);
/** * Creates a new GanttTask and copies all fields from the given task (excluding the predecessor and any children). * @param task * @return */ public static final TaskDO convertToTask(final GanttTask ganttObject) { final TaskDO task = new TaskDO(); // Do not copy the id! The id is given by the data base. task.setGanttPredecessorOffset(ganttObject.getPredecessorOffset()); task.setGanttRelationType(ganttObject.getRelationType()); task.setDuration(ganttObject.getDuration()); task.setStartDate(ganttObject.getStartDate()); task.setEndDate(ganttObject.getEndDate()); task.setProgress(ganttObject.getProgress()); task.setGanttObjectType(ganttObject.getType()); task.setDescription(ganttObject.getDescription()); task.setTitle(ganttObject.getTitle()); return task; }
task = parentTask.addTask(); taskMap.put(ganttTask.getId(), task); task.setName(ganttTask.getTitle()); if (ganttTask.getStartDate() != null) { task.setStart(ganttTask.getStartDate()); if (ganttTask.getEndDate() != null) { task.setFinish(ganttTask.getEndDate()); final BigDecimal duration = ganttTask.getDuration(); final double value; if (duration == null) { if (ganttTask.getProgress() != null) { task.setPercentageComplete(ganttTask.getProgress()); final List<GanttTask> children = ganttTask.getChildren(); if (children == null) { return;
} else { final Date date = (Date) selectedValue; obj.setStartDate(date); markStartDateModelAsChanged(obj.getId()); } else { final Date date = (Date) selectedValue; obj.setEndDate(date); markEndDateModelAsChanged(obj.getId()); GanttTask predecessor = findById(intValue); if (predecessor != null) { obj.setPredecessor(predecessor); } else { } else { predecessor = ganttChartData.ensureAndGetExternalGanttObject(task); obj.setPredecessor(predecessor);
final TaskDO task = taskTree.getTaskById((Integer) ganttTask.getId()); final Integer predecessorId = task.getGanttPredecessorId(); if (predecessorId != null) { GanttTask predecessor = ganttChartData.getRootObject().findById(predecessorId); if (predecessor == null) { ganttTask.setPredecessor(predecessor); if (ganttTask.getChildren() != null) { for (final GanttTask child : ganttTask.getChildren()) { processPredecessor(ganttChartData, taskTree, child);
@Test public void hasDuration() { 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()); } }
@Override public int compare(final GanttTask o1, final GanttTask o2) if (ObjectUtils.equals(o1.getId(), o2.getId()) == true) { return 0; final Date start1 = o1.getCalculatedStartDate(); final Date start2 = o2.getCalculatedStartDate(); if (start1 == null) { if (start2 != null) { final Date end1 = o1.getCalculatedEndDate(); final Date end2 = o2.getCalculatedEndDate(); if (end1 == null) { if (end2 != null) { if (StringUtils.equals(o1.getTitle(), o2.getTitle()) == false) { return StringHelper.compareTo(o1.getTitle(), o2.getTitle()); return StringHelper.compareTo(String.valueOf(o1.getId()), String.valueOf(o2.getId()));
private void drawLabel(final GanttTask node, final Document doc, final Element labels) { int indent = 0; GanttTask n = node; while (true) { n = rootNode.findParent(n.getId()); if (n == rootNode || n == null) { break; } if (n.isVisible() == true) { ++indent; } } final ObjectInfo taskInfo = getObjectInfo(node); if (StringUtils.isNotBlank(node.getWorkpackageCode()) == true && style.getWorkPackageLabelWidth() > 0) { labels.appendChild(SVGHelper.createText(doc, 0 + indent * 5, taskInfo.y, node.getWorkpackageCode())); } if (StringUtils.isNotBlank(node.getTitle()) == true) { labels.appendChild(SVGHelper.createText(doc, style.getWorkPackageLabelWidth() + indent * 10, taskInfo.y, node.getTitle())); } }
private void assertDurationAndProgress(final GanttTask root, final Integer id, final BigDecimal expectedDuration, final Integer expectedProgress) { final GanttTask task = root.findById(id); assertTrue(NumberHelper.isEqual(expectedDuration, task.getDuration())); if (expectedProgress == null) { assertNull(task.getProgress()); } else { assertEquals(expectedProgress, task.getProgress()); } }
private void assertExternalTasks(final GanttChartData ganttChartData, final String prefix) { GanttTask externalGanttTask = ganttChartData.getExternalObject(getTaskId(prefix + "2.1")); assertNull("Predecessor should be null.", externalGanttTask.getPredecessor()); assertDate("Start date unmodified.", 2010, Calendar.AUGUST, 16, externalGanttTask.getStartDate()); assertDate("End date should have been calculated and set.", 2010, Calendar.AUGUST, 30, externalGanttTask.getEndDate()); externalGanttTask = ganttChartData.getExternalObject(getTaskId(prefix + "2.2")); assertNull("Predecessor should be null.", externalGanttTask.getPredecessor()); assertDate("Start date should have been calculated and set.", 2010, Calendar.AUGUST, 30, externalGanttTask.getStartDate()); assertDate("End date should have been calculated and set.", 2010, Calendar.SEPTEMBER, 13, externalGanttTask.getEndDate()); }
.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}'>" // ganttChartDao.writeGanttObjects(ganttChartDO, data.getRootObject()); assertEquals("Gantt objects as xml.", xml, ganttChartDO.getGanttObjectsAsXml()); assertNull("Predecessor was set to null.", findById(data, prefix, "1.2.2").getPredecessor()); assertEquals("External predecessor expected.", prefix + "2.3", findById(data, prefix, "1.2").getPredecessor().getTitle());
@Override public boolean match(GanttTask object, Object expression) { return (StringUtils.equals(object.getTitle(), (String) expression) == true); } }, title);
private void drawDependency(final GanttTask node, final GanttObjectType objectType, final Document doc, final Element diagram) if (node.getPredecessor() != null) { final double dist; if (objectType == GanttObjectType.MILESTONE) { dist = 1; final ObjectInfo depObjectInfo = getObjectInfo(node.getPredecessor()); if (depObjectInfo.isVisible() == true) { final GanttRelationType type = node.getRelationType() != null ? node.getRelationType() : GanttRelationType.FINISH_START; final double depX1; final double depX2;
final GanttTask predecessor = ganttObject.getPredecessor(); final TaskDO predecessorTask = predecessor != null ? taskDao.getTaskTree().getTaskById((Integer) predecessor.getId()) : null; final Label asStringLabel = new Label("asString", new Model<String>() final String taskSelectProperty = "predecessorId:" + ganttObject.getId(); final IconLinkPanel selectSubmitLink = new IconLinkPanel("select", IconType.TASK, new SubmitLink(IconLinkPanel.LINK_ID)