public class ExtDBSyncHandler extends java.lang.Object implements TaskHandler
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ATT_VALIDATE_ACTION |
static java.lang.String |
ATT_VALIDATE_CODE |
static java.lang.String |
ATT_VALIDATE_CONDITIONS |
static java.lang.String |
ATT_VALIDATE_FILTER_FIELD |
static java.lang.String |
ATT_VALIDATE_FILTER_PATTERN |
static java.lang.String |
ATT_VALIDATE_MESSAGE |
static java.lang.String |
ATT_VALIDATE_PATTERN |
static java.lang.String |
MODE_ACID
ACID mode
|
static java.lang.String |
MODE_AUTO
AUTO mode
|
static java.lang.String |
TAG_VALIDATE |
| Constructor and Description |
|---|
ExtDBSyncHandler() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDataBase(java.lang.String name,
DataBase db,
java.lang.String mode)
Adds a new Database to the list of databases
|
void |
addDataBase(java.lang.String name,
java.lang.String type,
java.lang.String url,
java.lang.String user,
java.lang.String pass,
java.lang.String mode)
Adds a new Database to the list of databases
|
ExtDBSyncTableDef |
addTable(java.lang.String srcName,
java.lang.String destName,
java.lang.String databaseName)
Adds a new table definition to the definition list
|
ExtDBSyncTableDef |
addTable(java.lang.String srcClassName,
java.lang.String destName,
java.lang.String databaseName,
java.lang.String updateHandler,
java.lang.String filter)
Adds a new table definition to the definition list
|
protected TransactionAnalysis |
analyseTransactions(Executor executor,
long transID,
SoapResultSet transRecord)
analyze all the transactions.
|
void |
beginTask(TaskManager manager,
Executor executor,
java.lang.String xml)
begin the task and process any parameters
|
void |
configure(java.lang.String fileName)
Loads the table/field mappings from the supplied file
|
void |
doSort(ExtDBSyncUpdate[] sortedList)
Sort the list of updates so that the updates are done in the correct order based on
dependencies, i.e If an Invoice is linked to a Person then the Person must be created
first in the target database before the Invoice is.
|
java.lang.String |
encodeValue(DataBase db,
ExtDBSyncFieldDef fieldDef,
java.lang.String inValue)
Formats the supplied value so that it is compatible with the type of field being
updated
|
protected DataBase |
getDataBase(java.lang.String name)
Retrieves the database for the supplied database name
|
protected java.util.HashMap |
getFldValueMap(Executor executor,
DataBase db,
java.lang.String transid,
long rowid,
ExtDBSyncTableDef tableDef,
java.lang.String action,
TransactionAnalysis ta)
Get value map.
|
protected java.lang.String |
getMode(java.lang.String name) |
java.lang.String[] |
getSrcClasses()
Returns a list of classes from the source database based on the
mapping definitions
|
ExtDBSyncTableDef[] |
getTableDefinitions(java.lang.String srcClassName)
Returns a list of table definitions that have the supplied source class name
|
protected ExtDBSyncUpdate |
getUpdateHandler(ExtDBSyncTableDef tableDef,
java.lang.String transId,
java.lang.String action,
java.util.HashMap valMap,
Executor executor)
Get value map.
|
void |
handleTask(Executor executor,
java.lang.String transid,
SoapResultSet transRecord)
Processes the next supplied transaction by identifying the classes changed and updating
the external database based on the field mappings.
|
protected void |
initParentClasses(Executor executor) |
protected boolean |
isInteresting(Executor executor,
long transID,
ExtDBSyncTableDef td,
long rowID)
Is this transaction interesting ?
|
void |
loadDoc(java.io.File file)
Loads the table/field mappings from the supplied file
|
public static final java.lang.String MODE_ACID
public static final java.lang.String MODE_AUTO
public static final java.lang.String TAG_VALIDATE
public static final java.lang.String ATT_VALIDATE_CODE
public static final java.lang.String ATT_VALIDATE_CONDITIONS
public static final java.lang.String ATT_VALIDATE_MESSAGE
public static final java.lang.String ATT_VALIDATE_PATTERN
public static final java.lang.String ATT_VALIDATE_ACTION
public static final java.lang.String ATT_VALIDATE_FILTER_FIELD
public static final java.lang.String ATT_VALIDATE_FILTER_PATTERN
public void beginTask(@Nonnull
TaskManager manager,
@Nonnull
Executor executor,
@Nonnull
java.lang.String xml)
throws java.lang.Exception
beginTask in interface TaskHandlerxml - the parametersmanager - the task managerexecutor - the server connectionjava.lang.Exception - a serious problemprotected void initParentClasses(@Nonnull
Executor executor)
throws java.lang.Exception
executor - java.lang.Exception - a serious problem.@CheckReturnValue protected boolean isInteresting(Executor executor, long transID, ExtDBSyncTableDef td, long rowID)
executor - transID - td - rowID - protected TransactionAnalysis analyseTransactions(Executor executor, long transID, SoapResultSet transRecord) throws java.lang.Exception
executor - transID - transRecord - java.lang.Exception - a serious problem.public void handleTask(@Nonnull
Executor executor,
@Nonnull
java.lang.String transid,
@Nonnull
SoapResultSet transRecord)
throws java.lang.Exception
handleTask in interface TaskHandlerexecutor - an Executor object for running SQLtransid - the transaction id for this notificationtransRecord - the transaction record for this transaction idjava.lang.Exception - A serious errorpublic void doSort(ExtDBSyncUpdate[] sortedList)
sortedList - List of update objects that need to be sortedpublic java.lang.String encodeValue(DataBase db, ExtDBSyncFieldDef fieldDef, java.lang.String inValue) throws java.lang.Exception
db - - database to be updatedfieldDef - - field definition for external databaseinValue - - Value to be convertedjava.lang.Exception - A serious errorpublic void configure(java.lang.String fileName)
throws java.lang.Exception
fileName - - name of file to be loadedjava.lang.Exception - A serious errorpublic void loadDoc(@Nonnull
java.io.File file)
throws java.lang.Exception
file - - file to be loadedjava.lang.Exception - A serious error@CheckReturnValue @Nonnull protected DataBase getDataBase(@Nonnull java.lang.String name)
name - - name of database to be retrieved@CheckReturnValue
@Nullable
protected java.lang.String getMode(@Nonnull
java.lang.String name)
name - the databasepublic void addDataBase(java.lang.String name,
java.lang.String type,
java.lang.String url,
java.lang.String user,
java.lang.String pass,
java.lang.String mode)
throws java.lang.Exception
name - - Name used to retrieve the databasetype - - type of database, i.e. POSTGRESQLurl - - server/database URLuser - - user namepass - - password of usermode - the mode ACIDjava.lang.Exception - A serious errorpublic void addDataBase(java.lang.String name,
DataBase db,
java.lang.String mode)
throws java.lang.Exception
name - - Name used to retrieve the databasedb - - database to be addedmode - the mode ACIDjava.lang.Exception - A serious errorpublic ExtDBSyncTableDef addTable(java.lang.String srcName, java.lang.String destName, java.lang.String databaseName)
srcName - - name of class in source databasedestName - - name of table in destination databasedatabaseName - - name of destination database that this table is found inpublic ExtDBSyncTableDef addTable(java.lang.String srcClassName, java.lang.String destName, java.lang.String databaseName, java.lang.String updateHandler, java.lang.String filter)
filter - - filter for the classsrcClassName - - name of class in source databasedestName - - name of table in destination databasedatabaseName - - name of destination database that this table is found inupdateHandler - - name of handler class that updates will be performed throughpublic java.lang.String[] getSrcClasses()
public ExtDBSyncTableDef[] getTableDefinitions(java.lang.String srcClassName)
srcClassName - - name of class in source database@CheckReturnValue @Nonnull protected java.util.HashMap getFldValueMap(Executor executor, DataBase db, java.lang.String transid, long rowid, ExtDBSyncTableDef tableDef, java.lang.String action, TransactionAnalysis ta) throws java.lang.Exception
executor - executordb - the databasetransid - transaction idrowid - RowId for objecttableDef - tableDefaction - action performed on the objectta - the analysisjava.lang.Exception - A serious errorprotected ExtDBSyncUpdate getUpdateHandler(ExtDBSyncTableDef tableDef, java.lang.String transId, java.lang.String action, java.util.HashMap valMap, Executor executor) throws java.lang.Exception
tableDef - the table definition detailstransId - the transaction idaction - action that was performed on objectvalMap - list of fieldname/val pairsexecutor - who should run it.java.lang.Exception - in case of errorstSoftware Copyright © 2001-2014 stSoftware All Rights Reserved.