java.lang.Object
edu.internet2.middleware.grouper.ext.org.apache.ddlutils.model.Database
All Implemented Interfaces:
Serializable, Cloneable

public class Database extends Object implements Serializable, Cloneable
Represents the database model, ie. the tables in the database. It also contains the corresponding dyna classes for creating dyna beans for the objects stored in the tables.
Version:
$Revision: 504014 $
See Also:
  • Constructor Details

    • Database

      public Database()
  • Method Details

    • mergeWith

      public void mergeWith(Database otherDb) throws ModelException
      Adds all tables from the other database to this database. Note that the other database is not changed.
      Parameters:
      otherDb - The other database model
      Throws:
      ModelException
    • getName

      public String getName()
      Returns the name of this database model.
      Returns:
      The name
    • setName

      public void setName(String name)
      Sets the name of this database model.
      Parameters:
      name - The name
    • getVersion

      public String getVersion()
      Returns the version of this database model.
      Returns:
      The version
    • setVersion

      public void setVersion(String version)
      Sets the version of this database model.
      Parameters:
      version - The version
    • getIdMethod

      public String getIdMethod()
      Returns the method for generating primary key values.
      Returns:
      The method
    • setIdMethod

      public void setIdMethod(String idMethod)
      Sets the method for generating primary key values. Note that this value is ignored by DdlUtils and only for compatibility with Torque.
      Parameters:
      idMethod - The method
    • getTableCount

      public int getTableCount()
      Returns the number of tables in this model.
      Returns:
      The number of tables
    • getTables

      public Table[] getTables()
      Returns the tables in this model.
      Returns:
      The tables
    • getTable

      public Table getTable(int idx)
      Returns the table at the specified position.
      Parameters:
      idx - The index of the table
      Returns:
      The table
    • addTable

      public void addTable(Table table)
      Adds a table.
      Parameters:
      table - The table to add
    • addTable

      public void addTable(int idx, Table table)
      Adds a table at the specified position.
      Parameters:
      idx - The index where to insert the table
      table - The table to add
    • addTables

      public void addTables(Collection tables)
      Adds the given tables.
      Parameters:
      tables - The tables to add
    • removeTable

      public void removeTable(Table table)
      Removes the given table.
      Parameters:
      table - The table to remove
    • removeTable

      public void removeTable(int idx)
      Removes the indicated table.
      Parameters:
      idx - The index of the table to remove
    • initialize

      public void initialize() throws ModelException
      Initializes the model by establishing the relationships between elements in this model encoded eg. in foreign keys etc. Also checks that the model elements are valid (table and columns have a name, foreign keys rference existing tables etc.)
      Throws:
      ModelException
    • findTable

      public Table findTable(String name)
      Finds the table with the specified name, using case insensitive matching. Note that this method is not called getTable to avoid introspection problems.
      Parameters:
      name - The name of the table to find
      Returns:
      The table or null if there is no such table
    • findTable

      public Table findTable(String name, boolean caseSensitive)
      Finds the table with the specified name, using case insensitive matching. Note that this method is not called getTable) to avoid introspection problems.
      Parameters:
      name - The name of the table to find
      caseSensitive - Whether case matters for the names
      Returns:
      The table or null if there is no such table
    • resetDynaClassCache

      public void resetDynaClassCache()
      Resets the dyna class cache. This should be done for instance when a column has been added or removed to a table.
    • getDynaClassFor

      public SqlDynaClass getDynaClassFor(String tableName)
      Returns the org.apache.ddlutils.dynabean.SqlDynaClass for the given table name. If the it does not exist yet, a new one will be created based on the Table definition.
      Parameters:
      tableName - The name of the table to create the bean for
      Returns:
      The SqlDynaClass for the indicated table or null if the model contains no such table
    • getDynaClassFor

      public SqlDynaClass getDynaClassFor(org.apache.commons.beanutils.DynaBean bean)
      Returns the org.apache.ddlutils.dynabean.SqlDynaClass for the given dyna bean.
      Parameters:
      bean - The dyna bean
      Returns:
      The SqlDynaClass for the given bean
    • createDynaBeanFor

      public org.apache.commons.beanutils.DynaBean createDynaBeanFor(Table table) throws SqlDynaException
      Creates a new dyna bean for the given table.
      Parameters:
      table - The table to create the bean for
      Returns:
      The new dyna bean
      Throws:
      SqlDynaException
    • createDynaBeanFor

      public org.apache.commons.beanutils.DynaBean createDynaBeanFor(String tableName, boolean caseSensitive) throws SqlDynaException
      Convenience method that combines createDynaBeanFor(Table) and findTable(String, boolean).
      Parameters:
      tableName - The name of the table to create the bean for
      caseSensitive - Whether case matters for the names
      Returns:
      The new dyna bean
      Throws:
      SqlDynaException
    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toVerboseString

      public String toVerboseString()
      Returns a verbose string representation of this database.
      Returns:
      The string representation