com.rhi.architecture.parc.adapter.jdbc
Class JDBCOutputAdapter

java.lang.Object
  extended bycom.rhi.architecture.parc.adapter.AbstractOutputAdapter
      extended bycom.rhi.architecture.parc.adapter.jdbc.JDBCOutputAdapter
All Implemented Interfaces:
Adapter, OutputAdapter, java.lang.Runnable

public abstract class JDBCOutputAdapter
extends AbstractOutputAdapter

JDBC Output Adapter. Helper class for interfaces implementing an Output Adapter using JDBC.

Since:
1.0
Author:
Pete McKinstry

Field Summary
 
Fields inherited from interface com.rhi.architecture.parc.OutputAdapter
DEFAULT_THREAD_MODE, RUN_AS_THREAD, RUN_AS_THREAD_KEY
 
Constructor Summary
JDBCOutputAdapter()
          Default constructor
 
Method Summary
protected  void addErrorToRecord(Record r)
          Add error to valid record for a problem during output adapter processing.
 void cleanup()
          Cleanup any resources.
protected  java.lang.String getPersistErrorSQL()
          Return the SQL for inserting or updating an error record.
protected  java.lang.String getPersistValidSQL()
          Return the SQL for persisting (insert or update) a new valid record.
protected  java.lang.String getUpdateSQLForErrorSourceRecord()
          Return the SQL for updating the source record corresponding to the given output record.
protected  java.lang.String getUpdateSQLForValidSourceRecord()
          Return the SQL for updating the source record corresponding to the given output record.
protected  void handleErrorRecords(java.util.Collection c, Transaction t)
          General Case implementation for persisting error records.
protected  java.util.Collection handleValidRecords(java.util.Collection c, Transaction t)
          Handle persistence of valid records from the framework.
 void init(java.util.Properties props)
          Initialize the Logger, and load the SQL statements.
protected  boolean persistErrorRecord(Error error, Transaction t)
          Add or update the error record.
protected  boolean persistValidRecord(Record record, Transaction t)
          Add or update valid records to the output table.
protected  java.sql.PreparedStatement prepareErrorStatement(Error error, java.sql.Connection conn)
          Get SQL, prepare SQL statement, and set all the error fields.
protected  java.sql.PreparedStatement prepareStatementForErrorSourceRecord(Record record, java.sql.Connection conn)
          Get SQL, prepare SQL statement, and set all the error fields.
protected  java.sql.PreparedStatement prepareStatementForValidSourceRecord(Record record, java.sql.Connection conn)
          Get SQL, prepare SQL statement, and set all the error fields.
protected  java.sql.PreparedStatement prepareValidStatement(Record record, java.sql.Connection conn)
          Get SQL, prepare SQL statement, and set all the appropriate fields.
protected  void setErrorStatementFields(Error error, java.sql.PreparedStatement stmt)
          Set the appropriate fields on the prepared statement Not abstract so that sub-classes that don't use prepareErrorStatement need not implement this w/ a no-op, but if anyone who _should_ implement it doesn't, it will "fail fast" & let them know immediately.
protected  void setStatementForErrorSourceRecord(Record record, java.sql.PreparedStatement stmt)
          Set the appropriate fields on the prepared statement Not abstract so that sub-classes that don't use prepareErrorStatement need not implement this w/ a no-op, but if anyone who _should_ implement it doesn't, it will "fail fast" & let them know immediately.
protected  void setStatementForValidSourceRecord(Record record, java.sql.PreparedStatement stmt)
          Set the appropriate fields on the prepared statement Not abstract so that sub-classes that don't use prepareErrorStatement need not implement this w/ a no-op, but if anyone who _should_ implement it doesn't, it will "fail fast" & let them know immediately.
protected  void setValidStatementFields(Record record, java.sql.PreparedStatement stmt)
          Set all the fields on the prepared statement using the output record.
protected  boolean updateSourceForErrorRecord(Record record, Transaction t)
          Mark the source record complete.
protected  boolean updateSourceForValidRecord(Record record, Transaction t)
          Mark the source record complete.
 
Methods inherited from class com.rhi.architecture.parc.adapter.AbstractOutputAdapter
close, completeBatch, createTransaction, flush, getAuditAgent, log, markComplete, run, setAuditAgent, setErrorChannel, setExceptionHandler, setValidChannel, write, writeErrorRecords, writeValidRecords
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCOutputAdapter

public JDBCOutputAdapter()
Default constructor

Since:
1.0
Method Detail

init

public void init(java.util.Properties props)
          throws InitializationException
Initialize the Logger, and load the SQL statements.

Specified by:
init in interface OutputAdapter
Overrides:
init in class AbstractOutputAdapter
Parameters:
props - - the configuration data
Throws:
InitializationException - - Logger not properly configured
Since:
1.0

cleanup

public void cleanup()
Cleanup any resources.

Specified by:
cleanup in interface OutputAdapter
Overrides:
cleanup in class AbstractOutputAdapter
Since:
1.0

handleValidRecords

protected java.util.Collection handleValidRecords(java.util.Collection c,
                                                  Transaction t)
                                           throws ProcessingException
Handle persistence of valid records from the framework.

Specified by:
handleValidRecords in class AbstractOutputAdapter
Parameters:
c - - valid records.
t - - the transaction to use in committing the records.
Returns:
Collection - records errored during persistence.
Throws:
ProcessingException
Since:
1.0

persistValidRecord

protected boolean persistValidRecord(Record record,
                                     Transaction t)
                              throws ProcessingException
Add or update valid records to the output table.

Parameters:
record -
t -
Returns:
boolean - true or false if the record was persisted properly.
Throws:
ProcessingException - - irrecoverable failure.
Since:
1.0

prepareValidStatement

protected java.sql.PreparedStatement prepareValidStatement(Record record,
                                                           java.sql.Connection conn)
                                                    throws java.sql.SQLException,
                                                           ProcessingException
Get SQL, prepare SQL statement, and set all the appropriate fields.

Parameters:
record -
conn -
Returns:
PreparedStatement
Throws:
java.sql.SQLException
ProcessingException
Since:
1.0

setValidStatementFields

protected void setValidStatementFields(Record record,
                                       java.sql.PreparedStatement stmt)
                                throws java.sql.SQLException,
                                       ProcessingException
Set all the fields on the prepared statement using the output record. Not abstract so that sub-classes that don't use prepareValidStatement need not implement this w/ a no-op, but if anyone who _should_ implement it doesn't, it will "fail fast" & let them know immediately.

Parameters:
record -
stmt - - the statement to execute.
Throws:
ProcessingException
java.sql.SQLException
Since:
1.0

getPersistValidSQL

protected java.lang.String getPersistValidSQL()
Return the SQL for persisting (insert or update) a new valid record.

Returns:
String
Since:
1.0

handleErrorRecords

protected void handleErrorRecords(java.util.Collection c,
                                  Transaction t)
                           throws ProcessingException
General Case implementation for persisting error records.

Specified by:
handleErrorRecords in class AbstractOutputAdapter
Parameters:
c - - errored records
t - - the database transaction under which any SQL inserts/updates should be made.
Throws:
ProcessingException
Since:
1.0

persistErrorRecord

protected boolean persistErrorRecord(Error error,
                                     Transaction t)
                              throws ProcessingException
Add or update the error record.

Parameters:
error -
t -
Returns:
boolean
Throws:
ProcessingException
Since:
1.0

prepareErrorStatement

protected java.sql.PreparedStatement prepareErrorStatement(Error error,
                                                           java.sql.Connection conn)
                                                    throws java.sql.SQLException,
                                                           ProcessingException
Get SQL, prepare SQL statement, and set all the error fields.

Parameters:
error -
conn -
Returns:
PreparedStatement
Throws:
java.sql.SQLException
ProcessingException
Since:
1.0

setErrorStatementFields

protected void setErrorStatementFields(Error error,
                                       java.sql.PreparedStatement stmt)
                                throws java.sql.SQLException,
                                       ProcessingException
Set the appropriate fields on the prepared statement Not abstract so that sub-classes that don't use prepareErrorStatement need not implement this w/ a no-op, but if anyone who _should_ implement it doesn't, it will "fail fast" & let them know immediately.

Parameters:
error -
stmt -
Throws:
java.sql.SQLException
ProcessingException
Since:
1.0

getPersistErrorSQL

protected java.lang.String getPersistErrorSQL()
Return the SQL for inserting or updating an error record.

Returns:
String
Since:
1.0

updateSourceForValidRecord

protected boolean updateSourceForValidRecord(Record record,
                                             Transaction t)
                                      throws ProcessingException
Mark the source record complete.

Parameters:
record - the destination record.
t -
Returns:
boolean
Throws:
ProcessingException
Since:
1.0

prepareStatementForValidSourceRecord

protected java.sql.PreparedStatement prepareStatementForValidSourceRecord(Record record,
                                                                          java.sql.Connection conn)
                                                                   throws java.sql.SQLException,
                                                                          ProcessingException
Get SQL, prepare SQL statement, and set all the error fields.

Parameters:
record -
conn -
Returns:
PreparedStatement
Throws:
java.sql.SQLException
ProcessingException
Since:
1.0

setStatementForValidSourceRecord

protected void setStatementForValidSourceRecord(Record record,
                                                java.sql.PreparedStatement stmt)
                                         throws java.sql.SQLException,
                                                ProcessingException
Set the appropriate fields on the prepared statement Not abstract so that sub-classes that don't use prepareErrorStatement need not implement this w/ a no-op, but if anyone who _should_ implement it doesn't, it will "fail fast" & let them know immediately.

Parameters:
record -
stmt -
Throws:
java.sql.SQLException
ProcessingException
Since:
1.0

getUpdateSQLForValidSourceRecord

protected java.lang.String getUpdateSQLForValidSourceRecord()
Return the SQL for updating the source record corresponding to the given output record.

Returns:
String
Since:
1.0

updateSourceForErrorRecord

protected boolean updateSourceForErrorRecord(Record record,
                                             Transaction t)
                                      throws ProcessingException
Mark the source record complete.

Parameters:
record - the destination record.
t -
Returns:
boolean
Throws:
ProcessingException
Since:
1.0

prepareStatementForErrorSourceRecord

protected java.sql.PreparedStatement prepareStatementForErrorSourceRecord(Record record,
                                                                          java.sql.Connection conn)
                                                                   throws java.sql.SQLException,
                                                                          ProcessingException
Get SQL, prepare SQL statement, and set all the error fields.

Parameters:
record -
conn -
Returns:
PreparedStatement
Throws:
java.sql.SQLException
ProcessingException
Since:
1.0

setStatementForErrorSourceRecord

protected void setStatementForErrorSourceRecord(Record record,
                                                java.sql.PreparedStatement stmt)
                                         throws java.sql.SQLException,
                                                ProcessingException
Set the appropriate fields on the prepared statement Not abstract so that sub-classes that don't use prepareErrorStatement need not implement this w/ a no-op, but if anyone who _should_ implement it doesn't, it will "fail fast" & let them know immediately.

Parameters:
record -
stmt -
Throws:
java.sql.SQLException
ProcessingException
Since:
1.0

getUpdateSQLForErrorSourceRecord

protected java.lang.String getUpdateSQLForErrorSourceRecord()
Return the SQL for updating the source record corresponding to the given output record.

Returns:
String
Since:
1.0

addErrorToRecord

protected void addErrorToRecord(Record r)
Add error to valid record for a problem during output adapter processing. This method can be overridden to correctly add the program specific error to the record. By default, it does nothing.

Parameters:
r -
Since:
1.1


Copyright © 2002-2004 Robert Half International. All Rights Reserved.