Class Flow

java.lang.Object
weka.knowledgeflow.Flow

public class Flow extends Object
Class that encapsulates the Steps involved in a Knowledge Flow process.
Version:
$Revision: $
Author:
Mark Hall (mhall{[at]}pentaho{[dot]}com)
  • Field Details

    • FLOW_FILE_EXTENSIONS

      public static final List<FileFilter> FLOW_FILE_EXTENSIONS
      Holds available file extensions for flow files handled
  • Constructor Details

    • Flow

      public Flow()
  • Method Details

    • getFlowLoader

      public static FlowLoader getFlowLoader(String flowFileExtension, Logger log) throws WekaException
      Utility method to get a FlowLoader implementation suitable for loading a flow with the supplied file extension.
      Parameters:
      flowFileExtension - the file extension to get a FlowLoader for
      log - the log in use
      Returns:
      a FlowLoader
      Throws:
      WekaException - if a problem occurs
    • loadFlow

      public static Flow loadFlow(File flowFile, Logger log) throws WekaException
      Utility method to load a flow from a file
      Parameters:
      flowFile - the file to load from
      log - the log to use
      Returns:
      the loaded Flow
      Throws:
      WekaException - if a problem occurs
    • loadFlow

      public static Flow loadFlow(InputStream is, FlowLoader loader) throws WekaException
      Utility method to load a flow from the supplied input stream using the supplied FlowLoader
      Parameters:
      is - the input stream to load from
      loader - the FlowLoader to use
      Returns:
      the loaded Flow
      Throws:
      WekaException - if a problem occurs
    • loadFlow

      public static Flow loadFlow(Reader r, FlowLoader loader) throws WekaException
      Utility method to load a flow from the supplied reader using the supplied FlowLoader
      Parameters:
      r - the reader to load from
      loader - the FlowLoader to use
      Returns:
      the loaded flow
      Throws:
      WekaException - if a problem occurs
    • JSONToFlow

      public static Flow JSONToFlow(String flowJSON) throws WekaException
      Parse a Flow from the supplied JSON string
      Parameters:
      flowJSON - the JSON string to parse
      Returns:
      the Flow
      Throws:
      WekaException - if a problem occurs
    • JSONToFlow

      public static Flow JSONToFlow(String flowJSON, boolean dontComplainAboutMissingConnections) throws WekaException
      Parse a Flow from the supplied JSON string
      Parameters:
      flowJSON - the JSON string to parse
      dontComplainAboutMissingConnections - true to not raise an exception if there are connections to non-existent Steps in the JSON flow
      Returns:
      the Flow
      Throws:
      WekaException - if a problem occurs
    • saveFlow

      public void saveFlow(File file) throws WekaException
      Save this Flow to the supplied File
      Parameters:
      file - the File to save to
      Throws:
      WekaException - if a problem occurs
    • getFlowName

      public String getFlowName()
      Get the name of this Flow
      Returns:
      the name of this flow
    • setFlowName

      public void setFlowName(String name)
      Set the name of this Flow
      Parameters:
      name - the name to set
    • getFlowID

      public String getFlowID()
      Get an ID string for this flow. The ID is made up of the FlowName + "_" + the hashcode generated from the JSON representation of the flow.
      Returns:
    • addAll

      public void addAll(List<StepManagerImpl> steps)
      All all steps in the supplied list to this Flow
      Parameters:
      steps - a list of StepManagers for the steps to add
    • addStep

      public void addStep(StepManagerImpl manager)
      Add the given Step to this flow
      Parameters:
      manager - the StepManager containing the Step to add
    • connectSteps

      public boolean connectSteps(StepManagerImpl source, StepManagerImpl target, String connectionType)
      Connect the supplied source and target steps using the given connectionType. The connection will be successful only if both source and target are actually part of this Flow, and the target is able to accept the connection at this time.
      Parameters:
      source - the StepManager for the source step
      target - the StepManager for the target step
      connectionType - the connection type to use says it can accept the connection type at this time)
      Returns:
      true if the connection was successful
    • connectSteps

      public boolean connectSteps(StepManagerImpl source, StepManagerImpl target, String connectionType, boolean force)
      Connect the supplied source and target steps using the given connectionType. The connection will be successful only if both source and target are actually part of this Flow, and the target is able to accept the connection at this time.
      Parameters:
      source - the StepManager for the source step
      target - the StepManager for the target step
      connectionType - the connection type to use
      force - true to force the connection (i.e. even if the target step says it can accept the connection type at this time)
      Returns:
      true if the connection was successful
    • renameStep

      public void renameStep(StepManagerImpl step, String newName) throws WekaException
      Rename the supplied step with the supplied name
      Parameters:
      step - the StepManager of the Step to rename
      newName - the new name to give the step
      Throws:
      WekaException - if the Step is not part of this Flow.
    • renameStep

      public void renameStep(String oldName, String newName) throws WekaException
      Rename a Step.
      Parameters:
      oldName - the name of the Step to rename
      newName - the new name to use
      Throws:
      WekaException - if the named Step is not part of this flow
    • removeStep

      public void removeStep(StepManagerImpl manager) throws WekaException
      Remove the supplied Step from this flow
      Parameters:
      manager - the StepManager of the Step to remove
      Throws:
      WekaException - if the step is not part of this flow
    • getSteps

      public List<StepManagerImpl> getSteps()
      Get a list of the Steps in this Flow
      Returns:
      a list of StepManagers of the steps in this flow
    • iterator

      public Iterator<StepManagerImpl> iterator()
      Get an Iterator over the Steps in this flow
      Returns:
      an Iterator over the StepManagers of the Steps in this flow
    • size

      public int size()
      Get the number of steps in this flow
      Returns:
      the number of steps in this flow
    • findStep

      public StepManagerImpl findStep(String stepName)
      Find a Step by name
      Parameters:
      stepName - the name of the Step to find
      Returns:
      the StepManager of the named Step, or null if the Step is not part of this flow
    • findPotentialStartPoints

      public List<StepManagerImpl> findPotentialStartPoints()
      Get a list of potential start points in this Flow. Potential start points are those steps that have no incoming connections.
      Returns:
      a list of potential start points
    • initFlow

      public boolean initFlow(FlowExecutor executor) throws WekaException
      Initialize the flow by setting the execution environment and calling the init() method of each step
      Parameters:
      executor - the flow executor being used to execute the flow
      Returns:
      false if initialization failed
      Throws:
      WekaException - if a problem occurs during flow initialization
    • toJSON

      public String toJSON() throws WekaException
      Return the JSON encoded version of this Flow
      Returns:
      the flow in JSON format
      Throws:
      WekaException - if a problem occurs
    • copyFlow

      public Flow copyFlow() throws WekaException
      Make a copy of this Flow
      Returns:
      a copy of this Flow
      Throws:
      WekaException - if a problem occurs