org.embl.ebi.escience.scufl.tools
Class WorkflowLauncher

java.lang.Object
  extended by org.embl.ebi.escience.scufl.tools.WorkflowLauncher

public class WorkflowLauncher
extends java.lang.Object

A utility class that wraps the process of executing a workflow, allowing workflows to be easily executed independantly of the GUI.

Author:
Stuart Owen, Stian Soiland

Constructor Summary
WorkflowLauncher(java.io.InputStream xmlStream)
          Set userContext and instantiate the WorkflowLauncher, constructing an instance of the ScuflModel from the XML provided by the given input stream.
WorkflowLauncher(java.io.InputStream xmlStream, UserContext userContext)
          Set userContext and instantiate the WorkflowLauncher, constructing an instance of the ScuflModel from the XML provided by the given input stream.
WorkflowLauncher(ScuflModel model)
          Instantiate the WorkflowLauncher with a direct reference to the ScuflModel to be executed.
WorkflowLauncher(ScuflModel model, UserContext userContext)
          Instantiate the WorkflowLauncher with a direct reference to the ScuflModel to be executed, together with a UserContext for the user executing this model.
WorkflowLauncher(java.net.URL url)
          Instantiate the WorkflowLauncher, constructing an instance of the ScuflModel from the XML in the provided url
WorkflowLauncher(java.net.URL url, UserContext userContext)
          Instantiate the WorkflowLauncher, constructing an instance of the ScuflModel from the XML in the provided url
 
Method Summary
 java.util.Map<java.lang.String,DataThing> execute(java.util.Map<java.lang.String,DataThing> inputs)
           
 java.util.Map<java.lang.String,DataThing> execute(java.util.Map<java.lang.String,DataThing> inputs, WorkflowEventListener workflowEventListener)
          Executes the workflow with the provided inputs (which is a Map of DataThings) and userContext.
 java.util.Map<java.lang.String,DataThing> execute(java.util.Map<java.lang.String,DataThing> inputs, WorkflowEventListener[] workflowEventListeners)
          Executes the workflow with the provided inputs (which is a Map of DataThings) and userContext.
 java.lang.String getProgressReportXML()
          Provides access to the progress report after the workflow has be executed
static java.util.Map<java.lang.String,DataThing> loadInputDoc(java.io.File file)
          Load a XML-serialised Baclava data document from a file.
static void main(java.lang.String[] args)
          Allows a workflow to be executed stand-alone.
static void saveOutputDoc(java.util.Map<java.lang.String,DataThing> outputs, java.io.File outputDoc)
          Save workflow outputs as an DataThing XML document
static void saveOutputs(java.util.Map<java.lang.String,DataThing> outputs, java.io.File outputDir)
          Save workflow outputs as a directory structure.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkflowLauncher

public WorkflowLauncher(java.io.InputStream xmlStream,
                        UserContext userContext)
                 throws ProcessorCreationException,
                        DataConstraintCreationException,
                        UnknownProcessorException,
                        UnknownPortException,
                        DuplicateProcessorNameException,
                        MalformedNameException,
                        ConcurrencyConstraintCreationException,
                        DuplicateConcurrencyConstraintNameException,
                        XScuflFormatException
Set userContext and instantiate the WorkflowLauncher, constructing an instance of the ScuflModel from the XML provided by the given input stream.

Parameters:
xmlStream -
userContext - a UserContext
Throws:
ProcessorCreationException
DataConstraintCreationException
UnknownProcessorException
UnknownPortException
DuplicateProcessorNameException
MalformedNameException
ConcurrencyConstraintCreationException
DuplicateConcurrencyConstraintNameException
XScuflFormatException

WorkflowLauncher

public WorkflowLauncher(java.io.InputStream xmlStream)
                 throws ProcessorCreationException,
                        DataConstraintCreationException,
                        UnknownProcessorException,
                        UnknownPortException,
                        DuplicateProcessorNameException,
                        MalformedNameException,
                        ConcurrencyConstraintCreationException,
                        DuplicateConcurrencyConstraintNameException,
                        XScuflFormatException
Set userContext and instantiate the WorkflowLauncher, constructing an instance of the ScuflModel from the XML provided by the given input stream.

Parameters:
xmlStream -
Throws:
ProcessorCreationException
DataConstraintCreationException
UnknownProcessorException
UnknownPortException
DuplicateProcessorNameException
MalformedNameException
ConcurrencyConstraintCreationException
DuplicateConcurrencyConstraintNameException
XScuflFormatException

WorkflowLauncher

public WorkflowLauncher(java.net.URL url,
                        UserContext userContext)
                 throws java.io.FileNotFoundException,
                        ProcessorCreationException,
                        java.io.IOException,
                        DataConstraintCreationException,
                        UnknownProcessorException,
                        UnknownPortException,
                        DuplicateProcessorNameException,
                        MalformedNameException,
                        ConcurrencyConstraintCreationException,
                        DuplicateConcurrencyConstraintNameException,
                        XScuflFormatException
Instantiate the WorkflowLauncher, constructing an instance of the ScuflModel from the XML in the provided url

Parameters:
xmlFilename -
userContext - a UserContext
Throws:
java.io.FileNotFoundException
ProcessorCreationException
DataConstraintCreationException
UnknownProcessorException
UnknownPortException
DuplicateProcessorNameException
MalformedNameException
ConcurrencyConstraintCreationException
DuplicateConcurrencyConstraintNameException
XScuflFormatException
java.io.IOException

WorkflowLauncher

public WorkflowLauncher(java.net.URL url)
                 throws java.io.FileNotFoundException,
                        ProcessorCreationException,
                        java.io.IOException,
                        DataConstraintCreationException,
                        UnknownProcessorException,
                        UnknownPortException,
                        DuplicateProcessorNameException,
                        MalformedNameException,
                        ConcurrencyConstraintCreationException,
                        DuplicateConcurrencyConstraintNameException,
                        XScuflFormatException
Instantiate the WorkflowLauncher, constructing an instance of the ScuflModel from the XML in the provided url

Parameters:
xmlFilename -
Throws:
java.io.FileNotFoundException
ProcessorCreationException
DataConstraintCreationException
UnknownProcessorException
UnknownPortException
DuplicateProcessorNameException
MalformedNameException
ConcurrencyConstraintCreationException
DuplicateConcurrencyConstraintNameException
XScuflFormatException
java.io.IOException

WorkflowLauncher

public WorkflowLauncher(ScuflModel model)
Instantiate the WorkflowLauncher with a direct reference to the ScuflModel to be executed.

Parameters:
model - a ScuflModel

WorkflowLauncher

public WorkflowLauncher(ScuflModel model,
                        UserContext userContext)
Instantiate the WorkflowLauncher with a direct reference to the ScuflModel to be executed, together with a UserContext for the user executing this model.

Parameters:
model - a ScuflModel
userContext - a UserContext
Method Detail

getProgressReportXML

public java.lang.String getProgressReportXML()
Provides access to the progress report after the workflow has be executed

Returns:
progress report

execute

public java.util.Map<java.lang.String,DataThing> execute(java.util.Map<java.lang.String,DataThing> inputs)
                                                  throws WorkflowSubmissionException,
                                                         uk.ac.soton.itinnovation.freefluo.main.InvalidInputException
Throws:
WorkflowSubmissionException
uk.ac.soton.itinnovation.freefluo.main.InvalidInputException

execute

public java.util.Map<java.lang.String,DataThing> execute(java.util.Map<java.lang.String,DataThing> inputs,
                                                         WorkflowEventListener[] workflowEventListeners)
                                                  throws WorkflowSubmissionException,
                                                         uk.ac.soton.itinnovation.freefluo.main.InvalidInputException
Executes the workflow with the provided inputs (which is a Map of DataThings) and userContext. Returns the outputs of the workflow (which is also a Map of DataThings). An array of workflowEventListeners can be provided to allow handling of events as the workflow is executed.

Parameters:
inputs -
workflowEventListeners -
Returns:
Throws:
WorkflowSubmissionException
uk.ac.soton.itinnovation.freefluo.main.InvalidInputException
See Also:
DataThing, WorkflowEventListener

execute

public java.util.Map<java.lang.String,DataThing> execute(java.util.Map<java.lang.String,DataThing> inputs,
                                                         WorkflowEventListener workflowEventListener)
                                                  throws WorkflowSubmissionException,
                                                         uk.ac.soton.itinnovation.freefluo.main.InvalidInputException
Executes the workflow with the provided inputs (which is a Map of DataThings) and userContext. Returns the outputs of the workflow (which is also a Map of DataThings). A workflowEventListener can be provided to allow handling of events as the workflow is executed.

Parameters:
inputs -
workflowEventListener -
Returns:
Throws:
WorkflowSubmissionException
uk.ac.soton.itinnovation.freefluo.main.InvalidInputException
See Also:
DataThing, WorkflowEventListener

main

public static void main(java.lang.String[] args)
                 throws java.net.MalformedURLException
Allows a workflow to be executed stand-alone. Usage: [ ] ...

Parameters:
args -
Throws:
java.net.MalformedURLException

loadInputDoc

public static java.util.Map<java.lang.String,DataThing> loadInputDoc(java.io.File file)
                                                              throws org.jdom.JDOMException,
                                                                     java.io.IOException
Load a XML-serialised Baclava data document from a file.

Parameters:
file - The file to load
Returns:
The String -> DataThing Map of input values
Throws:
org.jdom.JDOMException - If the file could not be parsed
java.io.IOException - If the file could not be opened/read

saveOutputDoc

public static void saveOutputDoc(java.util.Map<java.lang.String,DataThing> outputs,
                                 java.io.File outputDoc)
                          throws java.io.IOException
Save workflow outputs as an DataThing XML document

Parameters:
outputs - Map of String -> DataThing to save
outputDoc - File to write the document
Throws:
java.io.IOException - If the file cannot be written

saveOutputs

public static void saveOutputs(java.util.Map<java.lang.String,DataThing> outputs,
                               java.io.File outputDir)
                        throws java.io.IOException
Save workflow outputs as a directory structure. One file will be created for each output, named the same as the output. If the output is a list, a directory will be created instead, and the content will be files or directories named 1, 2, etc.

Parameters:
outputs - Map of DataThing to save
outputDir - Base directory for structure
Throws:
java.io.IOException