org.afcs.warts.db
Class DataSynchronizationAction

java.lang.Object
  extended byorg.afcs.warts.db.DataSynchronization
      extended byorg.afcs.warts.db.DataSynchronizationAction

public final class DataSynchronizationAction
extends org.afcs.warts.db.DataSynchronization

The DataSynchronizationAction class is used to synchronize the contents of one dataset with another based on the analysis performed by a DataComparison instance.

LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.

Version:
Last Modified 4 February 2004
Author:
Warren Hedley ( whedley at sdsc dot edu )

Field Summary
protected  DataComparison _comparison
          A reference to the comparison we're working with.
protected  TableDescription _destDescription
          The description of the table we're going to be manipulating.
protected  java.lang.String _destQualTableName
          The fully qualified name of the destination table (this is used in comments and debugging messages).
protected  java.lang.String _sourceQualTableName
          The fully qualified name of the source table that data is being moved from (this is used in comments and debugging messages).
 
Constructor Summary
DataSynchronizationAction(DataComparison comparison)
          Initialises a new instance that will synchronize datasets based on the specified data comparison.
 
Method Summary
protected  int countRowsOfType(int[] rowIndices, int type)
          Returns the number of rows in the specified array of indices that are of the specified type in the current comparison.
 java.lang.String performDeletes(int[] rowsToSync)
          Deletes any rows found in dataset two from the referenced destination table that weren't in dataset one when the data comparison was performed and that have indices in the specified array.
 java.lang.String performInserts(int[] rowsToSync)
          Inserts any rows found in dataset one that weren't in dataset two when the data comparison was performed and that have indices in the specified array into the destination table.
 java.lang.String performSync(int[] rowsToSync, boolean doDeletes, boolean doUpdates, boolean doInserts)
          This method attempts to synchronize the data in all of the specified rows that require the operations permitted by the specified boolean flags.
 java.lang.String performUpdates(int[] rowsToSync)
          Updates any rows found in both dataset one and two but with differing non-primary key column values when the data comparison was performed and that have indices in the specified array.
 java.lang.String toString()
          Returns a textual representation of the current instance useful for debugging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_comparison

protected final DataComparison _comparison
A reference to the comparison we're working with.


_destDescription

protected final TableDescription _destDescription
The description of the table we're going to be manipulating.


_destQualTableName

protected final java.lang.String _destQualTableName
The fully qualified name of the destination table (this is used in comments and debugging messages).


_sourceQualTableName

protected final java.lang.String _sourceQualTableName
The fully qualified name of the source table that data is being moved from (this is used in comments and debugging messages).

Constructor Detail

DataSynchronizationAction

public DataSynchronizationAction(DataComparison comparison)
Initialises a new instance that will synchronize datasets based on the specified data comparison.

Parameters:
comparison - The comparison to generate scripts for.
Throws:
java.lang.NullPointerException - If comparison is null.
Method Detail

performSync

public java.lang.String performSync(int[] rowsToSync,
                                    boolean doDeletes,
                                    boolean doUpdates,
                                    boolean doInserts)
This method attempts to synchronize the data in all of the specified rows that require the operations permitted by the specified boolean flags. It is here to ensure that synchronization actions are performed in the correct order (deletes, updates, then inserts) and to consolidate the report produced into a single report.

Parameters:
rowsToSync - The indices of the rows to synchronize. If this is null, then all rows will be scanned.
doDeletes - Whether deletes should be performed.
doUpdates - Whether updates should be performed.
doInserts - Whether inserts should be performed.
Returns:
A report on the actions that were taken and on any errors that occurred.

performDeletes

public java.lang.String performDeletes(int[] rowsToSync)
Deletes any rows found in dataset two from the referenced destination table that weren't in dataset one when the data comparison was performed and that have indices in the specified array. (This allows clients to synchronize only a subset of the rows in a table.)

Parameters:
rowsToSync - The indices of the rows to synchronize. Only the row indices that represent deleted rows will be handled. If this is null, then all rows will be scanned.
Returns:
A report on the actions that were taken and on any errors that occurred.

performInserts

public java.lang.String performInserts(int[] rowsToSync)
Inserts any rows found in dataset one that weren't in dataset two when the data comparison was performed and that have indices in the specified array into the destination table. (This allows clients to synchronize only a subset of the rows in a table.)

Parameters:
rowsToSync - The indices of the rows to synchronize. Only the row indices that represent inserted rows will be handled. If this is null, then all rows will be scanned.
Returns:
A report on the actions that were taken and on any errors that occurred.

performUpdates

public java.lang.String performUpdates(int[] rowsToSync)
Updates any rows found in both dataset one and two but with differing non-primary key column values when the data comparison was performed and that have indices in the specified array. (This allows clients to synchronize only a subset of the rows in a table.)

Parameters:
rowsToSync - The indices of the rows to synchronize. Only the row indices that represent updated rows will be handled. If this is null, then all rows will be scanned.
Returns:
A report on the actions that were taken and on any errors that occurred.

toString

public java.lang.String toString()
Returns a textual representation of the current instance useful for debugging.

Returns:
A textual representation of the current instance.

countRowsOfType

protected int countRowsOfType(int[] rowIndices,
                              int type)
Returns the number of rows in the specified array of indices that are of the specified type in the current comparison.

Parameters:
rowIndices - The array of row indices to scan.
type - The row type to count.
Returns:
The number of rows in the specified array of indices that are of the specified type in the current comparison.