Package net.sf.mpxj

Examples of net.sf.mpxj.Task


      int tasks = taskFixedData.getItemCount();
      byte[] data;
      int uniqueID;
      int id;
      int deleted;
      Task task;
      boolean autoWBS = true;
      String notes;
      RTFUtility rtf = new RTFUtility();
      byte[] flags = new byte[3];
      RecurringTaskReader recurringTaskReader = null;

      for (int loop = 0; loop < tasks; loop++)
      {
         data = taskFixedData.getByteArrayValue(loop);

         //
         // Test for a valid unique id
         //
         uniqueID = MPPUtility.getInt(data, 0);
         if (uniqueID < 1)
         {
            continue;
         }

         //
         // Test to ensure this task has not been deleted.
         // This appears to be a set of flags rather than a single value.
         // The data I have seen to date shows deleted tasks having values of
         // 0x0001 and 0x0002. Valid tasks have had values of 0x0000, 0x0914,
         // 0x0040, 0x004A, 0x203D and 0x0031
         //
         deleted = MPPUtility.getShort(data, 272);
         if ((deleted & 0xC0) == 0 && (deleted & 0x03) != 0 && deleted != 0x0031 && deleted != 0x203D)
         {
            continue;
         }

         //
         // Load the var data if we have not already done so
         //
         if (taskVarData == null)
         {
            taskVarData = new FixDeferFix(new DocumentInputStream(((DocumentEntry) taskDir.getEntry("FixDeferFix   0"))));
         }

         //
         // Blank rows can be present in MPP files. The following flag
         // appears to indicate that a row is blank, and should be
         // ignored.
         //
         if ((data[8] & 0x01) != 0)
         {
            continue;
         }

         taskExtData = new ExtendedData(taskVarData, getOffset(data, 312));
         byte[] recurringData = taskExtData.getByteArray(TASK_RECURRING_DATA);

         id = MPPUtility.getInt(data, 4);
         flags[0] = (byte) (data[268] & data[303]);
         flags[1] = (byte) (data[269] & data[304]);
         flags[2] = (byte) (data[270] & data[305]);

         task = m_file.addTask();

         task.setActualCost(NumberUtility.getDouble(((double) MPPUtility.getLong6(data, 234)) / 100));
         task.setActualDuration(MPPUtility.getAdjustedDuration(m_file, MPPUtility.getInt(data, 74), MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, 72))));
         task.setActualFinish(MPPUtility.getTimestamp(data, 108));
         task.setActualOvertimeCost(NumberUtility.getDouble(((double) MPPUtility.getLong6(data, 210)) / 100));
         task.setActualOvertimeWork(MPPUtility.getDuration(((double) MPPUtility.getLong6(data, 192)) / 100, TimeUnit.HOURS));
         task.setActualStart(MPPUtility.getTimestamp(data, 104));
         task.setActualWork(MPPUtility.getDuration(((double) MPPUtility.getLong6(data, 180)) / 100, TimeUnit.HOURS));
         //task.setACWP(); // Calculated value
         //task.setAssignment(); // Calculated value
         //task.setAssignmentDelay(); // Calculated value
         //task.setAssignmentUnits(); // Calculated value
         task.setBaselineCost(NumberUtility.getDouble((double) MPPUtility.getLong6(data, 246) / 100));
         task.setBaselineDuration(MPPUtility.getAdjustedDuration(m_file, MPPUtility.getInt(data, 82), MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, 72))));
         task.setBaselineFinish(MPPUtility.getTimestamp(data, 116));
         task.setBaselineStart(MPPUtility.getTimestamp(data, 112));
         task.setBaselineWork(MPPUtility.getDuration(((double) MPPUtility.getLong6(data, 174)) / 100, TimeUnit.HOURS));
         //task.setBCWP(); // Calculated value
         //task.setBCWS(); // Calculated value
         //task.setConfirmed(); // Calculated value
         task.setConstraintDate(MPPUtility.getTimestamp(data, 120));
         task.setConstraintType(ConstraintType.getInstance(MPPUtility.getShort(data, 88)));
         task.setContact(taskExtData.getUnicodeString(TASK_CONTACT));
         task.setCost(NumberUtility.getDouble(((double) MPPUtility.getLong6(data, 222)) / 100));
         task.setCost1(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST1)) / 100));
         task.setCost2(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST2)) / 100));
         task.setCost3(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST3)) / 100));
         task.setCost4(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST4)) / 100));
         task.setCost5(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST5)) / 100));
         task.setCost6(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST6)) / 100));
         task.setCost7(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST7)) / 100));
         task.setCost8(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST8)) / 100));
         task.setCost9(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST9)) / 100));
         task.setCost10(NumberUtility.getDouble(((double) taskExtData.getLong(TASK_COST10)) / 100));
         //task.setCostRateTable(); // Calculated value
         //task.setCostVariance(); // Populated below
         task.setCreateDate(MPPUtility.getTimestamp(data, 138));
         //task.setCritical(); // Calculated value
         //task.setCV(); // Calculated value
         task.setDate1(taskExtData.getTimestamp(TASK_DATE1));
         task.setDate2(taskExtData.getTimestamp(TASK_DATE2));
         task.setDate3(taskExtData.getTimestamp(TASK_DATE3));
         task.setDate4(taskExtData.getTimestamp(TASK_DATE4));
         task.setDate5(taskExtData.getTimestamp(TASK_DATE5));
         task.setDate6(taskExtData.getTimestamp(TASK_DATE6));
         task.setDate7(taskExtData.getTimestamp(TASK_DATE7));
         task.setDate8(taskExtData.getTimestamp(TASK_DATE8));
         task.setDate9(taskExtData.getTimestamp(TASK_DATE9));
         task.setDate10(taskExtData.getTimestamp(TASK_DATE10));
         //task.setDelay(); // No longer supported by MS Project?
         task.setDuration(MPPUtility.getAdjustedDuration(m_file, MPPUtility.getInt(data, 68), MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, 72))));
         task.setDuration1(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION1), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION1_UNITS))));
         task.setDuration2(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION2), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION2_UNITS))));
         task.setDuration3(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION3), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION3_UNITS))));
         task.setDuration4(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION4), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION4_UNITS))));
         task.setDuration5(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION5), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION5_UNITS))));
         task.setDuration6(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION6), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION6_UNITS))));
         task.setDuration7(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION7), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION7_UNITS))));
         task.setDuration8(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION8), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION8_UNITS))));
         task.setDuration9(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION9), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION9_UNITS))));
         task.setDuration10(MPPUtility.getAdjustedDuration(m_file, taskExtData.getInt(TASK_DURATION10), MPPUtility.getDurationTimeUnits(taskExtData.getShort(TASK_DURATION10_UNITS))));
         //task.setDurationVariance(); // Calculated value
         task.setEarlyFinish(MPPUtility.getTimestamp(data, 20));
         task.setEarlyStart(MPPUtility.getTimestamp(data, 96));
         task.setEffortDriven((data[17] & 0x08) != 0);
         //task.setExternalTask(); // Calculated value
         task.setFinish(MPPUtility.getTimestamp(data, 20));
         task.setFinish1(taskExtData.getTimestamp(TASK_FINISH1));
         task.setFinish2(taskExtData.getTimestamp(TASK_FINISH2));
         task.setFinish3(taskExtData.getTimestamp(TASK_FINISH3));
         task.setFinish4(taskExtData.getTimestamp(TASK_FINISH4));
         task.setFinish5(taskExtData.getTimestamp(TASK_FINISH5));
         task.setFinish6(taskExtData.getTimestamp(TASK_FINISH6));
         task.setFinish7(taskExtData.getTimestamp(TASK_FINISH7));
         task.setFinish8(taskExtData.getTimestamp(TASK_FINISH8));
         task.setFinish9(taskExtData.getTimestamp(TASK_FINISH9));
         task.setFinish10(taskExtData.getTimestamp(TASK_FINISH10));
         //task.setFinishVariance(); // Calculated value
         task.setFixedCost(NumberUtility.getDouble(((double) MPPUtility.getLong6(data, 228)) / 100));
         task.setFixedCostAccrual(AccrueType.getInstance(MPPUtility.getShort(data, 136)));
         task.setFlag1((flags[0] & 0x02) != 0);
         task.setFlag2((flags[0] & 0x04) != 0);
         task.setFlag3((flags[0] & 0x08) != 0);
         task.setFlag4((flags[0] & 0x10) != 0);
         task.setFlag5((flags[0] & 0x20) != 0);
         task.setFlag6((flags[0] & 0x40) != 0);
         task.setFlag7((flags[0] & 0x80) != 0);
         task.setFlag8((flags[1] & 0x01) != 0);
         task.setFlag9((flags[1] & 0x02) != 0);
         task.setFlag10((flags[1] & 0x04) != 0);
         task.setFlag11((flags[1] & 0x08) != 0);
         task.setFlag12((flags[1] & 0x10) != 0);
         task.setFlag13((flags[1] & 0x20) != 0);
         task.setFlag14((flags[1] & 0x40) != 0);
         task.setFlag15((flags[1] & 0x80) != 0);
         task.setFlag16((flags[2] & 0x01) != 0);
         task.setFlag17((flags[2] & 0x02) != 0);
         task.setFlag18((flags[2] & 0x04) != 0);
         task.setFlag19((flags[2] & 0x08) != 0);
         task.setFlag20((flags[2] & 0x10) != 0); // note that this is not correct
         //task.setFreeSlack();  // Calculated value
         task.setHideBar((data[16] & 0x01) != 0);
         processHyperlinkData(task, taskVarData.getByteArray(-1 - taskExtData.getInt(TASK_HYPERLINK)));
         task.setID(Integer.valueOf(id));
         //task.setIndicators(); // Calculated value
         task.setLateFinish(MPPUtility.getTimestamp(data, 160));
         task.setLateStart(MPPUtility.getTimestamp(data, 24));
         task.setLevelAssignments((data[19] & 0x10) != 0);
         task.setLevelingCanSplit((data[19] & 0x08) != 0);
         task.setLevelingDelay(MPPUtility.getDuration(((double) MPPUtility.getInt(data, 90)) / 3, MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, 94))));
         //task.setLinkedFields();  // Calculated value
         task.setMarked((data[13] & 0x02) != 0);
         task.setMilestone((data[12] & 0x01) != 0);
         task.setName(taskVarData.getUnicodeString(getOffset(data, 264)));
         task.setNumber1(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER1)));
         task.setNumber2(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER2)));
         task.setNumber3(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER3)));
         task.setNumber4(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER4)));
         task.setNumber5(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER5)));
         task.setNumber6(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER6)));
         task.setNumber7(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER7)));
         task.setNumber8(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER8)));
         task.setNumber9(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER9)));
         task.setNumber10(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER10)));
         task.setNumber11(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER11)));
         task.setNumber12(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER12)));
         task.setNumber13(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER13)));
         task.setNumber14(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER14)));
         task.setNumber15(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER15)));
         task.setNumber16(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER16)));
         task.setNumber17(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER17)));
         task.setNumber18(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER18)));
         task.setNumber19(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER19)));
         task.setNumber20(NumberUtility.getDouble(taskExtData.getDouble(TASK_NUMBER20)));
         //task.setObjects(); // Calculated value
         task.setOutlineLevel(Integer.valueOf(MPPUtility.getShort(data, 48)));
         //task.setOutlineNumber(); // Calculated value
         //task.setOverallocated(); // Calculated value
         task.setOvertimeCost(NumberUtility.getDouble(((double) MPPUtility.getLong6(data, 204)) / 100));
         //task.setOvertimeWork(); // Calculated value
         //task.getPredecessors(); // Calculated value
         task.setPercentageComplete(MPPUtility.getPercentage(data, 130));
         task.setPercentageWorkComplete(MPPUtility.getPercentage(data, 132));
         task.setPreleveledFinish(MPPUtility.getTimestamp(data, 148));
         task.setPreleveledStart(MPPUtility.getTimestamp(data, 144));
         task.setPriority(Priority.getInstance((MPPUtility.getShort(data, 128) + 1) * 100));
         //task.setProject(); // Calculated value
         task.setRecurring(MPPUtility.getShort(data, 142) != 0);
         //task.setRegularWork(); // Calculated value
         task.setRemainingCost(NumberUtility.getDouble(((double) MPPUtility.getLong6(data, 240)) / 100));
         task.setRemainingDuration(MPPUtility.getAdjustedDuration(m_file, MPPUtility.getInt(data, 78), MPPUtility.getDurationTimeUnits(MPPUtility.getShort(data, 72))));
         task.setRemainingOvertimeCost(NumberUtility.getDouble(((double) MPPUtility.getLong6(data, 216)) / 100));
         task.setRemainingOvertimeWork(MPPUtility.getDuration(((double) MPPUtility.getLong6(data, 198)) / 100, TimeUnit.HOURS));
         task.setRemainingWork(MPPUtility.getDuration(((double) MPPUtility.getLong6(data, 186)) / 100, TimeUnit.HOURS));
         //task.setResourceGroup(); // Calculated value from resource
         //task.setResourceInitials(); // Calculated value from resource
         //task.setResourceNames(); // Calculated value from resource
         //task.setResourcePhonetics(); // Calculated value from resource
         //task.setResponsePending(); // Calculated value
         task.setResume(MPPUtility.getTimestamp(data, 32));
         //task.setResumeNoEarlierThan(); // Not in MSP98?
         task.setRollup((data[15] & 0x04) != 0);
         task.setStart(MPPUtility.getTimestamp(data, 96));
         task.setStart1(taskExtData.getTimestamp(TASK_START1));
         task.setStart2(taskExtData.getTimestamp(TASK_START2));
         task.setStart3(taskExtData.getTimestamp(TASK_START3));
         task.setStart4(taskExtData.getTimestamp(TASK_START4));
         task.setStart5(taskExtData.getTimestamp(TASK_START5));
         task.setStart6(taskExtData.getTimestamp(TASK_START6));
         task.setStart7(taskExtData.getTimestamp(TASK_START7));
         task.setStart8(taskExtData.getTimestamp(TASK_START8));
         task.setStart9(taskExtData.getTimestamp(TASK_START9));
         task.setStart10(taskExtData.getTimestamp(TASK_START10));
         //task.setStartVariance(); // Calculated value
         task.setStop(MPPUtility.getTimestamp(data, 124));
         //task.setSubprojectFile();
         //task.setSubprojectReadOnly();
         //task.setSuccessors(); // Calculated value
         //task.setSummary(); // Automatically generated by MPXJ
         //task.setSV(); // Calculated value
         //task.teamStatusPending(); // Calculated value
         task.setText1(taskExtData.getUnicodeString(TASK_TEXT1));
         task.setText2(taskExtData.getUnicodeString(TASK_TEXT2));
         task.setText3(taskExtData.getUnicodeString(TASK_TEXT3));
         task.setText4(taskExtData.getUnicodeString(TASK_TEXT4));
         task.setText5(taskExtData.getUnicodeString(TASK_TEXT5));
         task.setText6(taskExtData.getUnicodeString(TASK_TEXT6));
         task.setText7(taskExtData.getUnicodeString(TASK_TEXT7));
         task.setText8(taskExtData.getUnicodeString(TASK_TEXT8));
         task.setText9(taskExtData.getUnicodeString(TASK_TEXT9));
         task.setText10(taskExtData.getUnicodeString(TASK_TEXT10));
         task.setText11(taskExtData.getUnicodeString(TASK_TEXT11));
         task.setText12(taskExtData.getUnicodeString(TASK_TEXT12));
         task.setText13(taskExtData.getUnicodeString(TASK_TEXT13));
         task.setText14(taskExtData.getUnicodeString(TASK_TEXT14));
         task.setText15(taskExtData.getUnicodeString(TASK_TEXT15));
         task.setText16(taskExtData.getUnicodeString(TASK_TEXT16));
         task.setText17(taskExtData.getUnicodeString(TASK_TEXT17));
         task.setText18(taskExtData.getUnicodeString(TASK_TEXT18));
         task.setText19(taskExtData.getUnicodeString(TASK_TEXT19));
         task.setText20(taskExtData.getUnicodeString(TASK_TEXT20));
         task.setText21(taskExtData.getUnicodeString(TASK_TEXT21));
         task.setText22(taskExtData.getUnicodeString(TASK_TEXT22));
         task.setText23(taskExtData.getUnicodeString(TASK_TEXT23));
         task.setText24(taskExtData.getUnicodeString(TASK_TEXT24));
         task.setText25(taskExtData.getUnicodeString(TASK_TEXT25));
         task.setText26(taskExtData.getUnicodeString(TASK_TEXT26));
         task.setText27(taskExtData.getUnicodeString(TASK_TEXT27));
         task.setText28(taskExtData.getUnicodeString(TASK_TEXT28));
         task.setText29(taskExtData.getUnicodeString(TASK_TEXT29));
         task.setText30(taskExtData.getUnicodeString(TASK_TEXT30));
         //task.setTotalSlack(); // Calculated value
         task.setType(TaskType.getInstance(MPPUtility.getShort(data, 134)));
         task.setUniqueID(Integer.valueOf(uniqueID));
         //task.setUniqueIDPredecessors(); // Calculated value
         //task.setUniqueIDSuccessors(); // Calculated value
         //task.setUpdateNeeded(); // Calculated value
         task.setWBS(taskExtData.getUnicodeString(TASK_WBS));
         task.setWork(MPPUtility.getDuration(((double) MPPUtility.getLong6(data, 168)) / 100, TimeUnit.HOURS));
         //task.setWorkContour(); // Calculated from resource
         //task.setWorkVariance(); // Calculated value

         //
         // Retrieve task recurring data
         //
         if (recurringData != null)
         {
            if (recurringTaskReader == null)
            {
               recurringTaskReader = new RecurringTaskReader(m_file);
            }
            recurringTaskReader.processRecurringTask(task, recurringData);
         }

         //
         // Retrieve the task notes.
         //
         notes = taskExtData.getString(TASK_NOTES);
         if (notes != null)
         {
            if (m_reader.getPreserveNoteFormatting() == false)
            {
               notes = rtf.strip(notes);
            }

            task.setNotes(notes);
         }

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

         m_file.fireTaskReadEvent(task);
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.