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

The following examples show how to use net.sf.mpxj.Task#getSubProject() . 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: MppSubprojectTest.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Tests the various fields needed to read in subprojects.
 *
 * @param mpp The ProjectFile being tested.
 * @param isMPP is the source an MPP file
 * @throws Exception
 */
private void testSubprojects(ProjectFile mpp, boolean isMPP) throws Exception
{
   Task taskNormal = mpp.getTaskByUniqueID(Integer.valueOf(1));
   Task taskSubprojectA = mpp.getTaskByUniqueID(Integer.valueOf(2));
   Task taskSubprojectB = mpp.getTaskByUniqueID(Integer.valueOf(3));

   assertEquals("Normal Task", taskNormal.getName());
   assertEquals("SubprojectA-9", taskSubprojectA.getName());
   assertEquals("SubprojectB-9", taskSubprojectB.getName());

   // Subproject A
   SubProject subprojectA = taskSubprojectA.getSubProject();
   assertNotNull(subprojectA);
   final String expectedFilenameA = "\\SubprojectA-9.mpp";
   //assertEquals(expectedFilenameA, subprojectA.getDosFileName());
   assertTrue(expectedFilenameA.indexOf(subprojectA.getFileName()) != -1);
   //subprojectA.getDosFullPath(); don't need to test
   assertTrue(subprojectA.getFullPath().indexOf(expectedFilenameA) != -1);
   assertEquals(Integer.valueOf(2), subprojectA.getTaskUniqueID());

   //assertEquals(null, taskSubprojectA.getSubprojectName());  // TODO: why is this null?
   assertFalse(taskSubprojectA.getSubprojectReadOnly());

   if (isMPP)
   {
      assertEquals(Integer.valueOf(8388608), subprojectA.getUniqueIDOffset()); // MPD needs to be fixed
      assertEquals(Integer.valueOf(8388608), taskSubprojectA.getSubprojectTasksUniqueIDOffset());
      assertEquals(Integer.valueOf(0), taskSubprojectA.getSubprojectTaskUniqueID());
   }
}
 
Example 2
Source File: MPP9Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * The project files to which external tasks relate appear not to be
 * held against each task, instead there appears to be the concept
 * of the "current" external task file, i.e. the last one used.
 * This method iterates through the list of tasks marked as external
 * and attempts to ensure that the correct external project data (in the
 * form of a SubProject object) is linked to the task.
 *
 * @param externalTasks list of tasks marked as external
 */
private void processExternalTasks(List<Task> externalTasks)
{
   //
   // Sort the list of tasks into ID order
   //
   Collections.sort(externalTasks);

   //
   // Find any external tasks which don't have a sub project
   // object, and set this attribute using the most recent
   // value.
   //
   SubProject currentSubProject = null;

   for (Task currentTask : externalTasks)
   {
      SubProject sp = currentTask.getSubProject();
      if (sp == null)
      {
         currentTask.setSubProject(currentSubProject);

         //we need to set the external task project path now that we have
         //the subproject for this task (was skipped while processing the task earlier)
         if (currentSubProject != null)
         {
            currentTask.setExternalTaskProject(currentSubProject.getFullPath());
         }

      }
      else
      {
         currentSubProject = sp;
      }

      if (currentSubProject != null)
      {
         //System.out.println ("Task: " +currentTask.getUniqueID() + " " + currentTask.getName() + " File=" + currentSubProject.getFullPath() + " ID=" + currentTask.getExternalTaskID());
         currentTask.setProject(currentSubProject.getFullPath());
      }
   }
}
 
Example 3
Source File: MPP14Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * The project files to which external tasks relate appear not to be
 * held against each task, instead there appears to be the concept
 * of the "current" external task file, i.e. the last one used.
 * This method iterates through the list of tasks marked as external
 * and attempts to ensure that the correct external project data (in the
 * form of a SubProject object) is linked to the task.
 *
 * @param externalTasks list of tasks marked as external
 */
private void processExternalTasks(List<Task> externalTasks)
{
   //
   // Sort the list of tasks into ID order
   //
   Collections.sort(externalTasks);

   //
   // Find any external tasks which don't have a sub project
   // object, and set this attribute using the most recent
   // value.
   //
   SubProject currentSubProject = null;

   for (Task currentTask : externalTasks)
   {
      SubProject sp = currentTask.getSubProject();
      if (sp == null)
      {
         currentTask.setSubProject(currentSubProject);

         //we need to set the external task project path now that we have
         //the subproject for this task (was skipped while processing the task earlier)
         if (currentSubProject != null)
         {
            currentTask.setExternalTaskProject(currentSubProject.getFullPath());
         }

      }
      else
      {
         currentSubProject = sp;
      }

      if (currentSubProject != null)
      {
         //System.out.println ("Task: " +currentTask.getUniqueID() + " " + currentTask.getName() + " File=" + currentSubProject.getFullPath() + " ID=" + currentTask.getExternalTaskID());
         currentTask.setProject(currentSubProject.getFullPath());
      }
   }
}
 
Example 4
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * The project files to which external tasks relate appear not to be
 * held against each task, instead there appears to be the concept
 * of the "current" external task file, i.e. the last one used.
 * This method iterates through the list of tasks marked as external
 * and attempts to ensure that the correct external project data (in the
 * form of a SubProject object) is linked to the task.
 *
 * @param externalTasks list of tasks marked as external
 */
private void processExternalTasks(List<Task> externalTasks)
{
   //
   // Sort the list of tasks into ID order
   //
   Collections.sort(externalTasks);

   //
   // Find any external tasks which don't have a sub project
   // object, and set this attribute using the most recent
   // value.
   //
   SubProject currentSubProject = null;

   for (Task currentTask : externalTasks)
   {
      SubProject sp = currentTask.getSubProject();
      if (sp == null)
      {
         currentTask.setSubProject(currentSubProject);

         //we need to set the external task project path now that we have
         //the subproject for this task (was skipped while processing the task earlier)
         if (currentSubProject != null)
         {
            currentTask.setExternalTaskProject(currentSubProject.getFullPath());
         }

      }
      else
      {
         currentSubProject = sp;
      }

      if (currentSubProject != null)
      {
         //System.out.println ("Task: " +currentTask.getUniqueID() + " " + currentTask.getName() + " File=" + currentSubProject.getFullPath() + " ID=" + currentTask.getExternalTaskID());
         currentTask.setProject(currentSubProject.getFullPath());
      }
   }
}