Class SyncPair<U extends AbstractUnit,P extends AbstractUnit>
java.lang.Object
com.wisecoders.dbs.dbms.sync.engine.nodes.SyncPair<U,P>
- Type Parameters:
U
- The class of the elements (Table, Column, Constraint, Index )P
- The class of the parent element ( Schema for Tables, Table for Columns, Indexes, Constraints...)
- All Implemented Interfaces:
SyncDiff
- Direct Known Subclasses:
EditorSyncRoot
public class SyncPair<U extends AbstractUnit,P extends AbstractUnit>
extends Object
implements SyncDiff
A pair of two elements which are compared, and their parents. It can be two columns, foreign keys, constriants, indexes, etc.
One of elements can be empty (is missing) which will result in a TableExistsDiff, ColumnExistsDiff, IndexExistsDiff, etc.
The parents ( which is in most cases the schema ) is required to be able to handle the element missing differences.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSyncPair
(P leftParent, U left, P rightParent, U right, boolean descendIntoChildren, SchemaMapping mapping) Used in : - clone column by create fk on drag and drop - clone unit in diagramSyncPair
(U left, SchemaMapping mapping, U right) Can synchronize using a specific schema mapping.Used in: - diagram generate selected unit sql - drop item in table detail pane, workspace - schema script generator -
Method Summary
Modifier and TypeMethodDescriptionint
actionWillDrop
(SyncAction action, SyncSide into, boolean onlyTablesColumns) Get the count of dropped items if this action is applied.boolean
void
commitIntoDatabase
(Connector connector, SyncSide into, SyncAction onlyAction) Apply the selected actions in to the database.void
filter
(com.wisecoders.dbs.dbms.sync.model.SyncFilter filter) Filter all tree using a given filter.generateCommitScript
(String dbId, SyncAction onlyAction, SyncSide into) Generate the commit scriptgenerateCommitScript
(String dbId, SyncAction onlyAction, SyncSide into, boolean includeForeignKeysInCreateTable) int
List<AbstractDiff<?,
?>> Get a list of differences for this node.AbstractDiff<?,
?> getUnit()
boolean
boolean
hasNodesWithAction
(SyncAction action) boolean
matches
(SyncDiffFilter filter) void
mergeInto
(SyncSide into, SyncAction onlyAction) Merge differences into the local modelvoid
mergeInto
(SyncSide into, SyncAction onlyAction, com.wisecoders.dbs.diagram.fx.GenericLayoutPane layoutPane) void
removeChildrenWithAction
(SyncAction action) void
setAction
(SyncAction action, boolean recursive) Set an action for this and all sub-nodes.void
setAlwaysIncludeFks
(boolean alwaysIncludeFks) void
void
toSql
(String dbId, SyncAction onlyAction, SyncSide into, PrintWriter writer) Generate the script for a Synchronization operation.toString()
toString
(int level)
-
Field Details
-
mapping
-
parent
-
left
-
right
-
leftParent
-
rightParent
-
dependency
-
-
Constructor Details
-
SyncPair
Can synchronize using a specific schema mapping. Used in : - Synchronize with the database - Synchronize with a file.- Parameters:
left
- projectmapping
- between schemasright
- project
-
SyncPair
Used in: - diagram generate selected unit sql - drop item in table detail pane, workspace - schema script generator- Parameters:
left
- unitright
- unit
-
SyncPair
public SyncPair(P leftParent, U left, P rightParent, U right, boolean descendIntoChildren, SchemaMapping mapping) Used in : - clone column by create fk on drag and drop - clone unit in diagram- Parameters:
leftParent
- of leftleft
- unitrightParent
- of rightright
- unitdescendIntoChildren
- synchronize childrenmapping
- to map the model schema to a different schema in the database
-
-
Method Details
-
getMapping
-
synchronize
public void synchronize() -
hasDifferences
public boolean hasDifferences() -
getDiffCount
public int getDiffCount() -
setAction
Set an action for this and all sub-nodes. This is similar with the Synchronization dialog, like clicking an action for each element. SyncAction.toLeft would mean to modify the model, toRight to modify the database. -
getChildrenPairs
-
getDifferences
Get a list of differences for this node. A node can be a pair of tables, or columns, and differences can be rename, exists diff, data type diff, mandatory diff, etc.- Returns:
- A list of differences
-
hasNodesWithAction
-
actionWillDrop
Get the count of dropped items if this action is applied.- Parameters:
action
- to be appliedinto
- which directiononlyTablesColumns
- consider only tables and columns (no indexes, fks )- Returns:
- The count of dropped items.
-
toString
-
toString
-
getAction
-
toSql
public void toSql(String dbId, SyncAction onlyAction, SyncSide into, PrintWriter writer) throws IOException Generate the script for a Synchronization operation.- Parameters:
dbId
- The DBMS nameonlyAction
- Synchronize only this actions. The rest will be ignored.into
- In which direction to syncronize. This is similar with the SyncDialog (left-local model, right-database ).writer
- To write the script into- Throws:
IOException
-
commitIntoDatabase
public void commitIntoDatabase(Connector connector, SyncSide into, SyncAction onlyAction) throws Exception Apply the selected actions in to the database. This require to do first syncPair.setAction(SyncSide.toRight)- Parameters:
connector
- the database connectioninto
- the direction to commit toonlyAction
- the actions to filter- Throws:
Exception
- is most of the times an SQLException
-
generateCommitScript
Generate the commit script- Parameters:
dbId
- is the DBMSonlyAction
- only the given actionsinto
- in which direction to generate the commit. Usually is SyncSide.toRight (database )- Returns:
- a script as a list of statements.
-
generateCommitScript
public AlterScript generateCommitScript(String dbId, SyncAction onlyAction, SyncSide into, boolean includeForeignKeysInCreateTable) -
mergeInto
Merge differences into the local model- Parameters:
into
- use SyncSide.toLeft to apply to the local modelonlyAction
- filter only the given action
-
mergeInto
public void mergeInto(SyncSide into, SyncAction onlyAction, com.wisecoders.dbs.diagram.fx.GenericLayoutPane layoutPane) -
getUnit
-
getUnit
-
getParent
-
filter
public void filter(com.wisecoders.dbs.dbms.sync.model.SyncFilter filter) Filter all tree using a given filter. The rejected differences will be removed- Parameters:
filter
- to use for filtering
-
getNodeDiff
- Specified by:
getNodeDiff
in interfaceSyncDiff
-
removeChildrenWithAction
-
canSkipInDisplayAndShowChildrenDiffs
public boolean canSkipInDisplayAndShowChildrenDiffs() -
matches
-
setAlwaysIncludeFks
public void setAlwaysIncludeFks(boolean alwaysIncludeFks)
-