Class 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 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.
    • Constructor Detail

      • FlowSetup

        public FlowSetup()
    • Method Detail

      • 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 interface Pausable
      • isPaused

        public boolean isPaused()
        Returns whether the object is currently paused.
        Specified by:
        isPaused in interface Pausable
        Returns:
        true if object is paused
      • resumeExecution

        public void resumeExecution()
        Resumes the execution.
        Specified by:
        resumeExecution in interface Pausable
      • 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 interface Stoppable
      • 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 interface Comparable
        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.
        Overrides:
        equals in class Object
        Parameters:
        o - the object to be compared
        Returns:
        true if the object is the same as this one
      • 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