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 Stringm_Descriptionthe description of the flow.protected FlowFilem_Filethe flow file.protected HashSet<FlowSetupStateListener>m_FlowSetupStateListenersthe listeners for the flow execution to finish.protected FlowSetupWorkerm_FlowSetupWorkerthe thread executing the flow.protected booleanm_Headlesswhether the execution is to be headless, i.e., no GUI components.protected Actorm_LastActorthe last actor that was executed.protected Stringm_LastErrorthe last error when executing the flow.protected FlowSetupManagerm_Managerthe manager this setup belongs to.protected Stringm_Namethe name of the flow.protected Stringm_OnErrorthe name of the flow to execute when this one exits with an error.protected Stringm_OnFinishthe 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 voidaddFlowSetupStateChangeListener(FlowSetupStateListener l)Adds the listener to the internal list.voidcleanUp()Performs a clean up of a previously run actor.intcompareTo(Object o)Compares this object with the specified object for order.voiddefineOptions()Adds options to the internal list of options.StringdescriptionTipText()Returns the tip text for this property.booleanequals(Object o)Returns whether the two objects are the same.booleanexecute()Executes the flow, if not already running.booleanexecute(boolean wait)Executes the flow, if not already running.StringfileTipText()Returns the tip text for this property.voidfinish()Called when the worker thread finished.StringgetDescription()Returns the description of the flow.FlowFilegetFile()Returns the current flow file.protected HashSet<FlowSetupStateListener>getFlowSetupStateChangeListeners()Returns the listeners hashtable, instantiates it if necessary.StringgetName()Returns the name of the flow.StringgetOnError()Returns the name of the flow to execute when this setup exist with an error.StringgetOnFinish()Returns the name of the flow to execute when this setup finishes.FlowSetupManagergetOwner()Returns the manager thi setup belongs to.StringglobalInfo()Returns a string describing the object.booleanhasLastError()Checks whether an error was recorded with the last execution.booleanhasOnError()Checks whether a flow is defined in case of an error.booleanhasOnFinish()Checks whether a flow is defined in case of finishing the execution.StringheadlessTipText()Returns the tip text for this property.protected voidinitialize()Initializes the members.booleanisHeadless()Returns whether the actor is run in headless mode.booleanisPaused()Returns whether the object is currently paused.booleanisRunning()Returns whether the flow is running at the moment.StringnameTipText()Returns the tip text for this property.voidnotifyFlowSetupStateChangeListeners(FlowSetupStateEvent e)Notifies all listeners.StringonErrorTipText()Returns the tip text for this property.StringonFinishTipText()Returns the tip text for this property.voidpauseExecution()Pauses the execution.voidremoveFlowSetupStateChangeListener(FlowSetupStateListener l)Removes the listener to the internal list.voidresumeExecution()Resumes the execution.StringretrieveLastError()Returns the last error that occurred, if any.voidsetDescription(String value)Sets the description for the flow.voidsetFile(FlowFile value)Sets the flow file.voidsetHeadless(boolean value)Sets whether the actor is to be run in headless mode, i.e., suppressing GUI components.voidsetLastError(String value)Sets the error that was encountered.voidsetName(String value)Sets the name of the flow.voidsetOnError(String value)Sets the name of the flow to execute when this setup exits with an error.voidsetOnFinish(String value)Sets the name of the flow to execute when this setup finishes.voidsetOwner(FlowSetupManager value)Sets the manager this setup belongs to.FlowSetupshallowCopy()Returns a shallow copy of itself.FlowSetupshallowCopy(boolean expand)Returns a shallow copy of itself.voidshowStatus(String msg)Displays a message, using the manager's StatusMessageHandler (if one is set).voidstopExecution()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:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initializein 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:
pauseExecutionin interfacePausable
-
isPaused
public boolean isPaused()
Returns whether the object is currently paused.
-
resumeExecution
public void resumeExecution()
Resumes the execution.- Specified by:
resumeExecutionin 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:
stopExecutionin 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:
compareToin 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
-
-