Class DefaultPackage

java.lang.Object
weka.core.packageManagement.Package
weka.core.packageManagement.DefaultPackage
All Implemented Interfaces:
Serializable, Cloneable

public class DefaultPackage extends Package implements Serializable
A concrete implementation of Package that uses Java properties files/classes to manage package meta data. Assumes that meta data for individual packages is stored on the central repository (or possibly in a local cache - both accessible via http) in properties files that live in a sub-directory with the same name as the package. Furthermore, each property file is assumed to be named as the version number of the package in question with a ".props" extension. A "Latest.props" file should exist for each package and should always hold meta data on the latest version of a package.
Version:
$Revision: 52462 $
Author:
mhall (mhall{[at]}pentaho{[dot]}com).
See Also:
  • Constructor Details

    • DefaultPackage

      public DefaultPackage(File packageHome, PackageManager manager, Map<?,?> packageMetaData)
      Constructs an new DefaultPackage.
      Parameters:
      packageHome - the directory that packages are installed into.
      manager - the package manager in use.
      packageMetaData - A Map of package meta data for this package.
    • DefaultPackage

      public DefaultPackage(File packageHome, PackageManager manager)
      Constructs a new DefaultPackage.
      Parameters:
      packageHome - the directory that packages are installed into.
      manager - the package manager in use.
  • Method Details

    • clone

      public Object clone()
      Clone this package. Only makes a shallow copy of the meta data map
      Specified by:
      clone in class Package
      Returns:
      a copy of this package
    • setPackageManager

      public void setPackageManager(PackageManager p)
      Set the package manager for this package
      Parameters:
      p - the package manager to use
    • getPackageURL

      public URL getPackageURL() throws Exception
      Convenience method that returns the URL to the package (i.e the provider's URL). This information is assumed to be stored in the package meta data.
      Specified by:
      getPackageURL in class Package
      Returns:
      the URL to the package or null if the URL is not available for some reason
      Throws:
      Exception - if the URL can't be retrieved for some reason
    • getName

      public String getName()
      Convenience method to return the name of this package.
      Specified by:
      getName in class Package
      Returns:
      the name of this package.
    • getDependencies

      public List<Dependency> getDependencies() throws Exception
      Get the list of packages that this package depends on.
      Specified by:
      getDependencies in class Package
      Returns:
      the list of packages that this package depends on.
      Throws:
      Exception - if a problem occurs while getting the list of dependencies.
    • getBaseSystemDependency

      public List<Dependency> getBaseSystemDependency() throws Exception
      Gets the dependency on the base system that this package requires.
      Specified by:
      getBaseSystemDependency in class Package
      Returns:
      the base system dependency(s) for this package
      Throws:
      Exception - if the base system dependency can't be determined for some reason.
    • getMissingDependencies

      public List<Dependency> getMissingDependencies(List<Package> packages) throws Exception
      Gets a list of packages that this package depends on that are not in the supplied list of packages.
      Specified by:
      getMissingDependencies in class Package
      Parameters:
      packages - a list of packages to compare this package's dependencies against.
      Returns:
      those packages that this package depends on that aren't in the supplied list.
      Throws:
      Exception - if the list of missing depenencies can't be determined for some reason.
    • getMissingDependencies

      public List<Dependency> getMissingDependencies() throws Exception
      Gets a list of packages that this package depends on that are not currently installed.
      Specified by:
      getMissingDependencies in class Package
      Returns:
      a list of missing packages that this package depends on.
      Throws:
      Exception
    • getPrecludedPackages

      public List<Package> getPrecludedPackages(List<Package> packages) throws Exception
      Compares this package's precluded list (if any) against the list of supplied packages. Any packages in the supplied list that match (by name and version constraints) any in the precluded list are returned
      Specified by:
      getPrecludedPackages in class Package
      Parameters:
      packages - a list of packages to compare against those in this package's precluded list
      Returns:
      a list of packages that are covered by those in the precluded list
      Throws:
      Exception - if a problem occurs
    • getIncompatibleDependencies

      public List<Dependency> getIncompatibleDependencies(List<Package> packages) throws Exception
      Gets those packages from the supplied list that this package depends on and are currently incompatible with this package.
      Specified by:
      getIncompatibleDependencies in class Package
      Parameters:
      packages - a list of packages to compare this package's dependencies against
      Returns:
      those packages from the supplied list that are incompatible with respect to this package's dependencies
      Throws:
      Exception - if the list of incompatible dependencies can't be generated for some reason.
    • getIncompatibleDependencies

      public List<Dependency> getIncompatibleDependencies() throws Exception
      Gets a list of installed packages that this package depends on that are currently incompatible with this package.
      Specified by:
      getIncompatibleDependencies in class Package
      Returns:
      a list of incompatible installed packages that this package depends on.
      Throws:
      Exception
    • isCompatibleBaseSystem

      public boolean isCompatibleBaseSystem() throws Exception
      Returns true if this package is compatible with the currently installed version of the base system.
      Specified by:
      isCompatibleBaseSystem in class Package
      Returns:
      true if this package is compatible with the main software system.
      Throws:
      Exception - if a problem occurs while checking compatibility.
    • install

      public void install() throws Exception
      Install this package.
      Specified by:
      install in class Package
      Throws:
      Exception - if something goes wrong during installation.
    • isInstalled

      public boolean isInstalled()
      Returns true if this package is already installed
      Specified by:
      isInstalled in class Package
      Returns:
      true if this package is installed
    • main

      public static void main(String[] args)
    • setPackageMetaDataElement

      public void setPackageMetaDataElement(Object key, Object value) throws Exception
      Adds a key, value pair to the meta data map.
      Specified by:
      setPackageMetaDataElement in class Package
      Parameters:
      key - the key
      value - the value to add
      Throws:
      Exception - if there is no meta data map to add to.
    • toString

      public String toString()
      Overrides:
      toString in class Object