java.lang.Object
com.northconcepts.datapipeline.foundations.core.Bean
com.northconcepts.datapipeline.foundations.jdbc.JdbcTable
All Implemented Interfaces:
DataExceptionContributor, JsonSerializable, RecordSerializable, XmlSerializable, JdbcSink, JdbcSource, Serializable

public class JdbcTable extends Bean implements JdbcSource, JdbcSink
Metadata for a database table or view (name, schema, type, columns, keys and indexes), as loaded by JdbcConnection.loadTables(LoadTablesRequest).
See Also:
  • Constructor Details

    • JdbcTable

      public JdbcTable()
  • Method Details

    • getConnection

      public JdbcConnection getConnection()
      Returns the connection this table was added to, or null.
    • setConnection

      protected JdbcTable setConnection(JdbcConnection connection)
      Sets the connection this table belongs to; called by JdbcConnection.addTable(JdbcTable).
    • getQualifiedName

      public String getQualifiedName()
      Returns the name prefixed with the schema and a dot when there is a schema; the catalog is not included.
    • getName

      public String getName()
      Specified by:
      getName in interface JdbcSink
      Specified by:
      getName in interface JdbcSource
    • setName

      public JdbcTable setName(String name)
    • getNameAsJavaClassName

      public String getNameAsJavaClassName()
      Returns the name as a camel-case Java class name, e.g. OrderItem for ORDER_ITEM.
    • getNameAsJavaIdentifier

      public String getNameAsJavaIdentifier()
      Returns the name as a camel-case Java identifier, e.g. orderItem for ORDER_ITEM.
    • getCatalogName

      public String getCatalogName()
    • setCatalogName

      public JdbcTable setCatalogName(String catalogName)
    • getSchemaName

      public String getSchemaName()
    • setSchemaName

      public JdbcTable setSchemaName(String schemaName)
    • getType

      public String getType()
      Returns the table type reported by the database, such as TABLE or VIEW.
    • setType

      public JdbcTable setType(String type)
      Sets the table type reported by the database, such as TABLE or VIEW.
    • getRemarks

      public String getRemarks()
    • setRemarks

      public JdbcTable setRemarks(String remarks)
    • getColumn

      public JdbcTableColumn getColumn(String name)
      Returns the column with the given name, ignoring case, or null if there is none.
    • getColumns

      public List<JdbcTableColumn> getColumns()
    • addColumn

      public JdbcTable addColumn(JdbcTableColumn column)
      Adds the column and sets this as its table.
    • sortColumns

      public JdbcTable sortColumns()
      Sorts the columns by name, ignoring case.
    • getPrimaryKeyName

      public String getPrimaryKeyName()
      Returns the name of the primary key constraint (not a column), or null.
    • setPrimaryKeyName

      public JdbcTable setPrimaryKeyName(String primaryKeyName)
      Sets the name of the primary key constraint (not a column).
    • getImportedKey

      public JdbcImportedKey getImportedKey(String foriegnKeyName)
      Returns the first entry of the named foreign key, ignoring case, or null; a multi-column key has one entry per column.
    • getImportedKeys

      public List<JdbcImportedKey> getImportedKeys()
      Returns this table's foreign keys to other tables, one entry per key column.
    • addImportedKey

      public JdbcTable addImportedKey(JdbcImportedKey key)
      Adds the imported key and sets this as its table.
    • getExportedKey

      public JdbcExportedKey getExportedKey(String primaryKeyName)
      Returns the first exported key entry whose primary key constraint name matches, ignoring case, or null.
    • getExportedKeys

      public List<JdbcExportedKey> getExportedKeys()
      Returns the other tables' foreign keys that reference this table's primary key, one entry per key column.
    • addExportedKey

      public JdbcTable addExportedKey(JdbcExportedKey key)
      Adds the exported key and sets this as its table.
    • getIndexes

      public List<JdbcIndex> getIndexes()
    • getIndex

      public JdbcIndex getIndex(String indexName)
      Returns the index with the given name, ignoring case, or null if there is none.
    • addIndex

      public JdbcTable addIndex(JdbcIndex index)
      Adds the index and sets this as its table.
    • getPrimaryKeyColumns

      public List<JdbcTableColumn> getPrimaryKeyColumns()
      Returns the primary key columns in key sequence order.
    • getNonPrimaryKeyColumns

      public List<JdbcTableColumn> getNonPrimaryKeyColumns()
      Returns the columns outside the primary key, ordered by their position in the table.
    • getImportedKeyColumns

      public List<JdbcTableColumn> getImportedKeyColumns(String foreignKeyName)
      Returns this table's columns in the named foreign key (ignoring case), in key sequence order.
    • getExportedKeyColumns

      public List<JdbcTableColumn> getExportedKeyColumns(String foreignKeyName)
      Returns this table's primary key columns referenced by another table's named foreign key (ignoring case), in key sequence order.
    • getColumns

      public List<JdbcTableColumn> getColumns(String... names)
      Returns the columns with the given names, ignoring case, in the order given; unknown names are skipped.
    • getColumns

      public List<JdbcTableColumn> getColumns(Collection<String> names)
      Returns the columns with the given names, ignoring case, in the order given; unknown names are skipped.
    • getQuery

      public String getQuery()
      Description copied from interface: JdbcSource
      Returns the SQL that selects this source's rows.
      Specified by:
      getQuery in interface JdbcSink
      Specified by:
      getQuery in interface JdbcSource
    • getSourceType

      public JdbcSourceType getSourceType()
      Specified by:
      getSourceType in interface JdbcSource
    • isDirectlyDependentOn

      public boolean isDirectlyDependentOn(JdbcTable table)
      Returns true if this table is directly dependent on the supplied table (i.e they have a direct public-foreign key relationship).

      See

      invalid @link
      {@link #isDependentOn(JdbcTable))
      }
      Parameters:
      table -
      Returns:
    • isDependentOn

      public boolean isDependentOn(JdbcTable table)
      Returns true if this table is either directly or indirectly dependent on the supplied table.

      See isDirectlyDependentOn(JdbcTable)

      Parameters:
      table -
      Returns:
    • toRecord

      public Record toRecord()
      Description copied from interface: RecordSerializable
      Converts this object's state to a record that RecordSerializable.fromRecord(Record) can load.
      Specified by:
      toRecord in interface RecordSerializable
      Overrides:
      toRecord in class Bean
    • fromRecord

      public JdbcTable fromRecord(Record source)
      Description copied from interface: RecordSerializable
      Loads this instance's state from a record and returns this (for fluid API call chaining). For fluid API call chaining, the overridden method should change the declared return type to its class.
      Specified by:
      fromRecord in interface RecordSerializable
      Overrides:
      fromRecord in class Bean
      Parameters:
      source -
      Returns:
      this instance.