Java Code Examples for net.sf.mpxj.Task#getBaselineDuration()
The following examples show how to use
net.sf.mpxj.Task#getBaselineDuration() .
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: TaskBaselinesTest.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Test baseline durations. * * @param project project * @param startTaskID initial task ID * @param maxBaselines maximum baselines to test * @return task ID for next tests */ private int testDurations(ProjectFile project, int startTaskID, int maxBaselines) { int taskID = startTaskID; for (int index = 0; index < maxBaselines; index++) { Task task = project.getTaskByID(Integer.valueOf(taskID)); taskID++; Duration value; if (index == 0) { value = task.getBaselineDuration(); } else { value = task.getBaselineDuration(index); } assertEquals("Baseline" + index, DURATIONS[index], value.toString()); } return taskID; }
Example 2
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 3
Source File: MSPDIWriter.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Writes task baseline data. * * @param xmlTask MSPDI task * @param mpxjTask MPXJ task */ private void writeTaskBaselines(Project.Tasks.Task xmlTask, Task mpxjTask) { Project.Tasks.Task.Baseline baseline = m_factory.createProjectTasksTaskBaseline(); boolean populated = false; Number cost = mpxjTask.getBaselineCost(); if (cost != null && cost.intValue() != 0) { populated = true; baseline.setCost(DatatypeConverter.printCurrency(cost)); } Duration duration = mpxjTask.getBaselineDuration(); if (duration != null && duration.getDuration() != 0) { populated = true; baseline.setDuration(DatatypeConverter.printDuration(this, duration)); baseline.setDurationFormat(DatatypeConverter.printDurationTimeUnits(duration, false)); } Date date = mpxjTask.getBaselineFinish(); if (date != null) { populated = true; baseline.setFinish(date); } date = mpxjTask.getBaselineStart(); if (date != null) { populated = true; baseline.setStart(date); } duration = mpxjTask.getBaselineWork(); if (duration != null && duration.getDuration() != 0) { populated = true; baseline.setWork(DatatypeConverter.printDuration(this, duration)); } if (populated) { baseline.setNumber(BigInteger.ZERO); xmlTask.getBaseline().add(baseline); } for (int loop = 1; loop <= 10; loop++) { baseline = m_factory.createProjectTasksTaskBaseline(); populated = false; cost = mpxjTask.getBaselineCost(loop); if (cost != null && cost.intValue() != 0) { populated = true; baseline.setCost(DatatypeConverter.printCurrency(cost)); } duration = mpxjTask.getBaselineDuration(loop); if (duration != null && duration.getDuration() != 0) { populated = true; baseline.setDuration(DatatypeConverter.printDuration(this, duration)); baseline.setDurationFormat(DatatypeConverter.printDurationTimeUnits(duration, false)); } date = mpxjTask.getBaselineFinish(loop); if (date != null) { populated = true; baseline.setFinish(date); } date = mpxjTask.getBaselineStart(loop); if (date != null) { populated = true; baseline.setStart(date); } duration = mpxjTask.getBaselineWork(loop); if (duration != null && duration.getDuration() != 0) { populated = true; baseline.setWork(DatatypeConverter.printDuration(this, duration)); } if (populated) { baseline.setNumber(BigInteger.valueOf(loop)); xmlTask.getBaseline().add(baseline); } } }