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

The following examples show how to use net.sf.mpxj.Task#setGUID() . 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: ActivityRecord.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override public void process(Context context)
{
   String activityID = getString(0);
   Task task = context.addTask(activityID);
   task.setText(1, activityID);
   task.setName(getString(1));
   task.setDuration(getDuration(2));
   task.setConstraintDate(getDate(3));
   task.setConstraintType(getConstraintType(4));
   task.setCalendar(context.getCalendar(getString(5)));
   task.setText(2, getString(6));
   task.setNumber(1, getInteger(7));
   task.setText(3, getString(8));
   task.setText(4, getString(9));
   task.setText(5, getString(10));
   task.setText(6, getString(11));
   task.setText(7, getString(12));
   task.setText(8, getString(13));
   task.setText(9, getString(14));
   task.setGUID(UUID.nameUUIDFromBytes(activityID.getBytes()));
   task.setMilestone(task.getDuration() != null && task.getDuration().getDuration() == 0);
   context.getEventManager().fireTaskReadEvent(task);
}
 
Example 2
Source File: MerlinReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Read data for an individual task.
 *
 * @param row task data from database
 * @param task Task instance
 */
private void populateTask(Row row, Task task)
{
   task.setUniqueID(row.getInteger("Z_PK"));
   task.setName(row.getString("ZTITLE"));
   task.setPriority(Priority.getInstance(row.getInt("ZPRIORITY")));
   task.setMilestone(row.getBoolean("ZISMILESTONE"));
   task.setActualFinish(row.getTimestamp("ZGIVENACTUALENDDATE_"));
   task.setActualStart(row.getTimestamp("ZGIVENACTUALSTARTDATE_"));
   task.setNotes(row.getString("ZOBJECTDESCRIPTION"));
   task.setDuration(row.getDuration("ZGIVENDURATION_"));
   task.setOvertimeWork(row.getWork("ZGIVENWORKOVERTIME_"));
   task.setWork(row.getWork("ZGIVENWORK_"));
   task.setLevelingDelay(row.getDuration("ZLEVELINGDELAY_"));
   task.setActualOvertimeWork(row.getWork("ZGIVENACTUALWORKOVERTIME_"));
   task.setActualWork(row.getWork("ZGIVENACTUALWORK_"));
   task.setRemainingWork(row.getWork("ZGIVENACTUALWORK_"));
   task.setGUID(row.getUUID("ZUNIQUEID"));

   Integer calendarID = row.getInteger("ZGIVENCALENDAR");
   if (calendarID != null)
   {
      ProjectCalendar calendar = m_project.getCalendarByUniqueID(calendarID);
      if (calendar != null)
      {
         task.setCalendar(calendar);
      }
   }

   populateConstraints(row, task);

   // Percent complete is calculated bottom up from assignments and actual work vs. planned work

   m_eventManager.fireTaskReadEvent(task);
}
 
Example 3
Source File: PhoenixReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Retrieves the parent task for a Phoenix activity.
 *
 * @param activity Phoenix activity
 * @return parent task
 */
private ChildTaskContainer getParentTask(Activity activity)
{
   //
   // Make a map of activity codes and their values for this activity
   //
   Map<UUID, UUID> map = getActivityCodes(activity);

   //
   // Work through the activity codes in sequence
   //
   ChildTaskContainer parent = m_projectFile;
   StringBuilder uniqueIdentifier = new StringBuilder();
   for (UUID activityCode : m_codeSequence)
   {
      UUID activityCodeValue = map.get(activityCode);
      String activityCodeText = m_activityCodeValues.get(activityCodeValue);
      if (activityCodeText != null)
      {
         if (uniqueIdentifier.length() != 0)
         {
            uniqueIdentifier.append('>');
         }
         uniqueIdentifier.append(activityCodeValue.toString());
         UUID uuid = UUID.nameUUIDFromBytes(uniqueIdentifier.toString().getBytes());
         Task newParent = findChildTaskByUUID(parent, uuid);
         if (newParent == null)
         {
            newParent = parent.addTask();
            newParent.setGUID(uuid);
            newParent.setName(activityCodeText);
         }
         parent = newParent;
      }
   }
   return parent;
}
 
Example 4
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 5
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 6
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 7
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);
   }
}