Class Table

All Implemented Interfaces:
Comparable<Table>

public class Table extends ModelElement implements Comparable<Table>
Describes a database-table.
Author:
Ralf Wisser
  • Field Details

    • primaryKey

      public final PrimaryKey primaryKey
      The primary-key of the table.
    • associations

      public final List<Association> associations
      Associations to other tables.
    • upsert

      public Boolean upsert
      Use upsert (merge) or insert-statement for entities of this table in export-script.
    • defaultUpsert

      public final boolean defaultUpsert
      Data model default for export mode.
    • excludeFromDeletion

      public Boolean excludeFromDeletion
      Exclude from Deletion?
    • defaultExcludeFromDeletion

      public final boolean defaultExcludeFromDeletion
      Data Model default for Exclude from Deletion.
  • Constructor Details

    • Table

      public Table(String name, PrimaryKey primaryKey, boolean defaultUpsert, boolean defaultExcludeFromDeletion)
      Constructor.
      Parameters:
      name - the table-name
      primaryKey - the primary key of the table
      defaultUpsert - data model default for export mode
      defaultExcludeFromDeletion - data model default for exclude-from-deletion
  • Method Details

    • getName

      public String getName()
      Gets the table name.
      Returns:
      the table name
    • getUpsert

      public Boolean getUpsert()
      Gets export modus.
      Returns:
      Boolean.TRUE for upsert/merge, Boolean.FALSE for insert
    • setColumns

      public void setColumns(List<Column> columns)
      Sets columns.
      Parameters:
      columns - list of table columns
    • getColumns

      public List<Column> getColumns()
      Gets columns.
      Returns:
      list of table columns
    • equals

      public boolean equals(Object other)
      Compares tables by name.
      Overrides:
      equals in class Object
      Parameters:
      other - the object to compare with
      Returns:
      true if both tables have the same name
    • hashCode

      public int hashCode()
      Returns a hash code based on the table name.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code
    • toString

      public String toString()
      Stringifies the table.
      Overrides:
      toString in class Object
      Returns:
      string representation of the table including its primary key and associations
    • compareTo

      public int compareTo(Table o)
      Compares this table to another by name.
      Specified by:
      compareTo in interface Comparable<Table>
      Parameters:
      o - the other table
      Returns:
      a negative integer, zero, or a positive integer as this table's name is less than, equal to, or greater than the other table's name
    • closure

      public Set<Table> closure()
      Gets the closure of the table.
      Returns:
      closure of the table (all tables associated (in-)direct with table)
    • closure

      public Set<Table> closure(Set<Table> tablesToIgnore)
      Gets the closure of the table.
      Parameters:
      tablesToIgnore - ignore this tables
      Returns:
      closure of the table (all tables associated (in-)direct with table)
    • closure

      public Set<Table> closure(Set<Table> tablesToIgnore, Map<Table,Integer> distances)
      Gets the closure of the table.
      Parameters:
      tablesToIgnore - ignore this tables
      distances - put distances into it
      Returns:
      closure of the table (all tables associated (in-)direct with table)
    • unrestrictedClosure

      public Set<Table> unrestrictedClosure()
      Gets the closure of the table, ignoring restrictions.
      Returns:
      closure of the table (all tables associated (in-)directly with table)
    • setXmlTemplateInternal

      public void setXmlTemplateInternal(String xmlTemplate)
      Sets template for XML exports (for internal uses/GUI only).
      Parameters:
      xmlTemplate - the XML template string to set
    • setXmlTemplate

      public void setXmlTemplate(String xmlTemplate)
      Sets template for XML exports.
      Parameters:
      xmlTemplate - the XML template string to set
    • getXmlTemplate

      public String getXmlTemplate()
      Gets template for XML exports.
      Returns:
      the XML template string, or null if not set
    • getXmlTemplateAsDocument

      public Document getXmlTemplateAsDocument(Quoting quoting) throws ParserConfigurationException, SAXException, IOException
      Gets template for XML exports as DOM.
      Parameters:
      quoting - the quoting to use for column names
      Returns:
      the XML template as a DOM document
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • getDefaultXmlTemplate

      public Document getDefaultXmlTemplate(Quoting quoting) throws ParserConfigurationException, SAXException, IOException
      Gets default template for XML exports as DOM.
      Parameters:
      quoting - the quoting to use for column names
      Returns:
      the default XML template as a DOM document
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • getXmlTemplateAsDocument

      public Document getXmlTemplateAsDocument(String xmlTemplate, Quoting quoting) throws ParserConfigurationException, SAXException, IOException
      Gets template for XML exports as DOM.
      Parameters:
      xmlTemplate - the XML template string to use, or null for the default template
      quoting - the quoting to use for column names
      Returns:
      the XML template as a DOM document
      Throws:
      ParserConfigurationException
      SAXException
      IOException
    • getOriginalSchema

      public String getOriginalSchema(String defaultSchema)
      Gets un-mapped schema name of table.
      Parameters:
      defaultSchema - the default schema to return if table name is unqualified
      Returns:
      schema name
    • getSchema

      public String getSchema(String defaultSchema)
      Gets mapped schema name of table.
      Parameters:
      defaultSchema - the default schema to return if table name is unqualified
      Returns:
      schema name
    • getUnqualifiedName

      public String getUnqualifiedName()
      Gets unqualified name of table.
      Returns:
      unqualified name of table
    • setOriginalName

      public void setOriginalName(String originalName)
      Sets the original table-name. Differs from name if a source-schema-mapping has been applied to the name.
      Parameters:
      originalName - the original name
    • getOriginalName

      public String getOriginalName()
      Gets the original table-name. Differs from name if a source-schema-mapping has been applied to the name.
      Returns:
      the original name
    • getOrdinal

      public int getOrdinal()
      Gets unique number of this table to be used as type discriminator in JAILER_ENTITY table.
      Returns:
      unique number
    • getSelectionClause

      public List<Column> getSelectionClause()
      Gets all non-virtual columns of the table in the order in which they are selected.
      Returns:
      all non-virtual columns of the table in the order in which they are selected
    • isExcludedFromDeletion

      public boolean isExcludedFromDeletion()
      Gets whether this table is excluded from deletion.
      Returns:
      true if this table is excluded from deletion
    • clearSessionProperties

      public static void clearSessionProperties(Session session)
      Clears all session properties associated with this class.
      Parameters:
      session - the session whose properties should be cleared
    • getNonVirtualPKColumns

      public List<Column> getNonVirtualPKColumns(Session session)
      Gets non-virtual and non-filtered primary-key columns.
      Parameters:
      session - the session
      Returns:
      non-virtual and non-filtered primary-key columns
    • setIsArtifical

      public void setIsArtifical(boolean isArtifical)
      Sets whether this table is artificial (i.e. does not represent a table in a database).
      Parameters:
      isArtifical - value to set
    • isArtifical

      public boolean isArtifical()
      Gets whether this table is artificial (i.e. does not represent a table in a database).
      Returns:
      true if this table is artificial
    • setIsDistinct

      public void setIsDistinct(boolean isDistinct)
      Sets whether this table is a distinct join over several tables (needed for counting of column values).
      Parameters:
      isDistinct - value to set
    • isDistinct

      public boolean isDistinct()
      Gets whether this table is a distinct join over several tables (needed for counting of column values).
      Returns:
      true if this table is a distinct join