uk.org.ogsadai.activity.sql
Class SQLBulkLoadRowSetActivity

java.lang.Object
  |
  +--uk.org.ogsadai.activity.Activity
        |
        +--uk.org.ogsadai.activity.sql.AbstractSQLActivity
              |
              +--uk.org.ogsadai.activity.sql.SQLBulkLoadRowSetActivity

public class SQLBulkLoadRowSetActivity
extends AbstractSQLActivity

Bulk loads data, provided in the WebRowSet format, into a table. This activity performs an insert for each row in the input data.

The bulk load can be performed transactionally, meaning that all previously completed inserts will be rolled back if an insert fails.

For information on this activity see the OGSA-DAI user doc: OGSA-DAI/doc/interaction/activities/relational/sqlBulkLoadRowSet.html

Author:
The OGSA-DAI Project Team.

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
static java.lang.String LOAD_INTO_TABLE
          Activity XML constant
private static DAILogger LOG
          Logger object for logging in this class
private  java.sql.Connection mConnection
          JDBC database connection handler
private  boolean mFinishedProcessing
          Finished processing?
private  BlockReader mInput
          Activity input - WebRowSet
private  boolean mIsTransaction
          Execute transactionally?
private  ParameterList mParameters
          SQL expression parameters
private  java.lang.String mTableName
          Name of the table to bulk load to
private  int mTotalInsertCount
          Total number of rows processed
private  int mUpdateCount
          Update count
 
Fields inherited from class uk.org.ogsadai.activity.sql.AbstractSQLActivity
CREATE_DATABASE, DROP_DATABASE, EXPRESSION, mCredentials, mDataResource, mExpression, mInputStreamNames, mOutput, mStatement, RESULT_STREAM, SQL_OUT_PARAMETERS, SQL_PARAMETERS, STORED_PROCEDURE, WEB_ROW_SET_STREAM
 
Fields inherited from class uk.org.ogsadai.activity.Activity
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs
 
Constructor Summary
SQLBulkLoadRowSetActivity(org.w3c.dom.Element element)
          Constructs an activity using the specified element.
 
Method Summary
private  java.lang.String buildExpressionAndParameters(java.sql.ResultSet resultSet)
          Build bulk load expression and parameters.
protected  void cleanUp()
          This method can be overridden by any Activity implementations that need to free up resources in the event of an error or intermediate termination of the activity processing.
private  void endProcessing()
          Finish execution and clean up.
 void initialise()
          This method should be overridden by subclasses to perform any initialisation they require before the process method invocations begin.
private  void parseInputStream(org.w3c.dom.NodeList inputNL)
          Gets the name of the activity's input stream.
private  void parseTableName(org.w3c.dom.NodeList tableList)
          Gets the name of the table to bulk load into and also whether the activity is to be transational.
protected  void processBlock()
          Performs an iteration of the processing of an activity.
protected  void processFirst()
          This method is called during the first iteration of processing an activity.
 
Methods inherited from class uk.org.ogsadai.activity.sql.AbstractSQLActivity
createOutputPipe, parseExpression, parseResultStream
 
Methods inherited from class uk.org.ogsadai.activity.Activity
connectsTo, getActivityConfiguration, getActivityName, getCause, getName, getObservableStatus, getProperties, getSession, getStatus, hasActivityConfiguration, hasProperties, process, setActivityName, setCompleted, setError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

LOG

private static DAILogger LOG
Logger object for logging in this class


mConnection

private java.sql.Connection mConnection
JDBC database connection handler


LOAD_INTO_TABLE

public static java.lang.String LOAD_INTO_TABLE
Activity XML constant


mUpdateCount

private int mUpdateCount
Update count


mTotalInsertCount

private int mTotalInsertCount
Total number of rows processed


mFinishedProcessing

private boolean mFinishedProcessing
Finished processing?


mInput

private BlockReader mInput
Activity input - WebRowSet


mParameters

private ParameterList mParameters
SQL expression parameters


mTableName

private java.lang.String mTableName
Name of the table to bulk load to


mIsTransaction

private boolean mIsTransaction
Execute transactionally?

Constructor Detail

SQLBulkLoadRowSetActivity

public SQLBulkLoadRowSetActivity(org.w3c.dom.Element element)
                          throws ActivitySpecificationException,
                                 ActivityCreationException
Constructs an activity using the specified element.

Parameters:
element - Element to configure the activity with - from a perform document.
Throws:
ActivityCreationException - If there is a problem constructing the activity.
ActivitySpecificationException - If there is a problem constructing the activity due to an invalid setting in element.
See Also:
uk.org.ogsadai.activity
Method Detail

initialise

public void initialise()
                throws ActivitySpecificationException,
                       ActivityExecutionException
Description copied from class: Activity
This method should be overridden by subclasses to perform any initialisation they require before the process method invocations begin. This might be used for setting up convenient fields to reference objects contained in the context. It shouldn't be used for opening resources. That should be done in processFirst.

Overrides:
initialise in class AbstractSQLActivity
Throws:
ActivityExecutionException - If some system problem prevents the activity from initialising.
ActivitySpecificationException - If a problem with settings provided by a client prevents the activity from initialising.

processFirst

protected void processFirst()
Description copied from class: Activity
This method is called during the first iteration of processing an activity. It can be overridden by subclasses to define some processing that should be done only once during the first iteration of the activity processing, for example evaluating a database query.

Overrides:
processFirst in class Activity

processBlock

protected void processBlock()
Description copied from class: Activity
Performs an iteration of the processing of an activity. This may involve reading a block of input data and writing a block of output data, or may involve some other kind of processing. When an activity is processed by the OGSA-DAI engine, this method will be invoked repeatedly until the activity either completes or stops due to an error or termination call. An implementation of this method should invoke the setCompleted method to indicate that processing is complete, or the setError method if an error occurs that will prevent the processing from completing.

Specified by:
processBlock in class Activity

endProcessing

private void endProcessing()
Finish execution and clean up.


cleanUp

protected void cleanUp()
Description copied from class: Activity
This method can be overridden by any Activity implementations that need to free up resources in the event of an error or intermediate termination of the activity processing.

Overrides:
cleanUp in class Activity

parseInputStream

private void parseInputStream(org.w3c.dom.NodeList inputNL)
                       throws ActivitySpecificationException
Gets the name of the activity's input stream.

Parameters:
inputNL - Elements with name attributes. First node in the list has the value of the name attribute returned.
Throws:
ActivitySpecificationException - If there are no elements in the list.

parseTableName

private void parseTableName(org.w3c.dom.NodeList tableList)
Gets the name of the table to bulk load into and also whether the activity is to be transational.

Parameters:
tableList - Elements with tableName and transactionallity attributes. First node in the list has the value of these attributes extracted.

buildExpressionAndParameters

private java.lang.String buildExpressionAndParameters(java.sql.ResultSet resultSet)
                                               throws java.sql.SQLException
Build bulk load expression and parameters.

Parameters:
resultSet - Data to bulk load
Returns:
SQL expression
Throws:
java.sql.SQLException - If any problems arise in the driver.