Package weka.knowledgeflow
Class Flow
- java.lang.Object
-
- weka.knowledgeflow.Flow
-
public class Flow extends java.lang.ObjectClass that encapsulates the Steps involved in a Knowledge Flow process.- Version:
- $Revision: $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.List<javax.swing.filechooser.FileFilter>FLOW_FILE_EXTENSIONSHolds available file extensions for flow files handled
-
Constructor Summary
Constructors Constructor Description Flow()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAll(java.util.List<StepManagerImpl> steps)All all steps in the supplied list to this FlowvoidaddStep(StepManagerImpl manager)Add the given Step to this flowbooleanconnectSteps(StepManagerImpl source, StepManagerImpl target, java.lang.String connectionType)Connect the supplied source and target steps using the given connectionType.booleanconnectSteps(StepManagerImpl source, StepManagerImpl target, java.lang.String connectionType, boolean force)Connect the supplied source and target steps using the given connectionType.FlowcopyFlow()Make a copy of this Flowjava.util.List<StepManagerImpl>findPotentialStartPoints()Get a list of potential start points in this Flow.StepManagerImplfindStep(java.lang.String stepName)Find a Step by namejava.lang.StringgetFlowID()Get an ID string for this flow.static FlowLoadergetFlowLoader(java.lang.String flowFileExtension, Logger log)Utility method to get a FlowLoader implementation suitable for loading a flow with the supplied file extension.java.lang.StringgetFlowName()Get the name of this Flowjava.util.List<StepManagerImpl>getSteps()Get a list of the Steps in this FlowbooleaninitFlow(FlowExecutor executor)Initialize the flow by setting the execution environment and calling the init() method of each stepjava.util.Iterator<StepManagerImpl>iterator()Get an Iterator over the Steps in this flowstatic FlowJSONToFlow(java.lang.String flowJSON)Parse a Flow from the supplied JSON stringstatic FlowJSONToFlow(java.lang.String flowJSON, boolean dontComplainAboutMissingConnections)Parse a Flow from the supplied JSON stringstatic FlowloadFlow(java.io.File flowFile, Logger log)Utility method to load a flow from a filestatic FlowloadFlow(java.io.InputStream is, FlowLoader loader)Utility method to load a flow from the supplied input stream using the supplied FlowLoaderstatic FlowloadFlow(java.io.Reader r, FlowLoader loader)Utility method to load a flow from the supplied reader using the supplied FlowLoadervoidremoveStep(StepManagerImpl manager)Remove the supplied Step from this flowvoidrenameStep(java.lang.String oldName, java.lang.String newName)Rename a Step.voidrenameStep(StepManagerImpl step, java.lang.String newName)Rename the supplied step with the supplied namevoidsaveFlow(java.io.File file)Save this Flow to the supplied FilevoidsetFlowName(java.lang.String name)Set the name of this Flowintsize()Get the number of steps in this flowjava.lang.StringtoJSON()Return the JSON encoded version of this Flow
-
-
-
Method Detail
-
getFlowLoader
public static FlowLoader getFlowLoader(java.lang.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 forlog- the log in use- Returns:
- a FlowLoader
- Throws:
WekaException- if a problem occurs
-
loadFlow
public static Flow loadFlow(java.io.File flowFile, Logger log) throws WekaException
Utility method to load a flow from a file- Parameters:
flowFile- the file to load fromlog- the log to use- Returns:
- the loaded Flow
- Throws:
WekaException- if a problem occurs
-
loadFlow
public static Flow loadFlow(java.io.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 fromloader- the FlowLoader to use- Returns:
- the loaded Flow
- Throws:
WekaException- if a problem occurs
-
loadFlow
public static Flow loadFlow(java.io.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 fromloader- the FlowLoader to use- Returns:
- the loaded flow
- Throws:
WekaException- if a problem occurs
-
JSONToFlow
public static Flow JSONToFlow(java.lang.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(java.lang.String flowJSON, boolean dontComplainAboutMissingConnections) throws WekaException
Parse a Flow from the supplied JSON string- Parameters:
flowJSON- the JSON string to parsedontComplainAboutMissingConnections- 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(java.io.File file) throws WekaExceptionSave this Flow to the supplied File- Parameters:
file- the File to save to- Throws:
WekaException- if a problem occurs
-
getFlowName
public java.lang.String getFlowName()
Get the name of this Flow- Returns:
- the name of this flow
-
setFlowName
public void setFlowName(java.lang.String name)
Set the name of this Flow- Parameters:
name- the name to set
-
getFlowID
public java.lang.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(java.util.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, java.lang.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 steptarget- the StepManager for the target stepconnectionType- 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, java.lang.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 steptarget- the StepManager for the target stepconnectionType- the connection type to useforce- 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, java.lang.String newName) throws WekaException
Rename the supplied step with the supplied name- Parameters:
step- the StepManager of the Step to renamenewName- the new name to give the step- Throws:
WekaException- if the Step is not part of this Flow.
-
renameStep
public void renameStep(java.lang.String oldName, java.lang.String newName) throws WekaExceptionRename a Step.- Parameters:
oldName- the name of the Step to renamenewName- 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 java.util.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 java.util.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(java.lang.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 java.util.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 java.lang.String toJSON() throws WekaExceptionReturn 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
-
-