Class GrouperDdlUtils

java.lang.Object
edu.internet2.middleware.grouper.ddl.GrouperDdlUtils

public class GrouperDdlUtils extends Object
  • Field Details

    • isDropBeforeCreate

      public static boolean isDropBeforeCreate
      if we are dropping tables then creating
    • compareFromDbDllVersion

      public static boolean compareFromDbDllVersion
      true to compare ddl from db version to the current java version, false to start over and find all diffs (without deleting existing)
    • internal_printDdlUpdateMessage

      public static boolean internal_printDdlUpdateMessage
      set this to false for testing
  • Constructor Details

    • GrouperDdlUtils

      public GrouperDdlUtils()
  • Method Details

    • ddlVersionBeanThreadLocal

      public static DdlVersionBean ddlVersionBeanThreadLocal()
      Returns:
      the bean
    • ddlVersionBeanThreadLocalAssign

      public static void ddlVersionBeanThreadLocalAssign(DdlVersionBean ddlVersionBean)
      Parameters:
      ddlVersionBean -
    • ddlVersionBeanThreadLocalClear

      public static void ddlVersionBeanThreadLocalClear()
    • databaseType

      public static String databaseType()
      returns mysql, postgres, oracle, or exception
      Returns:
      database type
    • isPostgres

      public static boolean isPostgres()
      see if the config file seems to be postgres
      Returns:
      see if postgres
    • isPostgres

      public static boolean isPostgres(String connectionUrl)
      see if the config file seems to be postgres
      Parameters:
      connectionUrl -
      Returns:
      see if postgres
    • isOracle

      public static boolean isOracle()
      see if the config file seems to be oracle
      Returns:
      see if oracle
    • isOracle

      public static boolean isOracle(String connectionUrl)
      see if the config file seems to be oracle
      Parameters:
      connectionUrl -
      Returns:
      see if oracle
    • isMysql

      public static boolean isMysql()
      see if the config file seems to be mysql
      Returns:
      see if mysql
    • isMysql

      public static boolean isMysql(String connectionUrl)
      see if the config file seems to be mysql
      Parameters:
      connectionUrl -
      Returns:
      see if mysql
    • isSQLServer

      public static boolean isSQLServer()
      see if the config file seems to be sql server
      Returns:
      see if sql server
    • isSQLServer

      public static boolean isSQLServer(String connectionUrl)
      see if the config file seems to be sql server
      Parameters:
      connectionUrl -
      Returns:
      see if sql server
    • okToUseHibernate

      public static boolean okToUseHibernate()
      if we are inside the bootstrap, or if everything is ok, we are good to go
      Returns:
      true if ok
    • retrievePlatform

      public static Platform retrievePlatform()
      retrieve the ddl utils platform
      Returns:
      the platform object
    • retrievePlatform

      public static Platform retrievePlatform(boolean useCache)
      retrieve the ddl utils platform
      Parameters:
      useCache - if we should get from cache if it is available
      Returns:
      the platform object
    • retrievePlatform

      public static Platform retrievePlatform(boolean useCache, String databaseName)
      retrieve the ddl utils platform
      Parameters:
      useCache - if we should get from cache if it is available
      Returns:
      the platform object
    • main

      public static void main(String[] args)
      kick off bootstrap
      Parameters:
      args -
    • bootstrap

      public static void bootstrap(boolean callFromCommandLine, boolean installDefaultGrouperData, boolean promptUser, boolean fromStartup)
      startup the process, if the version table is not there, print out that ddl
      Parameters:
      callFromCommandLine -
      installDefaultGrouperData -
      promptUser - prompt user to see if they really want to do this
    • sqlRun

      public static String sqlRun(File scriptFile, boolean fromUnitTest, boolean printErrorToStdOut)
      run a script file against the default database
      Parameters:
      scriptFile -
      fromUnitTest -
      printErrorToStdOut -
      Returns:
      the output
    • convertUrlToDriverClassIfNeeded

      public static String convertUrlToDriverClassIfNeeded(String connectionUrl, String driverClassName)
      if there is no driver class specified, then try to derive it from the URL
      Parameters:
      connectionUrl -
      driverClassName -
      Returns:
      the driver class
    • convertUrlToQuartzDriverDelegateClass

      public static String convertUrlToQuartzDriverDelegateClass()
      if there is no quartz driver class specified, then try to derive it from the URL
      Parameters:
      connectionUrl -
      driverClassName -
      Returns:
      the driver class
    • convertUrlToHibernateDialectIfNeeded

      public static String convertUrlToHibernateDialectIfNeeded(String connectionUrl, String hibernateDialect)
      if there is no driver class specified, then try to derive it from the URL
      Parameters:
      connectionUrl -
      hibernateDialect -
      Returns:
      the driver class
    • sqlRun

      public static String sqlRun(File scriptFile, String driver, String url, String user, String pass, boolean fromUnitTest, boolean printErrorToStdOut)
      run some sql
      Parameters:
      scriptFile -
      driver -
      url -
      user -
      pass -
      fromUnitTest -
      printErrorToStdOut -
      Returns:
      the output
    • changeDatabase

      public static String changeDatabase(String objectName, DdlUtilsChangeDatabase ddlUtilsChangeDatabase)
       helper method to run custom db ddl, which is more easily testable
       TODO consolidate this code with the bootstrap code in the DdlVersionBean or somewhere
       Here is an example:
       
           GrouperDdlUtils.changeDatabase(GrouperDdl.V1.getObjectName(), new DdlUtilsChangeDatabase() {
       
             public void changeDatabase(DdlVersionBean ddlVersionBean) {
               
               Database database = ddlVersionBean.getDatabase();
               {
                 Table attributesTable = database.findTable(Attribute.TABLE_GROUPER_ATTRIBUTES);
                 Column attributesFieldIdColumn = attributesTable.findColumn(Attribute.COLUMN_FIELD_ID);
                 attributesTable.removeColumn(attributesFieldIdColumn);
               }
               
               {
                 Table membershipsTable = database.findTable(Membership.TABLE_GROUPER_MEMBERSHIPS);
                 Column membershipsFieldIdColumn = membershipsTable.findColumn(Membership.COLUMN_FIELD_ID);
                 membershipsTable.removeColumn(membershipsFieldIdColumn);
               }
               
             }
             
           });
       
       
       
      Parameters:
      objectName - (from enum of ddl utils type)
      ddlUtilsChangeDatabase - is the callback to change the database
      Returns:
      string
    • changeDatabase

      public static String changeDatabase(String objectName, boolean dropViewsConstraintsFirst, boolean runScript, DdlUtilsChangeDatabase ddlUtilsChangeDatabase)
       helper method to run custom db ddl, which is more easily testable
       TODO consolidate this code with the bootstrap code in the DdlVersionBean or somewhere
       Here is an example:
       
           GrouperDdlUtils.changeDatabase(GrouperDdl.V1.getObjectName(), new DdlUtilsChangeDatabase() {
       
             public void changeDatabase(DdlVersionBean ddlVersionBean) {
               
               Database database = ddlVersionBean.getDatabase();
               {
                 Table attributesTable = database.findTable(Attribute.TABLE_GROUPER_ATTRIBUTES);
                 Column attributesFieldIdColumn = attributesTable.findColumn(Attribute.COLUMN_FIELD_ID);
                 attributesTable.removeColumn(attributesFieldIdColumn);
               }
               
               {
                 Table membershipsTable = database.findTable(Membership.TABLE_GROUPER_MEMBERSHIPS);
                 Column membershipsFieldIdColumn = membershipsTable.findColumn(Membership.COLUMN_FIELD_ID);
                 membershipsTable.removeColumn(membershipsFieldIdColumn);
               }
               
             }
             
           });
       
       
       
      Parameters:
      objectName - (from enum of ddl utils type)
      ddlUtilsChangeDatabase - is the callback to change the database
      dropViewsConstraintsFirst -
      runScript -
      Returns:
      string
    • runScriptIfShouldReturnString

      public static String runScriptIfShouldReturnString(String script, boolean runScript, boolean deleteFileAfterwards)
    • runScriptIfShouldReturnString

      public static String runScriptIfShouldReturnString(String connectionName, String script, boolean runScript, boolean deleteFileAfterwards)
    • runScriptFileIfShouldReturnString

      public static String runScriptFileIfShouldReturnString(File scriptFile, boolean runScript)
    • runScriptFileIfShouldReturnString

      public static String runScriptFileIfShouldReturnString(String connectionName, File scriptFile, boolean runScript)
    • runScriptIfShouldAndPrintOutput

      public static void runScriptIfShouldAndPrintOutput(String script, boolean runScript)
    • dropAllForeignKeysScript

      public static void dropAllForeignKeysScript(GrouperDdlUtils.DbMetadataBean dbMetadataBean, DdlVersionBean ddlVersionBean)
      drop all foreign keys (database dependent), and generate the script
      Parameters:
      dbMetadataBean -
      ddlVersionBean -
    • removeAllTables

      public static void removeAllTables(Database database)
      remove all objects, the foreign keys, then the tables
      Parameters:
      database -
    • retrieveHistory

      public static StringBuilder retrieveHistory(String objectName)
      find history for a certain object name
      Parameters:
      objectName -
      Returns:
      the history or new stringbuilder if none available
    • retieveVersion

      public static DdlVersionable retieveVersion(String objectName, int version)
      retrieve a version of a ddl object versionable
      Parameters:
      objectName -
      version -
      Returns:
      the ddl versionable
    • retrieveDdlJavaVersion

      public static int retrieveDdlJavaVersion(String objectName)
      get the version of a ddl object in the DB
      Parameters:
      objectName -
      Returns:
      the version or -1 if not in the DB
    • retrieveDdlEnum

      public static Class<Enum> retrieveDdlEnum(String objectName)
      the relationship between object name and the enum is as follows. If the object name is "Grouper", then the enum is edu.internet2.middleware.grouper.ddl.GrouperDdl
      Parameters:
      objectName -
      Returns:
      the enum
    • ddlutilsDropViewIfExists

      public static void ddlutilsDropViewIfExists(DdlVersionBean ddlVersionBean, String viewName, boolean falseIfDropBeforeCreate)
      drop a view if it is detected as existing
      Parameters:
      ddlVersionBean -
      viewName -
      falseIfDropBeforeCreate -
    • ddlutilsBackupTable

      public static void ddlutilsBackupTable(DdlVersionBean ddlVersionBean, String tableName, String backupTableName)
      backup a table into another table (which should not exist)
      Parameters:
      ddlVersionBean -
      tableName -
      backupTableName -
    • ddlutilsCreateOrReplaceView

      public static void ddlutilsCreateOrReplaceView(DdlVersionBean ddlVersionBean, String viewName, String viewComment, Set<String> aliases, Set<String> columnComments, String sql)
      add a view if the DB supports it
      Parameters:
      ddlVersionBean -
      viewName -
      viewComment -
      aliases -
      columnComments -
      sql - should not have a semicolon at end
    • ddlutilsTableComment

      public static void ddlutilsTableComment(DdlVersionBean ddlVersionBean, String tableName, String tableComment)
      add a table comment if the DB supports it
      Parameters:
      ddlVersionBean -
      tableName -
      tableComment -
    • ddlutilsViewComment

      public static void ddlutilsViewComment(DdlVersionBean ddlVersionBean, String viewName, String tableComment)
      add a view comment if the DB supports it
      Parameters:
      ddlVersionBean -
      viewName -
      tableComment -
    • ddlutilsColumnComment

      public static void ddlutilsColumnComment(DdlVersionBean ddlVersionBean, String objectName, String columnName, String comment)
       add a table or view column comment if the DB supports it
         COMMENT ON COLUMN zip_code.zip_code IS '5 Digit Zip Code';
       
      Parameters:
      ddlVersionBean -
      objectName -
      comment -
      columnName -
    • supportsComments

      public static boolean supportsComments(DdlVersionBean ddlVersionBean)
      if supports comments
      Parameters:
      ddlVersionBean -
      Returns:
      true if supports comments
    • retrieveObjectNames

      public static List<String> retrieveObjectNames()
      get the object names from the
      Returns:
      the list of object names
    • retrieveDdlDbVersion

      public static int retrieveDdlDbVersion(String objectName)
      get the version of a ddl object in the DB
      Parameters:
      objectName -
      Returns:
      the version or -1 if not in the DB
    • retrieveDdlByIdFromDatabase

      public static Hib3GrouperDdl retrieveDdlByIdFromDatabase(String id)
      Parameters:
      id -
      Returns:
      the ddl
    • deleteDdlById

      public static void deleteDdlById(String id)
      Parameters:
      id -
    • deleteUtfDdls

      public static void deleteUtfDdls()
      delete all utf ddls
    • retrieveDdlByNameFromDatabase

      public static Hib3GrouperDdl retrieveDdlByNameFromDatabase(String objectName)
      retrieve a DDL by name
      Parameters:
      objectName -
      Returns:
      the ddl or null
    • storeAndReadUtfString

      public static Hib3GrouperDdl storeAndReadUtfString(String someUtfString, String id, String name)
      store and read a utf string, but dont commit it so its doesnt stay in the database
      Parameters:
      someUtfString -
      id -
      name -
      Returns:
      the ddl if it is found
    • storeDdl

      public static Hib3GrouperDdl storeDdl(HibernateSession hibernateSession, String id, String name, String someUtfString)
      Parameters:
      someUtfString -
      id -
      name -
      hibernateSession -
      Returns:
      the object
    • retrieveDdlsFromDb

      public static List<Hib3GrouperDdl> retrieveDdlsFromDb()
      get all the ddls, put grouper at the front
      Returns:
      the ddls
    • findScriptOverrideDatabase

      public static String findScriptOverrideDatabase()
    • findScriptOverrideDatabase

      public static String findScriptOverrideDatabase(String connectionName)
    • findScriptOverride

      public static String findScriptOverride(DdlVersionable dbObjectVersion, String dbname)
       File name must be objectName.V#.dbname.sql
       e.g. Grouper.5.oracle10.sql
       
       The dbname must be a valid ddlutils dbname:
       axion, cloudscape, db2, db2v8, derby, firebird, interbase, maxdb, mckoi, 
       mssql, mysql, mysql5, oracle, oracle10, oracle9, postgresql, sapdb, sybase, sybasease15
      
       Also the following catchalls are acceptable: oracleall, mysqlall, db2all, sybaseall
       
      Parameters:
      dbObjectVersion - e.g. Grouper or GrouperLoader
      dbname - e.g. oracle10 or mysql5
      Returns:
      the script or blank if it is not found
    • findScriptOverride

      public static String findScriptOverride(String objectName, int version, String dbNameExact)
       get an override file (exact, dont look for the all ones like oracleall)
       File name must be objectName.V#.dbname.sql
       e.g. Grouper.5.oracle10.sql
       
       
      Parameters:
      objectName -
      version -
      dbNameExact -
      Returns:
      the script or null if none found
    • versionIntFromEnum

      public static int versionIntFromEnum(Enum ddlVersion)
      find a version from an enum version int
      Parameters:
      ddlVersion -
      Returns:
      the version
    • objectName

      public static String objectName(Enum dbObjectVersion)
      find the object name from the db object version
      Parameters:
      dbObjectVersion -
      Returns:
      the object name
    • upgradeDatabaseVersion

      public static void upgradeDatabaseVersion(Database baseVersion, Database oldVersion, int baseDatabaseVersion, String objectName, int upgradeToVersion, StringBuilder additionalScripts, StringBuilder fullScript, Platform platform, Connection connection, String schema, SqlBuilder sqlBuilder)
      get a database object of a certain version based on the existing database, and tack on all the enums up to the version we want (if any)
      Parameters:
      baseVersion -
      oldVersion - old version if there is one, null if not
      baseDatabaseVersion -
      objectName -
      upgradeToVersion - eventual upgrade version
      additionalScripts -
      fullScript - so far
      platform -
      connection -
      schema -
      sqlBuilder -
    • upgradeDatabaseVersion

      public static void upgradeDatabaseVersion(Database baseVersion, Database oldVersion, int baseDatabaseVersion, String objectName, int upgradeToVersion, StringBuilder additionalScripts, StringBuilder fullScript, Platform platform, Connection connection, String schema, SqlBuilder sqlBuilder, GrouperDdlCompareResult grouperDdlCompareResult)
      get a database object of a certain version based on the existing database, and tack on all the enums up to the version we want (if any)
      Parameters:
      baseVersion -
      oldVersion - old version if there is one, null if not
      baseDatabaseVersion -
      objectName -
      upgradeToVersion - eventual upgrade version
      additionalScripts -
      fullScript - so far
      platform -
      connection -
      schema -
      sqlBuilder -
    • ddlutilsFindOrCreateTable

      public static Table ddlutilsFindOrCreateTable(Database database, String tableName)
      find or create table
      Parameters:
      database -
      tableName -
      Returns:
      the table
    • autoDdl2_5orAbove

      public static boolean autoDdl2_5orAbove()
    • autoDdlFor

      public static boolean autoDdlFor(GrouperVersion grouperVersion)
    • ddlutilsFindOrCreateIndex

      public static Index ddlutilsFindOrCreateIndex(Database database, String tableName, String indexName, boolean unique, String... columnNames)
      add an index on a table. drop a misnamed or a misuniqued index which is existing
      Parameters:
      database -
      tableName -
      indexName -
      unique -
      columnNames -
      Returns:
      the index which is the new one, or existing one if it already exists, or null if a custom index
    • columnNamesWithoutMaxLength

      public static Object[] columnNamesWithoutMaxLength(String[] columnNamesWithMaxLength)
       input: col1, col2, col3(40), col4
       output:
       object[]
         string[]: col1, col2, col3, col4
         integer[]: null, null, 40, null
       
      return the string array of column names and the Integer[] of max lengths
      Parameters:
      columnNamesWithMaxLength -
      Returns:
      the array of arrays
    • assertIndexHasColumn

      public static boolean assertIndexHasColumn(String tableName, String indexName, String columnName)
      see if an index has a column, if index isnt there its an exception
      Parameters:
      tableName -
      indexName -
      columnName -
      Returns:
      true or false
    • assertIndexExists

      public static boolean assertIndexExists(String tableName, String indexName)
      see if an index has a column, if index isnt there its an exception
      Parameters:
      tableName -
      indexName -
      columnName -
      Returns:
      true or false
    • assertForeignKeyExists

      public static boolean assertForeignKeyExists(String tableName, String foreignKeyName)
      see if an foreign key with the given name exists
      Parameters:
      tableName -
      foreignKey -
      Returns:
      true or false
    • assertPrimaryKeyExists

      public static boolean assertPrimaryKeyExists(String tableName)
      See if table has a primary key
      Parameters:
      tableName -
      Returns:
      true or false
    • ddlutilsFindIndex

      public static Index ddlutilsFindIndex(Database database, String tableName, String indexName)
      add an index on a table. drop a misnamed or a misuniqued index which is existing
      Parameters:
      database -
      ddlVersionBean - can be null unless custom script
      tableName -
      indexName -
      customScript - use this script to create the index, not ddlutils
      unique -
      columnNames - or column names with max length
      Returns:
      the index which is the new one, or existing one if it already exists, or null if a custom index
    • ddlutilsForeignKeyExists

      public static ForeignKey ddlutilsForeignKeyExists(Database database, String tableName, String foreignKey)
    • ddlutilsFindOrCreateIndex

      public static Index ddlutilsFindOrCreateIndex(Database database, DdlVersionBean ddlVersionBean, String tableName, String indexName, String customScript, boolean unique, String... columnNames)
      add an index on a table. drop a misnamed or a misuniqued index which is existing
      Parameters:
      database -
      ddlVersionBean - can be null unless custom script
      tableName -
      indexName -
      customScript - use this script to create the index, not ddlutils
      unique -
      columnNames - or column names with max length
      Returns:
      the index which is the new one, or existing one if it already exists, or null if a custom index
    • ddlutilsFindOrCreateForeignKey

      public static ForeignKey ddlutilsFindOrCreateForeignKey(Database database, String tableName, String foreignKeyName, String foreignTableName, String localColumnName, String foreignColumnName)
      add a foreign key on a table. drop a misnamed foreign key which is existing
      Parameters:
      database -
      tableName -
      foreignKeyName -
      foreignTableName -
      localColumnName -
      foreignColumnName -
      Returns:
      the foreign key which is the new one, or existing one if it already exists
    • ddlutilsFindOrCreateForeignKey

      public static ForeignKey ddlutilsFindOrCreateForeignKey(Database database, String tableName, String foreignKeyName, String foreignTableName, List<String> localColumnNames, List<String> foreignColumnNames)
      add a foreign key on a table. drop a misnamed foreign key which is existing
      Parameters:
      database -
      tableName -
      foreignKeyName -
      foreignTableName -
      localColumnNames -
      foreignColumnNames -
      Returns:
      the foreign key which is the new one, or existing one if it already exists
    • dropAllForeignKeys

      public static void dropAllForeignKeys(Database database)
      drop all foreign keys from a ddlutils database object
      Parameters:
      database -
    • ddlutilsFindTable

      public static Table ddlutilsFindTable(Database database, String tableName, boolean exceptionOnNotFound)
      find table, if not exist, throw exception
      Parameters:
      database -
      tableName -
      exceptionOnNotFound -
      Returns:
      the table
    • ddlutilsFindColumn

      public static Column ddlutilsFindColumn(Database database, String tableName, String columnName, boolean exceptionIfNotFound)
      find table, if not exist, throw exception
      Parameters:
      database -
      tableName -
      columnName -
      exceptionIfNotFound -
      Returns:
      the table
    • ddlutilsFindColumn

      public static Column ddlutilsFindColumn(Table table, String columnName, boolean exceptionOnNotFound)
      find column, if not exist, throw exception
      Parameters:
      table - table to get column from
      columnName - column name of column (case insensitive)
      exceptionOnNotFound -
      Returns:
      the column
    • ddlutilsFindOrCreateColumn

      public static Column ddlutilsFindOrCreateColumn(Table table, String columnName, int typeCode, String size, boolean primaryKey, boolean required)
      find or create column with various properties
      Parameters:
      table -
      columnName -
      typeCode - from java.sql.Types
      size - string, can be a simple int, or comma separated, see ddlutils docs
      primaryKey - this should only be true for new tables
      required - this should probably only be true for new tables (since ddlutils will copy to temp table)
      Returns:
      the column
    • ddlutilsFindOrCreateColumn

      public static Column ddlutilsFindOrCreateColumn(Table table, String columnName, int typeCode, String size, boolean primaryKey, boolean required, String defaultValue)
      find or create column with various properties
      Parameters:
      table -
      columnName -
      typeCode - from java.sql.Types
      size - string, can be a simple int, or comma separated, see ddlutils docs
      primaryKey - this should only be true for new tables
      required - this should probably only be true for new tables (since ddlutils will copy to temp table)
      defaultValue - is null for none, or something for default value
      Returns:
      the column
    • ddlutilsFixSizeColumn

      public static Column ddlutilsFixSizeColumn(Table table, String columnName, int typeCode, String size, boolean primaryKey, boolean required)
      find or create column with various properties
      Parameters:
      table -
      columnName -
      typeCode - from java.sql.Types
      size - string, can be a simple int, or comma separated, see ddlutils docs
      primaryKey - this should only be true for new tables
      required - this should probably only be true for new tables (since ddlutils will copy to temp table)
      Returns:
      the column
    • ddlutilsFixSizeColumn

      public static Column ddlutilsFixSizeColumn(Table table, String columnName, int typeCode, String size, boolean primaryKey, boolean required, String defaultValue)
      find or create column with various properties
      Parameters:
      table -
      columnName -
      typeCode - from java.sql.Types
      size - string, can be a simple int, or comma separated, see ddlutils docs
      primaryKey - this should only be true for new tables
      required - this should probably only be true for new tables (since ddlutils will copy to temp table)
      defaultValue - is null for none, or something for default value
      Returns:
      the column
    • ddlutilsDropColumn

      public static void ddlutilsDropColumn(Database database, String tableName, String columnName, DdlVersionBean ddlVersionBean)
      find and drop a column if it is there. If table not there, thats ok also drop all related indexes
      Parameters:
      database -
      tableName -
      ddlVersionBean -
      columnName -
    • ddlutilsDropTable

      public static void ddlutilsDropTable(DdlVersionBean ddlVersionBean, String tableName, boolean falseIfDropBeforeCreate)
      find and drop a table if it is there
      Parameters:
      ddlVersionBean -
      tableName -
      falseIfDropBeforeCreate -
    • ddlutilsDropColumn

      public static void ddlutilsDropColumn(Table table, String columnName, DdlVersionBean ddlVersionBean)
      find and drop a column if it is there also drop all related indexes
      Parameters:
      table -
      columnName -
      ddlVersionBean -
    • ddlutilsDropIndexes

      public static void ddlutilsDropIndexes(Table table, String columnName)
      drop all indexes by column name (e.g. if removing column)
      Parameters:
      table -
      columnName -
    • assertTablesThere

      public static boolean assertTablesThere(DdlVersionBean ddlVersionBean, boolean expectRecords, boolean expectTrue)
      see if tables are there (at least the grouper groups one)
      Parameters:
      ddlVersionBean -
      expectRecords -
      expectTrue - pritn exception if expecting true
      Returns:
      true if expect records, and records there. false if records not there. exception if exception is thrown and expect true.false if exception and not expect true
    • assertTablesThere

      public static boolean assertTablesThere(DdlVersionBean ddlVersionBean, boolean expectRecords, boolean expectTrue, String tableName, boolean falseIfDropBeforeCreate)
      see if tables are there (at least the grouper groups one)
      Parameters:
      ddlVersionBean -
      expectRecords -
      expectTrue - pritn exception if expecting true
      tableName -
      falseIfDropBeforeCreate -
      Returns:
      true if expect records, and records there. false if records not there. exception if exception is thrown and expect true.false if exception and not expect true
    • assertColumnThere

      public static boolean assertColumnThere(boolean expectTrue, String tableName, String columnName)
      see if tables are there (at least the grouper groups one)
      Parameters:
      expectTrue - what the expected outcome is
      tableName -
      columnName -
      Returns:
      true if everything ok, false if not
    • assertTableThere

      public static boolean assertTableThere(boolean expectTrue, String tableName)
      see if table is there
      Parameters:
      expectTrue - throw exception if expecting true and not there or vice versa
      tableName -
      columnName -
      Returns:
      true if everything ok, false if not
    • tableExists

      public static boolean tableExists(String tableName)
      see if tables are there (at least the grouper groups one)
      Parameters:
      tableName -
      Returns:
      true if everything ok, false if not
    • findDbMetadataBean

      public static GrouperDdlUtils.DbMetadataBean findDbMetadataBean(DdlVersionable ddlVersionable)
      find the correct metadata for the DB
      Parameters:
      ddlVersionable -
      Returns:
      the metadatabean
    • sqlConcatenation

      public static String sqlConcatenation(String field1, String field2, String separator)
      Returns the sql to concatenate these two fields separated by the separator
      Parameters:
      field1 -
      field2 -
      separator -
      Returns:
      sql for concatenation
    • sqlConcatenation

      public static String sqlConcatenation(String field1, String field2)
      Returns the sql to concatenate these two fields separated by the separator
      Parameters:
      field1 -
      field2 -
      Returns:
      sql for concatenation
    • getTableCount

      public static int getTableCount(String tableName, boolean exceptionIfTableDoesNotExist)
      Get the number of records in a table
      Parameters:
      tableName -
      exceptionIfTableDoesNotExist -
      Returns:
      count
    • isColumnNullable

      public static boolean isColumnNullable(String tableName, String columnName, String queryColumnName, String queryColumnValue)
      Checks if the columnName in the given tableName is allowed to be null.
      Parameters:
      tableName -
      columnName -
      queryColumnName -
      queryColumnValue -
      Returns:
    • isColumnNullable

      public static boolean isColumnNullable(String tableName, String columnName, String queryColumnName, long queryColumnValue)
      Checks if the columnName in the given tableName is allowed to be null.
      Parameters:
      tableName -
      columnName -
      queryColumnName -
      queryColumnValue -
      Returns:
    • getColumnType

      public static int getColumnType(String tableName, String columnName)
      Returns the java.sql.Types value for the column -5 is bigint. 93 is timestamp. 2 is numeric (number in Oracle).
      Parameters:
      tableName -
      columnName -
      Returns:
    • doesConstraintExistOracle

      public static boolean doesConstraintExistOracle(String constraintName)
    • doesFunctionExistOracle

      public static boolean doesFunctionExistOracle(String functionName)