Package com.im.commons.db.ddl
Class DBItemsCache
- java.lang.Object
-
- com.im.commons.db.ddl.DBItemsCache
-
public final class DBItemsCache extends java.lang.Object
A holder and cache for DB-related items such as TableSetInfo. Provides convenience methods for managing these items. Changing the contents of this cache does NOT cause a change to the database. Modifying the contents of this cache must reflect changes that have already been name to the underlying database.- Author:
- Tim Dudgeon
-
-
Constructor Summary
Constructors Constructor Description DBItemsCache(java.lang.String defaultSchema)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description TableSetInfo
addTableSetInfo(TableSetInfo item)
Adds an item to the cache.DBItemsCache
clone()
void
dump(java.lang.StringBuilder b)
Generate a human readable description of current contents and append it to the StringBuilder.java.lang.String[]
getAllSchemaPlusTableNames(boolean onlyMasterTable)
java.lang.String[]
getAllSchemaPlusTableNames(java.lang.String dbSchemaName, boolean onlyMasterTable)
Same as the #getAllTableNames(String) method, but returns the schema qualified table names.java.lang.String[]
getAllSchemaPlusViewNames()
java.lang.String[]
getAllSchemaPlusViewNames(java.lang.String dbSchemaName, boolean onlyMasterTable)
Same as the #getAllTableNames(String) method, but returns the schema qualified view names.java.util.List<? extends java.lang.String>
getAllSchemas()
Get all the schemas that are accessible to the db user.java.lang.String[]
getAllTableNames(java.lang.String dbSchemaName, boolean onlyMasterTable)
Get the names of the actual physical tables known to this cache.java.lang.String[]
getAllViewNames(java.lang.String dbSchemaName, boolean onlyMasterTable)
Get the names of the views known to this cache.SchemaQualifiedName[]
getConstraintNames()
java.lang.String
getDefaultSchema()
Get the value of defaultSchema.java.util.Set<java.lang.String>
getPropertyTableNames()
Get the schema qualified names of all property tables that we know about.java.util.Set<java.lang.String>
getPropertyTableNamesForSchema(java.lang.String dbSchemaName)
Get the non-qualified names of all property tables that we know about in the specified schemas.DBTableInfo
getTableInfo(java.lang.String schemaPlusTable)
DBTableInfo
getTableInfo(java.lang.String schema, java.lang.String table)
java.util.Set<java.lang.String>
getTablesAssociatedWithPropertyTable(java.lang.String propTableName)
Get the schema qualified table names (e.g.TableSetInfo
getTableSetInfo(SchemaQualifiedName table)
Deprecated.TableSetInfo
getTableSetInfo(java.lang.String schemaPlusTable)
Deprecated.TableSetInfo
getTableSetInfo(java.lang.String dbSchemaName, java.lang.String table)
Deprecated.java.util.List<? extends TableSetInfo>
getTableSetInfos(SchemaQualifiedName table)
java.util.List<? extends java.lang.String>
getUsedSchemas()
Get the schemas that are currently in use.TableSetInfo
removeTableSetInfo(TableSetInfo item)
Removes an item from the cache.void
setAllSchemas(java.util.List<java.lang.String> schemas)
Set all schemas accessible to the db user.void
setUsedSchemas(java.util.List<java.lang.String> schemas)
Sets used schemas.
-
-
-
Method Detail
-
getAllSchemas
public java.util.List<? extends java.lang.String> getAllSchemas()
Get all the schemas that are accessible to the db user.- Returns:
- All user accessible schemas
-
setAllSchemas
public void setAllSchemas(java.util.List<java.lang.String> schemas)
Set all schemas accessible to the db user. This does not ensure changes in tsiCache, you have to ensure initialization of TableSetInfos.- Parameters:
schemas
- The schemas
-
getUsedSchemas
public java.util.List<? extends java.lang.String> getUsedSchemas()
Get the schemas that are currently in use.- Returns:
- The schemas currently in use
-
setUsedSchemas
public void setUsedSchemas(java.util.List<java.lang.String> schemas)
Sets used schemas. This does not ensure changes in tsiCache, you have to ensure initialization of TableSetInfos.- Parameters:
schemas
- The schemas
-
getDefaultSchema
public java.lang.String getDefaultSchema()
Get the value of defaultSchema.- Returns:
- The value of defaultSchema
-
addTableSetInfo
public TableSetInfo addTableSetInfo(TableSetInfo item)
Adds an item to the cache.- Parameters:
item
- an item to add- Returns:
- Previous item with the same primary table name, or
null
.
-
removeTableSetInfo
public TableSetInfo removeTableSetInfo(TableSetInfo item)
Removes an item from the cache.- Parameters:
item
- an item to remove- Returns:
- The item removed or
null
if there was no item with the same primary table name in the cache.
-
getTableSetInfo
@Deprecated public TableSetInfo getTableSetInfo(java.lang.String schemaPlusTable)
Deprecated.
-
getTableSetInfo
@Deprecated public TableSetInfo getTableSetInfo(SchemaQualifiedName table)
Deprecated.
-
getTableSetInfo
@Deprecated public TableSetInfo getTableSetInfo(java.lang.String dbSchemaName, java.lang.String table)
Deprecated.
-
getTableSetInfos
public java.util.List<? extends TableSetInfo> getTableSetInfos(SchemaQualifiedName table)
-
getAllTableNames
public java.lang.String[] getAllTableNames(java.lang.String dbSchemaName, boolean onlyMasterTable)
Get the names of the actual physical tables known to this cache. This will not include views, synonyms etc.- Parameters:
dbSchemaName
- The schema. Must not be a valid schema name known to this cache if the database supports schemas. If the database does not support schemas you must specify null.onlyMasterTable
- Take only first table from table set info on true.- Returns:
- The known table names of the given schema
- Throws:
java.lang.IllegalArgumentException
- If argument is null and the DB supports schemas or if the DB does not support schemas and you specified non-null schema name
-
getAllSchemaPlusTableNames
public java.lang.String[] getAllSchemaPlusTableNames(java.lang.String dbSchemaName, boolean onlyMasterTable)
Same as the #getAllTableNames(String) method, but returns the schema qualified table names.- Parameters:
onlyMasterTable
- Take only first table from table set info on true.dbSchemaName
- The schema name- Returns:
- The schema qualified table name
-
getAllSchemaPlusTableNames
public java.lang.String[] getAllSchemaPlusTableNames(boolean onlyMasterTable)
- Parameters:
onlyMasterTable
- Take only first table from table set info on true.- Returns:
- The schema qualified table names of all tables in all schemas that we handle.
-
getAllViewNames
public java.lang.String[] getAllViewNames(java.lang.String dbSchemaName, boolean onlyMasterTable)
Get the names of the views known to this cache. This will not include tables, synonyms etc.- Parameters:
dbSchemaName
- The schema. Must not be a valid schema name known to this cache if the database supports schemas. If the database does not support schemas you must specify null.onlyMasterTable
- Take only first table from table set info on true.- Returns:
- The known view names of the given schema
- Throws:
java.lang.IllegalArgumentException
- If argument is null and the DB supports schemas or if the DB does not support schemas and you specified non-null schema name
-
getAllSchemaPlusViewNames
public java.lang.String[] getAllSchemaPlusViewNames(java.lang.String dbSchemaName, boolean onlyMasterTable)
Same as the #getAllTableNames(String) method, but returns the schema qualified view names.- Parameters:
dbSchemaName
- The name of the database schemaonlyMasterTable
- Take only first table from table set info on true.- Returns:
- The schema qualified view names
-
getAllSchemaPlusViewNames
public java.lang.String[] getAllSchemaPlusViewNames()
- Returns:
- The schema qualified names of all views in all schemas that we handle.
-
getTableInfo
public DBTableInfo getTableInfo(java.lang.String schemaPlusTable)
-
getTableInfo
public DBTableInfo getTableInfo(java.lang.String schema, java.lang.String table)
-
getConstraintNames
public SchemaQualifiedName[] getConstraintNames()
-
getPropertyTableNamesForSchema
public java.util.Set<java.lang.String> getPropertyTableNamesForSchema(java.lang.String dbSchemaName)
Get the non-qualified names of all property tables that we know about in the specified schemas.- Parameters:
dbSchemaName
- The schema name- Returns:
- The non-qualified names of all property tables
-
getPropertyTableNames
public java.util.Set<java.lang.String> getPropertyTableNames()
Get the schema qualified names of all property tables that we know about.- Returns:
- The schema qualified names of all property tables
-
getTablesAssociatedWithPropertyTable
public java.util.Set<java.lang.String> getTablesAssociatedWithPropertyTable(java.lang.String propTableName)
Get the schema qualified table names (e.g. schema.table) of all Jchem tables associated with the specified property table. For cartridge tables this is the JChem index table.- Parameters:
propTableName
-- Returns:
- The qualified table names of all associated JChem tables
-
clone
public DBItemsCache clone()
- Overrides:
clone
in classjava.lang.Object
-
dump
public void dump(java.lang.StringBuilder b)
Generate a human readable description of current contents and append it to the StringBuilder.
-
-