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

The following examples show how to use net.sf.mpxj.Task#getSummary() . 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: TaskDateDump.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Dump data for all non-summary tasks to stdout.
 *
 * @param name file name
 */
public void process(String name) throws Exception
{
   ProjectFile file = new UniversalProjectReader().read(name);
   for (Task task : file.getTasks())
   {
      if (!task.getSummary())
      {
         System.out.print(task.getWBS());
         System.out.print("\t");
         System.out.print(task.getName());
         System.out.print("\t");
         System.out.print(format(task.getStart()));
         System.out.print("\t");
         System.out.print(format(task.getActualStart()));
         System.out.print("\t");
         System.out.print(format(task.getFinish()));
         System.out.print("\t");
         System.out.print(format(task.getActualFinish()));
         System.out.println();
      }
   }
}
 
Example 2
Source File: PrimaveraPMFileWriter.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Writes assignment data to a PM XML file.
 */
private void writeAssignments()
{
   for (ResourceAssignment assignment : m_projectFile.getResourceAssignments())
   {
      Resource resource = assignment.getResource();
      if (resource != null)
      {
         Task task = assignment.getTask();
         if (task != null && task.getUniqueID().intValue() != 0 && !task.getSummary())
         {
            writeAssignment(assignment);
         }
      }
   }
}
 
Example 3
Source File: SDEFWriter.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Write each predecessor for a task.
 *
 * @param record Task instance
 */
private void writeTaskPredecessors(Task record)
{
   m_buffer.setLength(0);
   //
   // Write the task predecessor
   //
   if (!record.getSummary() && !record.getPredecessors().isEmpty())
   { // I don't use summary tasks for SDEF
      m_buffer.append("PRED ");
      List<Relation> predecessors = record.getPredecessors();

      for (Relation pred : predecessors)
      {
         m_buffer.append(SDEFmethods.rset(pred.getSourceTask().getUniqueID().toString(), 10) + " ");
         m_buffer.append(SDEFmethods.rset(pred.getTargetTask().getUniqueID().toString(), 10) + " ");
         String type = "C"; // default finish-to-start
         if (!pred.getType().toString().equals("FS"))
         {
            type = pred.getType().toString().substring(0, 1);
         }
         m_buffer.append(type + " ");

         Duration dd = pred.getLag();
         double duration = dd.getDuration();
         if (dd.getUnits() != TimeUnit.DAYS)
         {
            dd = Duration.convertUnits(duration, dd.getUnits(), TimeUnit.DAYS, m_minutesPerDay, m_minutesPerWeek, m_daysPerMonth);
         }
         Double days = Double.valueOf(dd.getDuration() + 0.5); // Add 0.5 so half day rounds up upon truncation
         Integer est = Integer.valueOf(days.intValue());
         m_buffer.append(SDEFmethods.rset(est.toString(), 4) + " "); // task duration in days required by USACE
      }
      m_writer.println(m_buffer.toString());
   }
}
 
Example 4
Source File: PrimaveraPMFileWriter.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Given a Task instance, this task determines if it should be written to the
 * PM XML file as an activity or as a WBS item, and calls the appropriate
 * method.
 *
 * @param task Task instance
 */
private void writeTask(Task task)
{
   if (!task.getNull())
   {
      if (extractAndConvertTaskType(task) == null || task.getSummary())
      {
         writeWBS(task);
      }
      else
      {
         writeActivity(task);
      }
   }
}
 
Example 5
Source File: SDEFWriter.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Write a task.
 *
 * @param record task instance
 * @throws IOException
 */
private void writeTask(Task record) throws IOException
{
   m_buffer.setLength(0);
   if (!record.getSummary())
   {
      m_buffer.append("ACTV ");
      m_buffer.append(SDEFmethods.rset(record.getUniqueID().toString(), 10) + " ");
      m_buffer.append(SDEFmethods.lset(record.getName(), 30) + " ");

      // Following just makes certain we have days for duration, as per USACE spec.
      Duration dd = record.getDuration();
      double duration = dd.getDuration();
      if (dd.getUnits() != TimeUnit.DAYS)
      {
         dd = Duration.convertUnits(duration, dd.getUnits(), TimeUnit.DAYS, m_minutesPerDay, m_minutesPerWeek, m_daysPerMonth);
      }
      Double days = Double.valueOf(dd.getDuration() + 0.5); // Add 0.5 so half day rounds up upon truncation
      Integer est = Integer.valueOf(days.intValue());
      m_buffer.append(SDEFmethods.rset(est.toString(), 3) + " "); // task duration in days required by USACE

      String conType = "ES "; // assume early start
      Date conDate = record.getEarlyStart();
      int test = record.getConstraintType().getValue(); // test for other types
      if (test == 1 || test == 3 || test == 6 || test == 7 || test == 9)
      {
         conType = "LF "; // see ConstraintType enum for definitions
         conDate = record.getLateFinish();
      }
      m_buffer.append(m_formatter.format(conDate).toUpperCase() + " "); // Constraint Date
      m_buffer.append(conType); // Constraint Type
      if (record.getCalendar() == null)
      {
         m_buffer.append("1 ");
      }
      else
      {
         m_buffer.append(SDEFmethods.lset(record.getCalendar().getUniqueID().toString(), 1) + " ");
      }
      // skipping hammock code in here
      // use of text fields for extra USACE data is suggested at my web site: www.geocomputer.com
      // not documented on how to do this here, so I need to comment out at present
      //	      m_buffer.append(SDEFmethods.Lset(record.getText1(), 3) + " ");
      //	      m_buffer.append(SDEFmethods.Lset(record.getText2(), 4) + " ");
      //	      m_buffer.append(SDEFmethods.Lset(record.getText3(), 4) + " ");
      //	      m_buffer.append(SDEFmethods.Lset(record.getText4(), 6) + " ");
      //	      m_buffer.append(SDEFmethods.Lset(record.getText5(), 6) + " ");
      //	      m_buffer.append(SDEFmethods.Lset(record.getText6(), 2) + " ");
      //	      m_buffer.append(SDEFmethods.Lset(record.getText7(), 1) + " ");
      //	      m_buffer.append(SDEFmethods.Lset(record.getText8(), 30) + " ");
      m_writer.println(m_buffer.toString());
      m_eventManager.fireTaskWrittenEvent(record);
   }
}
 
Example 6
Source File: SDEFWriter.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Writes a progress line to the SDEF file.
 *
 * Progress lines in SDEF are a little tricky, you need to assume a percent complete
 * this could be physical or temporal, I don't know what you're using???
 * So in this version of SDEFwriter, I just put in 0.00 for cost progress to date, see *** below
 *
 * @param record Task instance
 */
private void writePROG(Task record)
{
   m_buffer.setLength(0);
   //
   // Write the progress record
   //
   if (!record.getSummary())
   { // I don't use summary tasks for SDEF
      m_buffer.append("PROG ");
      m_buffer.append(SDEFmethods.rset(record.getUniqueID().toString(), 10) + " ");
      Date temp = record.getActualStart();
      if (temp == null)
      {
         m_buffer.append("        "); // SDEf is column sensitive, so the number of blanks here is crucial
      }
      else
      {
         m_buffer.append(m_formatter.format(record.getActualStart()).toUpperCase() + " "); // ACTUAL START DATE
      }
      temp = record.getActualFinish();
      if (temp == null)
      {
         m_buffer.append("        ");
      }
      else
      {
         m_buffer.append(m_formatter.format(record.getActualFinish()).toUpperCase() + " "); // ACTUAL FINISH DATE
      }

      Duration dd = record.getRemainingDuration();
      double duration = dd.getDuration();
      if (dd.getUnits() != TimeUnit.DAYS)
      {
         dd = Duration.convertUnits(duration, dd.getUnits(), TimeUnit.DAYS, m_minutesPerDay, m_minutesPerWeek, m_daysPerMonth);
      }
      Double days = Double.valueOf(dd.getDuration() + 0.5); // Add 0.5 so half day rounds up upon truncation
      Integer est = Integer.valueOf(days.intValue());
      m_buffer.append(SDEFmethods.rset(est.toString(), 3) + " "); // task duration in days required by USACE

      DecimalFormat twoDec = new DecimalFormat("#0.00"); // USACE required currency format
      m_buffer.append(SDEFmethods.rset(twoDec.format(record.getCost().floatValue()), 12) + " ");
      m_buffer.append(SDEFmethods.rset(twoDec.format(0.00), 12) + " "); // *** assume zero progress on cost
      m_buffer.append(SDEFmethods.rset(twoDec.format(0.00), 12) + " "); // *** assume zero progress on cost
      m_buffer.append(m_formatter.format(record.getEarlyStart()).toUpperCase() + " ");
      m_buffer.append(m_formatter.format(record.getEarlyFinish()).toUpperCase() + " ");
      m_buffer.append(m_formatter.format(record.getLateStart()).toUpperCase() + " ");
      m_buffer.append(m_formatter.format(record.getLateFinish()).toUpperCase() + " ");

      dd = record.getTotalSlack();
      duration = dd.getDuration();
      if (dd.getUnits() != TimeUnit.DAYS)
      {
         dd = Duration.convertUnits(duration, dd.getUnits(), TimeUnit.DAYS, m_minutesPerDay, m_minutesPerWeek, m_daysPerMonth);
      }
      days = Double.valueOf(dd.getDuration() + 0.5); // Add 0.5 so half day rounds up upon truncation
      est = Integer.valueOf(days.intValue());
      char slack;
      if (est.intValue() >= 0)
      {
         slack = '+'; // USACE likes positive slack, so they separate the sign from the value
      }
      else
      {
         slack = '-'; // only write a negative when it's negative, i.e. can't be done in project management terms!!!
      }
      m_buffer.append(slack + " ");
      est = Integer.valueOf(Math.abs(days.intValue()));
      m_buffer.append(SDEFmethods.rset(est.toString(), 4)); // task duration in days required by USACE
      m_writer.println(m_buffer.toString());
      m_eventManager.fireTaskWrittenEvent(record);
   }
}