uk.org.ogsadai.client.toolkit.activity.xmldb
Class XMLBulkLoad

java.lang.Object
  |
  +--uk.org.ogsadai.client.toolkit.activity.RequestComponent
        |
        +--uk.org.ogsadai.client.toolkit.activity.Activity
              |
              +--uk.org.ogsadai.client.toolkit.activity.xmldb.XMLBulkLoad

public class XMLBulkLoad
extends Activity

This activity bulk loads a set of documents into a collection. The data may either be included in the perform document or it can be loaded from another activity's output stream.

It has one (optional) input and one output. The format of the output is OGSA-DAI specific XML. For example: <resultCount> 2 </resultCount>

Author:
The OGSA-DAI Project Team

Constructor Summary
XMLBulkLoad()
          Constructs a request to bulk load data into a collection.
XMLBulkLoad(ActivityOutput input)
          Constructs a request to bulk load data into a collection.
 
Method Summary
protected  java.lang.String generateXML()
          Generates the XML representing the activity.
 ActivityOutput getOutput()
          Gets the activity's only output.
 int getResultCount()
          Get the number of documents imported by the bulk load operation.
 void setCollectionName(java.lang.String collectionName)
          Set the collection name.
 void setCollectionName(java.lang.String collectionName, boolean createIfNotExists)
          Set the collection name and specify whether the collection should be created if it does not exist.
 void setInput(ActivityOutput input)
          Set the bulk load input stream.
 void setInputData(org.w3c.dom.Document document)
          Sets the input data for the bulk load.
 void setInputData(org.xmldb.api.base.ResourceSet resources)
          Sets the input data for the bulk load as a resource set.
 void setInputData(java.lang.String content)
          Sets the input data for the bulk load.
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
addInput, addOutput, addOutputs, getDataResourceID, getDataServiceStub, getInputParameters, getOutputParameters, getOutputs, replaceSpecialCharacters, setDataResourceID, setDataServiceStub, setInput
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLBulkLoad

public XMLBulkLoad()
Constructs a request to bulk load data into a collection.


XMLBulkLoad

public XMLBulkLoad(ActivityOutput input)
Constructs a request to bulk load data into a collection.

Parameters:
input - The input data for this activity
Method Detail

setInput

public void setInput(ActivityOutput input)
Set the bulk load input stream. If the argument is null the bulk load data must be delivered in the perform document.

Parameters:
input -

setInputData

public void setInputData(org.xmldb.api.base.ResourceSet resources)
                  throws CommonSystemException
Sets the input data for the bulk load as a resource set.

Parameters:
resources - A org.xmldb.api.base.ResourceSet object
Throws:
CommonSystemException - if the resourceSet data cannot be written to a String

setInputData

public void setInputData(java.lang.String content)
                  throws CommonUserException
Sets the input data for the bulk load. The data must be a valid XML document fragment in the following format: For example:
 <resourceSet>
   <resource>
     <entry id="1" xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/littleblackbook" src:key="1">
       <name>Ally Antonioletti</name>
       <address>826 Hume Crescent, Southampton</address>
       <phone>01670061244</phone>
     </entry>
   </resource>
   <resource>
     <entry id="10" xmlns:src="http://xml.apache.org/xindice/Query" src:col="/db/littleblackbook" src:key="10">
       <name>Martin Laws</name>
       <address>224 Palansuriya Lane, Winchester</address>
       <phone>06686142062</phone>
     </entry>
   </resource>
 </resourceSet>
 

Parameters:
content - A string containing the data for bulk load.
CommonUserException

setInputData

public void setInputData(org.w3c.dom.Document document)
                  throws CommonSystemException
Sets the input data for the bulk load. The data will be delivered within the perform document. For a description of the format see setInputData(String).

Parameters:
document - An org.w3c.dom.Document containing the input data
Throws:
CommonSystemException - if the document could not be converted into a string.

setCollectionName

public void setCollectionName(java.lang.String collectionName)
Set the collection name. Note that this collection name must exist in the XMLDB data resource. If the collection name is null data will be loaded into the base collection of the data resource.

Parameters:
collectionName -

setCollectionName

public void setCollectionName(java.lang.String collectionName,
                              boolean createIfNotExists)
Set the collection name and specify whether the collection should be created if it does not exist. The collection can only be created if all its parent collections exist. For example: littleblackbook/address/newCollection - the new collection newCollection can only be created if the parent collections littleblackbook and address exist.

Parameters:
collectionName -
createIfNotExists - If true the collection will be created in the data resource if it does not exist. Default is false.

getResultCount

public int getResultCount()
                   throws ActivityOutputException,
                          DataFormatException
Get the number of documents imported by the bulk load operation.

Returns:
number of imported documents.
Throws:
DataFormatException - If the output data is not in the expected format.
ActivityOutputException - If there is no output data.

getOutput

public ActivityOutput getOutput()
Gets the activity's only output.

Returns:
the activity output.

generateXML

protected java.lang.String generateXML()
Description copied from class: RequestComponent
Generates the XML representing the activity. This XML can then be inserted into a perform document that is sent to a data service.

Specified by:
generateXML in class Activity
Returns:
the XML for the activity