uk.org.ogsadai.client.toolkit.activity
Class BaseActivity

java.lang.Object
  extended by uk.org.ogsadai.client.toolkit.activity.BaseActivity
All Implemented Interfaces:
Activity, RequestAndStatusHandler
Direct Known Subclasses:
ActivityUserErrorProducer, BaseCreateDataX, BaseResourceActivity, BlockCount, ByteArraysResize, ByteArraysToTuple, CalculateMean, CharArraysResize, CharArraysToDOM, CloneableObjectProducer, ControlledRepeat, Counter, CreateAnalyzer, CreateDQPResource, CreateMapper, CreateRelationalResource, CreateResourceGroup, CSVToTuple, DeliverToDataSink, DeliverToFTP, DeliverToNull, DeliverToRequestStatus, DeliverToSession, DeliverToSMTP, DOMToCharArrays, DQPPattern, Echo, ExtendedCreateRelationalResource, GenericActivity, GenericTupleJoin, GenericTupleTransform, GetDataSinkResource, GetDataSourceResource, GroupBy, HashCode, Head, ListConcatenate, ListControlledRepeat, ListMultiply, ListRandomSplit, ListRemove, ListSplit, MetadataRename, ObtainFromDataSource, ObtainFromFTP, ObtainFromHTTP, ObtainFromSession, OneTupleOnly, RandomSplit, ReplaceWithValue, Sleep, SortedTupleListDifference, Split, StringReplace, SummaryTupleToKMLPlacemarks, TableMetadataToXMLCharArraysList, Tee, Timestamp, ToSingleList, TupleArithmeticProject, TupleLeftOuterJoin, TupleMergeJoin, TupleProduct, TupleProjectByIDS, TupleProjection, TupleSelect, TupleSemiJoin, TupleSimpleMerge, TupleSort, TupleSplit, TupleThetaJoin, TupleToByteArrays, TupleToCSV, TupleToKMLPlacemarks, TupleToWebRowSetCharArrays, TupleUnionAll, WebRowSetCharacterDataToTuple, XSLTransform

public abstract class BaseActivity
extends java.lang.Object
implements Activity, RequestAndStatusHandler

Abstract base class that can be used for client toolkit activity implementations.

Author:
The OGSA-DAI project team

Constructor Summary
BaseActivity(ActivityName activityName)
          Constructor.
 
Method Summary
 void buildRequest(RequestBuilder builder)
          Builds a request by writing details to the given request builder.
 ActivityName getActivityName()
          Gets the activity name.
protected  SingleActivityOutput[] getConnectedOutputs(ActivityOutput[] outputs)
          Filters an array of activity outputs returning an array of those that are connected.
 Message[] getErrorMessages()
          Gets the error messages associated with the activity.
protected  ActivityInputDescriptor[] getInputDescriptors()
          Gets the input descriptors that describe the operational inputs of the activity.
protected abstract  ActivityInput[] getInputs()
          Gets the inputs associated with the activity.
 ActivityInstanceName getInstanceName()
          Gets the activity instance name.
protected abstract  ActivityOutput[] getOutputs()
          Gets the outputs associated with the activity.
 RequestAndStatusHandler getRequestAndStatusHandler()
          Gets an interface through which requests can be built and request status handled.
protected  Server getServer()
          Gets the server associated with this activity.
 ActivityStatus getStatus()
          Gets the activity status.
 Message[] getWarnings()
          Gets the warnings associated with the activity.
 boolean hasErrorMessages()
          Gets whether or not the activity has any error messages.
 boolean hasWarnings()
          Gets whether not the activity has reported any warnings.
 void processRequestStatus(RequestStatus requestStatus)
          Processes the given request status.
 void setActivityName(ActivityName activityName)
          Sets the name of the activity to invoke.
 void setServer(Server server)
          Sets the server associated with this resource.
 java.lang.String toString()
           
protected abstract  void validateIOState()
          Validates the state of the activity inputs and outputs.
protected  void validateState()
          Validates the state of the activity to ensure it has a complete and consistent set of inputs and outputs.
protected  java.lang.String writeToString(boolean includeResourceID, ResourceID resourceID)
          Writes the activity as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseActivity

public BaseActivity(ActivityName activityName)
Constructor. The activity instance name will be automatically generated.

Parameters:
activityName - the default activity name.
Method Detail

getActivityName

public ActivityName getActivityName()
Description copied from interface: Activity
Gets the activity name.

Specified by:
getActivityName in interface Activity
Returns:
gets the name of the activity.

getInstanceName

public ActivityInstanceName getInstanceName()
Description copied from interface: Activity
Gets the activity instance name.

Specified by:
getInstanceName in interface Activity
Returns:
activity instance name.

getStatus

public ActivityStatus getStatus()
Description copied from interface: Activity
Gets the activity status. The activity status retrieved will be the last activity status obtained from the request resource. This method does not make any calls to the server.

Specified by:
getStatus in interface Activity
Returns:
the activity status or null if there the activity status has not yet been obtained from the server. This would be the case if the request has not yet been passed to the server.

hasErrorMessages

public boolean hasErrorMessages()
Description copied from interface: Activity
Gets whether or not the activity has any error messages.

Specified by:
hasErrorMessages in interface Activity
Returns:
true if the activity has error messages, false otherwise.

getErrorMessages

public Message[] getErrorMessages()
Gets the error messages associated with the activity.

Specified by:
getErrorMessages in interface Activity
Returns:
array of error messages. These error messages form a chain of error message where the first message is the highest level description of the error and the last message is the lowest level description. If there are no error messages an empty array is returned.

hasWarnings

public boolean hasWarnings()
Gets whether not the activity has reported any warnings.

Specified by:
hasWarnings in interface Activity
Returns:
true if the activity has reported warnings, false otherwise.

getWarnings

public Message[] getWarnings()
Gets the warnings associated with the activity.

Specified by:
getWarnings in interface Activity
Returns:
array of warning messages. If there are no warnings an empty array is returned.

setActivityName

public void setActivityName(ActivityName activityName)
Description copied from interface: Activity
Sets the name of the activity to invoke. All activity classes will have a default activity name. The method can be used to override that default.

Specified by:
setActivityName in interface Activity
Parameters:
activityName - Name of the activity to invoke.

getRequestAndStatusHandler

public RequestAndStatusHandler getRequestAndStatusHandler()
Description copied from interface: Activity
Gets an interface through which requests can be built and request status handled. This method should only be called by client side framework implementations. It should not be called by OGSA-DAI client applications.

Specified by:
getRequestAndStatusHandler in interface Activity
Returns:
interface to the request and status handling methods.

setServer

public void setServer(Server server)
Description copied from interface: RequestAndStatusHandler
Sets the server associated with this resource.

Specified by:
setServer in interface RequestAndStatusHandler
Parameters:
server - the server associated with this resource.

buildRequest

public void buildRequest(RequestBuilder builder)
                  throws ActivityIllegalStateException
Description copied from interface: RequestAndStatusHandler
Builds a request by writing details to the given request builder.

Specified by:
buildRequest in interface RequestAndStatusHandler
Parameters:
builder - request builder user to build the request.
Throws:
ActivityIllegalStateException - if the request cannot be built because an activity is in an illegal state.

processRequestStatus

public void processRequestStatus(RequestStatus requestStatus)
Description copied from interface: RequestAndStatusHandler
Processes the given request status.

Specified by:
processRequestStatus in interface RequestAndStatusHandler
Parameters:
requestStatus - request status to process.

getServer

protected Server getServer()
Gets the server associated with this activity. The server will be send by the client toolkit framework when a request is executed.

Returns:
the server associated with the activity, if null if no server has been set.

getInputDescriptors

protected ActivityInputDescriptor[] getInputDescriptors()
Gets the input descriptors that describe the operational inputs of the activity.

Returns:
the input descriptors.

validateState

protected void validateState()
                      throws ActivityIllegalStateException
Validates the state of the activity to ensure it has a complete and consistent set of inputs and outputs.

Throws:
ActivityIllegalStateException - if the activity is not in a valid state.

validateIOState

protected abstract void validateIOState()
                                 throws ActivityIOIllegalStateException
Validates the state of the activity inputs and outputs.

Throws:
ActivityIOIllegalStateException - if an activity input is not in a valid state.

getInputs

protected abstract ActivityInput[] getInputs()
Gets the inputs associated with the activity. All the inputs including not operational optional inputs will be returned.

Returns:
the inputs associated with the activity.

getOutputs

protected abstract ActivityOutput[] getOutputs()
Gets the outputs associated with the activity. All the outputs including unconnected optional outputs will be returned.

Returns:
the outputs associated with the activity.

getConnectedOutputs

protected SingleActivityOutput[] getConnectedOutputs(ActivityOutput[] outputs)
Filters an array of activity outputs returning an array of those that are connected.

Parameters:
outputs - array of activity outputs
Returns:
array of those activity outputs that are connected.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

writeToString

protected java.lang.String writeToString(boolean includeResourceID,
                                         ResourceID resourceID)
Writes the activity as a String.

Parameters:
includeResourceID - should a resource ID be listed.
resourceID - resource ID to list.
Returns:
a String describing the activity.