com.sun.mdm.index.master.search.merge
Class MergeHistoryHelper

java.lang.Object
  extended bycom.sun.mdm.index.master.search.merge.MergeHistoryHelper

public class MergeHistoryHelper
extends java.lang.Object

Helper class to traverse merge history


Constructor Summary
MergeHistoryHelper(TransactionMgr transMgr)
          Creates a new instance of MergeHistoryHelper
 
Method Summary
 java.lang.String getActiveEUID(java.sql.Connection con, java.lang.String sourceEUID)
          Search the merge tree and find the active EUID associated with the merged EUID.
 java.lang.String getActiveEUIDHelper(java.sql.PreparedStatement selectActiveEUIDTimestamp, java.lang.String sourceEUID, java.sql.Timestamp ts)
          Search the merge tree and find the active EUID associated with the merged EUID.
 MergeHistoryNode getMergeHistory(java.sql.Connection con, java.lang.String euid)
          This method populates the MergeHistoryNode object based on the root EUID that is passed to it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MergeHistoryHelper

public MergeHistoryHelper(TransactionMgr transMgr)
Creates a new instance of MergeHistoryHelper

Parameters:
transMgr - handle to transaction manager
Method Detail

getActiveEUID

public java.lang.String getActiveEUID(java.sql.Connection con,
                                      java.lang.String sourceEUID)
                               throws java.sql.SQLException
Search the merge tree and find the active EUID associated with the merged EUID.

Parameters:
con - Connection handle to database
sourceEUID - EUID of merged record
Returns:
Returns EUID record that pairs with the merged EUID of a merged event
Throws:
java.sql.SQLException - An error occured.

getActiveEUIDHelper

public java.lang.String getActiveEUIDHelper(java.sql.PreparedStatement selectActiveEUIDTimestamp,
                                            java.lang.String sourceEUID,
                                            java.sql.Timestamp ts)
                                     throws java.sql.SQLException
Search the merge tree and find the active EUID associated with the merged EUID. The timestamp is used to prevent circular references.

Parameters:
selectActiveEUIDTimestamp - Prepared statement for selcting the active EUID.
sourceEUID - EUID of merged record
ts - Timestamp of the last of merge.
Returns:
Returns EUID record that pairs with the merged EUID of a merged event
Throws:
java.sql.SQLException - An error occured.

getMergeHistory

public MergeHistoryNode getMergeHistory(java.sql.Connection con,
                                        java.lang.String euid)
                                 throws java.sql.SQLException,
                                        OPSException
This method populates the MergeHistoryNode object based on the root EUID that is passed to it. The main table that is used to determine the merge history is SBYN_MERGETRANS. To demonstrate how this function is used, an example will be used. Suppose the following merges have been performed: F merged to C (C survives) at time 1 B merged to A (A survives) at time 2 C merged to A (A survives) at time 3 G merged to D (D survives) at time 4 A merged to D (D survives) at time 5 D merged to E (E survives) at time 6 The mrg trans table will appear as follows: Dest Source TransId (survivor) (merged) --------------------------------------------- C F 1 A B 2 A C 3 D G 4 D A 5 E D 6 The desired merge tree is: E |--E |--D |--D | |--D | |--G |--A |--A | |--A | |--B |--C |--C |--F In order to translate the sbyn_mrg_trans table into this tree, a list was created to hold EUID's and handles for both merged and survivor records. The code in this event populates the list as follows: 1 2 3 4 5 6 7 ---------------------------------------------------------- Dest_EUID E E D D A A C Source_UID D A G C B F To achieve this result the following algorithm was used: 1) Search mrg trans for all EUID's that equal root 2) Populate the list with the survivor and merged EUIDs of the result set 1 2 3 4 5 6 7 ---------------------------------------------------------- Dest_EUID E E Source_EUID D 3) Now search for all EUID's in mrg trans that equal the merged EUID 4) Populate the list with the survivor and merged EUID's of the result set (sorted by transaction id) 1 2 3 4 5 6 7 ---------------------------------------------------------- Dest_EUID E E D D Source_EUID D A G 5) Now search for all EUID's in mrg trans that equal the added merged EUID's (A, G) 6) Populate the list with the survivor and merged UID's of the result set (sorted by transaction id) 1 2 3 4 5 6 7 ---------------------------------------------------------- Dest_EUID E E D D A A Source_EUID D A G C B 5) Now search for all EUID's in mrg trans that equal the added merged EUID's (C, B) 6) Populate the list with the survivor and merged EUID's of the result set (sorted by transaction id) 1 2 3 4 5 6 7 ---------------------------------------------------------- Dest_EUID E E D D A A C Source_EUID D A G C B F 7) The above algorithm is executed as a loop until no new records are added to list 8) Do While list pointer <= size of list Set list pointer to next row. Find record in list where (survivor EUID or merged EUID = the survivor EUID of the current row) AND list_row < current row. IF survivor EUID = the survivor of the EUID of the current row THEN Add the item as a child of the survivor UEID ELSE Add the item as a child of the merged EUID END IF

Parameters:
con - Connection handle
euid - EUID
Returns:
Merge history
Throws:
java.sql.SQLException - An error occured.
OPSException - An error occured.


Sun Microsystems, Inc.