Java Code Examples for net.sf.mpxj.Task#setBaselineDuration()

The following examples show how to use net.sf.mpxj.Task#setBaselineDuration() . 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: MPD9AbstractReader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Read task baseline values.
 *
 * @param row result set row
 */
protected void processTaskBaseline(Row row)
{
   Integer id = row.getInteger("TASK_UID");
   Task task = m_project.getTaskByUniqueID(id);
   if (task != null)
   {
      int index = row.getInt("TB_BASE_NUM");

      task.setBaselineDuration(index, MPDUtility.getAdjustedDuration(m_project, row.getInt("TB_BASE_DUR"), MPDUtility.getDurationTimeUnits(row.getInt("TB_BASE_DUR_FMT"))));
      task.setBaselineStart(index, row.getDate("TB_BASE_START"));
      task.setBaselineFinish(index, row.getDate("TB_BASE_FINISH"));
      task.setBaselineWork(index, row.getDuration("TB_BASE_WORK"));
      task.setBaselineCost(index, row.getCurrency("TB_BASE_COST"));
   }
}
 
Example 2
Source File: MSPDIReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Reads baseline values for the current task.
 *
 * @param xmlTask MSPDI task instance
 * @param mpxjTask MPXJ task instance
 * @param durationFormat duration format to use
 */
private void readTaskBaselines(Project.Tasks.Task xmlTask, Task mpxjTask, TimeUnit durationFormat)
{
   for (Project.Tasks.Task.Baseline baseline : xmlTask.getBaseline())
   {
      int number = NumberHelper.getInt(baseline.getNumber());

      Double cost = DatatypeConverter.parseCurrency(baseline.getCost());
      Duration duration = DatatypeConverter.parseDuration(m_projectFile, durationFormat, baseline.getDuration());
      Date finish = baseline.getFinish();
      Date start = baseline.getStart();
      Duration work = DatatypeConverter.parseDuration(m_projectFile, TimeUnit.HOURS, baseline.getWork());

      if (number == 0)
      {
         mpxjTask.setBaselineCost(cost);
         mpxjTask.setBaselineDuration(duration);
         mpxjTask.setBaselineFinish(finish);
         mpxjTask.setBaselineStart(start);
         mpxjTask.setBaselineWork(work);
      }
      else
      {
         mpxjTask.setBaselineCost(number, cost);
         mpxjTask.setBaselineDuration(number, duration);
         mpxjTask.setBaselineFinish(number, finish);
         mpxjTask.setBaselineStart(number, start);
         mpxjTask.setBaselineWork(number, work);
      }
   }
}
 
Example 3
Source File: SageReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Process an individual task.
 *
 * @param line task record
 */
private void processTask(String line)
{
   String[] columns = line.split("\t");
   Task task = m_projectFile.addTask();

   task.setText(1, parseID(columns, 0));
   task.setName(getText(columns, 1));
   task.setDuration(parseDuration(columns, 2));
   // columns[3] task type, 1 - Work, 2 - Inspection, 3 - Bill, 4 - Milestone, 5 - Order Material, 6 - Owner Decision, 7 - Meeting, 8 - Subcontract
   setConstraint(task, ConstraintType.MUST_START_ON, columns, 4);
   setConstraint(task, ConstraintType.START_NO_EARLIER_THAN, columns, 5);
   setConstraint(task, ConstraintType.FINISH_NO_LATER_THAN, columns, 6);
   task.setStart(parseDate(columns, 7));
   task.setFinish(parseDate(columns, 8));
   task.setLateStart(parseDate(columns, 9));
   task.setLateFinish(parseDate(columns, 10));
   task.setTotalSlack(parseDuration(columns, 11));
   task.setBaselineDuration(parseDuration(columns, 12));
   task.setBaselineStart(parseDate(columns, 13));
   task.setBaselineFinish(parseDate(columns, 14));
   // columns[15] original float
   task.setText(2, getText(columns, 16));
   task.setNotes(getText(columns, 17));

   m_taskMap.put(task.getText(1), task);
   m_eventManager.fireTaskReadEvent(task);
}
 
Example 4
Source File: ConceptDrawProjectReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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 5
Source File: PhoenixReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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);
}