Java Code Examples for net.sf.mpxj.ProjectFile#getEventManager()

The following examples show how to use net.sf.mpxj.ProjectFile#getEventManager() . 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: AstaReader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Constructor.
 */
public AstaReader()
{
   m_project = new ProjectFile();
   m_eventManager = m_project.getEventManager();

   ProjectConfig config = m_project.getProjectConfig();

   config.setAutoTaskUniqueID(false);
   config.setAutoResourceUniqueID(false);

   config.setAutoCalendarUniqueID(false);

   m_project.getProjectProperties().setFileApplication("Asta");
   m_project.getProjectProperties().setFileType("PP");

   CustomFieldContainer fields = m_project.getCustomFields();
   fields.getCustomField(TaskField.TEXT1).setAlias("Code");
   fields.getCustomField(TaskField.NUMBER1).setAlias("Overall Percent Complete");
}
 
Example 2
Source File: SynchroReader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Reads data from the SP file.
 *
 * @return Project File instance
 */
private ProjectFile read() throws Exception
{
   m_project = new ProjectFile();
   m_eventManager = m_project.getEventManager();

   m_project.getProjectProperties().setFileApplication("Synchro");
   m_project.getProjectProperties().setFileType("SP");

   CustomFieldContainer fields = m_project.getCustomFields();
   fields.getCustomField(TaskField.TEXT1).setAlias("Code");

   m_eventManager.addProjectListeners(m_projectListeners);

   processCalendars();
   processResources();
   processTasks();
   processPredecessors();

   return m_project;
}
 
Example 3
Source File: MerlinReader.java    From mpxj with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Read the project data and return a ProjectFile instance.
 *
 * @return ProjectFile instance
 */
private ProjectFile read() throws Exception
{
   m_project = new ProjectFile();
   m_eventManager = m_project.getEventManager();

   ProjectConfig config = m_project.getProjectConfig();
   config.setAutoCalendarUniqueID(false);
   config.setAutoTaskUniqueID(false);
   config.setAutoResourceUniqueID(false);

   m_project.getProjectProperties().setFileApplication("Merlin");
   m_project.getProjectProperties().setFileType("SQLITE");

   m_eventManager.addProjectListeners(m_projectListeners);

   populateEntityMap();
   processProject();
   processCalendars();
   processResources();
   processTasks();
   processAssignments();
   processDependencies();

   return m_project;
}
 
Example 4
Source File: FastTrackReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Read FTS file data from the configured source and return a populated ProjectFile instance.
 *
 * @return ProjectFile instance
 */
private ProjectFile read() throws Exception
{
   m_project = new ProjectFile();
   m_eventManager = m_project.getEventManager();

   ProjectConfig config = m_project.getProjectConfig();
   config.setAutoCalendarUniqueID(false);
   config.setAutoTaskID(false);
   config.setAutoTaskUniqueID(false);
   config.setAutoResourceUniqueID(false);
   config.setAutoWBS(false);
   config.setAutoOutlineNumber(false);

   m_project.getProjectProperties().setFileApplication("FastTrack");
   m_project.getProjectProperties().setFileType("FTS");

   m_eventManager.addProjectListeners(m_projectListeners);

   // processProject();
   // processCalendars();
   processResources();
   processTasks();
   processDependencies();
   processAssignments();

   return m_project;
}
 
Example 5
Source File: SDEFWriter.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Write a project file in SDEF format to an output stream.
 *
 * @param projectFile ProjectFile instance
 * @param out output stream
 */
@Override public void write(ProjectFile projectFile, OutputStream out) throws IOException
{
   m_projectFile = projectFile;
   m_eventManager = projectFile.getEventManager();

   m_writer = new PrintStream(out); // the print stream class is the easiest way to create a text file
   m_buffer = new StringBuilder();

   try
   {
      write(); // method call a method, this is how MPXJ is structured, so I followed the lead?
   }

   //      catch (Exception e)
   //      { // used during console debugging
   //         System.out.println("Caught Exception in SDEFWriter.java");
   //         System.out.println(" " + e.toString());
   //      }

   finally
   { // keeps things cool after we're done
      m_writer = null;
      m_projectFile = null;
      m_buffer = null;
   }
}
 
Example 6
Source File: SageReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override public ProjectFile read(InputStream is) throws MPXJException
{
   try
   {
      m_projectFile = new ProjectFile();
      m_projectFile.getProjectProperties().setFileApplication("Sage");
      m_projectFile.getProjectProperties().setFileType("SCHEDULE_GRID");
      m_eventManager = m_projectFile.getEventManager();
      m_taskMap = new HashMap<>();

      BufferedReader reader = new BufferedReader(new InputStreamReader(is));
      List<String> lines = new ArrayList<>();
      String line;

      while ((line = reader.readLine()) != null)
      {
         lines.add(line);
      }

      processTasks(lines);
      processPredecessors(lines);

      return m_projectFile;
   }

   catch (IOException ex)
   {
      throw new MPXJException(MPXJException.READ_ERROR, ex);
   }

   finally
   {
      m_eventManager = null;
      m_taskMap = null;
   }
}
 
Example 7
Source File: PrimaveraReader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param taskUdfCounters UDF counters for tasks
 * @param resourceUdfCounters UDF counters for resources
 * @param assignmentUdfCounters UDF counters for assignments
 * @param resourceFields resource field mapping
 * @param wbsFields wbs field mapping
 * @param taskFields task field mapping
 * @param assignmentFields assignment field mapping
 * @param aliases alias mapping
 * @param matchPrimaveraWBS determine WBS behaviour
 * @param wbsIsFullPath determine the WBS attribute structure
 */
public PrimaveraReader(UserFieldCounters taskUdfCounters, UserFieldCounters resourceUdfCounters, UserFieldCounters assignmentUdfCounters, Map<FieldType, String> resourceFields, Map<FieldType, String> wbsFields, Map<FieldType, String> taskFields, Map<FieldType, String> assignmentFields, Map<FieldType, String> aliases, boolean matchPrimaveraWBS, boolean wbsIsFullPath)
{
   m_project = new ProjectFile();
   m_eventManager = m_project.getEventManager();

   ProjectConfig config = m_project.getProjectConfig();
   config.setAutoTaskUniqueID(false);
   config.setAutoResourceUniqueID(false);
   config.setAutoAssignmentUniqueID(false);
   config.setAutoWBS(false);

   m_resourceFields = resourceFields;
   m_wbsFields = wbsFields;
   m_taskFields = taskFields;
   m_assignmentFields = assignmentFields;

   applyAliases(aliases);

   m_taskUdfCounters = taskUdfCounters;
   m_taskUdfCounters.reset();
   m_resourceUdfCounters = resourceUdfCounters;
   m_resourceUdfCounters.reset();
   m_assignmentUdfCounters = assignmentUdfCounters;
   m_assignmentUdfCounters.reset();

   m_matchPrimaveraWBS = matchPrimaveraWBS;
   m_wbsIsFullPath = wbsIsFullPath;
}
 
Example 8
Source File: MPP8Reader.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Populate member data used by the rest of the reader.
 *
 * @param reader parent file reader
 * @param file parent MPP file
 * @param root Root of the POI file system.
 */
private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws IOException
{
   m_reader = reader;
   m_root = root;
   m_file = file;
   m_eventManager = file.getEventManager();

   m_calendarMap = new HashMap<>();
   m_projectDir = (DirectoryEntry) root.getEntry("   1");
   m_viewDir = (DirectoryEntry) root.getEntry("   2");

   m_file.getProjectProperties().setMppFileType(Integer.valueOf(8));
}
 
Example 9
Source File: MPXWriter.java    From mpxj with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override public void write(ProjectFile projectFile, OutputStream out) throws IOException
{
   m_projectFile = projectFile;
   m_eventManager = projectFile.getEventManager();

   if (m_useLocaleDefaults == true)
   {
      LocaleUtility.setLocale(m_projectFile.getProjectProperties(), m_locale);
   }

   m_delimiter = projectFile.getProjectProperties().getMpxDelimiter();
   m_writer = new OutputStreamWriter(new BufferedOutputStream(out), projectFile.getProjectProperties().getMpxCodePage().getCharset());
   m_buffer = new StringBuilder();
   m_formats = new MPXJFormats(m_locale, LocaleData.getString(m_locale, LocaleData.NA), m_projectFile);

   try
   {
      write();
   }

   finally
   {
      m_writer = null;
      m_projectFile = null;
      m_resourceModel = null;
      m_taskModel = null;
      m_buffer = null;
      m_locale = null;
      m_formats = null;
   }
}
 
Example 10
Source File: PlannerWriter.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override public void write(ProjectFile projectFile, OutputStream stream) throws IOException
{
   try
   {
      m_projectFile = projectFile;
      m_eventManager = projectFile.getEventManager();

      if (CONTEXT == null)
      {
         throw CONTEXT_EXCEPTION;
      }

      Marshaller marshaller = CONTEXT.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      if (m_encoding != null)
      {
         marshaller.setProperty(Marshaller.JAXB_ENCODING, m_encoding);
      }

      //
      // The Planner implementation used  as the basis for this work, 0.14.1
      // does not appear to have a particularly robust parser, and rejects
      // files with the full XML declaration produced by JAXB. The
      // following property suppresses this declaration.
      //
      marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

      m_factory = new ObjectFactory();
      m_plannerProject = m_factory.createProject();

      writeProjectProperties();
      writeCalendars();
      writeResources();
      writeTasks();
      writeAssignments();

      marshaller.marshal(m_plannerProject, stream);
   }

   catch (JAXBException ex)
   {
      throw new IOException(ex.toString());
   }

   finally
   {
      m_projectFile = null;
      m_factory = null;
      m_plannerProject = null;
   }
}
 
Example 11
Source File: TurboProjectReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override public ProjectFile read(InputStream stream) throws MPXJException
{
   try
   {
      m_projectFile = new ProjectFile();
      m_eventManager = m_projectFile.getEventManager();
      m_tables = new HashMap<>();

      ProjectConfig config = m_projectFile.getProjectConfig();
      config.setAutoResourceID(false);
      config.setAutoCalendarUniqueID(false);
      config.setAutoResourceUniqueID(false);
      config.setAutoTaskID(false);
      config.setAutoTaskUniqueID(false);
      config.setAutoOutlineLevel(true);
      config.setAutoOutlineNumber(true);
      config.setAutoWBS(true);

      m_projectFile.getProjectProperties().setFileApplication("TurboProject");
      m_projectFile.getProjectProperties().setFileType("PEP");

      m_eventManager.addProjectListeners(m_projectListeners);

      applyAliases();

      readFile(stream);
      readCalendars();
      readResources();
      readTasks();
      readRelationships();
      readResourceAssignments();

      //
      // Ensure that the unique ID counters are correct
      //
      config.updateUniqueCounters();

      return m_projectFile;
   }

   catch (IOException ex)
   {
      throw new MPXJException("Failed to parse file", ex);
   }

   finally
   {
      m_projectFile = null;
      m_eventManager = null;
      m_projectListeners = null;
      m_tables = null;
   }
}
 
Example 12
Source File: MPD9DatabaseReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Read a project from the current data source.
 *
 * @return ProjectFile instance
 * @throws MPXJException
 */
public ProjectFile read() throws MPXJException
{
   try
   {
      m_project = new ProjectFile();
      m_eventManager = m_project.getEventManager();

      ProjectConfig config = m_project.getProjectConfig();
      config.setAutoTaskID(false);
      config.setAutoTaskUniqueID(false);
      config.setAutoResourceID(false);
      config.setAutoResourceUniqueID(false);
      config.setAutoOutlineLevel(false);
      config.setAutoOutlineNumber(false);
      config.setAutoWBS(false);
      config.setAutoCalendarUniqueID(false);
      config.setAutoAssignmentUniqueID(false);

      m_project.getProjectProperties().setFileApplication("Microsoft");
      m_project.getProjectProperties().setFileType("MPD");

      m_project.getEventManager().addProjectListeners(m_projectListeners);

      processProjectProperties();
      processCalendars();
      processResources();
      processResourceBaselines();
      processTasks();
      processTaskBaselines();
      processLinks();
      processAssignments();
      processAssignmentBaselines();
      processExtendedAttributes();
      processSubProjects();
      postProcessing();

      return (m_project);
   }

   catch (SQLException ex)
   {
      throw new MPXJException(MPXJException.READ_ERROR, ex);
   }

   finally
   {
      reset();

      if (m_allocatedConnection)
      {
         AutoCloseableHelper.closeQuietly(m_connection);
         m_connection = null;
      }
   }
}
 
Example 13
Source File: SureTrakDatabaseReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override public ProjectFile read(File directory) throws MPXJException
{
   if (!directory.isDirectory())
   {
      throw new MPXJException("Directory expected");
   }

   try
   {
      m_projectFile = new ProjectFile();
      m_eventManager = m_projectFile.getEventManager();

      ProjectConfig config = m_projectFile.getProjectConfig();
      config.setAutoResourceID(true);
      config.setAutoResourceUniqueID(true);
      config.setAutoTaskID(true);
      config.setAutoTaskUniqueID(true);
      config.setAutoOutlineLevel(true);
      config.setAutoOutlineNumber(true);
      config.setAutoWBS(false);

      // Activity ID
      CustomFieldContainer customFields = m_projectFile.getCustomFields();
      customFields.getCustomField(TaskField.TEXT1).setAlias("Code");
      customFields.getCustomField(TaskField.TEXT2).setAlias("Department");
      customFields.getCustomField(TaskField.TEXT3).setAlias("Manager");
      customFields.getCustomField(TaskField.TEXT4).setAlias("Section");
      customFields.getCustomField(TaskField.TEXT5).setAlias("Mail");

      m_projectFile.getProjectProperties().setFileApplication("SureTrak");
      m_projectFile.getProjectProperties().setFileType("STW");

      m_eventManager.addProjectListeners(m_projectListeners);

      m_tables = new DatabaseReader().process(directory, m_projectName);
      m_definitions = new HashMap<>();
      m_calendarMap = new HashMap<>();
      m_resourceMap = new HashMap<>();
      m_wbsMap = new HashMap<>();
      m_activityMap = new HashMap<>();

      readProjectHeader();
      readDefinitions();
      readCalendars();
      readHolidays();
      readResources();
      readTasks();
      readRelationships();
      readResourceAssignments();

      return m_projectFile;
   }

   catch (IOException ex)
   {
      throw new MPXJException("Failed to parse file", ex);
   }

   finally
   {
      m_projectFile = null;
      m_eventManager = null;
      m_projectListeners = null;
      m_tables = null;
      m_definitions = null;
      m_wbsFormat = null;
      m_calendarMap = null;
      m_resourceMap = null;
      m_wbsMap = null;
      m_activityMap = null;
   }
}
 
Example 14
Source File: P3DatabaseReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override public ProjectFile read(File directory) throws MPXJException
{
   if (!directory.isDirectory())
   {
      throw new MPXJException("Directory expected");
   }

   try
   {
      m_projectFile = new ProjectFile();
      m_eventManager = m_projectFile.getEventManager();

      ProjectConfig config = m_projectFile.getProjectConfig();
      config.setAutoResourceID(true);
      config.setAutoResourceUniqueID(true);
      config.setAutoTaskID(true);
      config.setAutoTaskUniqueID(true);
      config.setAutoOutlineLevel(true);
      config.setAutoOutlineNumber(true);
      config.setAutoWBS(false);

      // Activity ID
      m_projectFile.getCustomFields().getCustomField(TaskField.TEXT1).setAlias("Code");

      m_projectFile.getProjectProperties().setFileApplication("P3");
      m_projectFile.getProjectProperties().setFileType("BTRIEVE");

      m_eventManager.addProjectListeners(m_projectListeners);

      m_tables = new DatabaseReader().process(directory, m_projectName);
      m_resourceMap = new HashMap<>();
      m_wbsMap = new HashMap<>();
      m_activityMap = new HashMap<>();

      readProjectHeader();
      readCalendars();
      readResources();
      readTasks();
      readRelationships();
      readResourceAssignments();

      return m_projectFile;
   }

   catch (IOException ex)
   {
      throw new MPXJException("Failed to parse file", ex);
   }

   finally
   {
      m_projectFile = null;
      m_eventManager = null;
      m_projectListeners = null;
      m_tables = null;
      m_resourceMap = null;
      m_wbsFormat = null;
      m_wbsMap = null;
      m_activityMap = null;
   }
}
 
Example 15
Source File: MPP9Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Populate member data used by the rest of the reader.
 *
 * @param reader parent file reader
 * @param file parent MPP file
 * @param root Root of the POI file system.
 */
private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws MPXJException, IOException
{
   m_reader = reader;
   m_file = file;
   m_eventManager = file.getEventManager();
   m_root = root;

   //
   // Retrieve the high level document properties (never encoded)
   //
   Props9 props9 = new Props9(new DocumentInputStream(((DocumentEntry) root.getEntry("Props9"))));
   //System.out.println(props9);

   file.getProjectProperties().setProjectFilePath(props9.getUnicodeString(Props.PROJECT_FILE_PATH));
   m_inputStreamFactory = new DocumentInputStreamFactory(props9);

   //
   // Test for password protection. In the single byte retrieved here:
   //
   // 0x00 = no password
   // 0x01 = protection password has been supplied
   // 0x02 = write reservation password has been supplied
   // 0x03 = both passwords have been supplied
   byte passwordProtectionFlag = props9.getByte(Props.PASSWORD_FLAG);
   boolean passwordRequiredToRead = (passwordProtectionFlag & 0x1) != 0;
   //boolean passwordRequiredToWrite = (passwordProtectionFlag & 0x2) != 0;

   if (passwordRequiredToRead && reader.getRespectPasswordProtection())
   {
      // File is password protected for reading, let's read the password
      // and see if the correct read password was given to us.
      String readPassword = MPPUtility.decodePassword(props9.getByteArray(Props.PROTECTION_PASSWORD_HASH), m_inputStreamFactory.getEncryptionCode());
      // It looks like it is possible for a project file to have the password protection flag on without a password. In
      // this case MS Project treats the file as NOT protected. We need to do the same. It is worth noting that MS Project does
      // correct the problem if the file is re-saved (at least it did for me).
      if (readPassword != null && readPassword.length() > 0)
      {
         // See if the correct read password was given
         if (reader.getReadPassword() == null || reader.getReadPassword().matches(readPassword) == false)
         {
            // Passwords don't match
            throw new MPXJException(MPXJException.PASSWORD_PROTECTED_ENTER_PASSWORD);
         }
      }
      // Passwords matched so let's allow the reading to continue.
   }

   m_resourceMap = new HashMap<>();
   m_projectDir = (DirectoryEntry) root.getEntry("   19");
   m_viewDir = (DirectoryEntry) root.getEntry("   29");
   DirectoryEntry outlineCodeDir = (DirectoryEntry) m_projectDir.getEntry("TBkndOutlCode");
   VarMeta outlineCodeVarMeta = new VarMeta9(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("VarMeta"))));
   m_outlineCodeVarData = new Var2Data(outlineCodeVarMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Var2Data"))));
   m_projectProps = new Props9(m_inputStreamFactory.getInstance(m_projectDir, "Props"));
   //MPPUtility.fileDump("c:\\temp\\props.txt", m_projectProps.toString().getBytes());

   m_fontBases = new HashMap<>();
   m_taskSubProjects = new HashMap<>();
   m_taskOrder = new TreeMap<>();
   m_nullTaskOrder = new TreeMap<>();

   m_file.getProjectProperties().setMppFileType(Integer.valueOf(9));
   m_file.getProjectProperties().setAutoFilter(props9.getBoolean(Props.AUTO_FILTER));
}
 
Example 16
Source File: MPP14Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Populate member data used by the rest of the reader.
 *
 * @param reader parent file reader
 * @param file parent MPP file
 * @param root Root of the POI file system.
 */
private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws FileNotFoundException, IOException, MPXJException
{
   m_reader = reader;
   m_file = file;
   m_eventManager = file.getEventManager();
   m_root = root;

   //
   // Retrieve the high level document properties
   //
   Props14 props14 = new Props14(new DocumentInputStream(((DocumentEntry) root.getEntry("Props14"))));
   //System.out.println(props14);

   file.getProjectProperties().setProjectFilePath(props14.getUnicodeString(Props.PROJECT_FILE_PATH));
   m_inputStreamFactory = new DocumentInputStreamFactory(props14);

   //
   // Test for password protection. In the single byte retrieved here:
   //
   // 0x00 = no password
   // 0x01 = protection password has been supplied
   // 0x02 = write reservation password has been supplied
   // 0x03 = both passwords have been supplied
   //
   byte passwordProtectionFlag = props14.getByte(Props.PASSWORD_FLAG);
   boolean passwordRequiredToRead = (passwordProtectionFlag & 0x1) != 0;
   //boolean passwordRequiredToWrite = (passwordProtectionFlag & 0x2) != 0;

   if (passwordRequiredToRead)
   {
      // Couldn't figure out how to get the password for MPP14 files so for now we just need to block the reading
      throw new MPXJException(MPXJException.PASSWORD_PROTECTED);
   }

   m_resourceMap = new HashMap<>();
   m_projectDir = (DirectoryEntry) root.getEntry("   114");
   m_viewDir = (DirectoryEntry) root.getEntry("   214");
   DirectoryEntry outlineCodeDir = (DirectoryEntry) m_projectDir.getEntry("TBkndOutlCode");
   m_outlineCodeVarMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("VarMeta"))));
   m_outlineCodeVarData = new Var2Data(m_outlineCodeVarMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Var2Data"))));
   m_outlineCodeFixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedMeta"))), 10);
   m_outlineCodeFixedData = new FixedData(m_outlineCodeFixedMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedData"))));
   m_outlineCodeFixedMeta2 = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Fixed2Meta"))), 10);
   m_outlineCodeFixedData2 = new FixedData(m_outlineCodeFixedMeta2, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Fixed2Data"))));
   m_projectProps = new Props14(m_inputStreamFactory.getInstance(m_projectDir, "Props"));
   //MPPUtility.fileDump("c:\\temp\\props.txt", m_projectProps.toString().getBytes());
   //FieldMap fm = new FieldMap14(m_file);
   //fm.dumpKnownFieldMaps(m_projectProps);

   m_fontBases = new HashMap<>();
   m_taskSubProjects = new HashMap<>();
   m_parentTasks = new HashMap<>();
   m_taskOrder = new TreeMap<>();
   m_nullTaskOrder = new TreeMap<>();

   m_file.getProjectProperties().setMppFileType(Integer.valueOf(14));
   m_file.getProjectProperties().setAutoFilter(props14.getBoolean(Props.AUTO_FILTER));
}
 
Example 17
Source File: MPP12Reader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Populate member data used by the rest of the reader.
 *
 * @param reader parent file reader
 * @param file parent MPP file
 * @param root Root of the POI file system.
 */
private void populateMemberData(MPPReader reader, ProjectFile file, DirectoryEntry root) throws MPXJException, IOException
{
   m_reader = reader;
   m_file = file;
   m_eventManager = file.getEventManager();
   m_root = root;

   //
   // Retrieve the high level document properties
   //
   Props12 props12 = new Props12(new DocumentInputStream(((DocumentEntry) root.getEntry("Props12"))));
   //System.out.println(props12);

   file.getProjectProperties().setProjectFilePath(props12.getUnicodeString(Props.PROJECT_FILE_PATH));
   m_inputStreamFactory = new DocumentInputStreamFactory(props12);

   //
   // Test for password protection. In the single byte retrieved here:
   //
   // 0x00 = no password
   // 0x01 = protection password has been supplied
   // 0x02 = write reservation password has been supplied
   // 0x03 = both passwords have been supplied
   //
   byte passwordProtectionFlag = props12.getByte(Props.PASSWORD_FLAG);
   boolean passwordRequiredToRead = (passwordProtectionFlag & 0x1) != 0;
   //boolean passwordRequiredToWrite = (passwordProtectionFlag & 0x2) != 0;

   if (passwordRequiredToRead)
   {
      // Couldn't figure out how to get the password for MPP12 files so for now we just need to block the reading
      throw new MPXJException(MPXJException.PASSWORD_PROTECTED);
   }

   m_resourceMap = new HashMap<>();
   m_projectDir = (DirectoryEntry) root.getEntry("   112");
   m_viewDir = (DirectoryEntry) root.getEntry("   212");
   DirectoryEntry outlineCodeDir = (DirectoryEntry) m_projectDir.getEntry("TBkndOutlCode");
   m_outlineCodeVarMeta = new VarMeta12(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("VarMeta"))));
   m_outlineCodeVarData = new Var2Data(m_outlineCodeVarMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Var2Data"))));
   m_outlineCodeFixedMeta = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedMeta"))), 10);
   m_outlineCodeFixedData = new FixedData(m_outlineCodeFixedMeta, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("FixedData"))));
   m_outlineCodeFixedMeta2 = new FixedMeta(new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Fixed2Meta"))), 10);
   m_outlineCodeFixedData2 = new FixedData(m_outlineCodeFixedMeta2, new DocumentInputStream(((DocumentEntry) outlineCodeDir.getEntry("Fixed2Data"))));
   m_projectProps = new Props12(m_inputStreamFactory.getInstance(m_projectDir, "Props"));

   //MPPUtility.fileDump("c:\\temp\\props.txt", m_projectProps.toString().getBytes());

   m_fontBases = new HashMap<>();
   m_taskSubProjects = new HashMap<>();
   m_taskOrder = new TreeMap<>();
   m_nullTaskOrder = new TreeMap<>();

   m_file.getProjectProperties().setMppFileType(Integer.valueOf(12));
   m_file.getProjectProperties().setAutoFilter(props12.getBoolean(Props.AUTO_FILTER));
}
 
Example 18
Source File: ProjectCommanderReader.java    From mpxj with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override public ProjectFile read(InputStream is) throws MPXJException
{
   try
   {
      m_projectFile = new ProjectFile();
      m_projectFile.getProjectProperties().setFileApplication("Project Commander");
      m_projectFile.getProjectProperties().setFileType("PC");

      ProjectConfig config = m_projectFile.getProjectConfig();
      config.setAutoTaskUniqueID(false);
      config.setAutoResourceUniqueID(false);

      m_eventManager = m_projectFile.getEventManager();
      m_taskMap = new TreeMap<>();
      m_childTaskCounts = new TreeMap<>();
      m_extraBarCounts = new HashMap<>();

      m_data = new ProjectCommanderData();
      //m_data.setLogFile("c:/temp/project-commander.log");
      m_data.process(is);

      readCalendars();
      readResources();
      readTasks();
      readRelationships();

      return m_projectFile;
   }

   catch (IOException ex)
   {
      throw new MPXJException(MPXJException.READ_ERROR, ex);
   }

   finally
   {
      m_eventManager = null;
      m_taskMap = null;
      m_childTaskCounts = null;
      m_extraBarCounts = null;
      m_data = null;
   }
}