uk.org.ogsadai.activity.indexedfiles
Class AddAndIndexFileActivity

java.lang.Object
  |
  +--uk.org.ogsadai.engine.Activity
        |
        +--uk.org.ogsadai.activity.files.AbstractFileActivity
              |
              +--uk.org.ogsadai.activity.indexedfiles.AddAndIndexFileActivity
All Implemented Interfaces:
ActivityConfigurationCreator

public class AddAndIndexFileActivity
extends AbstractFileActivity
implements ActivityConfigurationCreator

Imports a flat file into a file system data resource and builds an index using the Jakarta Lucene full-text search engine. An index helper extending the abstract FlatFileIndexWriter must be provided for each type of flat file that is to be indexed. The flat file type and the indexed fields are passed to the activity in the perform document.

Author:
The OGSA-DAI Project Team.

Field Summary
 
Fields inherited from class uk.org.ogsadai.activity.files.AbstractFileActivity
mConnectionManager, mTopDir
 
Fields inherited from class uk.org.ogsadai.engine.Activity
mContext, mExternalInputs, mExternalOutputs, mInternalInputs, mInternalOutputs
 
Constructor Summary
AddAndIndexFileActivity(org.w3c.dom.Element element)
          Constructs an AddAndIndexFileActivity from a perform document element.
 
Method Summary
protected  void cleanUp()
          Closes the file output stream and the index writer in case the activity is terminated before completion.
 ActivityConfiguration createActivityConfiguration()
          Creates the ActivityConfiguration object for a particular activity.
protected  void initialise()
          Initialises the activity by assigning input streams and ensuring that the output file name is valid and accessible.
protected  void processBlock()
          Processes a block.
protected  void processFirst()
          Starts processing by opening a file for writing.
 
Methods inherited from class uk.org.ogsadai.engine.Activity
connectsTo, getActivityConfiguration, getName, getObservableStatus, getProperties, getStatus, hasActivityConfiguration, hasProperties, setCompleted, setError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AddAndIndexFileActivity

public AddAndIndexFileActivity(org.w3c.dom.Element element)
                        throws ActivitySystemException,
                               ActivityUserException
Constructs an AddAndIndexFileActivity from a perform document element.

Parameters:
element - The activity element in the perform document
Throws:
ActivitySystemException
ActivityUserException
Method Detail

initialise

protected void initialise()
                   throws ActivitySystemException,
                          ActivityUserException
Initialises the activity by assigning input streams and ensuring that the output file name is valid and accessible. An index writer and the index helper are constructed and opened.

Overrides:
initialise in class AbstractFileActivity
Throws:
ActivityUserException - If there is a user problem intialising the activity, like the top-level directory specified in the connection configuration does not exist.
ActivitySystemException - If there is a problem intialising the activity, like not using the FileSystemConnectionManager connection manager.
See Also:
Activity.initialise()

processFirst

protected void processFirst()
Starts processing by opening a file for writing.

Overrides:
processFirst in class Activity
See Also:
Activity.processFirst()

processBlock

protected void processBlock()
Processes a block. This method writes input data to a file until there are no more blocks. When the input stream is closed the new file is indexed using the mIndexHelper.

Specified by:
processBlock in class Activity
See Also:
Activity.processBlock()

cleanUp

protected void cleanUp()
Closes the file output stream and the index writer in case the activity is terminated before completion.

Overrides:
cleanUp in class Activity
See Also:
Activity.cleanUp()

createActivityConfiguration

public ActivityConfiguration createActivityConfiguration()
Description copied from interface: ActivityConfigurationCreator
Creates the ActivityConfiguration object for a particular activity. The intialise method of the ActivityConfiguration object will be invoked by the ActivityCreator.

Specified by:
createActivityConfiguration in interface ActivityConfigurationCreator
Returns:
an ActivityConfiguration object
See Also:
ActivityConfigurationCreator.createActivityConfiguration()