com.ptc.windchill.upgrade.directives
Class ForEachClassNameDbColumn

java.lang.Object
  extended bycom.ptc.windchill.upgrade.directives.ForEachClassNameDbColumn
Direct Known Subclasses:
RenameClassReferencesInColumns

public abstract class ForEachClassNameDbColumn
extends Object

Given a database connection, find all columns containing java classnames and allow an extending class to specify a SQL update statement to be executed on the column.

The columns are determined by looking through the JDBC data for columns whose names contain the string 'CLASSNAME'. Also, additional columns which don't follow this naming convention but which are known to contain java class names are included. Set the property com.ptc.windchill.upgrade.directives.ForEachClassNameDbColumn.verbose=true to see the executed SQL on System.err.


Field Summary
private static String[][] exceptionTableColumns__
           
private  Statement jdbcStatement
           
private static boolean VERBOSE
           
 
Constructor Summary
ForEachClassNameDbColumn()
           
 
Method Summary
private  void assertValidSql(String sql)
          Check that the sql is not null.
 void processAllColumns(Connection db_connection)
          Traverses all relevant columns calling produceSqlForTableColumn for each one, and executes the sql that that method prepares.
private  void processTableColumn(String table_name, String column_name)
          For the specified table and column ask the subclass-defined method produceSqlForTableColumn to prepare a sql statement, check that it is valid and then execute it.
protected abstract  String produceSqlForTableColumn(String table_name, String column_name)
          Called for each relevant column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERBOSE

private static final boolean VERBOSE

exceptionTableColumns__

private static final String[][] exceptionTableColumns__

jdbcStatement

private Statement jdbcStatement
Constructor Detail

ForEachClassNameDbColumn

public ForEachClassNameDbColumn()
Method Detail

processAllColumns

public void processAllColumns(Connection db_connection)
                       throws SQLException
Traverses all relevant columns calling produceSqlForTableColumn for each one, and executes the sql that that method prepares.

Throws:
SQLException - if any SQL error occurs
See Also:
produceSqlForTableColumn(java.lang.String, java.lang.String)

processTableColumn

private void processTableColumn(String table_name,
                                String column_name)
                         throws SQLException
For the specified table and column ask the subclass-defined method produceSqlForTableColumn to prepare a sql statement, check that it is valid and then execute it.

Throws:
SQLException - if any SQL error occurs while executing the SQL generated by the subclass

assertValidSql

private void assertValidSql(String sql)
Check that the sql is not null.


produceSqlForTableColumn

protected abstract String produceSqlForTableColumn(String table_name,
                                                   String column_name)
Called for each relevant column.

Returns:
must always return a valid, non-null SQL