Package weka.knowledgeflow
Class Flow
java.lang.Object
weka.knowledgeflow.Flow
Class that encapsulates the Steps involved in a Knowledge Flow process.
- Version:
- $Revision: $
- Author:
- Mark Hall (mhall{[at]}pentaho{[dot]}com)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final List<FileFilter>
Holds available file extensions for flow files handled -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAll
(List<StepManagerImpl> steps) All all steps in the supplied list to this Flowvoid
addStep
(StepManagerImpl manager) Add the given Step to this flowboolean
connectSteps
(StepManagerImpl source, StepManagerImpl target, String connectionType) Connect the supplied source and target steps using the given connectionType.boolean
connectSteps
(StepManagerImpl source, StepManagerImpl target, String connectionType, boolean force) Connect the supplied source and target steps using the given connectionType.copyFlow()
Make a copy of this FlowGet a list of potential start points in this Flow.Find a Step by nameGet an ID string for this flow.static FlowLoader
getFlowLoader
(String flowFileExtension, Logger log) Utility method to get a FlowLoader implementation suitable for loading a flow with the supplied file extension.Get the name of this FlowgetSteps()
Get a list of the Steps in this Flowboolean
initFlow
(FlowExecutor executor) Initialize the flow by setting the execution environment and calling the init() method of each stepiterator()
Get an Iterator over the Steps in this flowstatic Flow
JSONToFlow
(String flowJSON) Parse a Flow from the supplied JSON stringstatic Flow
JSONToFlow
(String flowJSON, boolean dontComplainAboutMissingConnections) Parse a Flow from the supplied JSON stringstatic Flow
Utility method to load a flow from a filestatic Flow
loadFlow
(InputStream is, FlowLoader loader) Utility method to load a flow from the supplied input stream using the supplied FlowLoaderstatic Flow
loadFlow
(Reader r, FlowLoader loader) Utility method to load a flow from the supplied reader using the supplied FlowLoadervoid
removeStep
(StepManagerImpl manager) Remove the supplied Step from this flowvoid
renameStep
(String oldName, String newName) Rename a Step.void
renameStep
(StepManagerImpl step, String newName) Rename the supplied step with the supplied namevoid
Save this Flow to the supplied Filevoid
setFlowName
(String name) Set the name of this Flowint
size()
Get the number of steps in this flowtoJSON()
Return the JSON encoded version of this Flow
-
Field Details
-
FLOW_FILE_EXTENSIONS
Holds available file extensions for flow files handled
-
-
Constructor Details
-
Flow
public Flow()
-
-
Method Details
-
getFlowLoader
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
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
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
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
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 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
Save this Flow to the supplied File- Parameters:
file
- the File to save to- Throws:
WekaException
- if a problem occurs
-
getFlowName
Get the name of this Flow- Returns:
- the name of this flow
-
setFlowName
Set the name of this Flow- Parameters:
name
- the name to set
-
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
All all steps in the supplied list to this Flow- Parameters:
steps
- a list of StepManagers for the steps to add
-
addStep
Add the given Step to this flow- Parameters:
manager
- the StepManager containing the Step to add
-
connectSteps
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, 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
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
Rename 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
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
Get a list of the Steps in this Flow- Returns:
- a list of StepManagers of the steps in this flow
-
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
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
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
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
Return the JSON encoded version of this Flow- Returns:
- the flow in JSON format
- Throws:
WekaException
- if a problem occurs
-
copyFlow
Make a copy of this Flow- Returns:
- a copy of this Flow
- Throws:
WekaException
- if a problem occurs
-