org.embl.ebi.escience.scufl
Class ScuflModel

java.lang.Object
  extended by org.embl.ebi.escience.scufl.ScuflModel
All Implemented Interfaces:
java.io.Serializable

public class ScuflModel
extends java.lang.Object
implements java.io.Serializable

Represents a single scufl workflow model

Author:
Tom Oinn, Stian Soiland
See Also:
Serialized Form

Field Summary
 boolean isFiringEvents
          Whether the model should fire events to its listeners
 
Constructor Summary
ScuflModel()
           
 
Method Summary
 void addConcurrencyConstraint(ConcurrencyConstraint the_constraint)
          Add a concurrency constraint to the model
 void addDataConstraint(DataConstraint the_constraint)
          Add a data constraint to the model
 void addListener(ScuflModelEventListener listener)
          Add a new ScuflModelEventListener to the listener list.
 void addProcessor(Processor processor)
          Add a processor to the model.
 void clear()
          Clear the model, retaining any existing listeners but removing all model data.
 ScuflModel clone()
           
 void collectAllProcessors(java.util.Map target, java.lang.String prefix)
          Crawl down the workflow locating all processors and expanding nested workflow processors recursively to get a complete list of all (non workflow) processors in the workflow.
 void destroyConcurrencyConstraint(ConcurrencyConstraint the_constraint)
          Remove a concurrency constraint from the model
 void destroyDataConstraint(DataConstraint the_constraint)
          Remove a data constraint from the model
 void destroyProcessor(Processor processor)
          Destroy a processor, this also removes any data constraints that have the processor as either a source or a sink.
 void fireModelEvent(ScuflModelEvent event)
          Handle a ScuflModelEvent from one of our children or self, only send an event notification if the isFiringEvents is set to true.
 void forceUpdate()
          Create an internal model event to force an update of the model
 ConcurrencyConstraint[] getConcurrencyConstraints()
          Return an array of the concurrency constraints defined within this workflow model
 DataConstraint[] getDataConstraints()
          Return an array of data constraints defined within this workflow model
 WorkflowDescription getDescription()
           
 ScuflModelEventListener[] getListeners()
          Get an array copy of ScuflMovelEventListener implementors registered with this ScuflModel.
 int getLogLevel()
           
 Processor[] getProcessors()
          Return an array of the Processor objects defined by this workflow model
 Processor[] getProcessorsOfType(java.lang.Class type)
          Returns an array of Processors that are an instance of the Class
 java.lang.String getValidProcessorName(java.lang.String originalName)
          Get the next valid name based on the specified arbitrary string that could be used to create a new processor.
 Port[] getWorkflowSinkPorts()
          as for the getWorkflowSourcePorts, but returns an array of ports that act as overal outputs from the workflow.
 Processor getWorkflowSinkProcessor()
          Return the internal processor that holds the overall workflow sink ports
 Port[] getWorkflowSourcePorts()
          Return all the ports that act as overal workflow inputs; in this case the workflow input ports are actually going to be instances of OutputPort, this is because they act as flow sources into the workflow.
 Processor getWorkflowSourceProcessor()
          Return the internal processor that represents the workflow sources.
 boolean isOffline()
          Is the workflow in offline mode?
 Port locatePort(java.lang.String port_specifier)
          Locate a given named port, the name is in the form [PROCESSOR]:[PORT], and is not case sensitive.
 Processor locateProcessor(java.lang.String processor_name)
          Locate a named processor
 void removeListener(ScuflModelEventListener listener)
          Remove a ScuflModelEventListener from the listener list.
 void removeListeners()
          Remove all listeners, and in effect terminate the NotifyThread
 void setDescription(WorkflowDescription description)
           
 void setEventStatus(boolean reportEvents)
          Set the event reporting state, useful if you know you're going to be generating a large number of model events that actually reflect only a single change.
 void setLogLevel(int level)
           
 void setOffline(boolean goOffline)
          Set the online / offline status, true sets to offline, false to online (the initial value).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isFiringEvents

public boolean isFiringEvents
Whether the model should fire events to its listeners

Constructor Detail

ScuflModel

public ScuflModel()
Method Detail

clone

public ScuflModel clone()
                 throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

toString

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

clear

public void clear()
Clear the model, retaining any existing listeners but removing all model data. Restarts the notify thread.


isOffline

public boolean isOffline()
Is the workflow in offline mode?


setOffline

public void setOffline(boolean goOffline)
                throws SetOnlineException
Set the online / offline status, true sets to offline, false to online (the initial value). In online mode, processors are allowed to use the network. Use offline mode to load a workflow with network problems.

Throws:
SetOnlineException

getLogLevel

public int getLogLevel()

setLogLevel

public void setLogLevel(int level)

getDescription

public WorkflowDescription getDescription()

setDescription

public void setDescription(WorkflowDescription description)

getValidProcessorName

public java.lang.String getValidProcessorName(java.lang.String originalName)
Get the next valid name based on the specified arbitrary string that could be used to create a new processor. This method will strip non word characters, replacing with the '_' and append a numerical suffix if required to ensure that the name returned is both valid and not already in use


getWorkflowSourcePorts

public Port[] getWorkflowSourcePorts()
Return all the ports that act as overal workflow inputs; in this case the workflow input ports are actually going to be instances of OutputPort, this is because they act as flow sources into the workflow. One possibility here, to make things a bit easier, would be to duplicate the ports on the input side as well, and return the corresponding InputPort instances, this presumably maps the interal processor implementation to the current way the enactor handles these workflows by creating a special input task.


getWorkflowSinkPorts

public Port[] getWorkflowSinkPorts()
as for the getWorkflowSourcePorts, but returns an array of ports that act as overal outputs from the workflow.


getWorkflowSourceProcessor

public Processor getWorkflowSourceProcessor()
Return the internal processor that represents the workflow sources.


getWorkflowSinkProcessor

public Processor getWorkflowSinkProcessor()
Return the internal processor that holds the overall workflow sink ports


getProcessors

public Processor[] getProcessors()
Return an array of the Processor objects defined by this workflow model


getProcessorsOfType

public Processor[] getProcessorsOfType(java.lang.Class type)
Returns an array of Processors that are an instance of the Class

Returns:

collectAllProcessors

public void collectAllProcessors(java.util.Map target,
                                 java.lang.String prefix)
Crawl down the workflow locating all processors and expanding nested workflow processors recursively to get a complete list of all (non workflow) processors in the workflow. Consumes a Map to which the new processors are added as values, the key being the name of the processor in local scope with the prefix specified.


addProcessor

public void addProcessor(Processor processor)
Add a processor to the model.

Throws:
java.lang.NullPointerException - if the processor is null

destroyProcessor

public void destroyProcessor(Processor processor)
Destroy a processor, this also removes any data constraints that have the processor as either a source or a sink.


addDataConstraint

public void addDataConstraint(DataConstraint the_constraint)
Add a data constraint to the model


destroyDataConstraint

public void destroyDataConstraint(DataConstraint the_constraint)
Remove a data constraint from the model


addConcurrencyConstraint

public void addConcurrencyConstraint(ConcurrencyConstraint the_constraint)
Add a concurrency constraint to the model


destroyConcurrencyConstraint

public void destroyConcurrencyConstraint(ConcurrencyConstraint the_constraint)
Remove a concurrency constraint from the model


getConcurrencyConstraints

public ConcurrencyConstraint[] getConcurrencyConstraints()
Return an array of the concurrency constraints defined within this workflow model


getDataConstraints

public DataConstraint[] getDataConstraints()
Return an array of data constraints defined within this workflow model


setEventStatus

public void setEventStatus(boolean reportEvents)
Set the event reporting state, useful if you know you're going to be generating a large number of model events that actually reflect only a single change. Setting the event status to true will also fire a new model event, as this is normally only used where there have been events that were previously masked.


fireModelEvent

public void fireModelEvent(ScuflModelEvent event)
Handle a ScuflModelEvent from one of our children or self, only send an event notification if the isFiringEvents is set to true.


addListener

public void addListener(ScuflModelEventListener listener)
Add a new ScuflModelEventListener to the listener list. Start the NotifyThread if needed.


removeListener

public void removeListener(ScuflModelEventListener listener)
Remove a ScuflModelEventListener from the listener list. Stop the NotifyThread if needed.


removeListeners

public void removeListeners()
Remove all listeners, and in effect terminate the NotifyThread


getListeners

public ScuflModelEventListener[] getListeners()
Get an array copy of ScuflMovelEventListener implementors registered with this ScuflModel.


locatePort

public Port locatePort(java.lang.String port_specifier)
                throws UnknownProcessorException,
                       UnknownPortException,
                       MalformedNameException
Locate a given named port, the name is in the form [PROCESSOR]:[PORT], and is not case sensitive. If the processor part is missing, this method will attempt to locate a new external ports with the single supplied port name in either the internal sink or internal source processor.

Throws:
UnknownProcessorException
UnknownPortException
MalformedNameException

locateProcessor

public Processor locateProcessor(java.lang.String processor_name)
                          throws UnknownProcessorException
Locate a named processor

Throws:
UnknownProcessorException

forceUpdate

public void forceUpdate()
Create an internal model event to force an update of the model