public class ModelComparator extends Object
| Constructor and Description |
|---|
ModelComparator(PlatformInfo platformInfo,
TableDefinitionChangesPredicate tableDefChangePredicate,
boolean caseSensitive)
Creates a new model comparator object.
|
| Modifier and Type | Method and Description |
|---|---|
protected List |
checkForAddedColumns(Database sourceModel,
Table sourceTable,
Database intermediateModel,
Table intermediateTable,
Database targetModel,
Table targetTable)
Creates change objects for columns that are not present in the given source table but are in the target
table, and applies them to the given intermediate model.
|
protected List |
checkForAddedForeignKeys(Database sourceModel,
Database intermediateModel,
Database targetModel)
Creates change objects for foreign keys that are not present in the given source model but are in the target
model, and applies them to the given intermediate model.
|
protected List |
checkForAddedIndexes(Database sourceModel,
Table sourceTable,
Database intermediateModel,
Table intermediateTable,
Database targetModel,
Table targetTable)
Creates change objects for indexes that are not present in the given source table but are in the target
table, and applies them to the given intermediate model.
|
protected List |
checkForAddedTables(Database sourceModel,
Database intermediateModel,
Database targetModel)
Creates change objects for tables that are not present in the given source model but are in the target
model, and applies them to the given intermediate model.
|
protected List |
checkForChangedColumns(Database sourceModel,
Table sourceTable,
Database intermediateModel,
Table intermediateTable,
Database targetModel,
Table targetTable)
Creates change objects for columns that have a different in the given source and target table, and applies them
to the given intermediate model.
|
protected List |
checkForChangeOfColumnOrder(Database sourceModel,
Table sourceTable,
Database intermediateModel,
Table intermediateTable,
Database targetModel,
Table targetTable)
Checks for changes in the column order between the given source and target table, creates change objects for these and
applies them to the given intermediate model.
|
protected List |
checkForPrimaryKeyChanges(Database sourceModel,
Table sourceTable,
Database intermediateModel,
Table intermediateTable,
Database targetModel,
Table targetTable)
Creates change objects for primary key differences (primary key added/removed/changed), and applies them to the given intermediate model.
|
protected List |
checkForRemovedColumns(Database sourceModel,
Table sourceTable,
Database intermediateModel,
Table intermediateTable,
Database targetModel,
Table targetTable)
Creates change objects for columns that are present in the given source table but are no longer in the target
table, and applies them to the given intermediate model.
|
protected List |
checkForRemovedForeignKeys(Database sourceModel,
Database intermediateModel,
Database targetModel)
Creates change objects for foreign keys that are present in the given source model but are no longer in the target
model, and applies them to the given intermediate model.
|
protected List |
checkForRemovedIndexes(Database sourceModel,
Table sourceTable,
Database intermediateModel,
Table intermediateTable,
Database targetModel,
Table targetTable)
Creates change objects for indexes that are present in the given source table but are no longer in the target
table, and applies them to the given intermediate model.
|
protected List |
checkForRemovedTables(Database sourceModel,
Database intermediateModel,
Database targetModel)
Creates change objects for tables that are present in the given source model but are no longer in the target
model, and applies them to the given intermediate model.
|
List |
compare(Database sourceModel,
Database targetModel)
Compares the two models and returns the changes necessary to create the second
model from the first one.
|
protected ColumnDefinitionChange |
compareColumns(Table sourceTable,
Column sourceColumn,
Table targetTable,
Column targetColumn)
Compares the two columns and returns the change necessary to create the second
column from the first one if they differe.
|
protected List |
compareModels(Database sourceModel,
Database intermediateModel,
Database targetModel)
Compares the given source and target models and creates change objects to get from
the source to the target one.
|
protected List |
compareTables(Database sourceModel,
Table sourceTable,
Database intermediateModel,
Table intermediateTable,
Database targetModel,
Table targetTable)
Compares the two tables and returns the changes necessary to create the second
table from the first one.
|
protected ForeignKey |
findCorrespondingForeignKey(Table table,
ForeignKey fk)
Searches in the given table for a corresponding foreign key.
|
protected Index |
findCorrespondingIndex(Table table,
Index index)
Searches in the given table for a corresponding index.
|
protected String[] |
getIntermediateColumnNamesFor(Column[] columns,
Table intermediateTable)
Returns the names of the columns in the intermediate table corresponding to the given column objects.
|
protected PlatformInfo |
getPlatformInfo()
Returns the info object for the platform.
|
protected boolean |
isCaseSensitive()
Determines whether comparison should be case sensitive.
|
void |
setCanDropPrimaryKeyColumns(boolean canDropPrimaryKeyColumns)
Specifies whether the
RemoveColumnChange are fine even for primary key columns. |
void |
setGeneratePrimaryKeyChanges(boolean generatePrimaryKeyChanges)
Specifies whether the comparator should generate
PrimaryKeyChange objects or a
pair of RemovePrimaryKeyChange and AddPrimaryKeyChange objects instead. |
public ModelComparator(PlatformInfo platformInfo, TableDefinitionChangesPredicate tableDefChangePredicate, boolean caseSensitive)
platformInfo - The platform infotableDefChangePredicate - The predicate that defines whether tables changes are supported
by the platform or not; all changes are supported if this is nullcaseSensitive - Whether comparison is case sensitivepublic void setGeneratePrimaryKeyChanges(boolean generatePrimaryKeyChanges)
PrimaryKeyChange objects or a
pair of RemovePrimaryKeyChange and AddPrimaryKeyChange objects instead.
The default value is true.generatePrimaryKeyChanges - Whether to create PrimaryKeyChange objectspublic void setCanDropPrimaryKeyColumns(boolean canDropPrimaryKeyColumns)
RemoveColumnChange are fine even for primary key columns.
If the platform cannot drop primary key columns, set this to false and the
comparator will create additional primary key changes.
The default value is true.canDropPrimaryKeyColumns - Whether RemoveColumnChange objecs for primary
key columns are okprotected PlatformInfo getPlatformInfo()
protected boolean isCaseSensitive()
true if case matterspublic List compare(Database sourceModel, Database targetModel)
sourceModel - The source modeltargetModel - The target modelprotected List compareModels(Database sourceModel, Database intermediateModel, Database targetModel)
sourceModel - The source modelintermediateModel - The intermediate model to apply the changes totargetModel - The target modelprotected List checkForRemovedForeignKeys(Database sourceModel, Database intermediateModel, Database targetModel)
sourceModel - The source modelintermediateModel - The intermediate model to apply the changes totargetModel - The target modelprotected List checkForAddedForeignKeys(Database sourceModel, Database intermediateModel, Database targetModel)
sourceModel - The source modelintermediateModel - The intermediate model to apply the changes totargetModel - The target modelprotected List checkForRemovedTables(Database sourceModel, Database intermediateModel, Database targetModel)
sourceModel - The source modelintermediateModel - The intermediate model to apply the changes totargetModel - The target modelprotected List checkForAddedTables(Database sourceModel, Database intermediateModel, Database targetModel)
sourceModel - The source modelintermediateModel - The intermediate model to apply the changes totargetModel - The target modelprotected List compareTables(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable)
sourceModel - The source modelsourceTable - The source tableintermediateModel - The intermediate model to which the changes will be applied incrementallyintermediateTable - The table corresponding to the source table in the intermediate modeltargetModel - The target model which contains the target tabletargetTable - The target tableprotected String[] getIntermediateColumnNamesFor(Column[] columns, Table intermediateTable)
columns - The column objectsintermediateTable - The intermediate tableprotected List checkForRemovedIndexes(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable)
sourceModel - The source modelsourceTable - The source tableintermediateModel - The intermediate model to apply the changes tointermediateTable - The table from the intermediate model corresponding to the source tabletargetModel - The target modeltargetTable - The target tableprotected List checkForAddedIndexes(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable)
sourceModel - The source modelsourceTable - The source tableintermediateModel - The intermediate model to apply the changes tointermediateTable - The table from the intermediate model corresponding to the source tabletargetModel - The target modeltargetTable - The target tableprotected List checkForChangeOfColumnOrder(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable)
sourceModel - The source modelsourceTable - The source tableintermediateModel - The intermediate model to apply the changes tointermediateTable - The table from the intermediate model corresponding to the source tabletargetModel - The target modeltargetTable - The target tableprotected List checkForRemovedColumns(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable)
sourceModel - The source modelsourceTable - The source tableintermediateModel - The intermediate model to apply the changes tointermediateTable - The table from the intermediate model corresponding to the source tabletargetModel - The target modeltargetTable - The target tableprotected List checkForAddedColumns(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable)
sourceModel - The source modelsourceTable - The source tableintermediateModel - The intermediate model to apply the changes tointermediateTable - The table from the intermediate model corresponding to the source tabletargetModel - The target modeltargetTable - The target tableprotected List checkForChangedColumns(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable)
sourceModel - The source modelsourceTable - The source tableintermediateModel - The intermediate model to apply the changes tointermediateTable - The table from the intermediate model corresponding to the source tabletargetModel - The target modeltargetTable - The target tableprotected List checkForPrimaryKeyChanges(Database sourceModel, Table sourceTable, Database intermediateModel, Table intermediateTable, Database targetModel, Table targetTable)
sourceModel - The source modelsourceTable - The source tableintermediateModel - The intermediate model to apply the changes tointermediateTable - The table from the intermediate model corresponding to the source tabletargetModel - The target modeltargetTable - The target tableprotected ColumnDefinitionChange compareColumns(Table sourceTable, Column sourceColumn, Table targetTable, Column targetColumn)
sourceTable - The source table which contains the source columnsourceColumn - The source columntargetTable - The target table which contains the target columntargetColumn - The target columnnull if the columns are the sameprotected ForeignKey findCorrespondingForeignKey(Table table, ForeignKey fk)
table - The table to search infk - The original foreign keyprotected Index findCorrespondingIndex(Table table, Index index)
table - The table to search inindex - The original indexCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.