Java Code Examples for net.sf.mpxj.Task#getFinish()
The following examples show how to use
net.sf.mpxj.Task#getFinish() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MSPDIReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * When projectmanager.com exports schedules as MSPDI (via Aspose tasks) * they do not have finish dates, just a start date and a duration. * This method populates finish dates. * * @param task task to validate */ private void validateFinishDate(Task task) { if (task.getFinish() == null) { Date startDate = task.getStart(); if (startDate != null) { if (task.getMilestone()) { task.setFinish(startDate); } else { Duration duration = task.getDuration(); if (duration != null) { ProjectCalendar calendar = task.getEffectiveCalendar(); task.setFinish(calendar.getDate(startDate, duration, false)); } } } } }
Example 2
Source File: ProjectCommanderReader.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Propagate start and end dates to summary tasks. * * @param parentTask parent task */ private void updateDates(Task parentTask) { if (parentTask.hasChildTasks()) { Date plannedStartDate = parentTask.getStart(); Date plannedFinishDate = parentTask.getFinish(); for (Task task : parentTask.getChildTasks()) { updateDates(task); plannedStartDate = DateHelper.min(plannedStartDate, task.getStart()); plannedFinishDate = DateHelper.max(plannedFinishDate, task.getFinish()); } parentTask.setStart(plannedStartDate); parentTask.setFinish(plannedFinishDate); } }
Example 3
Source File: ProjectFileImporter.java From ganttproject with GNU General Public License v3.0 | 5 votes |
private Function<Task, Pair<TimeDuration, TimeDuration>> findDurationFunction(Task t, StringBuilder reportBuilder) { if (t.getStart() != null && t.getFinish() != null) { return DURATION_FROM_START_FINISH; } reportBuilder.append("start+finish not found"); if (t.getStart() != null && t.getDuration() != null) { return DURATION_FROM_START_AND_DURATION; } reportBuilder.append(", start+duration not found"); return null; }
Example 4
Source File: MpxjQuery.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * This method lists all tasks defined in the file. * * @param file MPX file */ private static void listTasks(ProjectFile file) { SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm z"); for (Task task : file.getTasks()) { Date date = task.getStart(); String text = task.getStartText(); String startDate = text != null ? text : (date != null ? df.format(date) : "(no start date supplied)"); date = task.getFinish(); text = task.getFinishText(); String finishDate = text != null ? text : (date != null ? df.format(date) : "(no finish date supplied)"); Duration dur = task.getDuration(); text = task.getDurationText(); String duration = text != null ? text : (dur != null ? dur.toString() : "(no duration supplied)"); dur = task.getActualDuration(); String actualDuration = dur != null ? dur.toString() : "(no actual duration supplied)"; String baselineDuration = task.getBaselineDurationText(); if (baselineDuration == null) { dur = task.getBaselineDuration(); if (dur != null) { baselineDuration = dur.toString(); } else { baselineDuration = "(no duration supplied)"; } } System.out.println("Task: " + task.getName() + " ID=" + task.getID() + " Unique ID=" + task.getUniqueID() + " (Start Date=" + startDate + " Finish Date=" + finishDate + " Duration=" + duration + " Actual Duration" + actualDuration + " Baseline Duration=" + baselineDuration + " Outline Level=" + task.getOutlineLevel() + " Outline Number=" + task.getOutlineNumber() + " Recurring=" + task.getRecurring() + ")"); } System.out.println(); }
Example 5
Source File: TaskFinishesTest.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Test the finish date values for a task. * * @param file parent file * @param task task * @param testIndex index of number being tested * @param maxIndex highest index to test * @param useDateFormat true=use date-only format false=use date time format */ private void testTaskFinishDates(File file, Task task, int testIndex, int maxIndex, boolean useDateFormat) throws ParseException { DateFormat format = useDateFormat ? m_dateFormat : m_dateTimeFormat; for (int index = 1; index <= maxIndex; index++) { Date expectedValue = testIndex == index ? format.parse(DATES[index - 1]) : null; Date actualValue = task.getFinish(index); assertEquals(file.getName() + " Finish" + index, expectedValue, actualValue); } }
Example 6
Source File: PhoenixReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * See the notes above. * * @param parentTask parent task. */ private void updateDates(Task parentTask) { if (parentTask.hasChildTasks()) { int finished = 0; Date plannedStartDate = parentTask.getStart(); Date plannedFinishDate = parentTask.getFinish(); Date actualStartDate = parentTask.getActualStart(); Date actualFinishDate = parentTask.getActualFinish(); Date earlyStartDate = parentTask.getEarlyStart(); Date earlyFinishDate = parentTask.getEarlyFinish(); Date lateStartDate = parentTask.getLateStart(); Date lateFinishDate = parentTask.getLateFinish(); for (Task task : parentTask.getChildTasks()) { updateDates(task); plannedStartDate = DateHelper.min(plannedStartDate, task.getStart()); plannedFinishDate = DateHelper.max(plannedFinishDate, task.getFinish()); actualStartDate = DateHelper.min(actualStartDate, task.getActualStart()); actualFinishDate = DateHelper.max(actualFinishDate, task.getActualFinish()); earlyStartDate = DateHelper.min(earlyStartDate, task.getEarlyStart()); earlyFinishDate = DateHelper.max(earlyFinishDate, task.getEarlyFinish()); lateStartDate = DateHelper.min(lateStartDate, task.getLateStart()); lateFinishDate = DateHelper.max(lateFinishDate, task.getLateFinish()); if (task.getActualFinish() != null) { ++finished; } } parentTask.setStart(plannedStartDate); parentTask.setFinish(plannedFinishDate); parentTask.setActualStart(actualStartDate); parentTask.setEarlyStart(earlyStartDate); parentTask.setEarlyFinish(earlyFinishDate); parentTask.setLateStart(lateStartDate); parentTask.setLateFinish(lateFinishDate); // // Only if all child tasks have actual finish dates do we // set the actual finish date on the parent task. // if (finished == parentTask.getChildTasks().size()) { parentTask.setActualFinish(actualFinishDate); } Duration duration = null; if (plannedStartDate != null && plannedFinishDate != null) { duration = m_projectFile.getDefaultCalendar().getWork(plannedStartDate, plannedFinishDate, TimeUnit.DAYS); parentTask.setDuration(duration); } } }
Example 7
Source File: SureTrakDatabaseReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * See the notes above. * * @param parentTask parent task. */ private void updateDates(Task parentTask) { if (parentTask.hasChildTasks()) { int finished = 0; Date startDate = parentTask.getStart(); Date finishDate = parentTask.getFinish(); Date actualStartDate = parentTask.getActualStart(); Date actualFinishDate = parentTask.getActualFinish(); Date earlyStartDate = parentTask.getEarlyStart(); Date earlyFinishDate = parentTask.getEarlyFinish(); Date lateStartDate = parentTask.getLateStart(); Date lateFinishDate = parentTask.getLateFinish(); for (Task task : parentTask.getChildTasks()) { updateDates(task); startDate = DateHelper.min(startDate, task.getStart()); finishDate = DateHelper.max(finishDate, task.getFinish()); actualStartDate = DateHelper.min(actualStartDate, task.getActualStart()); actualFinishDate = DateHelper.max(actualFinishDate, task.getActualFinish()); earlyStartDate = DateHelper.min(earlyStartDate, task.getEarlyStart()); earlyFinishDate = DateHelper.max(earlyFinishDate, task.getEarlyFinish()); lateStartDate = DateHelper.min(lateStartDate, task.getLateStart()); lateFinishDate = DateHelper.max(lateFinishDate, task.getLateFinish()); if (task.getActualFinish() != null) { ++finished; } } parentTask.setStart(startDate); parentTask.setFinish(finishDate); parentTask.setActualStart(actualStartDate); parentTask.setEarlyStart(earlyStartDate); parentTask.setEarlyFinish(earlyFinishDate); parentTask.setLateStart(lateStartDate); parentTask.setLateFinish(lateFinishDate); // // Only if all child tasks have actual finish dates do we // set the actual finish date on the parent task. // if (finished == parentTask.getChildTasks().size()) { parentTask.setActualFinish(actualFinishDate); } } }
Example 8
Source File: P3DatabaseReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * See the notes above. * * @param parentTask parent task. */ private void updateDates(Task parentTask) { if (parentTask.hasChildTasks()) { int finished = 0; Date startDate = parentTask.getStart(); Date finishDate = parentTask.getFinish(); Date actualStartDate = parentTask.getActualStart(); Date actualFinishDate = parentTask.getActualFinish(); Date earlyStartDate = parentTask.getEarlyStart(); Date earlyFinishDate = parentTask.getEarlyFinish(); Date lateStartDate = parentTask.getLateStart(); Date lateFinishDate = parentTask.getLateFinish(); for (Task task : parentTask.getChildTasks()) { updateDates(task); startDate = DateHelper.min(startDate, task.getStart()); finishDate = DateHelper.max(finishDate, task.getFinish()); actualStartDate = DateHelper.min(actualStartDate, task.getActualStart()); actualFinishDate = DateHelper.max(actualFinishDate, task.getActualFinish()); earlyStartDate = DateHelper.min(earlyStartDate, task.getEarlyStart()); earlyFinishDate = DateHelper.max(earlyFinishDate, task.getEarlyFinish()); lateStartDate = DateHelper.min(lateStartDate, task.getLateStart()); lateFinishDate = DateHelper.max(lateFinishDate, task.getLateFinish()); if (task.getActualFinish() != null) { ++finished; } } parentTask.setStart(startDate); parentTask.setFinish(finishDate); parentTask.setActualStart(actualStartDate); parentTask.setEarlyStart(earlyStartDate); parentTask.setEarlyFinish(earlyFinishDate); parentTask.setLateStart(lateStartDate); parentTask.setLateFinish(lateFinishDate); // // Only if all child tasks have actual finish dates do we // set the actual finish date on the parent task. // if (finished == parentTask.getChildTasks().size()) { parentTask.setActualFinish(actualFinishDate); } } }
Example 9
Source File: SynchroReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Extract data for a single task. * * @param parent task parent * @param row Synchro task data */ private void processTask(ChildTaskContainer parent, MapRow row) throws IOException { Task task = parent.addTask(); task.setName(row.getString("NAME")); task.setGUID(row.getUUID("UUID")); task.setText(1, row.getString("ID")); task.setDuration(row.getDuration("PLANNED_DURATION")); task.setRemainingDuration(row.getDuration("REMAINING_DURATION")); task.setHyperlink(row.getString("URL")); task.setPercentageComplete(row.getDouble("PERCENT_COMPLETE")); task.setNotes(getNotes(row.getRows("COMMENTARY"))); task.setMilestone(task.getDuration() != null && task.getDuration().getDuration() == 0); ProjectCalendar calendar = m_calendarMap.get(row.getUUID("CALENDAR_UUID")); if (calendar != m_project.getDefaultCalendar()) { task.setCalendar(calendar); } switch (row.getInteger("STATUS").intValue()) { case 1: // Planned { task.setStart(row.getDate("PLANNED_START")); if (task.getStart() != null && task.getDuration() != null) { task.setFinish(task.getEffectiveCalendar().getDate(task.getStart(), task.getDuration(), false)); } break; } case 2: // Started { task.setActualStart(row.getDate("ACTUAL_START")); task.setStart(task.getActualStart()); task.setFinish(row.getDate("ESTIMATED_FINISH")); if (task.getFinish() == null) { task.setFinish(row.getDate("PLANNED_FINISH")); } break; } case 3: // Finished { task.setActualStart(row.getDate("ACTUAL_START")); task.setActualFinish(row.getDate("ACTUAL_FINISH")); task.setPercentageComplete(Double.valueOf(100.0)); task.setStart(task.getActualStart()); task.setFinish(task.getActualFinish()); break; } } setConstraints(task, row); processChildTasks(task, row); m_taskMap.put(task.getGUID(), task); List<MapRow> predecessors = row.getRows("PREDECESSORS"); if (predecessors != null && !predecessors.isEmpty()) { m_predecessorMap.put(task, predecessors); } List<MapRow> resourceAssignmnets = row.getRows("RESOURCE_ASSIGNMENTS"); if (resourceAssignmnets != null && !resourceAssignmnets.isEmpty()) { processResourceAssignments(task, resourceAssignmnets); } }