Package net.sf.mpxj

Examples of net.sf.mpxj.Task


        List<DependencyDTO> dependencies = new ArrayList<DependencyDTO>();

        List<Relation> successors;

        Task task;

        DependencyDTO dependencyDTO;

        for (Map.Entry<Task, IHasTaskAssociated> mapEntry : mapTask.entrySet()) {

            task = mapEntry.getKey();

            successors = task.getSuccessors();

            if (successors != null) {

                for (Relation successor : successors) {
View Full Code Here


      Integer id;
      Integer offset;
      byte[] data;
      byte[] metaData;
      byte[] metaData2;
      Task task;
      boolean autoWBS = true;
      LinkedList<Task> externalTasks = new LinkedList<Task>();
      RecurringTaskReader recurringTaskReader = null;
      RTFUtility rtf = new RTFUtility();
      String notes;

      for (int loop = 0; loop < uniqueid.length; loop++)
      {
         id = (Integer) uniqueid[loop];

         offset = taskMap.get(id);
         if (taskFixedData.isValidOffset(offset) == false)
         {
            continue;
         }

         data = taskFixedData.getByteArrayValue(offset.intValue());
         if (data.length == 16)
         {
            task = m_file.addTask();
            task.setNull(true);
            task.setUniqueID(id);
            task.setID(Integer.valueOf(MPPUtility.getInt(data, 4)));
            m_nullTaskOrder.put(task.getID(), task.getUniqueID());
            //System.out.println(task);
            continue;
         }

         if (data.length < fieldMap.getMaxFixedDataOffset(0))
         {
            byte[] newData = new byte[fieldMap.getMaxFixedDataOffset(0) + 8];
            System.arraycopy(data, 0, newData, 0, data.length);
            data = newData;
         }

         metaData = taskFixedMeta.getByteArrayValue(offset.intValue());
         //System.out.println (MPPUtility.hexdump(data, false, 16, ""));
         //System.out.println (MPPUtility.hexdump(data,false));
         //System.out.println (MPPUtility.hexdump(metaData, false, 16, ""));
         //MPPUtility.dataDump(m_file, data, false, false, false, true, false, false, false, false);
         //MPPUtility.dataDump(metaData, true, true, true, true, true, true, true);
         //MPPUtility.varDataDump(taskVarData, id, true, true, true, true, true, true);

         metaData2 = taskFixed2Meta.getByteArrayValue(offset.intValue());
         byte[] data2 = taskFixed2Data.getByteArrayValue(offset.intValue());
         //System.out.println (MPPUtility.hexdump(metaData2, false, 16, ""));        
         //System.out.println(MPPUtility.hexdump(data2, false, 16, ""));
         //System.out.println (MPPUtility.hexdump(metaData2,false));

         byte[] recurringData = taskVarData.getByteArray(id, fieldMap.getVarDataKey(TaskField.RECURRING_DATA));

         Task temp = m_file.getTaskByID(Integer.valueOf(MPPUtility.getInt(data, 4)));
         if (temp != null)
         {
            // Task with this id already exists... determine if this is the 'real' task by seeing
            // if this task has some var data. This is sort of hokey, but it's the best method i have
            // been able to see.
            if (!taskVarMeta.getUniqueIdentifierSet().contains(id))
            {
               // Sometimes Project contains phantom tasks that coexist on the same id as a valid
               // task. In this case don't want to include the phantom task. Seems to be a very rare case.
               continue;
            }
            else
               if (temp.getName() == null)
               {
                  // Ok, this looks valid. Remove the previous instance since it is most likely not a valid task.
                  // At worst case this removes a task with an empty name.
                  m_file.removeTask(temp);
               }
View Full Code Here

      // Finally, we can renumber the tasks
      //
      nextID = (m_file.getTaskByUniqueID(Integer.valueOf(0)) == null ? 1 : 0);
      for (Map.Entry<Integer, Integer> entry : taskMap.entrySet())
      {
         Task task = m_file.getTaskByUniqueID(entry.getValue());
         if (task != null)
         {
            task.setID(Integer.valueOf(nextID));
         }
         nextID++;
      }
   }
View Full Code Here

                     int taskID1 = MPPUtility.getInt(data, 4);
                     int taskID2 = MPPUtility.getInt(data, 8);

                     if (taskID1 != taskID2)
                     {
                        Task task1 = m_file.getTaskByUniqueID(Integer.valueOf(taskID1));
                        Task task2 = m_file.getTaskByUniqueID(Integer.valueOf(taskID2));

                        if (task1 != null && task2 != null)
                        {
                           RelationType type = RelationType.getInstance(MPPUtility.getShort(data, 12));
                           TimeUnit durationUnits = MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, 14));
                           Duration lag = MPPUtility.getAdjustedDuration(m_file, MPPUtility.getInt(data, 16), durationUnits);
                           Relation relation = task2.addPredecessor(task1, type, lag);
                           m_file.fireRelationReadEvent(relation);
                        }
                     }
                  }
               }
View Full Code Here

         case MPPTaskField.TASK_FIELD_BASE :
         {
            TaskField field = MPPTaskField.getInstance(index);
            if (field != null && field != TaskField.NOTES)
            {
               Task task = m_project.getTaskByUniqueID(entityID);
               if (task != null)
               {
                  if (field.getDataType() == DataType.CURRENCY)
                  {
                     value = Double.valueOf(((Double) value).doubleValue() / 100);
                  }
                  task.set(field, value);
               }
            }
            break;
         }
View Full Code Here

   protected void processTask(Row row)
   {
      Integer uniqueID = row.getInteger("TASK_UID");
      if (uniqueID != null && uniqueID.intValue() >= 0)
      {
         Task task = m_project.addTask();
         TimeUnit durationFormat = MPDUtility.getDurationTimeUnits(row.getInt("TASK_DUR_FMT"));

         task.setActualCost(row.getCurrency("TASK_ACT_COST"));
         task.setActualDuration(MPDUtility.getAdjustedDuration(m_project, row.getInt("TASK_ACT_DUR"), durationFormat));
         task.setActualFinish(row.getDate("TASK_ACT_FINISH"));
         task.setActualOvertimeCost(row.getCurrency("TASK_ACT_OVT_COST"));
         task.setActualOvertimeWork(row.getDuration("TASK_ACT_OVT_WORK"));
         //task.setActualOvertimeWorkProtected();
         task.setActualStart(row.getDate("TASK_ACT_START"));
         task.setActualWork(row.getDuration("TASK_ACT_WORK"));
         //task.setActualWorkProtected();
         task.setACWP(row.getCurrency("TASK_ACWP"));
         task.setBaselineCost(row.getCurrency("TASK_BASE_COST"));
         task.setBaselineDuration(MPDUtility.getAdjustedDuration(m_project, row.getInt("TASK_BASE_DUR"), durationFormat));
         task.setBaselineFinish(row.getDate("TASK_BASE_FINISH"));
         task.setBaselineStart(row.getDate("TASK_BASE_START"));
         task.setBaselineWork(row.getDuration("TASK_BASE_WORK"));
         //task.setBCWP(row.getCurrency("TASK_BCWP")); //@todo FIXME
         //task.setBCWS(row.getCurrency("TASK_BCWS")); //@todo FIXME
         task.setCalendar(m_project.getBaseCalendarByUniqueID(row.getInteger("TASK_CAL_UID")));
         //task.setConfirmed();
         task.setConstraintDate(row.getDate("TASK_CONSTRAINT_DATE"));
         task.setConstraintType(ConstraintType.getInstance(row.getInt("TASK_CONSTRAINT_TYPE")));
         //task.setContact();
         task.setCost(row.getCurrency("TASK_COST"));
         //task.setCost1();
         //task.setCost2();
         //task.setCost3();
         //task.setCost4();     
         //task.setCost5();
         //task.setCost6();
         //task.setCost7();
         //task.setCost8();
         //task.setCost9();
         //task.setCost10();
         //task.setCostVariance();
         task.setCreateDate(row.getDate("TASK_CREATION_DATE"));
         //task.setCritical(row.getBoolean("TASK_IS_CRITICAL")); @todo FIX ME
         //task.setCV();
         //task.setDate1();
         //task.setDate2();
         //task.setDate3();
         //task.setDate4();
         //task.setDate5();
         //task.setDate6();
         //task.setDate7();
         //task.setDate8();
         //task.setDate9();
         //task.setDate10();
         task.setDeadline(row.getDate("TASK_DEADLINE"));
         //task.setDelay();
         task.setDuration(MPDUtility.getAdjustedDuration(m_project, row.getInt("TASK_DUR"), durationFormat));

         //task.setDuration1();
         //task.setDuration2();
         //task.setDuration3();
         //task.setDuration4();
         //task.setDuration5();
         //task.setDuration6();
         //task.setDuration7();
         //task.setDuration8();
         //task.setDuration9();
         //task.setDuration10();

         task.setDurationVariance(MPDUtility.getAdjustedDuration(m_project, row.getInt("TASK_DUR_VAR"), durationFormat));
         task.setEarlyFinish(row.getDate("TASK_EARLY_FINISH"));
         task.setEarlyStart(row.getDate("TASK_EARLY_START"));
         //task.setEarnedValueMethod();
         task.setEffortDriven(row.getBoolean("TASK_IS_EFFORT_DRIVEN"));
         task.setEstimated(row.getBoolean("TASK_DUR_IS_EST"));
         task.setExpanded(!row.getBoolean("TASK_IS_COLLAPSED"));
         task.setExternalTask(row.getBoolean("TASK_IS_EXTERNAL"));
         //task.setExternalTaskProject();
         task.setFinish(row.getDate("TASK_FINISH_DATE"));
         //task.setFinish1();
         //task.setFinish2();
         //task.setFinish3();
         //task.setFinish4();
         //task.setFinish5();
         //task.setFinish6();
         //task.setFinish7();
         //task.setFinish8();
         //task.setFinish9();
         //task.setFinish10();
         //task.setFinishVariance(MPDUtility.getAdjustedDuration(m_project, row.getInt("TASK_FINISH_VAR"), durationFormat)); // Calculate for consistent results?
         //task.setFixed();
         task.setFixedCost(row.getCurrency("TASK_FIXED_COST"));
         task.setFixedCostAccrual(AccrueType.getInstance(row.getInt("TASK_FIXED_COST_ACCRUAL")));
         //task.setFlag1();
         //task.setFlag2();
         //task.setFlag3();
         //task.setFlag4();
         //task.setFlag5();
         //task.setFlag6();
         //task.setFlag7();
         //task.setFlag8();
         //task.setFlag9();
         //task.setFlag10();
         //task.setFlag11();
         //task.setFlag12();
         //task.setFlag13();
         //task.setFlag14();
         //task.setFlag15();
         //task.setFlag16();
         //task.setFlag17();
         //task.setFlag18();
         //task.setFlag19();
         //task.setFlag20();
         task.setFreeSlack(row.getDuration("TASK_FREE_SLACK").convertUnits(durationFormat, m_project.getProjectHeader()));
         task.setHideBar(row.getBoolean("TASK_BAR_IS_HIDDEN"));
         //task.setHyperlink();
         //task.setHyperlinkAddress();
         //task.setHyperlinkSubAddress();
         task.setID(row.getInteger("TASK_ID"));
         task.setIgnoreResourceCalendar(row.getBoolean("TASK_IGNORES_RES_CAL"));
         task.setLateFinish(row.getDate("TASK_LATE_FINISH"));
         task.setLateStart(row.getDate("TASK_LATE_START"));
         task.setLevelAssignments(row.getBoolean("TASK_LEVELING_ADJUSTS_ASSN"));
         task.setLevelingCanSplit(row.getBoolean("TASK_LEVELING_CAN_SPLIT"));
         task.setLevelingDelayFormat(MPDUtility.getDurationTimeUnits(row.getInt("TASK_LEVELING_DELAY_FMT")));
         task.setLevelingDelay(MPDUtility.getAdjustedDuration(m_project, row.getInt("TASK_LEVELING_DELAY"), task.getLevelingDelayFormat()));
         //task.setLinkedFields(row.getBoolean("TASK_HAS_LINKED_FIELDS")); @todo FIXME
         task.setMarked(row.getBoolean("TASK_IS_MARKED"));
         task.setMilestone(row.getBoolean("TASK_IS_MILESTONE"));
         task.setName(row.getString("TASK_NAME"));
         //task.setNull();
         //task.setNumber1();
         //task.setNumber2();
         //task.setNumber3();
         //task.setNumber4();
         //task.setNumber5();
         //task.setNumber6();
         //task.setNumber7();
         //task.setNumber8();
         //task.setNumber9();
         //task.setNumber10();
         //task.setNumber11();
         //task.setNumber12();
         //task.setNumber13();
         //task.setNumber14();
         //task.setNumber15();
         //task.setNumber16();
         //task.setNumber17();
         //task.setNumber18();
         //task.setNumber19();
         //task.setNumber20();
         task.setObjects(getNullOnValue(row.getInteger("TASK_NUM_OBJECTS"), 0));
         //task.setOutlineCode1();
         //task.setOutlineCode2();
         //task.setOutlineCode3();
         //task.setOutlineCode4();
         //task.setOutlineCode5();
         //task.setOutlineCode6();
         //task.setOutlineCode7();
         //task.setOutlineCode8();
         //task.setOutlineCode9();
         //task.setOutlineCode10();
         task.setOutlineLevel(row.getInteger("TASK_OUTLINE_LEVEL"));
         task.setOutlineNumber(row.getString("TASK_OUTLINE_NUM"));
         task.setOverAllocated(row.getBoolean("TASK_IS_OVERALLOCATED"));
         task.setOvertimeCost(row.getCurrency("TASK_OVT_COST"));
         //task.setOvertimeWork();
         task.setPercentageComplete(row.getDouble("TASK_PCT_COMP"));
         task.setPercentageWorkComplete(row.getDouble("TASK_PCT_WORK_COMP"));
         //task.setPhysicalPercentComplete();
         task.setPreleveledFinish(row.getDate("TASK_PRELEVELED_FINISH"));
         task.setPreleveledStart(row.getDate("TASK_PRELEVELED_START"));
         task.setPriority(Priority.getInstance(row.getInt("TASK_PRIORITY")));
         task.setRecurring(row.getBoolean("TASK_IS_RECURRING"));
         task.setRegularWork(row.getDuration("TASK_REG_WORK"));
         task.setRemainingCost(row.getCurrency("TASK_REM_COST"));
         task.setRemainingDuration(MPDUtility.getAdjustedDuration(m_project, row.getInt("TASK_REM_DUR"), durationFormat));
         task.setRemainingOvertimeCost(row.getCurrency("TASK_REM_OVT_COST"));
         task.setRemainingOvertimeWork(row.getDuration("TASK_REM_OVT_WORK"));
         task.setRemainingWork(row.getDuration("TASK_REM_WORK"));
         //task.setResourceGroup();
         //task.setResourceInitials();
         //task.setResourceNames();
         task.setResume(row.getDate("TASK_RESUME_DATE"));
         //task.setResumeNoEarlierThan();
         //task.setResumeValid();
         task.setRollup(row.getBoolean("TASK_IS_ROLLED_UP"));
         task.setStart(row.getDate("TASK_START_DATE"));
         //task.setStart1();
         //task.setStart2();
         //task.setStart3();
         //task.setStart4();
         //task.setStart5();
         //task.setStart6();
         //task.setStart7();
         //task.setStart8();
         //task.setStart9();
         //task.setStart10();
         //task.setStartVariance(MPDUtility.getAdjustedDuration(m_project, row.getInt("TASK_START_VAR"), durationFormat)); // more accurate by calculation?
         task.setStop(row.getDate("TASK_STOP_DATE"));
         task.setSummary(row.getBoolean("TASK_IS_SUMMARY"));
         //task.setText1();
         //task.setText2();
         //task.setText3();
         //task.setText4();
         //task.setText5();
         //task.setText6();
         //task.setText7();
         //task.setText8();
         //task.setText9();
         //task.setText10();
         //task.setText11();
         //task.setText12();
         //task.setText13();
         //task.setText14();
         //task.setText15();
         //task.setText16();
         //task.setText17();
         //task.setText18();
         //task.setText19();
         //task.setText20();
         //task.setText21();
         //task.setText22();
         //task.setText23();
         //task.setText24();
         //task.setText25();
         //task.setText26();
         //task.setText27();
         //task.setText28();
         //task.setText29();
         //task.setText30();
         //task.setTotalSlack(row.getDuration("TASK_TOTAL_SLACK")); //@todo FIX ME
         task.setType(TaskType.getInstance(row.getInt("TASK_TYPE")));
         task.setUniqueID(uniqueID);
         //task.setUpdateNeeded();     
         task.setWBS(row.getString("TASK_WBS"));
         //task.setWBSLevel();
         task.setWork(row.getDuration("TASK_WORK"));
         //task.setWorkVariance();

         //TASK_HAS_NOTES = false ( java.lang.Boolean)
         //TASK_RTF_NOTES = null ( )    
         String notes = row.getString("TASK_RTF_NOTES");
         if (notes != null)
         {
            if (m_preserveNoteFormatting == false)
            {
               notes = m_rtf.strip(notes);
            }
            task.setNotes(notes);
         }

         //
         // Calculate the cost variance
         //
         if (task.getCost() != null && task.getBaselineCost() != null)
         {
            task.setCostVariance(NumberUtility.getDouble(task.getCost().doubleValue() - task.getBaselineCost().doubleValue()));
         }

         //
         // Set default flag values
         //
         task.setFlag1(false);
         task.setFlag2(false);
         task.setFlag3(false);
         task.setFlag4(false);
         task.setFlag5(false);
         task.setFlag6(false);
         task.setFlag7(false);
         task.setFlag8(false);
         task.setFlag9(false);
         task.setFlag10(false);

         //
         // If we have a WBS value from the MPD file, don't autogenerate
         //
         if (task.getWBS() != null)
         {
            m_autoWBS = false;
         }

         //
         // Attempt to identify null tasks
         //
         if (task.getName() == null && task.getStart() == null && task.getFinish() == null)
         {
            task.setNull(true);
         }

         m_project.fireTaskReadEvent(task);
      }
   }
View Full Code Here

    *
    * @param file MPX file
    */
   private static void listAssignments(ProjectFile file)
   {
      Task task;
      Resource resource;
      String taskName;
      String resourceName;

      for (ResourceAssignment assignment : file.getAllResourceAssignments())
      {
         task = assignment.getTask();
         if (task == null)
         {
            taskName = "(null task)";
         }
         else
         {
            taskName = task.getName();
         }

         resource = assignment.getResource();
         if (resource == null)
         {
View Full Code Here

      {
         System.out.println("Assignments for resource " + resource.getName() + ":");

         for (ResourceAssignment assignment : resource.getTaskAssignments())
         {
            Task task = assignment.getTask();
            System.out.println("   " + task.getName());
         }
      }

      System.out.println();
   }
View Full Code Here

    * @param row result set row
    */
   protected void processTaskBaseline(Row row)
   {
      Integer id = row.getInteger("TASK_UID");
      Task task = m_project.getTaskByUniqueID(id);
      if (task != null)
      {
         int index = row.getInt("TB_BASE_NUM");

         task.setBaselineDuration(index, MPDUtility.getAdjustedDuration(m_project, row.getInt("TB_BASE_DUR"), MPDUtility.getDurationTimeUnits(row.getInt("TB_BASE_DUR_FMT"))));
         task.setBaselineStart(index, row.getDate("TB_BASE_START"));
         task.setBaselineFinish(index, row.getDate("TB_BASE_FINISH"));
         task.setBaselineWork(index, row.getDuration("TB_BASE_WORK"));
         task.setBaselineCost(index, row.getCurrency("TB_BASE_COST"));
      }
   }
View Full Code Here

    *
    * @param row relationship data
    */
   protected void processLink(Row row)
   {
      Task predecessorTask = m_project.getTaskByUniqueID(row.getInteger("LINK_PRED_UID"));
      Task successorTask = m_project.getTaskByUniqueID(row.getInteger("LINK_SUCC_UID"));
      if (predecessorTask != null && successorTask != null)
      {
         RelationType type = RelationType.getInstance(row.getInt("LINK_TYPE"));
         TimeUnit durationUnits = MPDUtility.getDurationTimeUnits(row.getInt("LINK_LAG_FMT"));
         Duration duration = MPDUtility.getDuration(row.getDouble("LINK_LAG").doubleValue(), durationUnits);
         Relation relation = successorTask.addPredecessor(predecessorTask, type, duration);
         m_project.fireRelationReadEvent(relation);
      }
   }
View Full Code Here

TOP

Related Classes of net.sf.mpxj.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.