com.im.commons.db 5.9.2

com.im.commons.db.ddl
Class DBItemsCache

java.lang.Object
  extended by com.im.commons.db.ddl.DBItemsCache

public final class DBItemsCache
extends 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.


Constructor Summary
DBItemsCache(String defaultSchema)
           
 
Method Summary
 TableSetInfo addTableSetInfo(TableSetInfo item)
          Add a new item to the cache.
 DBItemsCache clone()
           
 boolean containsTableSetInfo(String schemaPlusTable)
           
 boolean containsTableSetInfo(String dbSchemaName, String table)
           
 void dump(StringBuilder b)
          Generate a human readable description of current contents and append it to the StringBuilder.
 TableSetInfo findTableSetInfoForTable(String schemaPlusTable)
           
 TableSetInfo findTableSetInfoForTable(String dbSchemaName, String table)
           
 String[] getAllSchemaPlusTableNames(boolean onlyMasterTable)
           
 String[] getAllSchemaPlusTableNames(String dbSchemaName, boolean onlyMasterTable)
          Same as the #getAllTableNames(String) method, but returns the schema qualified table names.
 String[] getAllSchemaPlusViewNames()
           
 String[] getAllSchemaPlusViewNames(String dbSchemaName, boolean onlyMasterTable)
          Same as the #getAllTableNames(String) method, but returns the schema qualified view names.
 List<String> getAllSchemas()
          Get all the schemas that are accessible to the db user.
 String[] getAllTableNames(String dbSchemaName, boolean onlyMasterTable)
          Get the names of the actual physical tables known to this cache.
 String[] getAllViewNames(String dbSchemaName, boolean onlyMasterTable)
          Get the names of the views known to this cache.
 SchemaQualifiedName[] getConstraintNames()
           
 String getDefaultSchema()
          Get the value of defaultSchema.
 Set<String> getPropertyTableNames()
          Get the schema qualified names of all property tables that we know about.
 Set<String> getPropertyTableNamesForSchema(String dbSchemaName)
          Get the non-qualified names of all property tables that we know about in the specified schemas.
 DBTableInfo getTableInfo(String schemaPlusTable)
           
 DBTableInfo getTableInfo(String schema, String table)
           
 Set<String> getTablesAssociatedWithPropertyTable(String propTableName)
          Get the schema qualified table names (e.g.
 TableSetInfo getTableSetInfo(SchemaQualifiedName table)
           
 TableSetInfo getTableSetInfo(String schemaPlusTable)
           
 TableSetInfo getTableSetInfo(String dbSchemaName, String table)
           
 List<String> getUsedSchemas()
          Get the schemas that are currently in use.
 TableSetInfo removeTableSetInfo(String schemaPlusTable)
           
 TableSetInfo removeTableSetInfo(String dbSchemaName, String table)
           
 TableSetInfo removeTableSetInfo(TableSetInfo item)
          Add a new item to the cache.
 void setAllSchemas(List<String> schemas)
          Set all schemas accessible to the db user.
 void setUsedSchemas(List<String> schemas)
          Sets used schemas.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBItemsCache

public DBItemsCache(String defaultSchema)
Method Detail

getAllSchemas

public List<String> getAllSchemas()
Get all the schemas that are accessible to the db user.

Returns:
All user accessible schemas

setAllSchemas

public void setAllSchemas(List<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 List<String> getUsedSchemas()
Get the schemas that are currently in use.

Returns:
The schemas currently in use

setUsedSchemas

public void setUsedSchemas(List<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 String getDefaultSchema()
Get the value of defaultSchema.

Returns:
The value of defaultSchema

addTableSetInfo

public TableSetInfo addTableSetInfo(TableSetInfo item)
Add a new item to the cache.

Parameters:
item - a new item
Returns:
The old item, or null

getTableSetInfo

public TableSetInfo getTableSetInfo(String schemaPlusTable)

getTableSetInfo

public TableSetInfo getTableSetInfo(SchemaQualifiedName table)

getTableSetInfo

public TableSetInfo getTableSetInfo(String dbSchemaName,
                                    String table)

containsTableSetInfo

public boolean containsTableSetInfo(String schemaPlusTable)

containsTableSetInfo

public boolean containsTableSetInfo(String dbSchemaName,
                                    String table)

removeTableSetInfo

public TableSetInfo removeTableSetInfo(TableSetInfo item)
Add a new item to the cache.

Parameters:
item - an item to remove
Returns:
The old item, or null

removeTableSetInfo

public TableSetInfo removeTableSetInfo(String schemaPlusTable)

removeTableSetInfo

public TableSetInfo removeTableSetInfo(String dbSchemaName,
                                       String table)

getAllTableNames

public String[] getAllTableNames(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:
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 String[] getAllSchemaPlusTableNames(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 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 String[] getAllViewNames(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:
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 String[] getAllSchemaPlusViewNames(String dbSchemaName,
                                          boolean onlyMasterTable)
Same as the #getAllTableNames(String) method, but returns the schema qualified view names.

Parameters:
dbSchemaName - The name of the database schema
onlyMasterTable - Take only first table from table set info on true.
Returns:
The schema qualified view names

getAllSchemaPlusViewNames

public String[] getAllSchemaPlusViewNames()
Returns:
The schema qualified names of all views in all schemas that we handle.

getTableInfo

public DBTableInfo getTableInfo(String schemaPlusTable)

getTableInfo

public DBTableInfo getTableInfo(String schema,
                                String table)

findTableSetInfoForTable

public TableSetInfo findTableSetInfoForTable(String schemaPlusTable)

findTableSetInfoForTable

public TableSetInfo findTableSetInfoForTable(String dbSchemaName,
                                             String table)

getConstraintNames

public SchemaQualifiedName[] getConstraintNames()

getPropertyTableNamesForSchema

public Set<String> getPropertyTableNamesForSchema(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 Set<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 Set<String> getTablesAssociatedWithPropertyTable(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 class Object

dump

public void dump(StringBuilder b)
Generate a human readable description of current contents and append it to the StringBuilder.


com.im.commons.db 5.9.2