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

The following examples show how to use net.sf.mpxj.Task#getMilestone() . 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: MSPDIReader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * When projectmanager.com exports schedules as MSPDI (via Aspose tasks)
 * they do not have finish dates, just a start date and a duration.
 * This method populates finish dates.
 *
 * @param task task to validate
 */
private void validateFinishDate(Task task)
{
   if (task.getFinish() == null)
   {
      Date startDate = task.getStart();
      if (startDate != null)
      {
         if (task.getMilestone())
         {
            task.setFinish(startDate);
         }
         else
         {
            Duration duration = task.getDuration();
            if (duration != null)
            {
               ProjectCalendar calendar = task.getEffectiveCalendar();
               task.setFinish(calendar.getDate(startDate, duration, false));
            }
         }
      }
   }
}
 
Example 2
Source File: ProjectFileImporter.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Pair<TimeDuration, TimeDuration> apply(Task t) {
  if (t.getMilestone()) {
    return Pair.create(getTaskManager().createLength(1), null);
  }
  return getDurations(t.getStart(), myNativeProject.getTimeUnitStack().getDefaultTimeUnit().adjustRight(t.getFinish()));
}
 
Example 3
Source File: ProjectFileImporter.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Pair<TimeDuration, TimeDuration> apply(Task t) {
  if (t.getMilestone()) {
    return Pair.create(getTaskManager().createLength(1), null);
  }
  Duration dayUnits = t.getDuration().convertUnits(TimeUnit.DAYS, myProjectFile.getProjectProperties());
  TimeDuration gpDuration = getTaskManager().createLength(GPTimeUnitStack.DAY, (float) dayUnits.getDuration());
  Date endDate = getTaskManager().shift(t.getStart(), gpDuration);
  return getDurations(t.getStart(), endDate);
}
 
Example 4
Source File: PlannerWriter.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * This method writes data for a single task to a Planner file.
 *
 * @param mpxjTask MPXJ Task instance
 * @param taskList list of child tasks for current parent
 */
private void writeTask(Task mpxjTask, List<net.sf.mpxj.planner.schema.Task> taskList) throws JAXBException
{
   net.sf.mpxj.planner.schema.Task plannerTask = m_factory.createTask();
   taskList.add(plannerTask);
   plannerTask.setEnd(getDateTimeString(mpxjTask.getFinish()));
   plannerTask.setId(getIntegerString(mpxjTask.getUniqueID()));
   plannerTask.setName(getString(mpxjTask.getName()));
   plannerTask.setNote(mpxjTask.getNotes());
   plannerTask.setPercentComplete(getIntegerString(mpxjTask.getPercentageWorkComplete()));
   plannerTask.setPriority(mpxjTask.getPriority() == null ? null : getIntegerString(mpxjTask.getPriority().getValue() * 10));
   plannerTask.setScheduling(getScheduling(mpxjTask.getType()));
   plannerTask.setStart(getDateTimeString(DateHelper.getDayStartDate(mpxjTask.getStart())));
   if (mpxjTask.getMilestone())
   {
      plannerTask.setType("milestone");
   }
   else
   {
      plannerTask.setType("normal");
   }
   plannerTask.setWork(getDurationString(mpxjTask.getWork()));
   plannerTask.setWorkStart(getDateTimeString(mpxjTask.getStart()));

   ConstraintType mpxjConstraintType = mpxjTask.getConstraintType();
   if (mpxjConstraintType != ConstraintType.AS_SOON_AS_POSSIBLE)
   {
      Constraint plannerConstraint = m_factory.createConstraint();
      plannerTask.setConstraint(plannerConstraint);
      if (mpxjConstraintType == ConstraintType.START_NO_EARLIER_THAN)
      {
         plannerConstraint.setType("start-no-earlier-than");
      }
      else
      {
         if (mpxjConstraintType == ConstraintType.MUST_START_ON)
         {
            plannerConstraint.setType("must-start-on");
         }
      }

      plannerConstraint.setTime(getDateTimeString(mpxjTask.getConstraintDate()));
   }

   //
   // Write predecessors
   //
   writePredecessors(mpxjTask, plannerTask);

   m_eventManager.fireTaskWrittenEvent(mpxjTask);

   //
   // Write child tasks
   //
   List<net.sf.mpxj.planner.schema.Task> childTaskList = plannerTask.getTask();
   for (Task task : mpxjTask.getChildTasks())
   {
      writeTask(task, childTaskList);
   }
}
 
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);
}