it.openutils.migration.generic
Class JdbcColumnBasedConditionalTask

java.lang.Object
  extended by it.openutils.migration.task.setup.BaseDbTask
      extended by it.openutils.migration.task.setup.BaseConditionalTask
          extended by it.openutils.migration.generic.JdbcColumnBasedConditionalTask
All Implemented Interfaces:
DbTask
Direct Known Subclasses:
IfColumnIsNotIdentityConditionalTask, JdbcIfColumnIsNotNullableConditionalTask

public abstract class JdbcColumnBasedConditionalTask
extends BaseConditionalTask

Base conditional task that operates on conditions related to a specific column. This base task takes care of retrieving the column metadata, so that subclasses only need to override checkColumnMetadata().

Version:
$Id: JdbcColumnBasedConditionalTask.java 834 2008-06-11 21:18:57Z fgiust $
Author:
fgiust

Field Summary
protected  java.lang.String catalog
          Catalog name
protected  java.lang.String column
          Column name
protected  java.lang.String schema
          Schema name
 
Fields inherited from class it.openutils.migration.task.setup.BaseConditionalTask
ddl, log, not, scripts, variables
 
Fields inherited from class it.openutils.migration.task.setup.BaseDbTask
description
 
Constructor Summary
JdbcColumnBasedConditionalTask()
           
 
Method Summary
 boolean check(org.springframework.jdbc.core.simple.SimpleJdbcTemplate jdbcTemplate)
          Subclasses need to override this method and provide specific checks.
protected abstract  boolean checkColumnMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)
           Check if a specific condition is met depending on column metadata.
 void setCatalog(java.lang.String catalog)
          Sets the catalog.
 void setColumn(java.lang.String column)
          Sets the column.
 void setSchema(java.lang.String schema)
          Sets the schema.
 
Methods inherited from class it.openutils.migration.task.setup.BaseConditionalTask
execute, executeSingle, getDescription, objectNameFromFileName, performSubstitution, setDdl, setDdlScript, setNot, setScripts
 
Methods inherited from class it.openutils.migration.task.setup.BaseDbTask
setDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

column

protected java.lang.String column
Column name


catalog

protected java.lang.String catalog
Catalog name


schema

protected java.lang.String schema
Schema name

Constructor Detail

JdbcColumnBasedConditionalTask

public JdbcColumnBasedConditionalTask()
Method Detail

setCatalog

public void setCatalog(java.lang.String catalog)
Sets the catalog.

Parameters:
catalog - the catalog to set

setSchema

public void setSchema(java.lang.String schema)
Sets the schema.

Parameters:
schema - the schema to set

setColumn

public void setColumn(java.lang.String column)
Sets the column.

Parameters:
column - the column to set

check

public boolean check(org.springframework.jdbc.core.simple.SimpleJdbcTemplate jdbcTemplate)
Subclasses need to override this method and provide specific checks.

Specified by:
check in class BaseConditionalTask
Parameters:
jdbcTemplate - SimpleJdbcTemplate
Returns:
true if the condition is met

checkColumnMetadata

protected abstract boolean checkColumnMetadata(java.util.Map<java.lang.String,java.lang.Object> metadata)

Check if a specific condition is met depending on column metadata.

Column attributes included in the Map are:
  1. TABLE_CAT String => table catalog (may be null)
  2. TABLE_SCHEM String => table schema (may be null)
  3. TABLE_NAME String => table name
  4. COLUMN_NAME String => column name
  5. DATA_TYPE int => SQL type from java.sql.Types
  6. TYPE_NAME String => Data source dependent type name, for a UDT the type name is fully qualified
  7. COLUMN_SIZE int => column size.
  8. BUFFER_LENGTH is not used.
  9. DECIMAL_DIGITS int => the number of fractional digits. Null is returned for data types where DECIMAL_DIGITS is not applicable.
  10. NUM_PREC_RADIX int => Radix (typically either 10 or 2)
  11. NULLABLE int => is NULL allowed.
    • columnNoNulls - might not allow NULL values
    • columnNullable - definitely allows NULL values
    • columnNullableUnknown - nullability unknown
  12. REMARKS String => comment describing column (may be null)
  13. COLUMN_DEF String => default value for the column, which should be interpreted as a string when the value is enclosed in single quotes (may be null)
  14. SQL_DATA_TYPE int => unused
  15. SQL_DATETIME_SUB int => unused
  16. CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
  17. ORDINAL_POSITION int => index of column in table (starting at 1)
  18. IS_NULLABLE String => ISO rules are used to determine the nullability for a column.
    • YES --- if the parameter can include NULLs
    • NO --- if the parameter cannot include NULLs
    • empty string --- if the nullability for the parameter is unknown
  19. SCOPE_CATLOG String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF)
  20. SCOPE_SCHEMA String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)
  21. SCOPE_TABLE String => table name that this the scope of a reference attribure (null if the DATA_TYPE isn't REF)
  22. SOURCE_DATA_TYPE short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)
  23. IS_AUTOINCREMENT String => Indicates whether this column is auto incremented
    • YES --- if the column is auto incremented
    • NO --- if the column is not auto incremented
    • empty string --- if it cannot be determined whether the column is auto incremented parameter is unknown

Parameters:
metadata - column metadata
Returns:
true if the condition is met


Copyright © 2009 Openmind. All Rights Reserved.