All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.mpxj.openplan.DependenciesReader Maven / Gradle / Ivy

Go to download

Library that provides facilities to allow project information to be manipulated in Java and .Net. Supports a range of data formats: Microsoft Project Exchange (MPX), Microsoft Project (MPP,MPT), Microsoft Project Data Interchange (MSPDI XML), Microsoft Project Database (MPD), Planner (XML), Primavera (PM XML, XER, and database), Asta Powerproject (PP, MDB), Asta Easyplan (PP), Phoenix Project Manager (PPX), FastTrack Schedule (FTS), and the Standard Data Exchange Format (SDEF).

The newest version!
/*
 * file:       DependencyReader.java
 * author:     Jon Iles
 * date:       2024-02-27
 */

/*
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */

package net.sf.mpxj.openplan;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.poi.poifs.filesystem.DirectoryEntry;

/**
 * Read a dependencies table and extract any
 * calendars, resources and code definitions listed.
 */
public class DependenciesReader extends AbstractReader
{
   /**
    * Constructor.
    *
    * @param dir parent directory
    */
   public DependenciesReader(DirectoryEntry dir)
   {
      super(dir, "Dependencies");
   }

   /**
    * Read the dependencies and extract details of any calendar,
    * resource and code directories listed as dependencies.
    *
    * @return self
    */
   public DependenciesReader read()
   {
      int count = getInt();
      for (int index = 0; index < count; index++)
      {
         String name = getString();
         String type = getString();
         getByte();

         String path = name + "_" + type;

         //         if (!path.endsWith("_VUE"))
         //         {
         //            System.out.println(path);
         //         }

         StoreDirectoryName x = TYPE_MAP.get(type);
         if (x != null)
         {
            x.add(this, path);
         }
      }

      return this;
   }

   /**
    * Retrieve code directory names.
    *
    * @return code directory names
    */
   public List getCodes()
   {
      return m_codes;
   }

   /**
    * Retrieve resource directory names.
    *
    * @return resource directory names
    */
   public List getResources()
   {
      return m_resources;
   }

   /**
    * Retrieve calendar directory names.
    *
    * @return calendar directory names
    */
   public List getCalendars()
   {
      return m_calendars;
   }

   private final List m_calendars = new ArrayList<>();
   private final List m_resources = new ArrayList<>();
   private final List m_codes = new ArrayList<>();

   private interface StoreDirectoryName
   {
      void add(DependenciesReader reader, String name);
   }

   private static final Map TYPE_MAP = new HashMap<>();
   static
   {
      TYPE_MAP.put("CLD", (d, c) -> d.m_calendars.add(c));
      TYPE_MAP.put("RDS", (d, c) -> d.m_resources.add(c));
      TYPE_MAP.put("COD", (d, c) -> d.m_codes.add(c));
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy