|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object
|
+--uk.org.ogsadai.engine.Activity
|
+--uk.org.ogsadai.activity.sql.SQLActivity
An Abstract class to hold common functions for Activities relate to relational database access.
The SQLStatementActivity is constructed from an Element corresponding to a statement
for execution on a database.
A Context can then be set detailing the environment in which this
activity exists. Where to obtain inputs from and send output too.
The activity must be able to decide the DataResource over which to carryout the statement. It must
be given a ConnectionManager
The credentials of the user should be available from the context
The activity can then be processed a block at a time.
| Nested Class Summary | |
protected class |
SQLActivity.ParameterInput
ParameterInput inner class. |
class |
SQLActivity.StreamInput
StreamInput inner class. |
class |
SQLActivity.ValueInput
ValueInput inner class. |
| Field Summary | |
static java.lang.String |
CREATE_DATABASE
|
static java.lang.String |
DROP_DATABASE
|
static java.lang.String |
EXPRESSION
|
protected SQLActivity.ParameterInput[] |
mAllInput
|
protected java.sql.Connection |
mConnection
|
protected JDBCConnectionManager |
mConnectionManager
|
protected java.lang.String |
mCredentials
|
protected java.lang.String |
mExpression
|
protected SQLActivity.ParameterInput |
mExpressionInput
|
protected java.util.Set |
mInputStreams
|
protected boolean |
mIsTransaction
|
protected java.util.Map |
mNameToInput
|
protected boolean |
mOpenConnection
|
protected BlockWriter |
mOutput
|
protected java.sql.Statement |
mStatement
|
static java.lang.String |
RESULT_STREAM
|
static java.lang.String |
SQL_PARAMETERS
|
static java.lang.String |
STORED_PROCEDURE
|
static java.lang.String |
WEB_ROW_SET_STREAM
|
| Fields inherited from class uk.org.ogsadai.engine.Activity |
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs |
| Constructor Summary | |
SQLActivity(org.w3c.dom.Element element)
Constructor : This constructor doesn't do much. |
|
| Method Summary | |
protected void |
endProcessing()
This method will complete the processing and tidy up |
protected boolean |
getResult()
This method will try and complete the statement with parameters Then try and execute the query and obtain the resultSet |
void |
initialise()
Completes initialisation of Activity. |
protected boolean |
loadNextExpression()
Helper method to retrieve expression from an input stream or value. |
protected void |
parseCommand(org.w3c.dom.NodeList commandNL)
This method will find the command appropriate for this actiivity, can be SQLStatement or a StoredProcedure. |
protected void |
parseResultStream(org.w3c.dom.NodeList resultStreamNL)
This method will find the webRowSetStream appropriate for this activity. |
protected void |
parseSQLParameters(org.w3c.dom.NodeList sqlParameterNL)
This method will find the SQLParameters appropriate for this activity if any are specified. |
protected boolean |
prepareStatement()
Helper method to prepare parameters for prepared statements This method runs through all parameters and retrieves the value from an input stream or the contents of an SQLParameter. |
protected void |
setupInputStreamNames()
Sets up the InputStream Names. |
| Methods inherited from class uk.org.ogsadai.engine.Activity |
cleanUp, connectsTo, getActivityConfiguration, getName, getObservableStatus, getProperties, getStatus, hasActivityConfiguration, hasProperties, processBlock, processFirst, setCompleted, setError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String EXPRESSION
public static final java.lang.String STORED_PROCEDURE
public static final java.lang.String CREATE_DATABASE
public static final java.lang.String DROP_DATABASE
public static final java.lang.String SQL_PARAMETERS
public static final java.lang.String WEB_ROW_SET_STREAM
public static final java.lang.String RESULT_STREAM
protected BlockWriter mOutput
protected java.util.Map mNameToInput
protected SQLActivity.ParameterInput[] mAllInput
protected SQLActivity.ParameterInput mExpressionInput
protected java.lang.String mExpression
protected java.util.Set mInputStreams
protected boolean mOpenConnection
protected boolean mIsTransaction
protected java.sql.Statement mStatement
protected java.sql.Connection mConnection
protected java.lang.String mCredentials
protected JDBCConnectionManager mConnectionManager
| Constructor Detail |
public SQLActivity(org.w3c.dom.Element element)
throws ActivityUserException,
ActivitySystemException
element - Element containing Statement conforming to schema for a SQLQueryStatement.
It is assumed schema checks have been carried out.
ActivityUserException
ActivitySystemException| Method Detail |
protected void parseSQLParameters(org.w3c.dom.NodeList sqlParameterNL)
throws ActivityUserException
These SQLParameters could be values or Input Streams and sqlParameters array at position x will hold the value for the sqlParameter at position x, while the sqlParametersAsInputStream array at position x will hold the name of the inputStream from which to read the value Further the same input stream could provide input for more than one parameter i.e. a datastore
sqlParameterNL - A nodeList correposnding to elements with Tag SQL_PARAMETERS
ActivityUserException - if SQL parameter is out of range, specified twice or complicated value
protected void parseCommand(org.w3c.dom.NodeList commandNL)
throws ActivityUserException,
ActivitySystemException
This command could be a value or Input Stream and command will hold the value for the command or commandAsInputStream will hold the name of the inputStream from which to read the value
commandNL - A nodeList corresponding to elements with a command tag, either
EXPRESSION or STORED_PROCEDURE
ActivityUserException - on complicated command, specifying both value and inputstream
ActivitySystemException
protected void parseResultStream(org.w3c.dom.NodeList resultStreamNL)
throws ActivityUserException
resultStreamNL - A nodeList corresponding to elements with a tag WEB_ROW_SET_STREAM
ActivityUserExceptionprotected void setupInputStreamNames()
public void initialise()
throws ActivityUserException
initialise in class ActivityActivityUserException - If a user problem prevents the activity from
initialising.protected boolean loadNextExpression()
protected boolean prepareStatement()
throws ActivitySystemException,
ActivityUserException,
java.sql.SQLException
ActivityUserException - if input streams don't end at the same time
ActivitySystemException
java.sql.SQLException
protected boolean getResult()
throws java.sql.SQLException,
ActivitySystemException,
ActivityUserException
ActivityUserException
ActivitySystemException
java.sql.SQLException
protected void endProcessing()
throws java.sql.SQLException,
ActivitySystemException
java.sql.SQLException
ActivitySystemException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||