Package adams.flow.setup
Class FlowSetup
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.setup.FlowSetup
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,Pausable
,SizeOfHandler
,Stoppable
,Serializable
,Comparable
public class FlowSetup extends AbstractOptionHandler implements Comparable, Stoppable, Pausable
Container object for a flow file with name and information about it.
Valid options are:
-D (property: debug) If set to true, scheme may output additional info to the console.
-name <java.lang.String> (property: name) The name of the flow. default: noname
-description <java.lang.String> (property: description) The description of the flow. default: nodescription
-file <adams.core.io.FlowFile> (property: file) The flow file. default: .
-headless (property: headless) If set to true, the flow is run in headless mode without GUI components.
-on-error <java.lang.String> (property: onError) The name of the flow setup to execute when this setup exist with an error . default:
-on-finish <java.lang.String> (property: onFinish) The name of the flow setup to execute when this setup finishes. default:
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_Description
the description of the flow.protected FlowFile
m_File
the flow file.protected HashSet<FlowSetupStateListener>
m_FlowSetupStateListeners
the listeners for the flow execution to finish.protected FlowSetupWorker
m_FlowSetupWorker
the thread executing the flow.protected boolean
m_Headless
whether the execution is to be headless, i.e., no GUI components.protected Actor
m_LastActor
the last actor that was executed.protected String
m_LastError
the last error when executing the flow.protected FlowSetupManager
m_Manager
the manager this setup belongs to.protected String
m_Name
the name of the flow.protected String
m_OnError
the name of the flow to execute when this one exits with an error.protected String
m_OnFinish
the name of the flow to execute when this one finishes.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description FlowSetup()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFlowSetupStateChangeListener(FlowSetupStateListener l)
Adds the listener to the internal list.void
cleanUp()
Performs a clean up of a previously run actor.int
compareTo(Object o)
Compares this object with the specified object for order.void
defineOptions()
Adds options to the internal list of options.String
descriptionTipText()
Returns the tip text for this property.boolean
equals(Object o)
Returns whether the two objects are the same.boolean
execute()
Executes the flow, if not already running.boolean
execute(boolean wait)
Executes the flow, if not already running.String
fileTipText()
Returns the tip text for this property.void
finish()
Called when the worker thread finished.String
getDescription()
Returns the description of the flow.FlowFile
getFile()
Returns the current flow file.protected HashSet<FlowSetupStateListener>
getFlowSetupStateChangeListeners()
Returns the listeners hashtable, instantiates it if necessary.String
getName()
Returns the name of the flow.String
getOnError()
Returns the name of the flow to execute when this setup exist with an error.String
getOnFinish()
Returns the name of the flow to execute when this setup finishes.FlowSetupManager
getOwner()
Returns the manager thi setup belongs to.String
globalInfo()
Returns a string describing the object.boolean
hasLastError()
Checks whether an error was recorded with the last execution.boolean
hasOnError()
Checks whether a flow is defined in case of an error.boolean
hasOnFinish()
Checks whether a flow is defined in case of finishing the execution.String
headlessTipText()
Returns the tip text for this property.protected void
initialize()
Initializes the members.boolean
isHeadless()
Returns whether the actor is run in headless mode.boolean
isPaused()
Returns whether the object is currently paused.boolean
isRunning()
Returns whether the flow is running at the moment.String
nameTipText()
Returns the tip text for this property.void
notifyFlowSetupStateChangeListeners(FlowSetupStateEvent e)
Notifies all listeners.String
onErrorTipText()
Returns the tip text for this property.String
onFinishTipText()
Returns the tip text for this property.void
pauseExecution()
Pauses the execution.void
removeFlowSetupStateChangeListener(FlowSetupStateListener l)
Removes the listener to the internal list.void
resumeExecution()
Resumes the execution.String
retrieveLastError()
Returns the last error that occurred, if any.void
setDescription(String value)
Sets the description for the flow.void
setFile(FlowFile value)
Sets the flow file.void
setHeadless(boolean value)
Sets whether the actor is to be run in headless mode, i.e., suppressing GUI components.void
setLastError(String value)
Sets the error that was encountered.void
setName(String value)
Sets the name of the flow.void
setOnError(String value)
Sets the name of the flow to execute when this setup exits with an error.void
setOnFinish(String value)
Sets the name of the flow to execute when this setup finishes.void
setOwner(FlowSetupManager value)
Sets the manager this setup belongs to.FlowSetup
shallowCopy()
Returns a shallow copy of itself.FlowSetup
shallowCopy(boolean expand)
Returns a shallow copy of itself.void
showStatus(String msg)
Displays a message, using the manager's StatusMessageHandler (if one is set).void
stopExecution()
Stops the flow, if running.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_File
protected FlowFile m_File
the flow file.
-
m_Name
protected String m_Name
the name of the flow.
-
m_Description
protected String m_Description
the description of the flow.
-
m_Headless
protected boolean m_Headless
whether the execution is to be headless, i.e., no GUI components.
-
m_OnFinish
protected String m_OnFinish
the name of the flow to execute when this one finishes.
-
m_OnError
protected String m_OnError
the name of the flow to execute when this one exits with an error.
-
m_FlowSetupWorker
protected transient FlowSetupWorker m_FlowSetupWorker
the thread executing the flow.
-
m_LastActor
protected Actor m_LastActor
the last actor that was executed.
-
m_LastError
protected transient String m_LastError
the last error when executing the flow.
-
m_FlowSetupStateListeners
protected transient HashSet<FlowSetupStateListener> m_FlowSetupStateListeners
the listeners for the flow execution to finish.
-
m_Manager
protected transient FlowSetupManager m_Manager
the manager this setup belongs to.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
getFlowSetupStateChangeListeners
protected HashSet<FlowSetupStateListener> getFlowSetupStateChangeListeners()
Returns the listeners hashtable, instantiates it if necessary.- Returns:
- the hashtable
-
setFile
public void setFile(FlowFile value)
Sets the flow file.- Parameters:
value
- the file
-
getFile
public FlowFile getFile()
Returns the current flow file.- Returns:
- the file
-
fileTipText
public String fileTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setName
public void setName(String value)
Sets the name of the flow.- Parameters:
value
- the name
-
getName
public String getName()
Returns the name of the flow.- Returns:
- the name
-
nameTipText
public String nameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setDescription
public void setDescription(String value)
Sets the description for the flow.- Parameters:
value
- the description
-
getDescription
public String getDescription()
Returns the description of the flow.- Returns:
- the description
-
descriptionTipText
public String descriptionTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setHeadless
public void setHeadless(boolean value)
Sets whether the actor is to be run in headless mode, i.e., suppressing GUI components.- Parameters:
value
- if true then GUI components will be suppressed
-
isHeadless
public boolean isHeadless()
Returns whether the actor is run in headless mode.- Returns:
- true if GUI components are suppressed
-
headlessTipText
public String headlessTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setOnFinish
public void setOnFinish(String value)
Sets the name of the flow to execute when this setup finishes.- Parameters:
value
- the name of the flow
-
getOnFinish
public String getOnFinish()
Returns the name of the flow to execute when this setup finishes.- Returns:
- the name of the flow
-
onFinishTipText
public String onFinishTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
hasOnFinish
public boolean hasOnFinish()
Checks whether a flow is defined in case of finishing the execution.- Returns:
- true if a flow is defined
-
setOnError
public void setOnError(String value)
Sets the name of the flow to execute when this setup exits with an error.- Parameters:
value
- the name of the flow
-
getOnError
public String getOnError()
Returns the name of the flow to execute when this setup exist with an error.- Returns:
- the name of the flow
-
onErrorTipText
public String onErrorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
hasOnError
public boolean hasOnError()
Checks whether a flow is defined in case of an error.- Returns:
- true if a flow is defined
-
hasLastError
public boolean hasLastError()
Checks whether an error was recorded with the last execution.- Returns:
- true if an error had occurred
-
setLastError
public void setLastError(String value)
Sets the error that was encountered.- Parameters:
value
- the error string or null
-
retrieveLastError
public String retrieveLastError()
Returns the last error that occurred, if any.- Returns:
- the error or null if none occurred
-
setOwner
public void setOwner(FlowSetupManager value)
Sets the manager this setup belongs to.- Parameters:
value
- the manager
-
getOwner
public FlowSetupManager getOwner()
Returns the manager thi setup belongs to.- Returns:
- the manager
-
showStatus
public void showStatus(String msg)
Displays a message, using the manager's StatusMessageHandler (if one is set).- Parameters:
msg
- the message to display
-
isRunning
public boolean isRunning()
Returns whether the flow is running at the moment.- Returns:
- true if the flow is being executed
-
pauseExecution
public void pauseExecution()
Pauses the execution.- Specified by:
pauseExecution
in interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecution
in interfacePausable
-
execute
public boolean execute()
Executes the flow, if not already running. Does not wait for the execution to finish.- Returns:
- true if successfully started
-
execute
public boolean execute(boolean wait)
Executes the flow, if not already running.- Parameters:
wait
- whether to wait for the execution to finish- Returns:
- true if successfully started
-
stopExecution
public void stopExecution()
Stops the flow, if running.- Specified by:
stopExecution
in interfaceStoppable
-
finish
public void finish()
Called when the worker thread finished.
-
cleanUp
public void cleanUp()
Performs a clean up of a previously run actor.
-
addFlowSetupStateChangeListener
public void addFlowSetupStateChangeListener(FlowSetupStateListener l)
Adds the listener to the internal list.- Parameters:
l
- the listener to add
-
removeFlowSetupStateChangeListener
public void removeFlowSetupStateChangeListener(FlowSetupStateListener l)
Removes the listener to the internal list.- Parameters:
l
- the listener to remove
-
notifyFlowSetupStateChangeListeners
public void notifyFlowSetupStateChangeListeners(FlowSetupStateEvent e)
Notifies all listeners.- Parameters:
e
- the event to send to all listeners
-
compareTo
public int compareTo(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
Only compares the commandlines of the two objects.- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
equals
public boolean equals(Object o)
Returns whether the two objects are the same.
Only compares the commandlines of the two objects.
-
shallowCopy
public FlowSetup shallowCopy()
Returns a shallow copy of itself.- Returns:
- the shallow copy
-
shallowCopy
public FlowSetup shallowCopy(boolean expand)
Returns a shallow copy of itself.- Parameters:
expand
- whether to expand variables to their current values- Returns:
- the shallow copy
-
-