Package com.im.commons.db.ddl
Class DBTableInfoImpl
- java.lang.Object
-
- com.im.commons.db.ddl.DBTableInfoImpl
-
- All Implemented Interfaces:
DBTableInfo
,java.io.Serializable
public final class DBTableInfoImpl extends java.lang.Object implements DBTableInfo
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.im.commons.db.ddl.DBTableInfo
DBTableInfo.Type
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DBTableInfoImpl()
protected
DBTableInfoImpl(DatabasePlatform dbPlatform, DBTableInfo.Type type, java.lang.String schema, java.lang.String tableName, java.lang.String sql, java.util.List<DBColInfo> columns, java.util.List<DBForeignKeyInfo> importedFKInfo, java.util.List<DBForeignKeyInfo> exportedFKInfo, java.util.List<DBConstraintInfo> uniqueConstraints, java.util.List<DBIndexInfo> indexInfo, java.util.List<DBTriggerInfo> triggerInfo, java.util.List<java.lang.String> primaryKeyColumns)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DBTableInfoImpl
copy()
Creates a duplicate copy of thisDBTableInfo
instance.static DBTableInfoImpl
create(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName, DBTableInfo.Type type, java.util.List<DBColInfo> columns, java.util.List<java.lang.String> primaryKeyColumns, java.lang.String sql)
CreatesDBTableInfo
instance with limited information.boolean
equals(java.lang.Object obj)
DBConstraintInfo
findUniqueConstraintNameForColumns(java.lang.String[] columnNames)
Retrieves constraint name for the named columns.static DBTableInfoImpl
forTable(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName, java.util.List<DBColInfo> columns, java.util.List<DBForeignKeyInfo> importedFKInfo, java.util.List<DBForeignKeyInfo> exportedFKInfo, java.util.List<DBConstraintInfo> uniqueConstraints, java.util.List<DBIndexInfo> indexInfo, java.util.List<DBTriggerInfo> triggerInfo, java.util.List<java.lang.String> primaryKeyColumns)
static DBTableInfoImpl
forTableLazy(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName)
static DBTableInfoImpl
forView(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String viewName, java.lang.String sql, java.util.List<DBColInfo> columns)
DBColInfo
getColumn(java.lang.String columnName)
Finds aDBColInfo
by its name.java.util.List<DBColInfo>
getColumns()
Getter for property columns.java.util.List<DBForeignKeyInfo>
getExportedFKInfo()
Get the foreign keys that involve this table but are defined in a foreign key constraint definition that is defined in another table (though possibly this table).java.util.List<DBForeignKeyInfo>
getImportedFKInfo()
Get the foreign keys that this table defines.java.util.List<DBIndexInfo>
getIndexInfo()
java.lang.String
getName()
Gets the name of the database artefact represented by thisDBTableInfo
.java.util.List<java.lang.String>
getPrimaryKeyColumns()
Get the value of primary key columns for the table.java.lang.String
getSchema()
Gets the database schema name of the associated artefact.java.lang.String
getSQL()
Getter for SQL that defines this view if it is a view, otherwise null.java.util.List<DBTriggerInfo>
getTriggerInfo()
DBTableInfo.Type
getType()
Gets the type of thisDBTableInfo
instance.java.util.List<DBConstraintInfo>
getUniqueConstraints()
int
hashCode()
boolean
isReadOnly()
Determines whether this database artifact allows modifications.java.lang.String
schemaPlusTable()
Gets the fully qualified name of the underlying database artifact.java.lang.String
toString()
DBTableInfo
updateColumns(java.util.List<DBColInfo> cols)
DBTableInfo
updateExportedForeignKeys(java.util.List<DBForeignKeyInfo> fkKeys)
DBTableInfo
updateImportedForeignKeys(java.util.List<DBForeignKeyInfo> pkKeys)
DBTableInfo
updateIndexInfos(java.util.List<DBIndexInfo> indexes)
DBTableInfo
updateUniqueConstraintInfos(java.util.List<DBConstraintInfo> constraints)
-
-
-
Constructor Detail
-
DBTableInfoImpl
protected DBTableInfoImpl()
-
DBTableInfoImpl
protected DBTableInfoImpl(DatabasePlatform dbPlatform, DBTableInfo.Type type, java.lang.String schema, java.lang.String tableName, java.lang.String sql, java.util.List<DBColInfo> columns, java.util.List<DBForeignKeyInfo> importedFKInfo, java.util.List<DBForeignKeyInfo> exportedFKInfo, java.util.List<DBConstraintInfo> uniqueConstraints, java.util.List<DBIndexInfo> indexInfo, java.util.List<DBTriggerInfo> triggerInfo, java.util.List<java.lang.String> primaryKeyColumns)
-
-
Method Detail
-
copy
public DBTableInfoImpl copy()
Description copied from interface:DBTableInfo
Creates a duplicate copy of thisDBTableInfo
instance.- Specified by:
copy
in interfaceDBTableInfo
- Returns:
- A new
DBTableInfo
instance.
-
forTable
public static DBTableInfoImpl forTable(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName, java.util.List<DBColInfo> columns, java.util.List<DBForeignKeyInfo> importedFKInfo, java.util.List<DBForeignKeyInfo> exportedFKInfo, java.util.List<DBConstraintInfo> uniqueConstraints, java.util.List<DBIndexInfo> indexInfo, java.util.List<DBTriggerInfo> triggerInfo, java.util.List<java.lang.String> primaryKeyColumns)
-
forTableLazy
public static DBTableInfoImpl forTableLazy(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName)
-
create
public static DBTableInfoImpl create(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String tableName, DBTableInfo.Type type, java.util.List<DBColInfo> columns, java.util.List<java.lang.String> primaryKeyColumns, java.lang.String sql)
CreatesDBTableInfo
instance with limited information.- Parameters:
dbPlatform
- The database platform.schema
- The database schema name.tableName
- The database table name.type
- The type of the createdDBTableInfo
.columns
- The database table columns.primaryKeyColumns
- The columns comprising the primary key.sql
- The SQL select statement definingDBTableInfo.Type.VIEW
andDBTableInfo.Type.INLINE_VIEW
. Can benull
.- Returns:
- The new
DBTableInfo
instance. - Since:
- 16.9.26.0
-
forView
public static DBTableInfoImpl forView(DatabasePlatform dbPlatform, java.lang.String schema, java.lang.String viewName, java.lang.String sql, java.util.List<DBColInfo> columns)
-
getType
public DBTableInfo.Type getType()
Description copied from interface:DBTableInfo
Gets the type of thisDBTableInfo
instance.- Specified by:
getType
in interfaceDBTableInfo
- Returns:
- This
DBTableInfo
's type.
-
getSchema
public java.lang.String getSchema()
Description copied from interface:DBTableInfo
Gets the database schema name of the associated artefact.- Specified by:
getSchema
in interfaceDBTableInfo
- Returns:
- The schema this item belongs to.
-
getName
public java.lang.String getName()
Description copied from interface:DBTableInfo
Gets the name of the database artefact represented by thisDBTableInfo
.- Specified by:
getName
in interfaceDBTableInfo
- Returns:
- The name.
-
schemaPlusTable
public java.lang.String schemaPlusTable()
Description copied from interface:DBTableInfo
Gets the fully qualified name of the underlying database artifact.- Specified by:
schemaPlusTable
in interfaceDBTableInfo
- Returns:
- The concatenated form of
DBTableInfo.getName()
andDBTableInfo.getSchema()
.
-
getSQL
public java.lang.String getSQL()
Getter for SQL that defines this view if it is a view, otherwise null.- Specified by:
getSQL
in interfaceDBTableInfo
- Returns:
- Value of property sql.
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:DBTableInfo
Determines whether this database artifact allows modifications.- Specified by:
isReadOnly
in interfaceDBTableInfo
- Returns:
true
if this database artifact is readonly and cannot be modified.
-
getColumn
public DBColInfo getColumn(java.lang.String columnName)
Description copied from interface:DBTableInfo
Finds aDBColInfo
by its name. This will search through the columns in thisDBTableInfo
for a column with the required name.- Specified by:
getColumn
in interfaceDBTableInfo
- Parameters:
columnName
- The name of the column to find.- Returns:
- The
DBColInfo
with the required name ornull
if no such column exists.
-
getColumns
public java.util.List<DBColInfo> getColumns()
Getter for property columns.- Specified by:
getColumns
in interfaceDBTableInfo
- Returns:
- Value of property columns.
-
updateColumns
public DBTableInfo updateColumns(java.util.List<DBColInfo> cols)
- Specified by:
updateColumns
in interfaceDBTableInfo
-
findUniqueConstraintNameForColumns
public DBConstraintInfo findUniqueConstraintNameForColumns(java.lang.String[] columnNames)
Retrieves constraint name for the named columns. The method will return name of the unique constraint for the given set of columns. The constraint name may beDatabasePlatform.NAME_PRIMARY_KEY_CONSTRAINT
, which may be handled differently in some databases - for drop, useDatabasePlatform.sqlDropPrimaryConstraint(String, String, String[])
.- Specified by:
findUniqueConstraintNameForColumns
in interfaceDBTableInfo
- Parameters:
columnNames
- DB columns- Returns:
- The constraint, or
null
if there's no unique constraint.
-
getImportedFKInfo
public java.util.List<DBForeignKeyInfo> getImportedFKInfo()
Get the foreign keys that this table defines. e.g. the primary keys of other tables (or possibly this table) that are referred to in a foreign key constraint definition.- Specified by:
getImportedFKInfo
in interfaceDBTableInfo
- Returns:
- A list of foreign keys
-
getExportedFKInfo
public java.util.List<DBForeignKeyInfo> getExportedFKInfo()
Get the foreign keys that involve this table but are defined in a foreign key constraint definition that is defined in another table (though possibly this table). e.g. the keys in this table that are referred to in a foreign key constraint definition somewhere.- Specified by:
getExportedFKInfo
in interfaceDBTableInfo
- Returns:
- A list of foreign keys
-
getUniqueConstraints
public java.util.List<DBConstraintInfo> getUniqueConstraints()
- Specified by:
getUniqueConstraints
in interfaceDBTableInfo
-
updateUniqueConstraintInfos
public DBTableInfo updateUniqueConstraintInfos(java.util.List<DBConstraintInfo> constraints)
- Specified by:
updateUniqueConstraintInfos
in interfaceDBTableInfo
-
updateImportedForeignKeys
public DBTableInfo updateImportedForeignKeys(java.util.List<DBForeignKeyInfo> pkKeys)
- Specified by:
updateImportedForeignKeys
in interfaceDBTableInfo
-
updateExportedForeignKeys
public DBTableInfo updateExportedForeignKeys(java.util.List<DBForeignKeyInfo> fkKeys)
- Specified by:
updateExportedForeignKeys
in interfaceDBTableInfo
-
getIndexInfo
public java.util.List<DBIndexInfo> getIndexInfo()
- Specified by:
getIndexInfo
in interfaceDBTableInfo
-
updateIndexInfos
public DBTableInfo updateIndexInfos(java.util.List<DBIndexInfo> indexes)
- Specified by:
updateIndexInfos
in interfaceDBTableInfo
-
getPrimaryKeyColumns
public java.util.List<java.lang.String> getPrimaryKeyColumns()
Get the value of primary key columns for the table.- Specified by:
getPrimaryKeyColumns
in interfaceDBTableInfo
- Returns:
- The primary key columns for the table in the order that they are defined
-
getTriggerInfo
public java.util.List<DBTriggerInfo> getTriggerInfo()
- Specified by:
getTriggerInfo
in interfaceDBTableInfo
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-