uk.org.ogsadai.activity.xmldb
Class XMLBulkLoadActivity

java.lang.Object
  |
  +--uk.org.ogsadai.activity.Activity
        |
        +--uk.org.ogsadai.activity.xmldb.XMLDBActivity
              |
              +--uk.org.ogsadai.activity.xmldb.XMLBulkLoadActivity

public class XMLBulkLoadActivity
extends XMLDBActivity

An XMLDBActivity for bulk loading data into a XMLDB compliant database collection.

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

Author:
The OGSA-DAI Project Team

Field Summary
static java.lang.String ATTRIBUTE_CREATE
          Constant for parsing activity XML - create new resource
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
static java.lang.String ELEMENT_FROM_LOCAL
          Constant for parsing activity XML - activity input
static java.lang.String ELEMENT_OUTPUT
          Constant for parsing activity XML - activity output
static java.lang.String FOOTER
          Footer for the XML representation of a set of resources.
static java.lang.String HEADER
          Header for the XML representation of a set of resources.
private static DAILogger LOG
          Logger object for logging in this class
private  org.xmldb.api.base.Collection mCollection
          Collection into which the resources will be loaded
private  boolean mCreateCollectionIfNotExists
          should we create a new collection if it doesn't exist?
private  int mCurrentResource
          Number of the resource we are currently processing
private  BlockReader mInput
          Input stream from another activity, providing the resources
private  org.w3c.dom.NodeList mResources
          Resources for bulk loading if they are included in the request
 
Fields inherited from class uk.org.ogsadai.activity.xmldb.XMLDBActivity
mDataResource, mOutput, mSubCollectionName, mUserCredentials
 
Fields inherited from class uk.org.ogsadai.activity.Activity
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs
 
Constructor Summary
XMLBulkLoadActivity(org.w3c.dom.Element element)
          Constructs an XMLBulkLoad activity using the specified XML element.
 
Method Summary
private  void addDocument(org.w3c.dom.Element element)
          Add a resource to the current collection.
 void initialise()
          This method should be overridden by subclasses to perform any initialisation they require before the process method invocations begin.
 void processBlock()
          Performs an iteration of the processing of an activity.
 void processFirst()
          This method is called during the first iteration of processing an activity.
private  java.lang.String resultsToXML(int numResources)
          Converts the results of the bulk load execution into an XML string representation.
 
Methods inherited from class uk.org.ogsadai.activity.Activity
cleanUp, connectsTo, createOutputPipe, 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


ELEMENT_FROM_LOCAL

public static final java.lang.String ELEMENT_FROM_LOCAL
Constant for parsing activity XML - activity input

See Also:
Constant Field Values

ELEMENT_OUTPUT

public static final java.lang.String ELEMENT_OUTPUT
Constant for parsing activity XML - activity output

See Also:
Constant Field Values

ATTRIBUTE_CREATE

public static final java.lang.String ATTRIBUTE_CREATE
Constant for parsing activity XML - create new resource

See Also:
Constant Field Values

HEADER

public static final java.lang.String HEADER
Header for the XML representation of a set of resources.

See Also:
Constant Field Values

FOOTER

public static final java.lang.String FOOTER
Footer for the XML representation of a set of resources.

See Also:
Constant Field Values

mResources

private org.w3c.dom.NodeList mResources
Resources for bulk loading if they are included in the request


mCurrentResource

private int mCurrentResource
Number of the resource we are currently processing


mInput

private BlockReader mInput
Input stream from another activity, providing the resources


mCollection

private org.xmldb.api.base.Collection mCollection
Collection into which the resources will be loaded


mCreateCollectionIfNotExists

private boolean mCreateCollectionIfNotExists
should we create a new collection if it doesn't exist?

Constructor Detail

XMLBulkLoadActivity

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

Parameters:
element - Element to configure the activity with - from a perform document.
Throws:
ActivityCreationException - If there is a problem constructing the activity due to an implementation error or OGSA-DAI confguration problem.
ActivitySpecificationException - If there is a problem constructing the activity due to an invalid setting in element. mistake such as an invalid setting.
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 XMLDBActivity
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

public 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

public 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 XMLDBActivity

addDocument

private void addDocument(org.w3c.dom.Element element)
                  throws ActivityExecutionException
Add a resource to the current collection.

Parameters:
element - The resource as a DOM object.
Throws:
ActivityExecutionException - If any problem occurs.

resultsToXML

private java.lang.String resultsToXML(int numResources)
Converts the results of the bulk load execution into an XML string representation. The format is:
 <resultCount>N<l/resultCount>
 

Parameters:
numResources - the number of resources in the result count.
Returns:
string representation