Java Code Examples for net.sf.mpxj.Task#getActualFinish()
The following examples show how to use
net.sf.mpxj.Task#getActualFinish() .
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: PrimaveraPMFileWriter.java From mpxj with GNU Lesser General Public License v2.1 | 6 votes |
/** * Retrieve an activity status. * * @param mpxj MPXJ Task instance * @return activity status */ private String getActivityStatus(Task mpxj) { String result; if (mpxj.getActualStart() == null) { result = "Not Started"; } else { if (mpxj.getActualFinish() == null) { result = "In Progress"; } else { result = "Completed"; } } return result; }
Example 2
Source File: AstaReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Populate summary task dates. * * @param parentTask summary task */ private void updateDates(Task parentTask) { if (parentTask.hasChildTasks()) { int finished = 0; 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); 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.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 3
Source File: PhoenixReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Create a Task instance from a Phoenix activity. * * @param activity Phoenix activity data */ private void processActivity(Activity activity) { Task task = getParentTask(activity).addTask(); task.setText(1, activity.getId()); task.setActualDuration(activity.getActualDuration()); task.setActualFinish(activity.getActualFinish()); task.setActualStart(activity.getActualStart()); //activity.getBaseunit() //activity.getBilled() //activity.getCalendar() //activity.getCostAccount() task.setCreateDate(activity.getCreationTime()); task.setFinish(activity.getCurrentFinish()); task.setStart(activity.getCurrentStart()); task.setName(activity.getDescription()); task.setDuration(activity.getDurationAtCompletion()); task.setEarlyFinish(activity.getEarlyFinish()); task.setEarlyStart(activity.getEarlyStart()); task.setFreeSlack(activity.getFreeFloat()); task.setLateFinish(activity.getLateFinish()); task.setLateStart(activity.getLateStart()); task.setNotes(activity.getNotes()); task.setBaselineDuration(activity.getOriginalDuration()); //activity.getPathFloat() task.setPhysicalPercentComplete(activity.getPhysicalPercentComplete()); task.setRemainingDuration(activity.getRemainingDuration()); task.setCost(activity.getTotalCost()); task.setTotalSlack(activity.getTotalFloat()); task.setMilestone(activityIsMilestone(activity)); //activity.getUserDefined() task.setGUID(activity.getUuid()); if (task.getMilestone()) { if (activityIsStartMilestone(activity)) { task.setFinish(task.getStart()); } else { task.setStart(task.getFinish()); } } if (task.getDuration().getDuration() == 0) { // Phoenix normally represents the finish date as the start of the // day following the end of the activity. For example a 2 day activity // starting on day 1 would be shown in the PPX file as having a finish // date of day 3. We subtract one day to make the dates consistent with // all other schedule formats MPXJ handles. Occasionally for zero // duration tasks (which aren't tagged as milestones) the finish date // will be the same as the start date, so applying our "subtract 1" fix // gives us a finish date before the start date. The code below // deals with this situation. if (DateHelper.compare(task.getStart(), task.getFinish()) > 0) { task.setFinish(task.getStart()); } if (task.getActualStart() != null && task.getActualFinish() != null && DateHelper.compare(task.getActualStart(), task.getActualFinish()) > 0) { task.setActualFinish(task.getActualStart()); } } if (task.getActualStart() == null) { task.setPercentageComplete(Integer.valueOf(0)); } else { if (task.getActualFinish() != null) { task.setPercentageComplete(Integer.valueOf(100)); } else { Duration remaining = activity.getRemainingDuration(); Duration total = activity.getDurationAtCompletion(); if (remaining != null && total != null && total.getDuration() != 0) { double percentComplete = ((total.getDuration() - remaining.getDuration()) * 100.0) / total.getDuration(); task.setPercentageComplete(Double.valueOf(percentComplete)); } } } m_activityMap.put(activity.getId(), task); }
Example 4
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 5
Source File: ProgressRecord.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void process(Context context) { Double totalCost = getDouble(4); Double costToDate = getDouble(5); Double remainingCost = Double.valueOf(NumberHelper.getDouble(totalCost) - NumberHelper.getDouble(costToDate)); Duration totalFloat = getDuration(12); if ("-".equals(getString(11))) { totalFloat = Duration.getInstance(-totalFloat.getDuration(), TimeUnit.DAYS); } Task task = context.getTask(getString(0)); task.setActualStart(getDate(1)); task.setActualFinish(getDate(2)); task.setRemainingDuration(getDuration(3)); task.setCost(getDouble(4)); task.setRemainingCost(remainingCost); task.setCost(1, getDouble(6)); task.setEarlyStart(getDate(7)); task.setEarlyFinish(getDate(8)); task.setLateStart(getDate(9)); task.setLateFinish(getDate(10)); task.setTotalSlack(totalFloat); Date start = task.getActualStart() == null ? task.getEarlyStart() : task.getActualStart(); Date finish = task.getActualFinish() == null ? task.getEarlyFinish() : task.getActualFinish(); double percentComplete = 0; if (task.getActualFinish() == null) { Duration duration = task.getDuration(); Duration remainingDuration = task.getRemainingDuration(); if (duration != null && remainingDuration != null) { double durationValue = duration.getDuration(); double remainingDurationValue = remainingDuration.getDuration(); if (durationValue != 0 && remainingDurationValue < durationValue) { percentComplete = ((durationValue - remainingDurationValue) * 100.0) / durationValue; } } } else { percentComplete = 100.0; } task.setStart(start); task.setFinish(finish); task.setPercentageComplete(Double.valueOf(percentComplete)); }
Example 6
Source File: SDEFWriter.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Writes a progress line to the SDEF file. * * Progress lines in SDEF are a little tricky, you need to assume a percent complete * this could be physical or temporal, I don't know what you're using??? * So in this version of SDEFwriter, I just put in 0.00 for cost progress to date, see *** below * * @param record Task instance */ private void writePROG(Task record) { m_buffer.setLength(0); // // Write the progress record // if (!record.getSummary()) { // I don't use summary tasks for SDEF m_buffer.append("PROG "); m_buffer.append(SDEFmethods.rset(record.getUniqueID().toString(), 10) + " "); Date temp = record.getActualStart(); if (temp == null) { m_buffer.append(" "); // SDEf is column sensitive, so the number of blanks here is crucial } else { m_buffer.append(m_formatter.format(record.getActualStart()).toUpperCase() + " "); // ACTUAL START DATE } temp = record.getActualFinish(); if (temp == null) { m_buffer.append(" "); } else { m_buffer.append(m_formatter.format(record.getActualFinish()).toUpperCase() + " "); // ACTUAL FINISH DATE } Duration dd = record.getRemainingDuration(); double duration = dd.getDuration(); if (dd.getUnits() != TimeUnit.DAYS) { dd = Duration.convertUnits(duration, dd.getUnits(), TimeUnit.DAYS, m_minutesPerDay, m_minutesPerWeek, m_daysPerMonth); } Double days = Double.valueOf(dd.getDuration() + 0.5); // Add 0.5 so half day rounds up upon truncation Integer est = Integer.valueOf(days.intValue()); m_buffer.append(SDEFmethods.rset(est.toString(), 3) + " "); // task duration in days required by USACE DecimalFormat twoDec = new DecimalFormat("#0.00"); // USACE required currency format m_buffer.append(SDEFmethods.rset(twoDec.format(record.getCost().floatValue()), 12) + " "); m_buffer.append(SDEFmethods.rset(twoDec.format(0.00), 12) + " "); // *** assume zero progress on cost m_buffer.append(SDEFmethods.rset(twoDec.format(0.00), 12) + " "); // *** assume zero progress on cost m_buffer.append(m_formatter.format(record.getEarlyStart()).toUpperCase() + " "); m_buffer.append(m_formatter.format(record.getEarlyFinish()).toUpperCase() + " "); m_buffer.append(m_formatter.format(record.getLateStart()).toUpperCase() + " "); m_buffer.append(m_formatter.format(record.getLateFinish()).toUpperCase() + " "); dd = record.getTotalSlack(); duration = dd.getDuration(); if (dd.getUnits() != TimeUnit.DAYS) { dd = Duration.convertUnits(duration, dd.getUnits(), TimeUnit.DAYS, m_minutesPerDay, m_minutesPerWeek, m_daysPerMonth); } days = Double.valueOf(dd.getDuration() + 0.5); // Add 0.5 so half day rounds up upon truncation est = Integer.valueOf(days.intValue()); char slack; if (est.intValue() >= 0) { slack = '+'; // USACE likes positive slack, so they separate the sign from the value } else { slack = '-'; // only write a negative when it's negative, i.e. can't be done in project management terms!!! } m_buffer.append(slack + " "); est = Integer.valueOf(Math.abs(days.intValue())); m_buffer.append(SDEFmethods.rset(est.toString(), 4)); // task duration in days required by USACE m_writer.println(m_buffer.toString()); m_eventManager.fireTaskWrittenEvent(record); } }
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); } } }