Class DBModelParser

java.lang.Object
org.apache.empire.db.validation.DBModelParser
Direct Known Subclasses:
MSSqlDBModelParser, MySQLDBModelParser, OracleDBModelParser

public class DBModelParser extends Object
  • Field Details

    • log

      protected static final org.slf4j.Logger log
    • catalog

      protected final String catalog
    • schema

      protected final String schema
    • remoteName

      protected final String remoteName
    • remoteDb

      protected DBDatabase remoteDb
    • tableMap

      protected final Map<String,DBRowSet> tableMap
  • Constructor Details

    • DBModelParser

      public DBModelParser(String catalog, String schema)
      Creates a new Model Checker
      Parameters:
      catalog - the catalog
      schema - the schema
  • Method Details

    • getCatalog

      public String getCatalog()
    • getSchema

      public String getSchema()
    • setStandardIdentityColumnName

      public void setStandardIdentityColumnName(String standardIdentityColumnName)
    • setStandardTimestampColumnName

      public void setStandardTimestampColumnName(String standardTimestampColumnName)
    • getDatabase

      public DBDatabase getDatabase()
      Returns the RemoteDatabase Only available after parseModel() is called
      Returns:
      the remote Database
    • parseModel

      public void parseModel(Connection conn)
      This method is used to parse the populate the remote database
      Parameters:
      conn - the connection for retrieving the remote database metadata
    • populateRemoteDatabase

      protected void populateRemoteDatabase(DatabaseMetaData dbMeta) throws SQLException
      Throws:
      SQLException
    • isSystemTable

      protected boolean isSystemTable(String tableName, ResultSet tableMeta)
      Checks if the tableName belongs to a system or hidden table
      Parameters:
      tableName - the table name
      tableMeta - the table meta
      Returns:
      true if the table is hidden or false otherwise
    • collectTablesAndViews

      protected int collectTablesAndViews(DatabaseMetaData dbMeta, String tablePattern) throws SQLException
      collects table and view information from database meta data
      Parameters:
      dbMeta - the database meta data
      tablePattern - the table pattern
      Returns:
      the table and view count
      Throws:
      SQLException - thrown if a database access error occurs
    • collectColumns

      protected int collectColumns(DatabaseMetaData dbMeta) throws SQLException
      collects column information from database meta data for each table
      Parameters:
      dbMeta - the database meta data
      Returns:
      the column count
      Throws:
      SQLException - thrown if a database access error occurs
    • collectColumns

      protected int collectColumns(DatabaseMetaData dbMeta, String tablePattern) throws SQLException
      collects column information from database meta data for whole schema
      Parameters:
      dbMeta - the database meta data
      tablePattern - the table pattern
      Returns:
      the column count
      Throws:
      SQLException - thrown if a database access error occurs
    • collectPrimaryKeys

      protected int collectPrimaryKeys(DatabaseMetaData dbMeta) throws SQLException
      collects primary key information from database meta data
      Parameters:
      dbMeta - the database meta data
      Returns:
      the primary key count
      Throws:
      SQLException - thrown if a database access error occurs
    • collectForeignKeys

      protected int collectForeignKeys(DatabaseMetaData dbMeta) throws SQLException
      collects foreign key information from database meta data
      Parameters:
      dbMeta - the database meta data
      Returns:
      the foreign key count
      Throws:
      SQLException - thrown if a database access error occurs
    • collectForeignKeys

      protected int collectForeignKeys(DatabaseMetaData dbMeta, String tablePattern) throws SQLException
      collects foreign key information from database meta data
      Parameters:
      dbMeta - the database meta data
      tablePattern - the table pattern
      Returns:
      the foreign key count
      Throws:
      SQLException - thrown if a database access error occurs
    • getTables

      protected final Collection<DBRowSet> getTables()
    • getTable

      protected final DBRowSet getTable(String tableName)
    • createRemoteDatabase

      protected DBDatabase createRemoteDatabase()
    • addTable

      protected void addTable(String tableName)
    • addView

      protected void addView(String viewName)
    • addRelation

      protected void addRelation(String relName, DBRelation.DBReference... references)
    • addColumn

      protected DBColumn addColumn(DBRowSet t, ResultSet rs) throws SQLException
      Throws:
      SQLException
    • getColumnSize

      protected double getColumnSize(DataType empireType, ResultSet rs) throws SQLException
      Throws:
      SQLException
    • isColumnRequired

      protected boolean isColumnRequired(ResultSet rs) throws SQLException
      Throws:
      SQLException
    • getColumnDefault

      protected Object getColumnDefault(ResultSet rs) throws SQLException
      Throws:
      SQLException
    • isIdentityColumn

      protected boolean isIdentityColumn(ResultSet rs)
    • isTimestampColumn

      protected boolean isTimestampColumn(ResultSet rs)
    • getEmpireDataType

      protected DataType getEmpireDataType(int sqlType)