xmlBlaster 2.2.0 API

org.xmlBlaster.contrib.replication
Class TableToWatchInfo

java.lang.Object
  extended by org.xmlBlaster.contrib.replication.TableToWatchInfo

public class TableToWatchInfo
extends java.lang.Object

TableToWatchInfo is a place holder (as an ejb) for data which is stored in the ${replPrefix}tables table. It also offers facility to retrieve the data from info objects.

Author:
Michele Laghi

Field Summary
static java.lang.String ACTION_KEY
           
private  java.lang.String actions
          flags which are set mean the replication does happen for these flags.
static java.lang.String ALL_TOKEN
           
private  java.lang.String catalog
           
private  long debug
           
static java.lang.String EMPTY
           
static java.lang.String KEY_SEP
           
private static java.util.logging.Logger log
           
private  long replKey
           
private  java.lang.String schema
           
static java.lang.String SCHEMA_PREFIX
           
static java.lang.String SEQUENCE_KEY
           
private  java.lang.String status
           
static java.lang.String STATUS_CREATING
           
static java.lang.String STATUS_OK
           
static java.lang.String STATUS_REMOVE
           
private  java.lang.String table
           
static java.lang.String TABLE_PREFIX
           
static java.lang.String TABLE_PREFIX_WITH_SEP
          this is used as the prefix for all tables to replicate
private  java.lang.String trigger
           
static java.lang.String TRIGGER_KEY
           
static java.lang.String VAL_SEP
           
 
Constructor Summary
TableToWatchInfo()
           
TableToWatchInfo(java.lang.String catalog, java.lang.String schema, java.lang.String table)
           
 
Method Summary
 void assignFromInfoPair(java.lang.String key, java.lang.String value)
          Parses the data which is passed as a key/value pair.
private static boolean checkIfForeignKeysAreResolved(SqlDescription desc, java.util.Set setOfProcessedTables, java.util.Map allTables)
          Checks if there are foreign keys which are not resolved yet
static TableToWatchInfo get(java.sql.Connection conn, java.lang.String tableName, java.lang.String catalog, java.lang.String schema, java.lang.String table, TableToWatchInfo tableToWatch)
           
private static TableToWatchInfo get(java.sql.ResultSet rs, TableToWatchInfo tableToWatch)
           
 java.lang.String getActions()
           
static TableToWatchInfo[] getAll(java.sql.Connection conn, java.lang.String confTableName)
          Gets the entire configuration information of the configuration table specified in the argument list.
 java.lang.String getCatalog()
           
 java.lang.String getConfigKey()
           
 java.lang.String getConfigValue()
           
 int getDebug()
           
 long getReplKey()
           
 java.lang.String getSchema()
           
static java.lang.String getSortedTablesToWatch(java.sql.Connection conn, I_Info info, java.util.List outputSequence)
           
 java.lang.String getStatus()
           
 java.lang.String getTable()
           
private static java.lang.String[] getTablesForSchema(java.lang.String prefixToAdd, java.sql.Connection conn, TableToWatchInfo tableToWatch)
          Returns all table names for the given catalog and schema.
static TableToWatchInfo[] getTablesToWatch(java.sql.Connection conn, I_Info originalInfo)
          Gets an array containing all the tables to watch found in this configuration info object.
 java.lang.String getTrigger()
           
 boolean isReplicate()
           
 boolean isStatusOk(I_DbSpecific dbSpecific, java.sql.Connection conn)
          Checks if the status is OK.
private  void parseKey(java.lang.String key)
          Parses the key and fills this object appropriately.
private  void parseValue(java.lang.String val)
          Parses the value and fills the object appropriately.
 void removeFromDb(java.lang.String replicationPrefix, I_DbPool dbPool)
           
 void setActions(java.lang.String actions)
           
 void setCatalog(java.lang.String catalog)
           
 void setDebug(int debug)
           
 void setReplKey(long replKey)
           
 void setSchema(java.lang.String schema)
           
 void setStatus(java.lang.String status)
           
 void setTable(java.lang.String table)
           
 void setTrigger(java.lang.String trigger)
           
 void store(java.lang.String replPrefix, I_DbPool dbPool, java.sql.Connection conn)
          First checks if the entry exists already.
 void storeStatus(java.lang.String replicationPrefix, I_DbPool dbPool)
           
 java.lang.String toXml()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log

ACTION_KEY

public static final java.lang.String ACTION_KEY
See Also:
Constant Field Values

TRIGGER_KEY

public static final java.lang.String TRIGGER_KEY
See Also:
Constant Field Values

SEQUENCE_KEY

public static final java.lang.String SEQUENCE_KEY
See Also:
Constant Field Values

STATUS_CREATING

public static final java.lang.String STATUS_CREATING
See Also:
Constant Field Values

STATUS_OK

public static final java.lang.String STATUS_OK
See Also:
Constant Field Values

STATUS_REMOVE

public static final java.lang.String STATUS_REMOVE
See Also:
Constant Field Values

catalog

private java.lang.String catalog

schema

private java.lang.String schema

table

private java.lang.String table

status

private java.lang.String status

replKey

private long replKey

trigger

private java.lang.String trigger

debug

private long debug

actions

private java.lang.String actions
flags which are set mean the replication does happen for these flags. For example 'IDU' means everything will be replicated: (I)nserts, (D)eletes, and (U)pdates.


TABLE_PREFIX

public static final java.lang.String TABLE_PREFIX
See Also:
Constant Field Values

SCHEMA_PREFIX

public static final java.lang.String SCHEMA_PREFIX
See Also:
Constant Field Values

KEY_SEP

public static final java.lang.String KEY_SEP
See Also:
Constant Field Values

VAL_SEP

public static final java.lang.String VAL_SEP
See Also:
Constant Field Values

EMPTY

public static final java.lang.String EMPTY
See Also:
Constant Field Values

ALL_TOKEN

public static final java.lang.String ALL_TOKEN
See Also:
Constant Field Values

TABLE_PREFIX_WITH_SEP

public static final java.lang.String TABLE_PREFIX_WITH_SEP
this is used as the prefix for all tables to replicate

See Also:
Constant Field Values
Constructor Detail

TableToWatchInfo

public TableToWatchInfo()

TableToWatchInfo

public TableToWatchInfo(java.lang.String catalog,
                        java.lang.String schema,
                        java.lang.String table)
Method Detail

checkIfForeignKeysAreResolved

private static boolean checkIfForeignKeysAreResolved(SqlDescription desc,
                                                     java.util.Set setOfProcessedTables,
                                                     java.util.Map allTables)
                                              throws java.lang.Exception
Checks if there are foreign keys which are not resolved yet

Returns:
true if all foreign keys are resolved or if there was no foreign key, false otherwise.
Throws:
java.lang.Exception

getTablesForSchema

private static final java.lang.String[] getTablesForSchema(java.lang.String prefixToAdd,
                                                           java.sql.Connection conn,
                                                           TableToWatchInfo tableToWatch)
                                                    throws java.sql.SQLException
Returns all table names for the given catalog and schema. It only returns tables (not views), and it uses the MetaData of the connection.

Parameters:
prefixToAdd - the prefix to be added to the table names, if null nothing is added.
conn - the connection to be used.
tableToWatch - The tableToWatch object containing the name of the catalog and schema
Returns:
a String[] containing the names of the tables. The name of the tables is the absolute name.
Throws:
java.lang.Exception - if an exception on the backend occurs.
java.sql.SQLException

getSortedTablesToWatch

public static java.lang.String getSortedTablesToWatch(java.sql.Connection conn,
                                                      I_Info info,
                                                      java.util.List outputSequence)
                                               throws java.lang.Exception
Throws:
java.lang.Exception

getTablesToWatch

public static TableToWatchInfo[] getTablesToWatch(java.sql.Connection conn,
                                                  I_Info originalInfo)
                                           throws java.lang.Exception
Gets an array containing all the tables to watch found in this configuration info object.

Parameters:
info -
Returns:
Throws:
java.lang.Exception

parseKey

private final void parseKey(java.lang.String key)
                     throws java.lang.Exception
Parses the key and fills this object appropriately. The syntax to be parsed is of the kind:
table.[${catalog}.][${schema}.]${table}
examples:

Parameters:
key -
Throws:
java.lang.Exception

getConfigKey

public java.lang.String getConfigKey()

getConfigValue

public java.lang.String getConfigValue()

parseValue

private final void parseValue(java.lang.String val)
                       throws java.lang.Exception
Parses the value and fills the object appropriately. The syntax to be parsed is of the kind:
action=IDU,trigger=TRIGGER_NAME,sequence=100 Defaults are action=IDU, triggerName=null (will be assigned by the application, sequenceNr=-1, will be assigned by the application.

Parameters:
val -
Throws:
java.lang.Exception

assignFromInfoPair

public void assignFromInfoPair(java.lang.String key,
                               java.lang.String value)
                        throws java.lang.Exception
Parses the data which is passed as a key/value pair.

Parameters:
key -
value -
Throws:
java.lang.Exception

getCatalog

public java.lang.String getCatalog()
Returns:
Returns the catalog.

setCatalog

public void setCatalog(java.lang.String catalog)
Parameters:
catalog - The catalog to set.

isReplicate

public boolean isReplicate()
Returns:
Returns the replicate.

setActions

public void setActions(java.lang.String actions)
Parameters:
replicate - The replicate to set.

getReplKey

public long getReplKey()
Returns:
Returns the replKey.

setReplKey

public void setReplKey(long replKey)
Parameters:
replKey - The replKey to set.

getSchema

public java.lang.String getSchema()
Returns:
Returns the schema.

setSchema

public void setSchema(java.lang.String schema)
Parameters:
schema - The schema to set.

getStatus

public java.lang.String getStatus()
Returns:
Returns the status.

setStatus

public void setStatus(java.lang.String status)
Parameters:
status - The status to set.

getTable

public java.lang.String getTable()
Returns:
Returns the table.

setTable

public void setTable(java.lang.String table)
Parameters:
table - The table to set.

getTrigger

public java.lang.String getTrigger()
Returns:
Returns the trigger.

setTrigger

public void setTrigger(java.lang.String trigger)
Parameters:
trigger - The trigger to set.

store

public void store(java.lang.String replPrefix,
                  I_DbPool dbPool,
                  java.sql.Connection conn)
           throws java.lang.Exception
First checks if the entry exists already. If it exists, it is first removed, otherwise it is just added.

Parameters:
replPrefix -
dbPool -
conn -
Throws:
java.lang.Exception

get

private static TableToWatchInfo get(java.sql.ResultSet rs,
                                    TableToWatchInfo tableToWatch)
                             throws java.sql.SQLException
Parameters:
rs -
tableToWatch - can be null. If not it will be the instance returned (after having filled it of course).
Returns:
Throws:
java.sql.SQLException

get

public static TableToWatchInfo get(java.sql.Connection conn,
                                   java.lang.String tableName,
                                   java.lang.String catalog,
                                   java.lang.String schema,
                                   java.lang.String table,
                                   TableToWatchInfo tableToWatch)
                            throws java.lang.Exception
Parameters:
conn -
tableName - The name of the table from which to retrieve the information
catalog -
schema -
table -
tableToWatch - can be null. If it is not null, it will be changed appropriately and returned.
Returns:
Throws:
java.lang.Exception

getAll

public static TableToWatchInfo[] getAll(java.sql.Connection conn,
                                        java.lang.String confTableName)
Gets the entire configuration information of the configuration table specified in the argument list. Never throws exception nor returns null.

Parameters:
conn -
tableName -
Returns:

getActions

public java.lang.String getActions()

toXml

public java.lang.String toXml()

getDebug

public int getDebug()

setDebug

public void setDebug(int debug)

storeStatus

public void storeStatus(java.lang.String replicationPrefix,
                        I_DbPool dbPool)
                 throws java.lang.Exception
Throws:
java.lang.Exception

removeFromDb

public void removeFromDb(java.lang.String replicationPrefix,
                         I_DbPool dbPool)
                  throws java.lang.Exception
Throws:
java.lang.Exception

isStatusOk

public boolean isStatusOk(I_DbSpecific dbSpecific,
                          java.sql.Connection conn)
Checks if the status is OK. To return true the status flag in the tables table must be OK, the trigger must exist and no exception shall be thrown by requesting the existence of the trigger.

Parameters:
dbSpecific -
conn -
Returns:

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.