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

The following examples show how to use net.sf.mpxj.Task#setStart() . 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: SynchroReader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Recursively update parent task dates.
 *
 * @param parentTask parent task
 */
private void updateDates(Task parentTask)
{
   if (parentTask.hasChildTasks())
   {
      Date plannedStartDate = null;
      Date plannedFinishDate = null;

      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 2
Source File: ProjectCommanderReader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * 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: GanttDesignerReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * 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 4
Source File: ExportMSProject.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private static void addTask(final ProjectFile file, final Map<Serializable, Task> taskMap, final Task parentTask,
    final GanttTask ganttTask)
{
  final Task task;
  if (parentTask == null) {
    task = file.addTask();
  } else {
    task = parentTask.addTask();
  }
  taskMap.put(ganttTask.getId(), task);
  task.setName(ganttTask.getTitle());
  if (ganttTask.getStartDate() != null) {
    task.setStart(ganttTask.getStartDate());
  }
  if (ganttTask.getEndDate() != null) {
    task.setFinish(ganttTask.getEndDate());
  }
  final BigDecimal duration = ganttTask.getDuration();
  final double value;
  if (duration == null) {
    value = 0.0;
  } else {
    value = duration.doubleValue();
  }
  task.setDuration(Duration.getInstance(value, TimeUnit.DAYS));
  if (ganttTask.getProgress() != null) {
    task.setPercentageComplete(ganttTask.getProgress());
  }
  // task2.setActualStart(df.parse("01/01/2003"));
  // milestone1.setDuration(Duration.getInstance(0, TimeUnit.DAYS));

  final List<GanttTask> children = ganttTask.getChildren();
  if (children == null) {
    return;
  }
  for (final GanttTask child : children) {
    addTask(file, taskMap, task, child);
  }
}
 
Example 5
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 6
Source File: TurboProjectReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Read data for an individual task from the tables in a PEP file.
 *
 * @param parent parent task
 * @param id task ID
 * @return task instance
 */
private Task readTask(ChildTaskContainer parent, Integer id)
{
   Table a0 = getTable("A0TAB");
   Table a1 = getTable("A1TAB");
   Table a2 = getTable("A2TAB");
   Table a3 = getTable("A3TAB");
   Table a4 = getTable("A4TAB");

   Task task = parent.addTask();
   MapRow a1Row = a1.find(id);
   MapRow a2Row = a2.find(id);

   setFields(A0TAB_FIELDS, a0.find(id), task);
   setFields(A1TAB_FIELDS, a1Row, task);
   setFields(A2TAB_FIELDS, a2Row, task);
   setFields(A3TAB_FIELDS, a3.find(id), task);
   setFields(A5TAB_FIELDS, a4.find(id), task);

   task.setStart(task.getEarlyStart());
   task.setFinish(task.getEarlyFinish());
   if (task.getName() == null)
   {
      task.setName(task.getText(1));
   }

   m_eventManager.fireTaskReadEvent(task);

   return task;
}
 
Example 7
Source File: AstaReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Uses data from a bar to populate a task.
 *
 * @param row bar data
 * @param task task to populate
 */
private void populateBar(Row row, Task task)
{
   Integer calendarID = row.getInteger("_CALENDAU");
   if (calendarID == null)
   {
      calendarID = row.getInteger("_COMMON_CALENDAR");
   }

   ProjectCalendar calendar = m_project.getCalendarByUniqueID(calendarID);

   //PROJID
   task.setUniqueID(row.getInteger("BARID"));
   task.setStart(row.getDate("STARV"));
   task.setFinish(row.getDate("ENF"));
   //NATURAL_ORDER
   //SPARI_INTEGER
   task.setName(row.getString("NAMH"));
   //EXPANDED_TASK
   //PRIORITY
   //UNSCHEDULABLE
   //MARK_FOR_HIDING
   //TASKS_MAY_OVERLAP
   //SUBPROJECT_ID
   //ALT_ID
   //LAST_EDITED_DATE
   //LAST_EDITED_BY
   //Proc_Approve
   //Proc_Design_info
   //Proc_Proc_Dur
   //Proc_Procurement
   //Proc_SC_design
   //Proc_Select_SC
   //Proc_Tender
   //QA Checked
   //Related_Documents
   task.setCalendar(calendar);

   task.setDuration(task.getEffectiveCalendar().getDuration(task.getStart(), task.getFinish()));
}
 
Example 8
Source File: GanttProjectReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Recursively read a task, and any sub tasks.
 *
 * @param mpxjParent Parent for the MPXJ tasks
 * @param gpTask GanttProject task
 */
private void readTask(ChildTaskContainer mpxjParent, net.sf.mpxj.ganttproject.schema.Task gpTask)
{
   Task mpxjTask = mpxjParent.addTask();
   mpxjTask.setUniqueID(Integer.valueOf(NumberHelper.getInt(gpTask.getId()) + 1));
   mpxjTask.setName(gpTask.getName());
   mpxjTask.setPercentageComplete(gpTask.getComplete());
   mpxjTask.setPriority(getPriority(gpTask.getPriority()));
   mpxjTask.setHyperlink(gpTask.getWebLink());

   Duration duration = Duration.getInstance(NumberHelper.getDouble(gpTask.getDuration()), TimeUnit.DAYS);
   mpxjTask.setDuration(duration);

   if (duration.getDuration() == 0)
   {
      mpxjTask.setMilestone(true);
   }
   else
   {
      mpxjTask.setStart(gpTask.getStart());
      mpxjTask.setFinish(m_mpxjCalendar.getDate(gpTask.getStart(), mpxjTask.getDuration(), false));
   }

   mpxjTask.setConstraintDate(gpTask.getThirdDate());
   if (mpxjTask.getConstraintDate() != null)
   {
      // TODO: you don't appear to be able to change this setting in GanttProject
      // task.getThirdDateConstraint()
      mpxjTask.setConstraintType(ConstraintType.START_NO_EARLIER_THAN);
   }

   readTaskCustomFields(gpTask, mpxjTask);

   m_eventManager.fireTaskReadEvent(mpxjTask);

   // TODO: read custom values

   //
   // Process child tasks
   //
   for (net.sf.mpxj.ganttproject.schema.Task childTask : gpTask.getTask())
   {
      readTask(mpxjTask, childTask);
   }
}
 
Example 9
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);
}
 
Example 10
Source File: PhoenixReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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 11
Source File: ProgressRecord.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
@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 12
Source File: ConceptDrawProjectReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Read a project from a ConceptDraw PROJECT file.
 *
 * @param project ConceptDraw PROJECT project
 */
private void readProject(Project project)
{
   Task mpxjTask = m_projectFile.addTask();
   //project.getAuthor()
   mpxjTask.setBaselineCost(project.getBaselineCost());
   mpxjTask.setBaselineFinish(project.getBaselineFinishDate());
   mpxjTask.setBaselineStart(project.getBaselineStartDate());
   //project.getBudget();
   //project.getCompany()
   mpxjTask.setFinish(project.getFinishDate());
   //project.getGoal()
   //project.getHyperlinks()
   //project.getMarkerID()
   mpxjTask.setName(project.getName());
   mpxjTask.setNotes(project.getNote());
   mpxjTask.setPriority(project.getPriority());
   //      project.getSite()
   mpxjTask.setStart(project.getStartDate());
   //      project.getStyleProject()
   //      project.getTask()
   //      project.getTimeScale()
   //      project.getViewProperties()

   String projectIdentifier = project.getID().toString();
   mpxjTask.setGUID(UUID.nameUUIDFromBytes(projectIdentifier.getBytes()));

   //
   // Sort the tasks into the correct order
   //
   List<Document.Projects.Project.Task> tasks = new ArrayList<>(project.getTask());
   final AlphanumComparator comparator = new AlphanumComparator();

   Collections.sort(tasks, new Comparator<Document.Projects.Project.Task>()
   {
      @Override public int compare(Document.Projects.Project.Task o1, Document.Projects.Project.Task o2)
      {
         return comparator.compare(o1.getOutlineNumber(), o2.getOutlineNumber());
      }
   });

   Map<String, Task> map = new HashMap<>();
   map.put("", mpxjTask);

   for (Document.Projects.Project.Task task : tasks)
   {
      readTask(projectIdentifier, map, task);
   }
}
 
Example 13
Source File: SureTrakDatabaseReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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 14
Source File: P3DatabaseReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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 15
Source File: AstaReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Populate a milestone from a Row instance.
 *
 * @param row Row instance
 * @param task Task instance
 */
private void populateMilestone(Row row, Task task)
{
   task.setMilestone(true);
   //PROJID
   task.setUniqueID(row.getInteger("MILESTONEID"));
   task.setStart(row.getDate("GIVEN_DATE_TIME"));
   task.setFinish(row.getDate("GIVEN_DATE_TIME"));
   //PROGREST_PERIOD
   //SYMBOL_APPEARANCE
   //MILESTONE_TYPE
   //PLACEMENU
   //INTERRUPTIBLE_X
   //ACTUAL_DURATIONTYPF
   //ACTUAL_DURATIONELA_MONTHS
   //ACTUAL_DURATIONHOURS
   task.setEarlyStart(row.getDate("EARLY_START_DATE"));
   task.setLateStart(row.getDate("LATE_START_DATE"));
   //FREE_START_DATE
   //START_CONSTRAINT_DATE
   //END_CONSTRAINT_DATE
   //EFFORT_BUDGET
   //NATURAO_ORDER
   //LOGICAL_PRECEDENCE
   //SPAVE_INTEGER
   //SWIM_LANE
   //USER_PERCENT_COMPLETE
   //OVERALL_PERCENV_COMPLETE
   //OVERALL_PERCENT_COMPL_WEIGHT
   task.setName(row.getString("NARE"));
   //NOTET
   task.setText(1, row.getString("UNIQUE_TASK_ID"));
   task.setCalendar(m_project.getCalendarByUniqueID(row.getInteger("CALENDAU")));
   //EFFORT_TIMI_UNIT
   //WORL_UNIT
   //LATEST_ALLOC_PROGRESS_PERIOD
   //WORN
   //CONSTRAINU
   //PRIORITB
   //CRITICAM
   //USE_PARENU_CALENDAR
   //BUFFER_TASK
   //MARK_FOS_HIDING
   //OWNED_BY_TIMESHEEV_X
   //START_ON_NEX_DAY
   //LONGEST_PATH
   //DURATIOTTYPF
   //DURATIOTELA_MONTHS
   //DURATIOTHOURS
   //STARZ
   //ENJ
   //DURATION_TIMJ_UNIT
   //UNSCHEDULABLG
   //SUBPROJECT_ID
   //ALT_ID
   //LAST_EDITED_DATE
   //LAST_EDITED_BY
   task.setDuration(Duration.getInstance(0, TimeUnit.HOURS));

   if (row.getBoolean("COMPLETED"))
   {        
      task.setPercentageComplete(COMPLETE);
      task.setActualStart(task.getStart());
      task.setActualFinish(task.getFinish());
   }
   else
   {
      task.setPercentageComplete(INCOMPLETE);
   }
   
   m_weights.put(task, row.getDouble("OVERALL_PERCENT_COMPL_WEIGHT"));
}
 
Example 16
Source File: SynchroReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * 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);
   }
}
 
Example 17
Source File: BasicTest.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * This method exercises task notes, ensuring that
 * embedded commas and quotes are handled correctly.
 *
 * @throws Exception
 */
@Test public void testTaskNotes() throws Exception
{
   String notes1 = "Notes, containing a comma. Done.";
   String notes2 = "Notes \"containing embedded quotes\" Done.";
   String notes3 = "Notes, \"containing embedded quotes, and comma's too.\" Done.";
   String notes4 = "\"Notes containing embedded quotes as first and last chars. Done.\"";
   String notes5 = "Normal unquoted notes. Done.";

   ProjectFile file1 = new ProjectFile();

   Task task1 = file1.addTask();
   task1.setName("Test Task 1");
   task1.setDuration(Duration.getInstance(10, TimeUnit.DAYS));
   task1.setStart(new Date());
   task1.setNotes(notes1);

   Task task2 = file1.addTask();
   task2.setName("Test Task 2");
   task2.setDuration(Duration.getInstance(10, TimeUnit.DAYS));
   task2.setStart(new Date());
   task2.setNotes(notes2);

   Task task3 = file1.addTask();
   task3.setName("Test Task 3");
   task3.setDuration(Duration.getInstance(10, TimeUnit.DAYS));
   task3.setStart(new Date());
   task3.setNotes(notes3);

   Task task4 = file1.addTask();
   task4.setName("Test Task 4");
   task4.setDuration(Duration.getInstance(10, TimeUnit.DAYS));
   task4.setStart(new Date());
   task4.setNotes(notes4);

   Task task5 = file1.addTask();
   task5.setName("Test Task 5");
   task5.setDuration(Duration.getInstance(10, TimeUnit.DAYS));
   task5.setStart(new Date());
   task5.setNotes(notes5);

   File out = File.createTempFile("junit", ".mpx");
   new MPXWriter().write(file1, out);

   ProjectFile file2 = new MPXReader().read(out);
   String notes;
   Task task1a = file2.getTaskByUniqueID(task1.getUniqueID());
   notes = task1a.getNotes();
   assertEquals(notes1, notes);

   Task task2a = file2.getTaskByUniqueID(task2.getUniqueID());
   notes = task2a.getNotes();
   assertEquals(notes2, notes);

   Task task3a = file2.getTaskByUniqueID(task3.getUniqueID());
   notes = task3a.getNotes();
   assertEquals(notes3, notes);

   Task task4a = file2.getTaskByUniqueID(task4.getUniqueID());
   notes = task4a.getNotes();
   assertEquals(notes4, notes);

   Task task5a = file2.getTaskByUniqueID(task5.getUniqueID());
   notes = task5a.getNotes();
   assertEquals(notes5, notes);

   out.deleteOnExit();
}
 
Example 18
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);
   }
}