public class JDBCMetaDataBasedModelElementFinder extends java.lang.Object implements ModelElementFinder
Modifier and Type | Class and Description |
---|---|
static interface |
JDBCMetaDataBasedModelElementFinder.PrivilegedSessionProvider |
Modifier and Type | Field and Description |
---|---|
static JDBCMetaDataBasedModelElementFinder.PrivilegedSessionProvider |
privilegedSessionProvider |
static java.util.Set<java.lang.String> |
TYPES_WITH_LENGTH
Set of sql types (uppercase) not listed in
Types which needs a length argument. |
Constructor and Description |
---|
JDBCMetaDataBasedModelElementFinder() |
Modifier and Type | Method and Description |
---|---|
static int |
filterLength(int length,
int precision,
java.lang.String typeName,
int type,
DBMS dbms,
int origLength)
Filters the length attribute of a column in a DBMS specific way.
|
static int |
filterPrecision(int length,
int precision,
java.lang.String typeName,
int type,
DBMS dbms,
int origLength)
Filters the precision attribute of a column in a DBMS specific way.
|
static java.lang.String |
filterType(java.lang.String sqlType,
int length,
java.lang.String typeName,
int type,
DBMS dbms,
int origLength)
Filters the type attribute of a column in a DBMS specific way.
|
java.util.Collection<Association> |
findAssociations(DataModel dataModel,
java.util.Map<Association,java.lang.String[]> namingSuggestion,
Session session,
ExecutionContext executionContext)
Finds associations by reading the databases meta-data.
|
java.util.List<Column> |
findColumns(Table table,
Session session,
ExecutionContext executionContext)
|
static java.util.Set<java.lang.String> |
findPartitions(Session session,
java.lang.String introspectionSchema) |
java.util.Set<Table> |
findTables(Session session,
ExecutionContext executionContext)
Finds all tables in DB schema.
|
static java.util.List<java.lang.String> |
getCatalogsWithSchemas(Session session)
Finds all catalogs with all schemas in DB.
|
static java.sql.ResultSet |
getColumns(Session session,
java.lang.String schemaPattern,
java.lang.String tableNamePattern,
java.lang.String columnNamePattern,
boolean withCaching,
boolean onlyIfCached,
java.lang.String tableType)
Calls
DatabaseMetaData.getColumns(String, String, String, String) . |
java.util.Map<Pair<Table,Column>,java.lang.String> |
getComments()
Finds comments for all model elements.
|
static java.lang.String |
getDefaultSchema(Session session,
java.lang.String userName)
Gets default schema of DB.
|
static java.lang.String |
getDefaultSchema(Session session,
java.lang.String userName,
java.util.List<java.lang.String> schemaNames)
Gets default schema of DB.
|
static java.sql.ResultSet |
getExportedKeys(Session session,
java.lang.String schema,
java.lang.String table) |
static java.sql.ResultSet |
getImportedKeys(Session session,
java.lang.String schema,
java.lang.String table,
boolean withCaching) |
static java.sql.ResultSet |
getIndexes(Session session,
java.lang.String schemaPattern,
java.lang.String tableNamePattern)
Calls {@link DatabaseMetaData#getIndexInfo(String, String, String, boolean, boolean).
|
static java.sql.ResultSet |
getPrimaryKeys(Session session,
java.lang.String schema,
java.lang.String table,
boolean withCaching) |
static java.sql.ResultSet |
getProcedures(Session session,
java.lang.String schemaPattern,
java.lang.String functionPattern)
Calls
DatabaseMetaData.getProcedures(String, String, String) . |
static java.util.List<java.lang.String> |
getSchemas(Session session,
java.lang.String userName)
Finds all schemas in DB.
|
static java.sql.ResultSet |
getTables(Session session,
java.lang.String schemaPattern,
java.lang.String tableNamePattern,
java.lang.String[] types) |
static void |
resetCaches(Session session) |
static Column |
toColumn(java.sql.ResultSetMetaData metaData,
int i,
Session session) |
java.lang.String |
toString()
Gets description.
|
public static final java.util.Set<java.lang.String> TYPES_WITH_LENGTH
Types
which needs a length argument.public static JDBCMetaDataBasedModelElementFinder.PrivilegedSessionProvider privilegedSessionProvider
public java.util.Collection<Association> findAssociations(DataModel dataModel, java.util.Map<Association,java.lang.String[]> namingSuggestion, Session session, ExecutionContext executionContext) throws java.lang.Exception
findAssociations
in interface ModelElementFinder
session
- the statement executor for executing SQL-statementsdataModel
- model containing already known elementsnamingSuggestion
- to put naming suggestions for associations intojava.lang.Exception
- on each errorpublic static java.sql.ResultSet getImportedKeys(Session session, java.lang.String schema, java.lang.String table, boolean withCaching) throws java.sql.SQLException
java.sql.SQLException
public static java.sql.ResultSet getExportedKeys(Session session, java.lang.String schema, java.lang.String table) throws java.sql.SQLException
java.sql.SQLException
public java.util.Set<Table> findTables(Session session, ExecutionContext executionContext) throws java.lang.Exception
findTables
in interface ModelElementFinder
session
- the statement executor for executing SQL-statementsTable
sjava.lang.Exception
- on each errorpublic static java.util.Set<java.lang.String> findPartitions(Session session, java.lang.String introspectionSchema)
public static java.sql.ResultSet getPrimaryKeys(Session session, java.lang.String schema, java.lang.String table, boolean withCaching) throws java.sql.SQLException
java.sql.SQLException
public static java.sql.ResultSet getTables(Session session, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String[] types) throws java.sql.SQLException
java.sql.SQLException
public java.util.Map<Pair<Table,Column>,java.lang.String> getComments()
getComments
in interface ModelElementFinder
public static java.sql.ResultSet getIndexes(Session session, java.lang.String schemaPattern, java.lang.String tableNamePattern) throws java.sql.SQLException
java.sql.SQLException
public static java.sql.ResultSet getColumns(Session session, java.lang.String schemaPattern, java.lang.String tableNamePattern, java.lang.String columnNamePattern, boolean withCaching, boolean onlyIfCached, java.lang.String tableType) throws java.sql.SQLException
DatabaseMetaData.getColumns(String, String, String, String)
. Uses schemaPattern as catalogPattern on MySQL.withCaching
- java.sql.SQLException
public static java.sql.ResultSet getProcedures(Session session, java.lang.String schemaPattern, java.lang.String functionPattern) throws java.sql.SQLException
DatabaseMetaData.getProcedures(String, String, String)
. Uses schemaPattern as catalogPattern on MySQL.java.sql.SQLException
public static java.util.List<java.lang.String> getSchemas(Session session, java.lang.String userName)
session
- the statement executor for executing SQL-statementsuserName
- schema with this name may be emptypublic static java.util.List<java.lang.String> getCatalogsWithSchemas(Session session)
session
- the statement executor for executing SQL-statementspublic static java.lang.String getDefaultSchema(Session session, java.lang.String userName)
session
- the statement executor for executing SQL-statementsuserName
- schema with this name may be emptypublic static java.lang.String getDefaultSchema(Session session, java.lang.String userName, java.util.List<java.lang.String> schemaNames)
session
- the statement executor for executing SQL-statementsuserName
- schema with this name may be emptypublic java.util.List<Column> findColumns(Table table, Session session, ExecutionContext executionContext) throws java.sql.SQLException
findColumns
in interface ModelElementFinder
table
- the tablesession
- the statement executor for executing SQL-statementsjava.lang.Exception
- on each errorjava.sql.SQLException
public static int filterLength(int length, int precision, java.lang.String typeName, int type, DBMS dbms, int origLength)
length
- the length as given from driverprecision
- the precision as given from drivertype
- the sql typedbms
- the DBMSpublic static int filterPrecision(int length, int precision, java.lang.String typeName, int type, DBMS dbms, int origLength)
length
- the length as given from driverprecision
- type
- the sql typedbms
- the DBMSpublic static java.lang.String filterType(java.lang.String sqlType, int length, java.lang.String typeName, int type, DBMS dbms, int origLength)
length
- the length as given from drivertype
- the sql typedbms
- the DBMSpublic static Column toColumn(java.sql.ResultSetMetaData metaData, int i, Session session) throws java.sql.SQLException
java.sql.SQLException
public static void resetCaches(Session session)
public java.lang.String toString()
toString
in class java.lang.Object