Java Code Examples for net.sf.mpxj.Task#setCost()
The following examples show how to use
net.sf.mpxj.Task#setCost() .
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: GanttDesignerReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * Read task data from a Gantt Designer file. * * @param gantt Gantt Designer file */ private void processTasks(Gantt gantt) { ProjectCalendar calendar = m_projectFile.getDefaultCalendar(); for (Gantt.Tasks.Task ganttTask : gantt.getTasks().getTask()) { String wbs = ganttTask.getID(); ChildTaskContainer parentTask = getParentTask(wbs); Task task = parentTask.addTask(); //ganttTask.getB() // bar type //ganttTask.getBC() // bar color task.setCost(ganttTask.getC()); task.setName(ganttTask.getContent()); task.setDuration(ganttTask.getD()); task.setDeadline(ganttTask.getDL()); //ganttTask.getH() // height //ganttTask.getIn(); // indent task.setWBS(wbs); task.setPercentageComplete(ganttTask.getPC()); task.setStart(ganttTask.getS()); //ganttTask.getU(); // Unknown //ganttTask.getVA(); // Valign task.setFinish(calendar.getDate(task.getStart(), task.getDuration(), false)); m_taskMap.put(wbs, task); } }
Example 2
Source File: PrimaveraReader.java From mpxj with GNU Lesser General Public License v2.1 | 5 votes |
/** * See the notes above. * * @param parentTask parent task */ private void updateTaskCosts(Task parentTask) { double baselineCost = 0; double actualCost = 0; double remainingCost = 0; double cost = 0; //process children first before adding their costs for (Task child : parentTask.getChildTasks()) { updateTaskCosts(child); baselineCost += NumberHelper.getDouble(child.getBaselineCost()); actualCost += NumberHelper.getDouble(child.getActualCost()); remainingCost += NumberHelper.getDouble(child.getRemainingCost()); cost += NumberHelper.getDouble(child.getCost()); } List<ResourceAssignment> resourceAssignments = parentTask.getResourceAssignments(); for (ResourceAssignment assignment : resourceAssignments) { baselineCost += NumberHelper.getDouble(assignment.getBaselineCost()); actualCost += NumberHelper.getDouble(assignment.getActualCost()); remainingCost += NumberHelper.getDouble(assignment.getRemainingCost()); cost += NumberHelper.getDouble(assignment.getCost()); } parentTask.setBaselineCost(NumberHelper.getDouble(baselineCost)); parentTask.setActualCost(NumberHelper.getDouble(actualCost)); parentTask.setRemainingCost(NumberHelper.getDouble(remainingCost)); parentTask.setCost(NumberHelper.getDouble(cost)); }
Example 3
Source File: ConceptDrawProjectReader.java From mpxj with GNU Lesser General Public License v2.1 | 4 votes |
/** * Read a task from a ConceptDraw PROJECT file. * * @param projectIdentifier parent project identifier * @param map outline number to task map * @param task ConceptDraw PROJECT task */ private void readTask(String projectIdentifier, Map<String, Task> map, Document.Projects.Project.Task task) { Task parentTask = map.get(getParentOutlineNumber(task.getOutlineNumber())); Task mpxjTask = parentTask.addTask(); TimeUnit units = task.getBaseDurationTimeUnit(); mpxjTask.setCost(task.getActualCost()); mpxjTask.setDuration(getDuration(units, task.getActualDuration())); mpxjTask.setFinish(task.getActualFinishDate()); mpxjTask.setStart(task.getActualStartDate()); mpxjTask.setBaselineDuration(getDuration(units, task.getBaseDuration())); mpxjTask.setBaselineFinish(task.getBaseFinishDate()); mpxjTask.setBaselineCost(task.getBaselineCost()); // task.getBaselineFinishDate() // task.getBaselineFinishTemplateOffset() // task.getBaselineStartDate() // task.getBaselineStartTemplateOffset() mpxjTask.setBaselineStart(task.getBaseStartDate()); // task.getCallouts() mpxjTask.setPercentageComplete(task.getComplete()); mpxjTask.setDeadline(task.getDeadlineDate()); // task.getDeadlineTemplateOffset() // task.getHyperlinks() // task.getMarkerID() mpxjTask.setName(task.getName()); mpxjTask.setNotes(task.getNote()); mpxjTask.setPriority(task.getPriority()); // task.getRecalcBase1() // task.getRecalcBase2() mpxjTask.setType(task.getSchedulingType()); // task.getStyleProject() // task.getTemplateOffset() // task.getValidatedByProject() if (task.isIsMilestone()) { mpxjTask.setMilestone(true); mpxjTask.setDuration(Duration.getInstance(0, TimeUnit.HOURS)); mpxjTask.setBaselineDuration(Duration.getInstance(0, TimeUnit.HOURS)); } String taskIdentifier = projectIdentifier + "." + task.getID(); m_taskIdMap.put(task.getID(), mpxjTask); mpxjTask.setGUID(UUID.nameUUIDFromBytes(taskIdentifier.getBytes())); map.put(task.getOutlineNumber(), mpxjTask); for (Document.Projects.Project.Task.ResourceAssignments.ResourceAssignment assignment : task.getResourceAssignments().getResourceAssignment()) { readResourceAssignment(mpxjTask, assignment); } }
Example 4
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 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)); }