com.ptc.windchill.upgrade.modeldiff
Class CompareSchema

java.lang.Object
  extended bycom.ptc.windchill.upgrade.modeldiff.CompareSchema
All Implemented Interfaces:
WTAttributeNameIfc

public class CompareSchema
extends Object
implements WTAttributeNameIfc

This is an Upgrade tool for comparing Windchill schema. It uses introspection information from the source database metadata (via JDBC standard services) and target codebase to generate an Upgrade Schema and Add Constraints scripts. These scripts may be executed against the source database to alter it's schema to match the target codebase. The tables are allowed to have data in them. A Compare Schema Report is created, summarizing the differences between the persistence model of the source database and the persistence model of the target codebase.


Nested Class Summary
(package private) static class CompareSchema.SetOf2Strings
           
 
Field Summary
(package private)  String ADD_CONSTRAINTS
           
(package private)  String ADD_CONSTRAINTS_REPORTS
           
private  HashSet addedFbiRelatedTriggerNames_
           
(package private)  String BAD_CONNECTION
           
private  String BAD_INIT_VAL
           
(package private)  String BAD_SQL
           
private  String begin_
           
private  int checkPointNumber_
           
private  String CODEBASE
           
(package private)  String COMPARE_SCHEMA
           
 String COMPARE_SCHEMA_ONLY
           
(package private)  String COMPARE_SCHEMA_REPORTS
           
private  CompareSchemaListener compareSchemaListener_
           
private  String CONCLUDE1_NO_E_NO_W
           
private  String CONCLUDE2_NO_E
           
private  String CONCLUDE3_SOFT_ERROR
           
private  String CONCLUDE4_HARD_ERROR
           
private  String CONCLUDE5_CANCELED
           
private  String CONCLUDE6_JAVA_ERROR
           
private  String CONCLUDE7_NO_E_NO_W_CSO
           
private  String CONCLUDE8_NO_E_CSO
           
(package private)  String CONNECT_STRING_DEFAULT
           
(package private)  String CONNECT_STRING_STRING_TRY
           
private  String constraintsActivityName_
           
(package private)  Date dateSQL_
           
(package private)  String dateSQLString_
           
private  Db db_
           
private  String DB_DIR
           
private  String end_
           
private  String END_TEXT
           
private  File file_pac_
           
private  File file_pcs_
           
private  File file_pus_
           
private  File file_rac_
           
private  File file_rcs_
           
private  File file_rus_
           
(package private)  String fileNamePrefix_
           
(package private)  String FIND_REM_END_STREAM
           
(package private)  String FIND_REM_GUI_DISPLAY
           
private  GuiManager guiManager_
           
private  HashSet holdFbiRelatedDbTriggerNames_
           
private  Vector holdPreExistingFbis_
           
(package private)  boolean INCREASE_MAX_BYTES_PER_CHAR
           
 Vector initialValues_
           
(package private)  boolean isCompareSchemaOnly_
           
(package private)  String LINE_SEPARATOR
           
(package private)  String modeledSequencersScript_Name_
           
(package private)  String modeledSequencersScript_RelativePath_
           
private  String newCheckPointActivityName_
           
private  Vector newTableIndicesSqlPostAddFunctions_
           
(package private)  String nonModeledProceduresScript_Name_
           
(package private)  String nonModeledProceduresScript_RelativePath_
           
(package private)  String nonModeledSequencersScript_Name_
           
(package private)  String nonModeledSequencersScript_RelativePath_
           
private  Vector nonModeledTableNames_
           
(package private)  String nonModeledTypesScript_Name_
           
(package private)  String nonModeledTypesScript_RelativePath_
           
(package private)  String NOT_NULL_TEMP_COUNT
           
(package private)  String NOT_NULL_TEST_OUTPUT
           
private  int notNullActivityCount_
           
private  String oldCheckPointActivityName_
           
private  Vector oldTableIndicesSqlPostAddFunctions_
           
private  Output output_
           
(package private)  String primaryKeysScript_Name_
           
private  String REG_FILE
           
(package private)  String REM_END_STREAM
           
(package private)  String REM_GUI_DISPLAY
           
(package private)  String REM_GUI_DISPLAY_A
           
(package private)  String REM_GUI_DISPLAY_As
           
(package private)  String REM_GUI_DISPLAY_S
           
(package private)  String REM_GUI_DISPLAY_Ss
           
private  HashSet replacedFbiRelatedTriggerNames_
           
(package private)  String REPORT_NAME_HTML_SAVE
           
(package private)  String REPORT0_XML
           
(package private)  String REPORT0_XML_LONG
           
private  String REPORT0a_XML
           
private  SimpleDateFormat reportDateLineFormatter_
           
(package private)  String reportDateLineFormatterString_
           
(package private)  String reportHtmlName_
           
private  CompareSchemaReportXml reportXml_
           
private  SchemaResults schemaResults_
           
(package private)  String SCRIPT0_PREFIX
           
(package private)  String SCRIPT0_WORK
           
(package private)  String SCRIPT0_WORK_LONG
           
private  String SCRIPT0a_WORK
           
private  PrintWriter script0Work_
           
(package private)  String SCRIPT1_PREFIX
           
(package private)  String SCRIPT1_WORK
           
(package private)  String SCRIPT1_WORK_LONG
           
private  String SCRIPT1a_WORK
           
private  PrintWriter script1Debug_
           
private  PrintWriter script1Test_
           
private  PrintWriter script1Work_
           
(package private)  String SCRIPT2_PREFIX
           
(package private)  String SCRIPT2_WORK
           
(package private)  String SCRIPT2_WORK_LONG
           
private  String SCRIPT2a_WORK
           
private  PrintWriter script2Debug_
           
private  PrintWriter script2Test_
           
private  PrintWriter script2Work_
           
(package private)  String SCRIPT4_WORK_LONG
           
(package private)  String SEE_LOG
           
(package private)  String SEE_SPOOL
           
private  boolean shortcut_
           
private  String SPOOL0_WORK
           
(package private)  String SPOOL0_WORK_LONG
           
private  String SPOOL1_WORK
           
(package private)  String SPOOL1_WORK_LONG
           
private  String SPOOL2_WORK
           
(package private)  String SPOOL2_WORK_LONG
           
(package private)  String SPOOL3_WORK_LONG
           
(package private)  String SPOOL4_WORK_LONG
           
(package private)  String SPOOL5_WORK_LONG
           
private  Vector sqlUniquenessColumns_
           
private  Vector sqlUniquenessIndices_
           
private  Vector sqlUniquenessTables_
           
(package private)  SimpleDateFormat standardNameDateFormatter_
           
(package private)  String standardNameDateFormatterString_
           
(package private)  String TARGET_MAX_BYTES_PER_CHAR_STRING
           
private  boolean test_
           
(package private)  String TIMEOUT_CONSTRAINTS_STRING_TRY
           
(package private)  String TIMEOUT_DBINACTIVITY_DEFAULT
           
(package private)  String TIMEOUT_DBINACTIVITY_STRING_TRY
           
(package private)  String TIMEOUT_DBTEST_DEFAULT
           
(package private)  String TIMEOUT_DBTEST_STRING
           
(package private)  String TIMEOUT_DBTEST_STRING_TRY
           
private  String[] typeTables
           
private  String[] typeTablesAndViews
           
private  String[] typeViews
           
(package private)  String UNIQUE_TEMP_COLUMN
           
(package private)  String UNIQUE_TEMP_COUNT
           
(package private)  String UNIQUE_TEST_OUTPUT
           
private  int uniqueActivityCount_
           
(package private)  String UPGRADE_SCHEMA
           
(package private)  String UPGRADE_SCHEMA_REPORTS
           
private  String upgradeActivityName_
           
private  UpgradeContext upgradeContext_
           
private  int upgradeSchemaActivityCount_
           
 int width1ColumnName_
           
 int width1IndexName_
           
 int width1TableName_
           
 
Fields inherited from interface wt.util.WTAttributeNameIfc
CREATE_STAMP_NAME, ID_NAME, LATEST_ITERATION, LINK_REFA, LINK_REFB, MODIFY_STAMP_NAME, OBJECT_IDENTIFIER, OID_CLASSNAME, PERSIST_INFO, REF_CLASSNAME, REF_OBJECT_ID, REF_SUFFIX, ROLE_AOBJECT_ROLE, ROLE_BOBJECT_ROLE, ROLEA_CLASSNAME, ROLEA_OBJECT_ID, ROLEA_VERSION_ID, ROLEB_CLASSNAME, ROLEB_OBJECT_ID, ROLEB_VERSION_ID, UPDATE_COUNT_NAME, UPDATE_STAMP_NAME
 
Constructor Summary
CompareSchema()
          Creates a CompareSchema object that is only used to get at the init() constants.
CompareSchema(CancellationMonitor cancellation_monitor)
          Used to support the use of the UpgradeTool GUI.
 
Method Summary
private  void AddFunctionsForIndicesSql()
           
private  void addPreMigrateIndicesSql()
           
private  void AddSequencesSql()
           
private  String addSpaces(String original, String trimmed)
           
private  void addTwoLines(PrintWriter pw, String str1, String str2)
           
private  void AddTypesForIndicesFunctionsSql()
           
private  void alterColumnCharToLonger(AttribsList dbAttribs, AttribsList clDbAttribs)
           
private  void alterColumnCharToShorter(AttribsList dbAttribs, AttribsList clDbAttribs)
           
private  void alterColumnToNotNull(AttribsList dbAttribs, AttribsList clDbAttribs, AttribsList columnDef)
           
private  void alterColumnToNullable(AttribsList dbAttribs, AttribsList clDbAttribs, AttribsList columnDef, Vector sqlForBlobsWithNullReferences)
           
private  void alterColumnType(AttribsList dbAttribs, AttribsList clDbAttribs)
           
private  void buildSql()
           
private  void createDataForUniquenessTest(IndexInfo indexInfo, TableDef tableDef)
          Test the data in a table that has new UNIQUE indices
private  void createForcedTriggerEvaluationScript(String table_name, HashSet columns_that_trigger)
          Generate update statement that will cause database to execute row-level triggers on table for all triggers that are bound to updates of the columns in columns_that_trigger.
private  void createNewFiles()
           
private  void createSqlForANewTable(String class_name, DatabaseInfo dbInfo, StringBuffer table, StringBuffer index, StringBuffer trigger)
          This method exists only until the class \SystemGeneration\src\wt\tools\generation\sql\CreateTable.java can be made to test which DB vendor is being used and provide the table and index creation, together.
private  void deleteOldFiles()
           
private  Vector dropDbFbisUsedInModify(String mod_table_name, Vector dbInds, Vector clDbInds, TableDef tableDef)
           
private  Vector editTableDefForKeptColumns(String table_name, String class_name, Hashtable dbCols, Hashtable clDbCols, TableDef tableDef)
           
private  Vector editTableDefForNewColumns(String table_name, String class_name, Hashtable dbCols, Hashtable clDbCols, TableDef tableDef)
           
private  void editTableDefForRemovedColumns(String table_name, String class_name, Hashtable dbCols, Hashtable clDbCols, TableDef tableDef)
           
 boolean executeFromGui()
          Used to execute this class from a GUI application (with NO options).
 boolean executeFromGui(String option)
          Used to execute this class from a GUI application (with options).
private  void fillTableLists(Hashtable classes, Hashtable dbTables, Hashtable clDbTables, Hashtable dbViews, Hashtable clDbViews)
           
private  String filterOutBlankLines(String x)
          Oracle may pause on zero length or white space lines.
private  String findInitialValue(AttribsList attribsList)
          Determine the initial value for the property with the WTIntrospector.QUERY_NAME as specified by the attribute_list.getQueryName().
private  void generateAddIndexScripts(Vector dbInds, Vector clDbInds, TableDef tableDef)
           
private  void generateAlterTableModifyScript(String table_name, String class_name, TableDef tableDef)
           
private  void generateDropRemovedIndexScript(Vector dbInds, Vector clDbInds, Vector dbFbisUsedInModify)
           
private  void generateTriggerScript(String table_name, String class_name, ClassInfo classInfo, TableDef tableDef)
           
private  Vector getClassDbIndexes(String table_name, Hashtable column_list, BaseTableInfo tableInfo)
           
private  Hashtable getClassDbTableColumns(ClassDbInfo clDbInfo, Hashtable all_types_4)
           
private  Vector getDbIndexes(String table_name)
           
private  Hashtable getDbTableColumns(String table_name)
           
private  Vector getFunctionArguments(String colConstraint)
          Extract the column names.
private  ClassInfo[] getModeledSequences()
           
private  void groupAddedOrReplacedFbiRelatedDbTriggerNames(HashSet trigger_names)
          Add each of the specified trigger names to the collection of added Function Based Index Triggers if it does not exist in the set of trigger names found in the database.
private  Vector indListDiff(Vector h1, Vector h2)
          Return a list of IndexInfo's that are in h1 but not in h2.
private  Vector indListIntersect(Vector h1, Vector h2)
          Return a list of IndexInfo's that are in h1 and in h2.
private  void init()
          Only contains items that are also needed by other Upgrade steps.
private  void initializeNewSmallBlobUsingNotNullOldBlobForInlineBlob(Vector sqlForNewSmallBlobsUsingNotNullOldBlobs)
           
 String interpretConstraint(String colConstraint)
          Returns a part of an SQL command for the UNIQUENESS test.
private  Vector keyDiff(Hashtable h1, Hashtable h2)
          Returns a vector containing keys from h1 which do not exist in h2.
private  Vector keyIntersect(Hashtable h1, Hashtable h2)
          Returns a vector representing keys existing in both h1 and h2.
private  void loadNonModeledTableNames()
          Used to not output non-modeled tables as removed from the other schema.
private  void markIndexes(Vector dbInds, Vector clDbInds)
           
private  boolean nameFound(IndexInfo ind, Vector inds)
           
private  void noCheckPointVerification()
           
private  void processAllPreExistingTables(Hashtable dbTables, Hashtable clDbTables, Hashtable all_types_2)
           
private  void processAllViews(Hashtable clDbViews)
           
private  void processNewTables(Hashtable dbTables, Hashtable clDbTables)
           
private  void processPreExistingTableDefinition(String table_name, ClassDbInfo clDbInfo, Hashtable all_types_3)
          For a pre-existing table, edit columns, add column, and report.
private  void readAllClasses(Vector allClasses, Hashtable dbTables, Hashtable clDbTables, Hashtable dbViews, Hashtable clDbViews)
          Generate a vector of all classes from the target model registry property file.
private  void readAllPackages(Vector allClasses)
          Extracts package name from filled class list.
private  void reAddDbFbisUsedInModify(Vector dbFbisUsedInModify)
          Re-add the PreExisting Function Based Indices disallowed to exist during the MODIFY.
private  void removeNullBlobReferences(Hashtable dbTables)
           
private  void renameBlobColumnsForInlineBlob(Hashtable dbCols, Hashtable clDbCols)
           
private  void replaceNullReferencesForNewlyNullableOldBlobsNotInInlineBlobs(Vector sqlForBlobsWithNullReferences)
           
private  void reportAddedFbiRelatedTriggers()
          Report added Function Based Index Triggers.
private  void reportColumnSmallBlobToLonger(AttribsList dbAttribs, AttribsList clDbAttribs)
           
private  void reportDroppedFbiRelatedTriggers()
          Drop from the database any Function Based Index triggers that are still in the set of trigger names.
private  void reportNewUniqueIndexForPreExistingData()
          If errors, insert a New Unique Indices section.
private  void reportNewViews(Hashtable dbViews, Hashtable clDbViews)
           
private  void reportRemovedTables(Hashtable dbTables, Hashtable clDbTables)
           
private  void reportRemovedViews(Hashtable dbViews, Hashtable clDbViews)
           
private  void reportReplacedFbiRelatedTriggers()
          Report added Function Based Index Triggers.
 void setListener(CompareSchemaListener listener)
          Called by applications that must run this class through a listener.
private  void sleep(int i, String doing)
           
private  String sqlToRemoveNullBlobReference(String tableName, String columnName)
           
private  boolean testedDeleteOfFile(String path_and_file_name)
           
private  void testGuiForACancel()
           
private  void updateGuiActivitySubject(String activity_name, String activity_subject_type, String activity_subject)
           
private  void updateGuiActivitySubject(String activity_name, String activity_subject_type, String activity_subject, int activity_subject_progress_min, int activity_subject_progress_current, int activity_subject_progress_max)
           
private  void updateGuiAsCompleted()
           
private  void updateGuiAtACheckPoint(int next_i, String next)
           
private  void updateGuiWithSchemaResults()
           
private  void verifyMaxBytesPerCharFactor(Hashtable dbTables, Hashtable clDbTables, Hashtable all_types_5)
          Use a column's character width to verify the wt.properties value for wt.db.maxBytesPerChar (default == 1).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

shortcut_

private final boolean shortcut_
See Also:
Constant Field Values

COMPARE_SCHEMA_ONLY

public final String COMPARE_SCHEMA_ONLY
See Also:
Constant Field Values

isCompareSchemaOnly_

boolean isCompareSchemaOnly_

fileNamePrefix_

String fileNamePrefix_

primaryKeysScript_Name_

final String primaryKeysScript_Name_
See Also:
Constant Field Values

nonModeledSequencersScript_RelativePath_

final String nonModeledSequencersScript_RelativePath_
See Also:
Constant Field Values

nonModeledSequencersScript_Name_

final String nonModeledSequencersScript_Name_
See Also:
Constant Field Values

modeledSequencersScript_Name_

final String modeledSequencersScript_Name_
See Also:
Constant Field Values

modeledSequencersScript_RelativePath_

final String modeledSequencersScript_RelativePath_
See Also:
Constant Field Values

nonModeledTypesScript_RelativePath_

final String nonModeledTypesScript_RelativePath_
See Also:
Constant Field Values

nonModeledTypesScript_Name_

final String nonModeledTypesScript_Name_
See Also:
Constant Field Values

nonModeledProceduresScript_RelativePath_

final String nonModeledProceduresScript_RelativePath_
See Also:
Constant Field Values

nonModeledProceduresScript_Name_

final String nonModeledProceduresScript_Name_
See Also:
Constant Field Values

CONNECT_STRING_STRING_TRY

final String CONNECT_STRING_STRING_TRY
See Also:
Constant Field Values

CONNECT_STRING_DEFAULT

final String CONNECT_STRING_DEFAULT

TIMEOUT_DBTEST_STRING_TRY

final String TIMEOUT_DBTEST_STRING_TRY
See Also:
Constant Field Values

TIMEOUT_DBTEST_DEFAULT

final String TIMEOUT_DBTEST_DEFAULT
See Also:
Constant Field Values

TIMEOUT_DBINACTIVITY_STRING_TRY

final String TIMEOUT_DBINACTIVITY_STRING_TRY
See Also:
Constant Field Values

TIMEOUT_DBINACTIVITY_DEFAULT

final String TIMEOUT_DBINACTIVITY_DEFAULT
See Also:
Constant Field Values

TIMEOUT_CONSTRAINTS_STRING_TRY

final String TIMEOUT_CONSTRAINTS_STRING_TRY
See Also:
Constant Field Values

BAD_CONNECTION

final String BAD_CONNECTION
See Also:
Constant Field Values

BAD_SQL

final String BAD_SQL
See Also:
Constant Field Values

SEE_LOG

final String SEE_LOG
See Also:
Constant Field Values

SEE_SPOOL

final String SEE_SPOOL
See Also:
Constant Field Values

CONCLUDE1_NO_E_NO_W

private final String CONCLUDE1_NO_E_NO_W
See Also:
Constant Field Values

CONCLUDE2_NO_E

private final String CONCLUDE2_NO_E
See Also:
Constant Field Values

CONCLUDE3_SOFT_ERROR

private final String CONCLUDE3_SOFT_ERROR
See Also:
Constant Field Values

CONCLUDE4_HARD_ERROR

private final String CONCLUDE4_HARD_ERROR
See Also:
Constant Field Values

CONCLUDE5_CANCELED

private final String CONCLUDE5_CANCELED
See Also:
Constant Field Values

CONCLUDE6_JAVA_ERROR

private final String CONCLUDE6_JAVA_ERROR
See Also:
Constant Field Values

CONCLUDE7_NO_E_NO_W_CSO

private final String CONCLUDE7_NO_E_NO_W_CSO
See Also:
Constant Field Values

CONCLUDE8_NO_E_CSO

private final String CONCLUDE8_NO_E_CSO
See Also:
Constant Field Values

typeTablesAndViews

private final String[] typeTablesAndViews

typeTables

private final String[] typeTables

typeViews

private final String[] typeViews

REG_FILE

private String REG_FILE

CODEBASE

private String CODEBASE

DB_DIR

private String DB_DIR

LINE_SEPARATOR

String LINE_SEPARATOR

COMPARE_SCHEMA

String COMPARE_SCHEMA

UPGRADE_SCHEMA

String UPGRADE_SCHEMA

ADD_CONSTRAINTS

String ADD_CONSTRAINTS

COMPARE_SCHEMA_REPORTS

String COMPARE_SCHEMA_REPORTS

UPGRADE_SCHEMA_REPORTS

String UPGRADE_SCHEMA_REPORTS

ADD_CONSTRAINTS_REPORTS

String ADD_CONSTRAINTS_REPORTS

TARGET_MAX_BYTES_PER_CHAR_STRING

String TARGET_MAX_BYTES_PER_CHAR_STRING

INCREASE_MAX_BYTES_PER_CHAR

boolean INCREASE_MAX_BYTES_PER_CHAR

TIMEOUT_DBTEST_STRING

String TIMEOUT_DBTEST_STRING

REPORT_NAME_HTML_SAVE

String REPORT_NAME_HTML_SAVE

REPORT0_XML_LONG

String REPORT0_XML_LONG

SCRIPT0_WORK_LONG

String SCRIPT0_WORK_LONG

SPOOL0_WORK_LONG

String SPOOL0_WORK_LONG

SCRIPT1_WORK_LONG

String SCRIPT1_WORK_LONG

SPOOL1_WORK_LONG

String SPOOL1_WORK_LONG

SCRIPT2_WORK_LONG

String SCRIPT2_WORK_LONG

SPOOL2_WORK_LONG

String SPOOL2_WORK_LONG

SPOOL3_WORK_LONG

String SPOOL3_WORK_LONG

SCRIPT4_WORK_LONG

String SCRIPT4_WORK_LONG

SPOOL4_WORK_LONG

String SPOOL4_WORK_LONG

SPOOL5_WORK_LONG

String SPOOL5_WORK_LONG

UNIQUE_TEMP_COUNT

final String UNIQUE_TEMP_COUNT
See Also:
Constant Field Values

UNIQUE_TEMP_COLUMN

final String UNIQUE_TEMP_COLUMN
See Also:
Constant Field Values

NOT_NULL_TEMP_COUNT

final String NOT_NULL_TEMP_COUNT
See Also:
Constant Field Values

UNIQUE_TEST_OUTPUT

final String UNIQUE_TEST_OUTPUT
See Also:
Constant Field Values

NOT_NULL_TEST_OUTPUT

final String NOT_NULL_TEST_OUTPUT
See Also:
Constant Field Values

REM_GUI_DISPLAY

final String REM_GUI_DISPLAY
See Also:
Constant Field Values

REM_GUI_DISPLAY_A

final String REM_GUI_DISPLAY_A
See Also:
Constant Field Values

REM_GUI_DISPLAY_S

final String REM_GUI_DISPLAY_S
See Also:
Constant Field Values

REM_GUI_DISPLAY_As

final String REM_GUI_DISPLAY_As
See Also:
Constant Field Values

REM_GUI_DISPLAY_Ss

final String REM_GUI_DISPLAY_Ss
See Also:
Constant Field Values

FIND_REM_GUI_DISPLAY

final String FIND_REM_GUI_DISPLAY
See Also:
Constant Field Values

END_TEXT

private final String END_TEXT
See Also:
Constant Field Values

REM_END_STREAM

final String REM_END_STREAM
See Also:
Constant Field Values

FIND_REM_END_STREAM

final String FIND_REM_END_STREAM
See Also:
Constant Field Values

upgradeSchemaActivityCount_

private int upgradeSchemaActivityCount_

uniqueActivityCount_

private int uniqueActivityCount_

notNullActivityCount_

private int notNullActivityCount_

SCRIPT0_PREFIX

final String SCRIPT0_PREFIX
See Also:
Constant Field Values

SCRIPT1_PREFIX

final String SCRIPT1_PREFIX
See Also:
Constant Field Values

SCRIPT2_PREFIX

final String SCRIPT2_PREFIX
See Also:
Constant Field Values

REPORT0a_XML

private final String REPORT0a_XML
See Also:
Constant Field Values

SCRIPT0a_WORK

private final String SCRIPT0a_WORK
See Also:
Constant Field Values

SCRIPT1a_WORK

private final String SCRIPT1a_WORK
See Also:
Constant Field Values

SCRIPT2a_WORK

private final String SCRIPT2a_WORK
See Also:
Constant Field Values

REPORT0_XML

String REPORT0_XML

SCRIPT0_WORK

String SCRIPT0_WORK

SCRIPT1_WORK

String SCRIPT1_WORK

SCRIPT2_WORK

String SCRIPT2_WORK

SPOOL0_WORK

private final String SPOOL0_WORK
See Also:
Constant Field Values

SPOOL1_WORK

private final String SPOOL1_WORK
See Also:
Constant Field Values

SPOOL2_WORK

private final String SPOOL2_WORK
See Also:
Constant Field Values

file_pcs_

private File file_pcs_

file_pus_

private File file_pus_

file_pac_

private File file_pac_

file_rcs_

private File file_rcs_

file_rus_

private File file_rus_

file_rac_

private File file_rac_

script0Work_

private PrintWriter script0Work_

script1Test_

private PrintWriter script1Test_

script1Debug_

private PrintWriter script1Debug_

script1Work_

private PrintWriter script1Work_

script2Test_

private PrintWriter script2Test_

script2Debug_

private PrintWriter script2Debug_

script2Work_

private PrintWriter script2Work_

output_

private Output output_

BAD_INIT_VAL

private final String BAD_INIT_VAL
See Also:
Constant Field Values

nonModeledTableNames_

private Vector nonModeledTableNames_

initialValues_

public Vector initialValues_

oldTableIndicesSqlPostAddFunctions_

private Vector oldTableIndicesSqlPostAddFunctions_

newTableIndicesSqlPostAddFunctions_

private Vector newTableIndicesSqlPostAddFunctions_

holdPreExistingFbis_

private Vector holdPreExistingFbis_

holdFbiRelatedDbTriggerNames_

private HashSet holdFbiRelatedDbTriggerNames_

addedFbiRelatedTriggerNames_

private HashSet addedFbiRelatedTriggerNames_

replacedFbiRelatedTriggerNames_

private HashSet replacedFbiRelatedTriggerNames_

sqlUniquenessTables_

private Vector sqlUniquenessTables_

sqlUniquenessIndices_

private Vector sqlUniquenessIndices_

sqlUniquenessColumns_

private Vector sqlUniquenessColumns_

width1TableName_

public int width1TableName_

width1IndexName_

public int width1IndexName_

width1ColumnName_

public int width1ColumnName_

dateSQL_

Date dateSQL_

standardNameDateFormatterString_

String standardNameDateFormatterString_

reportDateLineFormatterString_

String reportDateLineFormatterString_

standardNameDateFormatter_

SimpleDateFormat standardNameDateFormatter_

reportDateLineFormatter_

private SimpleDateFormat reportDateLineFormatter_

dateSQLString_

String dateSQLString_

compareSchemaListener_

private CompareSchemaListener compareSchemaListener_

upgradeContext_

private UpgradeContext upgradeContext_

guiManager_

private GuiManager guiManager_

checkPointNumber_

private int checkPointNumber_

oldCheckPointActivityName_

private String oldCheckPointActivityName_

newCheckPointActivityName_

private String newCheckPointActivityName_

upgradeActivityName_

private String upgradeActivityName_

constraintsActivityName_

private String constraintsActivityName_

schemaResults_

private SchemaResults schemaResults_

reportXml_

private CompareSchemaReportXml reportXml_

reportHtmlName_

String reportHtmlName_

begin_

private String begin_

end_

private String end_

db_

private Db db_

test_

private boolean test_
Constructor Detail

CompareSchema

public CompareSchema()
Creates a CompareSchema object that is only used to get at the init() constants.


CompareSchema

public CompareSchema(CancellationMonitor cancellation_monitor)
Used to support the use of the UpgradeTool GUI.

Parameters:
cancellation_monitor - Has methods to see if a CANCEL was requested.
Method Detail

setListener

public void setListener(CompareSchemaListener listener)
Called by applications that must run this class through a listener.

Parameters:
listener - The listener used by the application and this class.

init

private void init()
Only contains items that are also needed by other Upgrade steps.


deleteOldFiles

private void deleteOldFiles()
                     throws Throwable
Throws:
Throwable

testedDeleteOfFile

private boolean testedDeleteOfFile(String path_and_file_name)

createNewFiles

private void createNewFiles()
                     throws CompareSchemaException
Throws:
CompareSchemaException

executeFromGui

public boolean executeFromGui(String option)
                       throws CompareSchemaException,
                              Throwable
Used to execute this class from a GUI application (with options).

Parameters:
option - Identifies what execution option is required.
Returns:
A true if completed without or before a CANCEL.
Throws:
CompareSchemaException - If a known error or exception was caught and already reported to the log.
Throwable - If there is an unknown exception.

executeFromGui

public boolean executeFromGui()
                       throws CompareSchemaException,
                              Throwable
Used to execute this class from a GUI application (with NO options).

Returns:
A true if completed without or before a CANCEL.
Throws:
CompareSchemaException - If a known error or exception was caught and already reported to the log.
Throwable - If there is an unknown exception.

buildSql

private void buildSql()
               throws CompareSchemaException,
                      CancelException
Throws:
CompareSchemaException
CancelException

readAllClasses

private void readAllClasses(Vector allClasses,
                            Hashtable dbTables,
                            Hashtable clDbTables,
                            Hashtable dbViews,
                            Hashtable clDbViews)
                     throws CompareSchemaException,
                            CancelException
Generate a vector of all classes from the target model registry property file.

Parameters:
allClasses - This output is all the classes from the target model registry property file.
clDbTables - Tables seen in the target model.
dbTables - Tables seen in the source DB.
clDbViews - Views seen in the target model.
dbViews - Views seen in the source DB.
Throws:
CompareSchemaException - If a known error or exception was caught and already reported to the log.
CancelException - Used to gracefully exit code after a CANCEL was detected.

fillTableLists

private void fillTableLists(Hashtable classes,
                            Hashtable dbTables,
                            Hashtable clDbTables,
                            Hashtable dbViews,
                            Hashtable clDbViews)
                     throws CompareSchemaException
Throws:
CompareSchemaException

verifyMaxBytesPerCharFactor

private void verifyMaxBytesPerCharFactor(Hashtable dbTables,
                                         Hashtable clDbTables,
                                         Hashtable all_types_5)
                                  throws CompareSchemaException
Use a column's character width to verify the wt.properties value for wt.db.maxBytesPerChar (default == 1).

Throws:
CompareSchemaException

readAllPackages

private void readAllPackages(Vector allClasses)
Extracts package name from filled class list. This method ensures that only packages, with at least one persistent class, are in the list.

Parameters:
allClasses - All classes from the target model registry property file.

removeNullBlobReferences

private void removeNullBlobReferences(Hashtable dbTables)
                               throws CompareSchemaException
Throws:
CompareSchemaException

sqlToRemoveNullBlobReference

private String sqlToRemoveNullBlobReference(String tableName,
                                            String columnName)

reportRemovedTables

private void reportRemovedTables(Hashtable dbTables,
                                 Hashtable clDbTables)

loadNonModeledTableNames

private void loadNonModeledTableNames()
Used to not output non-modeled tables as removed from the other schema.


processNewTables

private void processNewTables(Hashtable dbTables,
                              Hashtable clDbTables)
                       throws CompareSchemaException,
                              CancelException
Throws:
CompareSchemaException
CancelException

createSqlForANewTable

private void createSqlForANewTable(String class_name,
                                   DatabaseInfo dbInfo,
                                   StringBuffer table,
                                   StringBuffer index,
                                   StringBuffer trigger)
                            throws WTException
This method exists only until the class \SystemGeneration\src\wt\tools\generation\sql\CreateTable.java can be made to test which DB vendor is being used and provide the table and index creation, together. When it is made available, use it and delete this method.

Parameters:
class_name - The class that is to become a table.
dbInfo - All the database info.
table - The database table associated with the class.
index - The database index for that table.
trigger - The database trigger for that table.
Throws:
WTException - A forwarded exception.

processAllPreExistingTables

private void processAllPreExistingTables(Hashtable dbTables,
                                         Hashtable clDbTables,
                                         Hashtable all_types_2)
                                  throws CompareSchemaException,
                                         CancelException
Throws:
CompareSchemaException
CancelException

reportDroppedFbiRelatedTriggers

private void reportDroppedFbiRelatedTriggers()
Drop from the database any Function Based Index triggers that are still in the set of trigger names.


reportAddedFbiRelatedTriggers

private void reportAddedFbiRelatedTriggers()
Report added Function Based Index Triggers. These are triggers that did not exist in the database at the start of the comparison, but for which DDL was generated.


reportReplacedFbiRelatedTriggers

private void reportReplacedFbiRelatedTriggers()
Report added Function Based Index Triggers. These are triggers that did exist in the database at the start of the comparison and for which DDL was generated.


groupAddedOrReplacedFbiRelatedDbTriggerNames

private void groupAddedOrReplacedFbiRelatedDbTriggerNames(HashSet trigger_names)
Add each of the specified trigger names to the collection of added Function Based Index Triggers if it does not exist in the set of trigger names found in the database. Then, Remove the specified triggers from the set of FBI triggers that will be dropped near the end of the upgrade script.

Parameters:
trigger_names - A hash of trigger names.

createForcedTriggerEvaluationScript

private void createForcedTriggerEvaluationScript(String table_name,
                                                 HashSet columns_that_trigger)
Generate update statement that will cause database to execute row-level triggers on table for all triggers that are bound to updates of the columns in columns_that_trigger.

Parameters:
table_name - The database table.
columns_that_trigger - The sub-set of columns that have triggers.

reportRemovedViews

private void reportRemovedViews(Hashtable dbViews,
                                Hashtable clDbViews)

reportNewViews

private void reportNewViews(Hashtable dbViews,
                            Hashtable clDbViews)

processAllViews

private void processAllViews(Hashtable clDbViews)
                      throws CompareSchemaException
Throws:
CompareSchemaException

reportNewUniqueIndexForPreExistingData

private void reportNewUniqueIndexForPreExistingData()
If errors, insert a New Unique Indices section.


AddSequencesSql

private void AddSequencesSql()
                      throws WTIntrospectionException,
                             WTException
Throws:
WTIntrospectionException
WTException

getModeledSequences

private ClassInfo[] getModeledSequences()
                                 throws WTIntrospectionException
Throws:
WTIntrospectionException

AddTypesForIndicesFunctionsSql

private void AddTypesForIndicesFunctionsSql()

AddFunctionsForIndicesSql

private void AddFunctionsForIndicesSql()

addPreMigrateIndicesSql

private void addPreMigrateIndicesSql()

getDbIndexes

private Vector getDbIndexes(String table_name)
                     throws CompareSchemaException
Throws:
CompareSchemaException

getDbTableColumns

private Hashtable getDbTableColumns(String table_name)
                             throws CompareSchemaException
Throws:
CompareSchemaException

getClassDbTableColumns

private Hashtable getClassDbTableColumns(ClassDbInfo clDbInfo,
                                         Hashtable all_types_4)
                                  throws CompareSchemaException
Throws:
CompareSchemaException

getClassDbIndexes

private Vector getClassDbIndexes(String table_name,
                                 Hashtable column_list,
                                 BaseTableInfo tableInfo)
                          throws CompareSchemaException
Throws:
CompareSchemaException

keyDiff

private Vector keyDiff(Hashtable h1,
                       Hashtable h2)
Returns a vector containing keys from h1 which do not exist in h2.

Parameters:
h1 - Entries in this hash may be returned.
h2 - This hash is only used for comparisons.
Returns:
Entries from the first hash.

keyIntersect

private Vector keyIntersect(Hashtable h1,
                            Hashtable h2)
Returns a vector representing keys existing in both h1 and h2.

Parameters:
h1 - Entries in this hash may be returned.
h2 - This hash is only used for comparisons.
Returns:
Entries happen to be from the first hash, but do exist in both.

markIndexes

private void markIndexes(Vector dbInds,
                         Vector clDbInds)

nameFound

private boolean nameFound(IndexInfo ind,
                          Vector inds)

indListDiff

private Vector indListDiff(Vector h1,
                           Vector h2)
Return a list of IndexInfo's that are in h1 but not in h2. The equality is based on whether or not they index the same information in the same way.

Parameters:
h1 - Entries in this Vector may be returned.
h2 - This Vector is only used for comparisons.
Returns:
Entries from the first Vector.

indListIntersect

private Vector indListIntersect(Vector h1,
                                Vector h2)
Return a list of IndexInfo's that are in h1 and in h2. The equality is based on whether or not they index the same information in the same way.

Parameters:
h1 - Entries in this Vector may be returned.
h2 - This Vector is only used for comparisons.
Returns:
Entries from the first Vector.

findInitialValue

private String findInitialValue(AttribsList attribsList)
                         throws CompareSchemaException
Determine the initial value for the property with the WTIntrospector.QUERY_NAME as specified by the attribute_list.getQueryName().

Parameters:
attribsList - The source DB or target model column attributes.
Returns:
The string representation of the initial value OR "&060;InitialValueNotFound&062;" if there is no initial value for the property.
Throws:
CompareSchemaException - If a known error or exception was caught and already reported to the log.

filterOutBlankLines

private String filterOutBlankLines(String x)
Oracle may pause on zero length or white space lines.

Returns:
The user must test for null before adding to the script file.

addSpaces

private String addSpaces(String original,
                         String trimmed)

processPreExistingTableDefinition

private void processPreExistingTableDefinition(String table_name,
                                               ClassDbInfo clDbInfo,
                                               Hashtable all_types_3)
                                        throws CompareSchemaException
For a pre-existing table, edit columns, add column, and report.

Parameters:
table_name - The table being processed.
all_types_3 - A complete list of the types.
Throws:
CompareSchemaException - If a known error or exception was caught and already reported to the log.

renameBlobColumnsForInlineBlob

private void renameBlobColumnsForInlineBlob(Hashtable dbCols,
                                            Hashtable clDbCols)
                                     throws CompareSchemaException
Throws:
CompareSchemaException

editTableDefForNewColumns

private Vector editTableDefForNewColumns(String table_name,
                                         String class_name,
                                         Hashtable dbCols,
                                         Hashtable clDbCols,
                                         TableDef tableDef)
                                  throws CompareSchemaException
Throws:
CompareSchemaException

editTableDefForRemovedColumns

private void editTableDefForRemovedColumns(String table_name,
                                           String class_name,
                                           Hashtable dbCols,
                                           Hashtable clDbCols,
                                           TableDef tableDef)
                                    throws CompareSchemaException
Throws:
CompareSchemaException

editTableDefForKeptColumns

private Vector editTableDefForKeptColumns(String table_name,
                                          String class_name,
                                          Hashtable dbCols,
                                          Hashtable clDbCols,
                                          TableDef tableDef)
                                   throws CompareSchemaException
Throws:
CompareSchemaException

generateAlterTableModifyScript

private void generateAlterTableModifyScript(String table_name,
                                            String class_name,
                                            TableDef tableDef)
                                     throws CompareSchemaException
Throws:
CompareSchemaException

replaceNullReferencesForNewlyNullableOldBlobsNotInInlineBlobs

private void replaceNullReferencesForNewlyNullableOldBlobsNotInInlineBlobs(Vector sqlForBlobsWithNullReferences)

initializeNewSmallBlobUsingNotNullOldBlobForInlineBlob

private void initializeNewSmallBlobUsingNotNullOldBlobForInlineBlob(Vector sqlForNewSmallBlobsUsingNotNullOldBlobs)

generateTriggerScript

private void generateTriggerScript(String table_name,
                                   String class_name,
                                   ClassInfo classInfo,
                                   TableDef tableDef)
                            throws CompareSchemaException
Throws:
CompareSchemaException

generateDropRemovedIndexScript

private void generateDropRemovedIndexScript(Vector dbInds,
                                            Vector clDbInds,
                                            Vector dbFbisUsedInModify)

generateAddIndexScripts

private void generateAddIndexScripts(Vector dbInds,
                                     Vector clDbInds,
                                     TableDef tableDef)
                              throws CompareSchemaException
Throws:
CompareSchemaException

dropDbFbisUsedInModify

private Vector dropDbFbisUsedInModify(String mod_table_name,
                                      Vector dbInds,
                                      Vector clDbInds,
                                      TableDef tableDef)
                               throws CompareSchemaException
Throws:
CompareSchemaException

reAddDbFbisUsedInModify

private void reAddDbFbisUsedInModify(Vector dbFbisUsedInModify)
Re-add the PreExisting Function Based Indices disallowed to exist during the MODIFY.

Parameters:
dbFbisUsedInModify - PreExisting FBIs temporarily dropped due to a MODIFY.

createDataForUniquenessTest

private void createDataForUniquenessTest(IndexInfo indexInfo,
                                         TableDef tableDef)
                                  throws CompareSchemaException
Test the data in a table that has new UNIQUE indices

Parameters:
indexInfo - The information for one index.
tableDef - All the definitions for one table.
Throws:
CompareSchemaException - If a known error or exception was caught and already reported to the log.

getFunctionArguments

private Vector getFunctionArguments(String colConstraint)
Extract the column names. Expressions are typically column names, but this method also handles SQL function calls that use columns as arguments. This method is used to avoid performing a UNIQUENESS test with Function Based Indices. This method is used to temporarily drop and re-add Function Based Indices for AlterTableModify.

Parameters:
colConstraint - May be a complex mathematical expression that combines arguments.
Returns:
The arguments contained in the colConstraint.

interpretConstraint

public String interpretConstraint(String colConstraint)
Returns a part of an SQL command for the UNIQUENESS test. Example: xxx becomes " and a.xxx = b.xxx" Example: funct(xxx,yyy) becomes " and funct(a.xxx,a.yyy) = funct(b.xxx,b.yyy)" Example: funct(xxx,0) becomes " and funct(a.xxx,0) = funct(b.xxx,0)" Example: xxx+yyy becomes " and a.xxx+a.yyy = b.xxx+b.yyy" Example: xxx || yyy becomes " and a.xxx || a.yyy = b.xxx || b.yyy" Example: x || '/' || y becomes " and a.x || a.y = b.x || b.y"

Parameters:
colConstraint - May be a complex mathematical expression that combines arguments.
Returns:
An "and" fragment of an SQL command.

alterColumnType

private void alterColumnType(AttribsList dbAttribs,
                             AttribsList clDbAttribs)

alterColumnToNotNull

private void alterColumnToNotNull(AttribsList dbAttribs,
                                  AttribsList clDbAttribs,
                                  AttribsList columnDef)
                           throws CompareSchemaException
Throws:
CompareSchemaException

alterColumnToNullable

private void alterColumnToNullable(AttribsList dbAttribs,
                                   AttribsList clDbAttribs,
                                   AttribsList columnDef,
                                   Vector sqlForBlobsWithNullReferences)

alterColumnCharToShorter

private void alterColumnCharToShorter(AttribsList dbAttribs,
                                      AttribsList clDbAttribs)

alterColumnCharToLonger

private void alterColumnCharToLonger(AttribsList dbAttribs,
                                     AttribsList clDbAttribs)

reportColumnSmallBlobToLonger

private void reportColumnSmallBlobToLonger(AttribsList dbAttribs,
                                           AttribsList clDbAttribs)

sleep

private void sleep(int i,
                   String doing)

updateGuiAtACheckPoint

private void updateGuiAtACheckPoint(int next_i,
                                    String next)
                             throws CompareSchemaException,
                                    CancelException
Throws:
CompareSchemaException
CancelException

updateGuiActivitySubject

private void updateGuiActivitySubject(String activity_name,
                                      String activity_subject_type,
                                      String activity_subject,
                                      int activity_subject_progress_min,
                                      int activity_subject_progress_current,
                                      int activity_subject_progress_max)

updateGuiActivitySubject

private void updateGuiActivitySubject(String activity_name,
                                      String activity_subject_type,
                                      String activity_subject)

updateGuiWithSchemaResults

private void updateGuiWithSchemaResults()
                                 throws CompareSchemaException
Throws:
CompareSchemaException

updateGuiAsCompleted

private void updateGuiAsCompleted()
                           throws CompareSchemaException
Throws:
CompareSchemaException

testGuiForACancel

private void testGuiForACancel()
                        throws CompareSchemaException,
                               CancelException
Throws:
CompareSchemaException
CancelException

addTwoLines

private void addTwoLines(PrintWriter pw,
                         String str1,
                         String str2)

noCheckPointVerification

private void noCheckPointVerification()