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

The following examples show how to use net.sf.mpxj.Task#setConstraintType() . 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: SageReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Set a task constraint if a constraint dat has been supplied.
 *
 * @param task Task instance
 * @param type constraint type
 * @param columns record
 * @param index constraint date field index
 */
private void setConstraint(Task task, ConstraintType type, String[] columns, int index)
{
   Date date = parseDate(columns, index);
   if (date != null)
   {
      task.setConstraintType(type);
      task.setConstraintDate(date);
   }
}
 
Example 3
Source File: AstaReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Determines the constraints relating to a task.
 *
 * @param row row data
 * @param task Task instance
 */
private void processConstraints(Row row, Task task)
{
   ConstraintType constraintType = ConstraintType.AS_SOON_AS_POSSIBLE;
   Date constraintDate = null;

   switch (row.getInt("CONSTRAINU"))
   {
      case 0:
      {
         if (row.getInt("PLACEMENT") == 0)
         {
            constraintType = ConstraintType.AS_SOON_AS_POSSIBLE;
         }
         else
         {
            constraintType = ConstraintType.AS_LATE_AS_POSSIBLE;
         }
         break;
      }

      case 1:
      {
         constraintType = ConstraintType.MUST_START_ON;
         constraintDate = row.getDate("START_CONSTRAINT_DATE");
         break;
      }

      case 2:
      {
         constraintType = ConstraintType.START_NO_LATER_THAN;
         constraintDate = row.getDate("START_CONSTRAINT_DATE");
         break;
      }

      case 3:
      {
         constraintType = ConstraintType.START_NO_EARLIER_THAN;
         constraintDate = row.getDate("START_CONSTRAINT_DATE");
         break;
      }

      case 4:
      {
         constraintType = ConstraintType.MUST_FINISH_ON;
         constraintDate = row.getDate("END_CONSTRAINT_DATE");
         break;
      }

      case 5:
      {
         constraintType = ConstraintType.FINISH_NO_LATER_THAN;
         constraintDate = row.getDate("END_CONSTRAINT_DATE");
         break;
      }

      case 6:
      {
         constraintType = ConstraintType.FINISH_NO_EARLIER_THAN;
         constraintDate = row.getDate("END_CONSTRAINT_DATE");
         break;
      }

      case 8:
      {
         task.setDeadline(row.getDate("END_CONSTRAINT_DATE"));
         break;
      }
   }

   task.setConstraintType(constraintType);
   task.setConstraintDate(constraintDate);
}
 
Example 4
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 5
Source File: MerlinReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Populate the constraint type and constraint date.
 * Note that Merlin allows both start and end constraints simultaneously.
 * As we can't have both, we'll prefer the start constraint.
 *
 * @param row task data from database
 * @param task Task instance
 */
private void populateConstraints(Row row, Task task)
{
   Date endDateMax = row.getTimestamp("ZGIVENENDDATEMAX_");
   Date endDateMin = row.getTimestamp("ZGIVENENDDATEMIN_");
   Date startDateMax = row.getTimestamp("ZGIVENSTARTDATEMAX_");
   Date startDateMin = row.getTimestamp("ZGIVENSTARTDATEMIN_");

   ConstraintType constraintType = null;
   Date constraintDate = null;

   if (endDateMax != null)
   {
      constraintType = ConstraintType.FINISH_NO_LATER_THAN;
      constraintDate = endDateMax;
   }

   if (endDateMin != null)
   {
      constraintType = ConstraintType.FINISH_NO_EARLIER_THAN;
      constraintDate = endDateMin;
   }

   if (endDateMin != null && endDateMin == endDateMax)
   {
      constraintType = ConstraintType.MUST_FINISH_ON;
      constraintDate = endDateMin;
   }

   if (startDateMax != null)
   {
      constraintType = ConstraintType.START_NO_LATER_THAN;
      constraintDate = startDateMax;
   }

   if (startDateMin != null)
   {
      constraintType = ConstraintType.START_NO_EARLIER_THAN;
      constraintDate = startDateMin;
   }

   if (startDateMin != null && startDateMin == endDateMax)
   {
      constraintType = ConstraintType.MUST_START_ON;
      constraintDate = endDateMin;
   }

   task.setConstraintType(constraintType);
   task.setConstraintDate(constraintDate);
}
 
Example 6
Source File: SynchroReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Map Synchro constraints to MPXJ constraints.
 *
 * @param task task
 * @param row Synchro constraint data
 */
private void setConstraints(Task task, MapRow row)
{
   ConstraintType constraintType = null;
   Date constraintDate = null;
   Date lateDate = row.getDate("CONSTRAINT_LATE_DATE");
   Date earlyDate = row.getDate("CONSTRAINT_EARLY_DATE");

   switch (row.getInteger("CONSTRAINT_TYPE").intValue())
   {
      case 2: // Cannot Reschedule
      {
         constraintType = ConstraintType.MUST_START_ON;
         constraintDate = task.getStart();
         break;
      }

      case 12: //Finish Between
      {
         constraintType = ConstraintType.MUST_FINISH_ON;
         constraintDate = lateDate;
         break;
      }

      case 10: // Finish On or After
      {
         constraintType = ConstraintType.FINISH_NO_EARLIER_THAN;
         constraintDate = earlyDate;
         break;
      }

      case 11: // Finish On or Before
      {
         constraintType = ConstraintType.FINISH_NO_LATER_THAN;
         constraintDate = lateDate;
         break;
      }

      case 13: // Mandatory Start
      case 5: // Start On
      case 9: // Finish On
      {
         constraintType = ConstraintType.MUST_START_ON;
         constraintDate = earlyDate;
         break;
      }

      case 14: // Mandatory Finish
      {
         constraintType = ConstraintType.MUST_FINISH_ON;
         constraintDate = earlyDate;
         break;
      }

      case 4: // Start As Late As Possible
      {
         constraintType = ConstraintType.AS_LATE_AS_POSSIBLE;
         break;
      }

      case 3: // Start As Soon As Possible
      {
         constraintType = ConstraintType.AS_SOON_AS_POSSIBLE;
         break;
      }

      case 8: // Start Between
      {
         constraintType = ConstraintType.AS_SOON_AS_POSSIBLE;
         constraintDate = earlyDate;
         break;
      }

      case 6: // Start On or Before
      {
         constraintType = ConstraintType.START_NO_LATER_THAN;
         constraintDate = earlyDate;
         break;
      }

      case 15: // Work Between
      {
         constraintType = ConstraintType.START_NO_EARLIER_THAN;
         constraintDate = earlyDate;
         break;
      }
   }
   task.setConstraintType(constraintType);
   task.setConstraintDate(constraintDate);
}