org.embl.ebi.escience.scufl.enactor.implementation
Class WorkflowInstanceImpl

java.lang.Object
  extended by org.embl.ebi.escience.scufl.enactor.implementation.WorkflowInstanceImpl
All Implemented Interfaces:
WorkflowInstance

public class WorkflowInstanceImpl
extends java.lang.Object
implements WorkflowInstance

Represents a receipt for a workflow submitted by the client

This class is used as the handle for all client operations on a running or scheduled workflow instance. It includes methods to extract status and result documents and is augemented by Taverna to also include methods to return the inputs and outputs to a specific processor for debug purpopses during the construction of a workflow.

Author:
Darren Marvin, Tom Oinn, Justin Ferris, Stian Soiland

Method Summary
 void addWorkflowStateListener(uk.ac.soton.itinnovation.freefluo.event.WorkflowStateListener listener)
          Register the specified listener with the engine for this instance and use the internal workflow ID
 void cancelExecution()
          Cancel the currently running workflow, freeing any resources used
 boolean changeOutputPortTaskData(java.lang.String processorId, java.lang.String OutputPortName, java.lang.Object newData)
          Changes intermediate output data on the output porttask.
 void destroy()
          Ask for the the workflow instance to be destroyed.
 java.lang.String getDefinitionLSID()
           
 java.lang.String getErrorMessage()
          Returns a human readable string containing details of errors that occurred during execution of this WorkflowInstance
 java.lang.String getID()
          Return a unique identifier for this workflow run.
static WorkflowInstanceImpl getInstance(uk.ac.soton.itinnovation.freefluo.main.Engine engine, ScuflModel workflowModel, java.lang.String engineId)
          Get the workflow as compiled to the given engine with the given engineId.
 java.util.Map<java.lang.String,DataThing>[] getIntermediateResultsForProcessor(java.lang.String processorName)
          Returns two Map objects of port name -> dataThing.
 java.util.Map<java.lang.String,DataThing> getOutput()
          Return the Map of DataThing objects for all known workflow outputs, keys are the output names and values are the DataThing objects.
 java.lang.String getProgressReportXMLString()
          Updated progress report code to use the event lists
 java.lang.String getProvenanceXMLString()
          Return the XML string containing the provenance report, this document is currently poorly defined but will in the future contain the set of RDF statements generated by the knowledge collection code.
 java.lang.String getStatus()
          This method can be used to get a simple String that describes the current state of this workflow instance object.
 UserContext getUserContext()
          Get the user context for this workflow instance in the form of a UserContext implementation
 ScuflModel getWorkflowModel()
          Return a reference to the ScuflModel which this workflow was built from
 boolean isDataNonVolatile(java.lang.String processorId)
          Checks if task's output is allowed to be editied.
 boolean isPaused()
          Return whether the workflow is currently paused
 void pause(java.lang.String processorId)
          Add breakoint to the specific processor.
 void pauseExecution()
          Pause the workflow enactment.
 void removeWorkflowStateListener(uk.ac.soton.itinnovation.freefluo.event.WorkflowStateListener listener)
          Remove a workflow state listener
 void resume(java.lang.String processorId)
          Remove breakoint to the specific processor and resume it.
 void resumeExecution()
          Resume the workflow enactment.
 void run()
          Start this workflow istance running.
 void setInputs(java.util.Map inputMap)
          Set workflow inputs.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static WorkflowInstanceImpl getInstance(uk.ac.soton.itinnovation.freefluo.main.Engine engine,
                                               ScuflModel workflowModel,
                                               java.lang.String engineId)
Get the workflow as compiled to the given engine with the given engineId.

Instances are cached until the instance is destroyed by destroy()

Parameters:
engine - Engine the workflow was compiled on
workflowModel - Workflow that was compiled
engineId - Identifier returned when compiling
Returns:
A WorkflowInstanceImpl representing given workflow compilation. Instances are cached, so that each call to getInstance() with the same parameters will return the same instance.
See Also:
destroy()

toString

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

getWorkflowModel

public ScuflModel getWorkflowModel()
Return a reference to the ScuflModel which this workflow was built from

Specified by:
getWorkflowModel in interface WorkflowInstance

getID

public java.lang.String getID()
Return a unique identifier for this workflow run. If the system default LSID provider is set in DataThing.SYSTEM_DEFAULT_LSID_PROVIDER, a fresh LSID will be assigned. Otherwise, a semi-unique string will be generated from the internal engine representation.

Specified by:
getID in interface WorkflowInstance

getDefinitionLSID

public java.lang.String getDefinitionLSID()

addWorkflowStateListener

public void addWorkflowStateListener(uk.ac.soton.itinnovation.freefluo.event.WorkflowStateListener listener)
Register the specified listener with the engine for this instance and use the internal workflow ID


removeWorkflowStateListener

public void removeWorkflowStateListener(uk.ac.soton.itinnovation.freefluo.event.WorkflowStateListener listener)
Remove a workflow state listener


setInputs

public void setInputs(java.util.Map inputMap)
Description copied from interface: WorkflowInstance
Set workflow inputs. Takes a Map of DataThing objects, with the keys in the map being String objects corresponding to the named workflow inputs within the workflow that this instance represents the state of.

Specified by:
setInputs in interface WorkflowInstance

run

public void run()
         throws uk.ac.soton.itinnovation.freefluo.main.InvalidInputException
Description copied from interface: WorkflowInstance
Start this workflow istance running.

Specified by:
run in interface WorkflowInstance
Throws:
uk.ac.soton.itinnovation.freefluo.main.InvalidInputException - if the input is doesn't map to source in the dataflow.

getStatus

public java.lang.String getStatus()
Description copied from interface: WorkflowInstance
This method can be used to get a simple String that describes the current state of this workflow instance object. The possible values for the return value are enumerated in FlowStateDefinition.

Specified by:
getStatus in interface WorkflowInstance
Returns:
simple string to that describes the workflow status see uk.ac.soton.itinnovation.freefluo.main.FlowStateDefinition

getIntermediateResultsForProcessor

public java.util.Map<java.lang.String,DataThing>[] getIntermediateResultsForProcessor(java.lang.String processorName)
                                                                               throws UnknownProcessorException
Returns two Map objects of port name -> dataThing. The input document is at position 0, the output at position 1 and the result array has exactly two slots, the documents are in the format defined by the Baclava package and used elsewhere - this allows reuse of the display code from the main workbench.

Specified by:
getIntermediateResultsForProcessor in interface WorkflowInstance
Throws:
UnknownProcessorException - if a ProcessorTask with the supplied name cannot be found within the DiGraph that this FlowReceipt is associated with.

getProgressReportXMLString

public java.lang.String getProgressReportXMLString()
Updated progress report code to use the event lists

Specified by:
getProgressReportXMLString in interface WorkflowInstance
Returns:
XML progress report document

getOutput

public java.util.Map<java.lang.String,DataThing> getOutput()
Description copied from interface: WorkflowInstance
Return the Map of DataThing objects for all known workflow outputs, keys are the output names and values are the DataThing objects.

Specified by:
getOutput in interface WorkflowInstance
Returns:
Map of DataThing objects

getErrorMessage

public java.lang.String getErrorMessage()
Description copied from interface: WorkflowInstance
Returns a human readable string containing details of errors that occurred during execution of this WorkflowInstance

Specified by:
getErrorMessage in interface WorkflowInstance

getProvenanceXMLString

public java.lang.String getProvenanceXMLString()
Description copied from interface: WorkflowInstance
Return the XML string containing the provenance report, this document is currently poorly defined but will in the future contain the set of RDF statements generated by the knowledge collection code.

Specified by:
getProvenanceXMLString in interface WorkflowInstance
Returns:
XML provenance doument

pauseExecution

public void pauseExecution()
Description copied from interface: WorkflowInstance
Pause the workflow enactment. This consists of setting the paused boolean flag, then cancelling all running workflow processes. Be aware therefore that calling this is not always safe as it may interrupt processes that maintain some kind of external state.

Specified by:
pauseExecution in interface WorkflowInstance

resumeExecution

public void resumeExecution()
Description copied from interface: WorkflowInstance
Resume the workflow enactment.

Specified by:
resumeExecution in interface WorkflowInstance

isPaused

public boolean isPaused()
Description copied from interface: WorkflowInstance
Return whether the workflow is currently paused

Specified by:
isPaused in interface WorkflowInstance
Returns:
boolean true if the workflow is paused

cancelExecution

public void cancelExecution()
Description copied from interface: WorkflowInstance
Cancel the currently running workflow, freeing any resources used

Specified by:
cancelExecution in interface WorkflowInstance

destroy

public void destroy()
Ask for the the workflow instance to be destroyed.

This happens in two stages. First, an WorkflowToBeDestroyedEvent is sent to each of the registered WorkflowEventListener. A mini-listener has been added by this method, which will be the latest listener to receive that event, uppon when the real destruction (through doDestroy()) will occur. After that, a WorkflowDestroyedEvent is sent out to confirm the destruction. Finally, cleanup() is called.

Specified by:
destroy in interface WorkflowInstance
See Also:
doDestroy(), cleanup(), WorkflowToBeDestroyedEvent, WorkflowDestroyedEvent, WorkflowEventDispatcher

pause

public void pause(java.lang.String processorId)
Description copied from interface: WorkflowInstance
Add breakoint to the specific processor. This consists of setting the hasBreakpoint boolean flag. The procesor will pause when it is about to run.

Specified by:
pause in interface WorkflowInstance

isDataNonVolatile

public boolean isDataNonVolatile(java.lang.String processorId)
Description copied from interface: WorkflowInstance
Checks if task's output is allowed to be editied.

Specified by:
isDataNonVolatile in interface WorkflowInstance

changeOutputPortTaskData

public boolean changeOutputPortTaskData(java.lang.String processorId,
                                        java.lang.String OutputPortName,
                                        java.lang.Object newData)
Description copied from interface: WorkflowInstance
Changes intermediate output data on the output porttask.

Specified by:
changeOutputPortTaskData in interface WorkflowInstance
Returns:
true if data is non volatile and the changes can be performed.

resume

public void resume(java.lang.String processorId)
Description copied from interface: WorkflowInstance
Remove breakoint to the specific processor and resume it. This consists of setting the hasBreakpoint boolean flag.

Specified by:
resume in interface WorkflowInstance

getUserContext

public UserContext getUserContext()
Description copied from interface: WorkflowInstance
Get the user context for this workflow instance in the form of a UserContext implementation

Specified by:
getUserContext in interface WorkflowInstance