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 an XML collection exposed by an XMLDB data service resource. The documents can either be included in-line in the request or can be read from another activity's output. If a collection is named but does not exist then it can be created if this option is set (see setCollectionName).

The activity has one (optional) input - XML data from another activity - and one output - the number of resources bulk loaded. The format of the output is OGSA-DAI specific XML. For example:

<resultCount> 2 </resultCount>

Author:
The OGSA-DAI Project Team

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private  java.lang.String mCollectionName
          Collection name
private  boolean mCreateIfNotExists
          Create the collection if it does not exist?
private  java.lang.String mData
          Optional input data to be provided in-line.
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.Activity
 
Fields inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
 
Constructor Summary
XMLBulkLoad()
          Constructs a request to bulk load resources 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 - the number of inserted resources.
 int getResultCount()
          Gets the number of inserted resources.
 void setCollectionName(java.lang.String collectionName)
          Set the collection name.
 void setCollectionName(java.lang.String collectionName, boolean createIfNotExists)
          Set the collection name.
 void setInput(ActivityOutput input)
          Sets the input of this activity to be the output from another activity that will provide the XML content of the new resource.
 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 to be the resources held within a org.xmldb.api.base.ResourceSet.
 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, getInputParameters, getOutputParameters, getOutputs, replaceSpecialCharacters, setDataResourceID, setInput
 
Methods inherited from class uk.org.ogsadai.client.toolkit.activity.RequestComponent
getDataService, getName, getSession, setDataService, setSession
 
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

mCollectionName

private java.lang.String mCollectionName
Collection name


mCreateIfNotExists

private boolean mCreateIfNotExists
Create the collection if it does not exist?


mData

private java.lang.String mData
Optional input data to be provided in-line.

Constructor Detail

XMLBulkLoad

public XMLBulkLoad()
Constructs a request to bulk load resources into a collection. The documents must be specified using setInput or setInputData By default the documents will be bulk loaded into the base collection.


XMLBulkLoad

public XMLBulkLoad(ActivityOutput input)
Constructs a request to bulk load data into a collection. By default the documents will be bulk loaded into the base collection.

Parameters:
input - Output from another activity.
Throws:
java.lang.IllegalArgumentException - If input is null.
Method Detail

setInput

public final void setInput(ActivityOutput input)
Sets the input of this activity to be the output from another activity that will provide the XML content of the new resource.

Parameters:
input - Output from another activity.
Throws:
java.lang.IllegalArgumentException - If input is null.

setInputData

public void setInputData(org.xmldb.api.base.ResourceSet resources)
                  throws XMLDBResourceException
Sets the input data for the bulk load to be the resources held within a org.xmldb.api.base.ResourceSet.

Parameters:
resources - ResourceSet
Throws:
XMLDBResourceException - If the resourceSet data cannot be written to a string.

setInputData

public void setInputData(java.lang.String content)
                  throws XMLDBResourceException
Sets the input data for the bulk load. The data must be a valid XML document fragment in the following format (however, no check is made for conformance to this format only for valid XML). For example:
 <resourceSet>
   <resource>
     <entry id="1">
       <name>Ally Antonioletti</name>
       <address>826 Hume Crescent, Southampton</address>
       <phone>01670061244</phone>
     </entry>
   </resource>
   <resource>
     <entry id="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.
Throws:
XMLDBResourceException - If content is not null and cannot be parsed as XML.

setInputData

public void setInputData(org.w3c.dom.Document document)
Sets the input data for the bulk load. The data must be a valid XML document fragment in the same format as that of setInputData(java.lang.String) (however, no check is made for conformance to this format only for valid XML).

Parameters:
document - An XML fragment containing the data for bulk load.

setCollectionName

public void setCollectionName(java.lang.String collectionName)
Set the collection name. The resources will be loaded into this collection. If this is set to null then the resource will loaded in the base collection. If the collection does not exist then it will not be created and the activity will raise an error.

Parameters:
collectionName - The name of the collection or null.

setCollectionName

public void setCollectionName(java.lang.String collectionName,
                              boolean createIfNotExists)
Set the collection name. The resources will be loaded into this collection. If this is set to null then the resource will loaded in the base collection.

Parameters:
collectionName - The name of the collection or null.
createIfNotExists - If collectionName is not null and does not exist then should it be created? 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.

getResultCount

public int getResultCount()
                   throws NoActivityOutputException,
                          DataFormatException
Gets the number of inserted resources.

Returns:
number of inserted resources.
Throws:
NoActivityOutputException - if there is no output data or the data has not yet been processed to this output or the activity that generates this output has not yet been executed.
DataFormatException - if the output from the activity cannot be parsed into a count.

getOutput

public ActivityOutput getOutput()
Gets the activity's only output - the number of inserted resources.

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