Package mondrian.rolap.aggmatcher
Class JdbcSchema
java.lang.Object
mondrian.rolap.aggmatcher.JdbcSchema
Metadata gleaned from JDBC about the tables and columns in the star schema.
This class is used to scrape a database and store information about its
tables and columnIter.
The structure of this information is as follows: A database has tables. A table has columnIter. A column has one or more usages. A usage might be a column being used as a foreign key or as part of a measure.
Tables are created when calling code requests the set of available
tables. This call getTables()
causes all tables to be loaded.
But a table's columnIter are not loaded until, on a table-by-table basis,
a request is made to get the set of columnIter associated with the table.
Since, the AggTableManager first attempts table name matches (recognition)
most tables do not match, so why load their columnIter.
Of course, as a result, there are a host of methods that can throw an
SQLException
, rats.
- Author:
- Richard M. Emberson
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
class
A table in a database.static enum
Enumeration of ways that an aggregate table can use a column. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Makes a Table from an ResultSet: the table's name is the ResultSet third entry.protected void
clear()
static void
static void
clearDB
(DataSource dataSource) Clears information in a JdbcSchema associated with a DataSource.static String
convertColumnTypeToName
(Set<JdbcSchema.UsageType> columnType) Maps from column type enum to column type name or list of names if the parameter represents more than on usage.void
flushes all star usage referencesReturns the database's catalog name.static Dialect.Datatype
getDatatype
(int javaType) Converts aTypes
value to aDialect.Datatype
.org.apache.logging.log4j.Logger
Returns the Logger.Returns the database's schema name.Gets a table by name.Returns the database's tables.protected SortedMap<String,
JdbcSchema.Table> static boolean
isText
(int javaType) Returns true if the parameter is a java.sql.Type text type.static boolean
isUniqueColumnType
(Set<JdbcSchema.UsageType> columnType) Determine if the parameter represents a single column type, i.e., the column only has one usage.void
load()
Deprecated.void
load
(Util.PropertyList connectInfo) This forces the tables to be loaded.protected void
loadTables
(Util.PropertyList connectInfo) Gets all of the tables (and views) in the database.static JdbcSchema
makeDB
(DataSource dataSource) Creates or retrieves an instance of the JdbcSchema for the given DataSource.void
print
(PrintWriter pw, String prefix) protected void
remove()
static void
removeDB
(DataSource dataSource) Removes a JdbcSchema associated with a DataSource.void
setCatalogName
(String catalog) Sets the database's catalog name.protected void
setDataSource
(DataSource dataSource) void
setSchemaName
(String schema) Sets the database's schema name.toString()
-
Field Details
-
UNKNOWN_COLUMN_USAGE
public static final int UNKNOWN_COLUMN_USAGE- See Also:
-
FOREIGN_KEY_COLUMN_USAGE
public static final int FOREIGN_KEY_COLUMN_USAGE- See Also:
-
MEASURE_COLUMN_USAGE
public static final int MEASURE_COLUMN_USAGE- See Also:
-
LEVEL_COLUMN_USAGE
public static final int LEVEL_COLUMN_USAGE- See Also:
-
FACT_COUNT_COLUMN_USAGE
public static final int FACT_COUNT_COLUMN_USAGE- See Also:
-
IGNORE_COLUMN_USAGE
public static final int IGNORE_COLUMN_USAGE- See Also:
-
UNKNOWN_COLUMN_NAME
- See Also:
-
FOREIGN_KEY_COLUMN_NAME
- See Also:
-
MEASURE_COLUMN_NAME
- See Also:
-
LEVEL_COLUMN_NAME
- See Also:
-
FACT_COUNT_COLUMN_NAME
- See Also:
-
IGNORE_COLUMN_NAME
- See Also:
-
-
Constructor Details
-
JdbcSchema
-
-
Method Details
-
getLogger
public org.apache.logging.log4j.Logger getLogger()Returns the Logger. -
makeDB
Creates or retrieves an instance of the JdbcSchema for the given DataSource.- Parameters:
dataSource
- DataSource- Returns:
- instance of the JdbcSchema for the given DataSource
-
clearDB
Clears information in a JdbcSchema associated with a DataSource.- Parameters:
dataSource
- DataSource
-
removeDB
Removes a JdbcSchema associated with a DataSource.- Parameters:
dataSource
- DataSource
-
isUniqueColumnType
Determine if the parameter represents a single column type, i.e., the column only has one usage.- Parameters:
columnType
- Column types- Returns:
- true if column has only one usage.
-
convertColumnTypeToName
Maps from column type enum to column type name or list of names if the parameter represents more than on usage. -
getDatatype
Converts aTypes
value to aDialect.Datatype
.- Parameters:
javaType
- JDBC type code, as perTypes
- Returns:
- Datatype
-
isText
public static boolean isText(int javaType) Returns true if the parameter is a java.sql.Type text type. -
load
Deprecated.API updated to pass Mondrian connection properties See:load(PropertyList)
- Throws:
SQLException
-
load
This forces the tables to be loaded.- Parameters:
connectInfo
- Mondrian connection properties- Throws:
SQLException
-
clear
protected void clear() -
remove
protected void remove() -
getDataSource
-
setDataSource
-
setSchemaName
Sets the database's schema name.- Parameters:
schema
- Schema name
-
getSchemaName
Returns the database's schema name. -
setCatalogName
Sets the database's catalog name. -
getCatalogName
Returns the database's catalog name. -
getTables
Returns the database's tables. The collection is sorted by table name. -
flushUsages
public void flushUsages()flushes all star usage references -
getTable
Gets a table by name. -
toString
-
print
-
loadTables
Gets all of the tables (and views) in the database. If called a second time, this method is a no-op.- Parameters:
connectInfo
- The Mondrian connection properties- Throws:
SQLException
-
addTable
Makes a Table from an ResultSet: the table's name is the ResultSet third entry.- Parameters:
rs
- Result set- Throws:
SQLException
-
getTablesMap
-
clearAllDBs
public static void clearAllDBs()
-
load(PropertyList)