com.rhi.architecture.batch
Class AbstractAuditAgent

java.lang.Object
  extended bycom.rhi.architecture.batch.AuditAgent
      extended bycom.rhi.architecture.batch.AbstractAuditAgent

public abstract class AbstractAuditAgent
extends AuditAgent

Abstract Audit Agent providing common audit count functionality

Since:
1.0
Author:
Pete McKinstry

Field Summary
static java.lang.String INSERT_SQL_KEY
          key for audit agent insert sql statement.
static java.lang.String SELECT_SQL_KEY
          key for audit agent select sql statement.
static java.lang.String UPDATE_SQL_KEY
          key for audit agent update sql statement.
 
Constructor Summary
AbstractAuditAgent()
          Constructor.
 
Method Summary
 void auditCollection(java.util.Collection c, Transaction t)
          Audit the given collection.
 void commitAudits()
          No op.
abstract  void configureRecord(java.util.Properties p)
          Allow concrete subclasses a hook to set values on their AuditRecord class.
 void createAudits(java.util.Collection c)
          Create an appropriate audit /control record.
protected  java.lang.String getInsertSQL()
          get insert SQL
protected  java.lang.String getInsertSQLKey()
          Allow subclasses to override config key.
abstract  AuditRecord getRecord()
          Get concrete AuditRecord Concrete AuditAgent will return the actual audit record being used.
protected  java.lang.String getSelectSQL()
          get select SQL
protected  java.lang.String getSelectSQLKey()
          Allow subclasses to override config key.
protected  java.lang.String getUpdateSQL()
          get update SQL
protected  java.lang.String getUpdateSQLKey()
          Allow subclasses to override config key.
 void init(java.util.Properties p)
          Initialization Logic
protected abstract  void insertRecord(java.sql.Connection conn)
          Insert new audit record
protected abstract  boolean loadRecord(java.sql.Connection conn)
          Load record (check for existence.
protected  void loadSQL(java.util.Properties p)
          Helper method called by init() to load the required SQL entries from the properties file.
 Logger log()
          Get the Logger reference
protected abstract  void updateRecord(java.sql.Connection conn)
          Update record
protected  void updateRecordCounts(java.util.Collection c)
          Update record counts based on the new collection.
 
Methods inherited from class com.rhi.architecture.batch.AuditAgent
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSERT_SQL_KEY

public static final java.lang.String INSERT_SQL_KEY
key for audit agent insert sql statement. (in config)

See Also:
Constant Field Values

UPDATE_SQL_KEY

public static final java.lang.String UPDATE_SQL_KEY
key for audit agent update sql statement. (in config)

See Also:
Constant Field Values

SELECT_SQL_KEY

public static final java.lang.String SELECT_SQL_KEY
key for audit agent select sql statement. (in config)

See Also:
Constant Field Values
Constructor Detail

AbstractAuditAgent

public AbstractAuditAgent()
Constructor.

Since:
1.0
Method Detail

init

public void init(java.util.Properties p)
          throws InitializationException
Initialization Logic

Specified by:
init in class AuditAgent
Parameters:
p - configuration properties for the audit agent.
Throws:
InitializationException - thrown when a problem is encountered configuring the audit agent.
Since:
1.0

configureRecord

public abstract void configureRecord(java.util.Properties p)
                              throws InitializationException
Allow concrete subclasses a hook to set values on their AuditRecord class.

Parameters:
p - configuration properties for the audit agent.
Throws:
InitializationException - error initializing the audit agent
Since:
1.0

loadSQL

protected void loadSQL(java.util.Properties p)
                throws InitializationException
Helper method called by init() to load the required SQL entries from the properties file.

Parameters:
p - configuration properties for the audit agent.
Throws:
InitializationException - error initializing the audit agent
Since:
1.0

createAudits

public void createAudits(java.util.Collection c)
                  throws AuditException
Create an appropriate audit /control record. This method should create a record w/ only a unprocessed count > 0. The auditCollection method will be called as records are passed through the pipeline & this method will modify the counts; subtracting from the unprocesed, and adding to the errored, valid, or duplicate counts.

Specified by:
createAudits in class AuditAgent
Parameters:
c - a collection of records that need to be audited.
Throws:
AuditException - error auditing collection, usually fatal.
Since:
1.0

auditCollection

public void auditCollection(java.util.Collection c,
                            Transaction t)
                     throws AuditException
Audit the given collection. This method should subtract the given collection.size() from the un- processed count for this audit set & add the collection.size() in some manner to the processed columns (valid,errored,duplicate,other)

Specified by:
auditCollection in class AuditAgent
Parameters:
c - - records to be audited.
t - - the transaction to participate in.
Throws:
AuditException - thrown when an error occurs auditing the given collection.
Since:
1.0

updateRecordCounts

protected void updateRecordCounts(java.util.Collection c)
                           throws AuditException
Update record counts based on the new collection.

Parameters:
c - update counts for this collection
Throws:
AuditException - thrown if error updating counts.
Since:
1.0

loadRecord

protected abstract boolean loadRecord(java.sql.Connection conn)
                               throws AuditException
Load record (check for existence.

Parameters:
conn - db connection used for audits. (maintaining a single db transaction)
Returns:
true if records exists, else false.
Throws:
AuditException - error retrieving audit record.
Since:
1.0

insertRecord

protected abstract void insertRecord(java.sql.Connection conn)
                              throws AuditException
Insert new audit record

Parameters:
conn - db connection used for audits in order to maintain all data updates w/in a single transaction.
Throws:
AuditException - error inserting a new audit record.
Since:
1.0

updateRecord

protected abstract void updateRecord(java.sql.Connection conn)
                              throws AuditException
Update record

Parameters:
conn - db connection used for audits in order to maintain all data updates w/in a single transaction.
Throws:
AuditException - error updating a audit record.
Since:
1.0

commitAudits

public void commitAudits()
                  throws AuditException
No op. This method is not very useful now that a Transaction is used for all OutputAdapter commit logic. Subclasses will probably not need to override this method.

Specified by:
commitAudits in class AuditAgent
Throws:
AuditException - error commiting the audits.
Since:
1.0

getRecord

public abstract AuditRecord getRecord()
Get concrete AuditRecord Concrete AuditAgent will return the actual audit record being used. Allow more flexibility in sub-classes.

Returns:
AuditRecord the audit record sub-class to be used.
Since:
1.0

getInsertSQL

protected java.lang.String getInsertSQL()
get insert SQL

Returns:
String insert sql
Since:
1.0

getUpdateSQL

protected java.lang.String getUpdateSQL()
get update SQL

Returns:
String update sql
Since:
1.0

getSelectSQL

protected java.lang.String getSelectSQL()
get select SQL

Returns:
String select sql
Since:
1.0

getInsertSQLKey

protected java.lang.String getInsertSQLKey()
Allow subclasses to override config key.

Returns:
String insert sql
Since:
1.0

getUpdateSQLKey

protected java.lang.String getUpdateSQLKey()
Allow subclasses to override config key.

Returns:
String update sql key
Since:
1.0

getSelectSQLKey

protected java.lang.String getSelectSQLKey()
Allow subclasses to override config key.

Returns:
String select sql key
Since:
1.0

log

public Logger log()
Get the Logger reference

Returns:
Logger log instance.
Since:
1.0


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