org.knime.core.node.workflow
Class WorkflowManager

java.lang.Object
  extended by org.knime.core.node.workflow.NodeContainer
      extended by org.knime.core.node.workflow.WorkflowManager
All Implemented Interfaces:
EventListener, NodeProgressListener

public final class WorkflowManager
extends NodeContainer

Container holding nodes and connections of a (sub) workflow. In contrast to previous implementations, this class will now handle all control, such as transport of data and specs from node to subsequent nodes. That is, nodes do not know their pre- or successors anymore. A WorkflowManager can also play the role of a NodeContainer, thus representing a metanode/subworkflow.

Author:
M. Berthold/B. Wiswedel, University of Konstanz

Nested Class Summary
 
Nested classes/interfaces inherited from class org.knime.core.node.workflow.NodeContainer
NodeContainer.NodeContainerSettings, NodeContainer.State
 
Field Summary
(package private) static String CFG_CREATED_BY
          Version of KNIME that has written the workflow.
(package private) static String CFG_VERSION
          Workflow version, indicates the "oldest" version that is compatible to the current workflow format.
static WorkflowManager ROOT
          The root of everything, a workflow with no in- or outputs.
 
Fields inherited from class org.knime.core.node.workflow.NodeContainer
m_nodeMutex
 
Method Summary
 ConnectionContainer addConnection(NodeID source, int sourcePort, NodeID dest, int destPort)
          Add new connection - throw Exception if the same connection already exists.
 void addListener(WorkflowListener listener)
          Add listener to list.
 void addWorkflowVariables(boolean skipReset, FlowVariable... newVars)
          Set new workflow variables.
 boolean areDialogAndNodeSettingsEqual()
          
(package private)  boolean areSettingsValid(NodeSettingsRO settings)
          
(package private)  void assembleInputSpecs(NodeID id, PortObjectSpec[] inSpecs)
          Fill array holding all input specs for the given node.
 boolean canAddConnection(NodeID source, int sourcePort, NodeID dest, int destPort)
          Check if a new connection can be added.
(package private)  void cancelExecution()
          Cancel execution of a marked, queued, or executing node.
 void cancelExecution(NodeContainer nc)
          Cancel execution of the given NodeContainer.
 boolean canExecuteNode(NodeID nodeID)
          Check if a node can be executed directly.
 boolean canRemoveConnection(ConnectionContainer cc)
          Check if a connection can safely be removed.
 boolean canRemoveNode(NodeID nodeID)
          Check if specific node can be removed (i.e.
 boolean canResetNode(NodeID nodeID)
          Check if a node can be reset, meaning that it is executed and all of it's successors are idle or executed as well.
 boolean canSetJobManager(NodeID nodeID)
          Is the node with the given ID ready to take a new job manager.
(package private)  void cleanup()
          Method that's called when the node is discarded.
 boolean containsNodeContainer(NodeID id)
          Does the workflow contain a node with the argument id?
(package private)  boolean continueExecutionOnLoad(NodeContainer nc, NodeContainerPersistor persistor)
           
 WorkflowPersistor copy(NodeID... nodeIDs)
          Copy the nodes with the given ids.
 NodeID[] copyFromAndPasteHere(WorkflowManager sourceManager, NodeID... nodeIDs)
          Copies the nodes with the given ids from the argument workflow manager into this wfm instance.
 NodeID createAndAddNode(NodeFactory<?> factory)
          Uses given Factory to create a new node and then adds new node to the workflow manager.
 WorkflowManager createAndAddProject(String name)
          Create new project - which is the same as creating a new subworkflow at this level with no in- or outports.
 WorkflowManager createAndAddSubWorkflow(PortType[] inPorts, PortType[] outPorts, String name)
          Creates new meta node.
 WorkflowExecutionResult createExecutionResult(ExecutionMonitor exec)
          Saves all internals that are necessary to mimic the computed result into a new execution result object.
(package private)  WorkflowManager createSubWorkflow(WorkflowPersistor persistor, NodeID newID)
          Creates new meta node from a persistor instance.
(package private)  void doAfterExecution(NodeContainer nc, NodeContainerExecutionStatus status)
          Cleanup a node after execution.
(package private)  void doBeforeExecution(NodeContainer nc)
          Call-back from NodeContainer called before node is actually executed.
(package private)  void doBeforePostExecution(NodeContainer nc)
          Callback from NodeContainer to request a safe transition into the NodeContainer.State.POSTEXECUTE state.
(package private)  boolean doBeforePreExecution(NodeContainer nc)
          Callback from NodeContainer to request a safe transition into the NodeContainer.State.PREEXECUTE state.
 void executeAll()
          Convenience method: (Try to) Execute all nodes in the workflow.
 boolean executeAllAndWaitUntilDone()
          Convenience method: execute all and wait for execution to be done.
 void executeUpToHere(NodeID... ids)
          mark these nodes and all not-yet-executed predecessors for execution.
 Collection<ConnectionContainer> getConnectionContainers()
           
protected  NodeContainerPersistor getCopyPersistor(HashMap<Integer,ContainerTable> tableRep, boolean preserveDeletableFlags)
          Get a new persistor that is used to copy this node (copy&paste action).
(package private)  NodeDialogPane getDialogPane()
          
(package private)  NodeDialogPane getDialogPaneWithSettings(PortObjectSpec[] inSpecs)
          
(package private)  HashMap<Integer,ContainerTable> getGlobalTableRepository()
           
 URL getIcon()
          
 ConnectionContainer getIncomingConnectionFor(NodeID id, int portIdx)
          Returns the incoming connection of the node with the passed node id at the specified port.
 Set<ConnectionContainer> getIncomingConnectionsFor(NodeID id)
          Get all incoming connections for a node.
 WorkflowInPort getInPort(int index)
          
 UIInformation getInPortsBarUIInfo()
          Get UI information for workflow input ports.
 String getName()
          Get the name of the workflow.
(package private)  String getNameField()
           
 NodeContainer getNodeContainer(NodeID id)
           
 Collection<NodeContainer> getNodeContainers()
           
 List<NodeMessage> getNodeErrorMessages()
           
 NodeView<NodeModel> getNodeView(int i)
          Return the view with the specified index provided by the node.
 String getNodeViewName(int i)
          
 int getNrInPorts()
          
 int getNrNodeViews()
          Returns the number of views provided by the node implementation.
 int getNrOutPorts()
          
 int getNrWorkflowIncomingPorts()
           
 int getNrWorkflowOutgoingPorts()
           
 Set<ConnectionContainer> getOutgoingConnectionsFor(NodeID id)
          Get all outgoing connections for a node.
 Set<ConnectionContainer> getOutgoingConnectionsFor(NodeID id, int portIdx)
          Returns the set of outgoing connections for the node with the passed id at the specified port.
 WorkflowOutPort getOutPort(int index)
          
 UIInformation getOutPortsBarUIInfo()
          Get UI information for workflow output ports.
 NodeFactory.NodeType getType()
          
(package private)  Workflow getWorkflow()
           
 NodeOutPort getWorkflowIncomingPort(int i)
           
 NodeInPort getWorkflowOutgoingPort(int i)
           
 List<FlowVariable> getWorkflowVariables()
          Get read-only access on the current workflow variables.
 boolean hasDialog()
          
(package private)  void invokeResetOnPortSuccessors(int inportIndex)
          Reset those nodes which are connected to a specific workflow incoming port.
protected  boolean isLocalWFM()
          Is this node a to be locally executed workflow.
(package private)  boolean isResetable()
          check if node can be safely reset.
 WorkflowPersistor.WorkflowLoadResult load(File directory, ExecutionMonitor exec, boolean keepNodeMessages)
          Loads the workflow contained in the directory as node into this workflow instance.
(package private)  NodeID[] loadContent(NodeContainerPersistor nodePersistor, Map<Integer,BufferedDataTable> tblRep, FlowObjectStack ignoredStack, ExecutionMonitor exec, WorkflowPersistor.LoadResult loadResult, boolean preserveNodeMessage)
          Restore content from persistor.
 void loadExecutionResult(NodeContainerExecutionResult result, ExecutionMonitor exec, WorkflowPersistor.LoadResult loadResult)
          Load information from execution result.
 void loadNodeSettings(NodeID id, NodeSettingsRO settings)
          Load Settings into specified node.
static WorkflowPersistor.WorkflowLoadResult loadProject(File directory, ExecutionMonitor exec)
           
(package private)  void loadSettings(NodeSettingsRO settings)
          
(package private)  void markForExecution(boolean flag)
          Enable (or disable) queuing of underlying node for execution.
(package private)  void mimicRemoteExecuted(NodeContainerExecutionStatus status)
          Put this node into either the NodeContainer.State.EXECUTED or NodeContainer.State.IDLE state depending on the argument.
(package private)  void mimicRemoteExecuting()
          Marks this node as remotely executing.
(package private)  void mimicRemotePostExecute()
          Puts this node (and all its children) into the NodeContainer.State.POSTEXECUTE state.
(package private)  void mimicRemotePreExecute()
          Puts this node (and all its children) into the NodeContainer.State.PREEXECUTE state.
protected  void notifyJobManagerChangedListener()
          
 NodeID[] paste(WorkflowPersistor persistor)
          Pastes the contents of the argument persistor into this wfm.
(package private)  void performShutdown()
          Called when the workflow is to be disposed.
(package private)  void performStateTransitionEXECUTED(NodeContainerExecutionStatus status)
          This should be used to change the nodes states correctly (and likely needs to be synchronized with other changes visible to successors of this node as well!) AFTER the actual execution.
(package private)  void performStateTransitionEXECUTING()
          This should be used to change the nodes states correctly (and likely needs to be synchronized with other changes visible to successors of this node as well!) BEFORE the actual execution.
(package private)  void performStateTransitionPOSTEXECUTE()
          Called when the state of a node should switch from NodeContainer.State.EXECUTING (or NodeContainer.State.EXECUTINGREMOTELY) to NodeContainer.State.POSTEXECUTE.
(package private)  boolean performStateTransitionPREEXECUTE()
          Called when the state of a node should switch from NodeContainer.State.QUEUED to NodeContainer.State.PREEXECUTE.
 String printNodeSummary(NodeID prefix, int indent)
          Produce summary of node.
(package private)  void reconfigureAllNodesOnlyInThisWFM()
          Re-configure all configured (NOT executed) nodes in this workflow to make sure that new workflow variables are spread accordingly.
 void removeConnection(ConnectionContainer cc)
          Remove connection.
 void removeListener(WorkflowListener listener)
          Remove listener.
 void removeNode(NodeID nodeID)
          Remove node if possible.
 void removeProject(NodeID id)
          Remove a project - the same as remove node but we make sure it really looks like a project (i.e.
 void removeWorkflowVariable(String name)
          Remove workflow variable of given name.
 boolean renameWorkflowDirectory(String newName)
          Renames the underlying workflow directory to the new name.
 void resetAll()
          Reset all nodes in this workflow.
(package private)  void resetAllNodesInWFM()
          Reset all nodes in this workflow.
(package private)  void resetAllNodesOnlyInThisWFM()
          Reset all executed nodes in this workflow to make sure that new workflow variables are spread accordingly.
 void resetAndConfigureNode(NodeID id)
          Reset node and all executed successors of a specific node.
 void save(File directory, ExecutionMonitor exec, boolean isSaveData)
           
 void saveNodeSettings(NodeID id, NodeSettingsWO settings)
          write node settings into Settings object.
(package private)  void saveSettings(NodeSettingsWO settings)
          
 void setDirty()
          Mark this node container to be changed, that is, it needs to be saved.
 void setInPortsBarUIInfo(UIInformation inPortsBarUIInfo)
          Set UI information for workflow's input ports (typically aligned as a bar).
 void setJobManager(NodeID nodeID, NodeExecutionJobManager jobMgr)
          Sets a new job manager on the node with the given ID.
 void setName(String name)
          Set new name of this workflow or null to reset the name (will then return the workflow directory in getName() or null if this flow has not been saved yet).
 void setOutPortsBarUIInfo(UIInformation outPortsBarUIInfo)
          Set UI information for workflow's output ports (typically aligned as a bar).
 void shutdown()
          Attempts to cancel or running nodes in preparation for a removal of this node (or its parent) from the root.
(package private)  boolean sweep(boolean propagate)
          Performs sanity check on workflow.
 String toString()
          
 
Methods inherited from class org.knime.core.node.workflow.NodeContainer
addJobManagerChangedListener, addNodeMessageListener, addNodeStateChangeListener, addProgressListener, addUIInformationListener, addWaitingLoop, applySettingsFromDialog, areDialogSettingsValid, clearWaitingLoopList, closeAllJobManagerViews, continueExecutionOnLoad, findJobManager, getCustomDescription, getCustomName, getDialogPaneWithSettings, getDisplayLabel, getExecutionJob, getID, getJobManager, getNameWithID, getNodeContainerDirectory, getNodeMessage, getNrViews, getParent, getProgressMonitor, getSplitType, getState, getUIInformation, getView, getViewName, getWaitingLoops, isDeletable, isDirty, notifyMessageListeners, notifyParentExecuteFinished, notifyParentExecuteStart, notifyParentPostExecuteStart, notifyParentPreExecuteStart, notifyProgressListeners, notifyStateChangeListeners, notifyUIListeners, openDialogInJFrame, progressChanged, queue, removeJobManagerChangedListener, removeNodeMessageListener, removeNodeProgressListener, removeNodeStateChangeListener, removeUIInformationListener, removeWaitingLoopHeadNode, resetJobManagerViews, saveExecutionResult, saveNodeExecutionJobReconnectInfo, setCustomDescription, setCustomName, setExecutionJob, setJobManager, setNodeContainerDirectory, setNodeMessage, setState, setState, setUIInformation, throwIllegalStateException, unsetDirty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ROOT

public static final WorkflowManager ROOT
The root of everything, a workflow with no in- or outputs. This workflow holds the top level projects.


CFG_VERSION

static final String CFG_VERSION
Workflow version, indicates the "oldest" version that is compatible to the current workflow format.

See Also:
Constant Field Values

CFG_CREATED_BY

static final String CFG_CREATED_BY
Version of KNIME that has written the workflow.

See Also:
Constant Field Values
Method Detail

getWorkflow

Workflow getWorkflow()
Returns:
workflow

createAndAddProject

public WorkflowManager createAndAddProject(String name)
Create new project - which is the same as creating a new subworkflow at this level with no in- or outports.

Parameters:
name - The name of the workflow (null value is ok)
Returns:
newly created workflow

removeProject

public void removeProject(NodeID id)
Remove a project - the same as remove node but we make sure it really looks like a project (i.e. has no in- or outports).

Parameters:
id - of the project to be removed.

createAndAddNode

public NodeID createAndAddNode(NodeFactory<?> factory)
Uses given Factory to create a new node and then adds new node to the workflow manager. We will automatically find the next available free index for the new node within the given prefix.

Parameters:
factory - NodeFactory used to create the new node
Returns:
newly created (unique) NodeID

canRemoveNode

public boolean canRemoveNode(NodeID nodeID)
Check if specific node can be removed (i.e. is not currently being executed or waiting to be).

Parameters:
nodeID - id of node to be removed
Returns:
true if node can safely be removed.

removeNode

public void removeNode(NodeID nodeID)
Remove node if possible. Throws an exception if node is "busy" and can not be removed at this time. If the node does not exist, this method returns without exception.

Parameters:
nodeID - id of node to be removed

createAndAddSubWorkflow

public WorkflowManager createAndAddSubWorkflow(PortType[] inPorts,
                                               PortType[] outPorts,
                                               String name)
Creates new meta node. We will automatically find the next available free index for the new node within this workflow.

Parameters:
inPorts - types of external inputs (going into this workflow)
outPorts - types of external outputs (exiting this workflow)
name - Name of the workflow (null values will be handled)
Returns:
newly created WorflowManager

createSubWorkflow

WorkflowManager createSubWorkflow(WorkflowPersistor persistor,
                                  NodeID newID)
Creates new meta node from a persistor instance.

Parameters:
persistor - to read from
newID - new id to be used
Returns:
newly created WorflowManager

addConnection

public ConnectionContainer addConnection(NodeID source,
                                         int sourcePort,
                                         NodeID dest,
                                         int destPort)
Add new connection - throw Exception if the same connection already exists.

Parameters:
source - node id
sourcePort - port index at source node
dest - destination node id
destPort - port index at destination node
Returns:
newly created Connection object
Throws:
IllegalArgumentException - if connection already exists

canAddConnection

public boolean canAddConnection(NodeID source,
                                int sourcePort,
                                NodeID dest,
                                int destPort)
Check if a new connection can be added.

Parameters:
source - node id
sourcePort - port index at source node
dest - destination node id
destPort - port index at destination node
Returns:
true if connection can be added.

canRemoveConnection

public boolean canRemoveConnection(ConnectionContainer cc)
Check if a connection can safely be removed.

Parameters:
cc - connection
Returns:
true if connection cc is removable.

removeConnection

public void removeConnection(ConnectionContainer cc)
Remove connection.

Parameters:
cc - connection

getOutgoingConnectionsFor

public Set<ConnectionContainer> getOutgoingConnectionsFor(NodeID id,
                                                          int portIdx)
Returns the set of outgoing connections for the node with the passed id at the specified port.

Parameters:
id - id of the node of interest
portIdx - port index of that node
Returns:
all outgoing connections for the passed node at the specified port

getOutgoingConnectionsFor

public Set<ConnectionContainer> getOutgoingConnectionsFor(NodeID id)
Get all outgoing connections for a node.

Parameters:
id - The requested node
Returns:
All current outgoing connections in a new set.
Throws:
IllegalArgumentException - If the node is unknown or null.

getIncomingConnectionFor

public ConnectionContainer getIncomingConnectionFor(NodeID id,
                                                    int portIdx)
Returns the incoming connection of the node with the passed node id at the specified port.

Parameters:
id - id of the node of interest
portIdx - port index
Returns:
incoming connection at that port of the given node

getIncomingConnectionsFor

public Set<ConnectionContainer> getIncomingConnectionsFor(NodeID id)
Get all incoming connections for a node.

Parameters:
id - The requested node
Returns:
All current incoming connections in a new set.
Throws:
IllegalArgumentException - If the node is unknown or null.

loadNodeSettings

public void loadNodeSettings(NodeID id,
                             NodeSettingsRO settings)
                      throws InvalidSettingsException
Load Settings into specified node.

Parameters:
id - of node
settings - to be load by node
Throws:
InvalidSettingsException - if settings are wrong
IllegalArgumentException - if node does not exist

saveNodeSettings

public void saveNodeSettings(NodeID id,
                             NodeSettingsWO settings)
                      throws InvalidSettingsException
write node settings into Settings object.

Parameters:
id - of node
settings - to be saved to
Throws:
InvalidSettingsException - thrown if nonsense is written

resetAll

public void resetAll()
Reset all nodes in this workflow. Make sure the reset is propagated in the right order, that is, only actively reset the "left most" nodes in the workflow or the ones connected to meta node input ports. The will also trigger resets of subsequent nodes. Also re-configure not executed nodes the same way to make sure that new workflow variables are spread accordingly.


reconfigureAllNodesOnlyInThisWFM

void reconfigureAllNodesOnlyInThisWFM()
Re-configure all configured (NOT executed) nodes in this workflow to make sure that new workflow variables are spread accordingly. Note that this does NOT affect any successors of this workflow manager but touches all nodes inside this wfm and its kids.


resetAllNodesOnlyInThisWFM

void resetAllNodesOnlyInThisWFM()
Reset all executed nodes in this workflow to make sure that new workflow variables are spread accordingly. If a node is already reset (or we just reset it), also configure it. Note that this does NOT affect any successors of this workflow manager but touches all nodes inside this wfm and its kids.


resetAllNodesInWFM

void resetAllNodesInWFM()
Reset all nodes in this workflow. Note that this routine will NOT trigger any resets connected to possible outports of this WFM.


executeUpToHere

public void executeUpToHere(NodeID... ids)
mark these nodes and all not-yet-executed predecessors for execution. They will be marked first, queued when all inputs are available and finally executed.

Parameters:
ids - node ids to mark

doBeforePreExecution

boolean doBeforePreExecution(NodeContainer nc)
Callback from NodeContainer to request a safe transition into the NodeContainer.State.PREEXECUTE state. This method is mostly only called with SingleNodeContainer as argument but may also be called with a remotely executed meta node.

Parameters:
nc - node whose execution is about to start
Returns:
whether there was an actual state transition, false if the execution was canceled (cancel checking to be done in synchronized block)

doBeforePostExecution

void doBeforePostExecution(NodeContainer nc)
Callback from NodeContainer to request a safe transition into the NodeContainer.State.POSTEXECUTE state. This method is mostly only called with SingleNodeContainer as argument but may also be called with a remotely executed meta node.

Parameters:
nc - node whose execution is ending (and is now copying result data, e.g.)

doBeforeExecution

void doBeforeExecution(NodeContainer nc)
Call-back from NodeContainer called before node is actually executed. The argument node is in usually a SingleNodeContainer, although it can also be a meta node (i.e. a WorkflowManager), which is executed remotely (execution takes place as a single operation).

Parameters:
nc - node whose execution is about to start
Throws:
IllegalFlowObjectStackException - If loop end nodes have problems identifying their start node

doAfterExecution

void doAfterExecution(NodeContainer nc,
                      NodeContainerExecutionStatus status)
Cleanup a node after execution. This will also permit the argument node to change its state in NodeContainer.performStateTransitionEXECUTED(NodeContainerExecutionStatus). This method also takes care of restarting loops, if there are any to be continued.

As in doBeforeExecution(NodeContainer) the argument node is usually a SingleNodeContainer but can also be a remotely executed WorkflowManager.

Parameters:
nc - node which just finished execution
status - indicates if node execution was finished successfully (note that this does not imply State=EXECUTED e.g. for loop ends)

isResetable

boolean isResetable()
check if node can be safely reset. In case of a WFM we will check if one of the internal nodes can be reset and none of the nodes are "in progress".

Specified by:
isResetable in class NodeContainer
Returns:
if all internal nodes can be reset.

markForExecution

void markForExecution(boolean flag)
Enable (or disable) queuing of underlying node for execution. This really only changes the state of the node and once all pre-conditions for execution are fulfilled (e.g. configuration succeeded and all ingoing objects are available) the node will be actually queued.

Specified by:
markForExecution in class NodeContainer
Parameters:
flag - determines if node is marked or unmarked for execution

mimicRemoteExecuting

void mimicRemoteExecuting()
Marks this node as remotely executing. This is necessary if the entire (sub-) flow that this node is part of is executed remotely.

Specified by:
mimicRemoteExecuting in class NodeContainer

mimicRemotePreExecute

void mimicRemotePreExecute()
Puts this node (and all its children) into the NodeContainer.State.PREEXECUTE state. This method is used when a workflow is executed remotely.

Specified by:
mimicRemotePreExecute in class NodeContainer

mimicRemotePostExecute

void mimicRemotePostExecute()
Puts this node (and all its children) into the NodeContainer.State.POSTEXECUTE state. This method is used when a workflow is executed remotely.

Specified by:
mimicRemotePostExecute in class NodeContainer

mimicRemoteExecuted

void mimicRemoteExecuted(NodeContainerExecutionStatus status)
Put this node into either the NodeContainer.State.EXECUTED or NodeContainer.State.IDLE state depending on the argument. This method is applied recursively on all of this node's children (if a meta node).

Specified by:
mimicRemoteExecuted in class NodeContainer
Parameters:
status - Where to get the success flag from.

performStateTransitionPREEXECUTE

boolean performStateTransitionPREEXECUTE()
Called when the state of a node should switch from NodeContainer.State.QUEUED to NodeContainer.State.PREEXECUTE. The method is to be called from the node's parent in a synchronized environment.

Specified by:
performStateTransitionPREEXECUTE in class NodeContainer
Returns:
whether there was an actual state transition, false if the execution was canceled (cancel checking to be done in synchronized block)

performStateTransitionEXECUTING

void performStateTransitionEXECUTING()
This should be used to change the nodes states correctly (and likely needs to be synchronized with other changes visible to successors of this node as well!) BEFORE the actual execution. The main reason is that the actual execution should be performed unsynchronized!

Specified by:
performStateTransitionEXECUTING in class NodeContainer

performStateTransitionPOSTEXECUTE

void performStateTransitionPOSTEXECUTE()
Called when the state of a node should switch from NodeContainer.State.EXECUTING (or NodeContainer.State.EXECUTINGREMOTELY) to NodeContainer.State.POSTEXECUTE. The method is to be called from the node's parent in a synchronized environment.

Specified by:
performStateTransitionPOSTEXECUTE in class NodeContainer

performStateTransitionEXECUTED

void performStateTransitionEXECUTED(NodeContainerExecutionStatus status)
This should be used to change the nodes states correctly (and likely needs to be synchronized with other changes visible to successors of this node as well!) AFTER the actual execution. The main reason is that the actual execution should be performed unsynchronized!

Specified by:
performStateTransitionEXECUTED in class NodeContainer
Parameters:
status - indicates if execution was successful

canResetNode

public boolean canResetNode(NodeID nodeID)
Check if a node can be reset, meaning that it is executed and all of it's successors are idle or executed as well. We do not want to mess with executing chains.

Parameters:
nodeID - the id of the node
Returns:
true if the node can safely be reset.

invokeResetOnPortSuccessors

void invokeResetOnPortSuccessors(int inportIndex)
Reset those nodes which are connected to a specific workflow incoming port.

Parameters:
inportIndex - index of port.

resetAndConfigureNode

public void resetAndConfigureNode(NodeID id)
Reset node and all executed successors of a specific node.

Parameters:
id - of first node in chain to be reset.

canExecuteNode

public boolean canExecuteNode(NodeID nodeID)
Check if a node can be executed directly.

Parameters:
nodeID - id of node
Returns:
true of node is configured and all immediate predecessors are executed.

cancelExecution

void cancelExecution()
Cancel execution of a marked, queued, or executing node. (Tolerate execute as this may happen throughout cancelation).

Specified by:
cancelExecution in class NodeContainer

cancelExecution

public void cancelExecution(NodeContainer nc)
Cancel execution of the given NodeContainer.

Parameters:
nc - node to be canceled

canSetJobManager

public boolean canSetJobManager(NodeID nodeID)
Is the node with the given ID ready to take a new job manager. This is generally true if the node is currently not executing.

Parameters:
nodeID - The node in question.
Returns:
Whether it's save to invoke the setJobManager(NodeID, NodeExecutionJobManager) method.

setJobManager

public void setJobManager(NodeID nodeID,
                          NodeExecutionJobManager jobMgr)
Sets a new job manager on the node with the given ID.

Parameters:
nodeID - The node in question.
jobMgr - The new job manager (may be null to use parent's one).
Throws:
IllegalStateException - If the node is not ready
IllegalArgumentException - If the node is unknown
See Also:
canSetJobManager(NodeID)

shutdown

public void shutdown()
Attempts to cancel or running nodes in preparation for a removal of this node (or its parent) from the root. Executing nodes, which can be disconnected from the execution (e.g. remote cluster execution) are disconnected if their status has been saved before.


performShutdown

void performShutdown()
Called when the workflow is to be disposed. It will cancel this node if it is still running. If this node is being executed remotely (cluster execution) and has been saved, it will just disconnect it.

Specified by:
performShutdown in class NodeContainer

executeAllAndWaitUntilDone

public boolean executeAllAndWaitUntilDone()
Convenience method: execute all and wait for execution to be done.

Returns:
true if execution was successful

executeAll

public void executeAll()
Convenience method: (Try to) Execute all nodes in the workflow. This method returns immediately, leaving it to the associated executor to do the job.


continueExecutionOnLoad

boolean continueExecutionOnLoad(NodeContainer nc,
                                NodeContainerPersistor persistor)
                          throws InvalidSettingsException,
                                 NodeExecutionJobReconnectException
Throws:
InvalidSettingsException
NodeExecutionJobReconnectException

hasDialog

public boolean hasDialog()

Specified by:
hasDialog in class NodeContainer

getDialogPaneWithSettings

NodeDialogPane getDialogPaneWithSettings(PortObjectSpec[] inSpecs)
                                   throws NotConfigurableException

Specified by:
getDialogPaneWithSettings in class NodeContainer
Throws:
NotConfigurableException

getDialogPane

NodeDialogPane getDialogPane()

Specified by:
getDialogPane in class NodeContainer

areDialogAndNodeSettingsEqual

public boolean areDialogAndNodeSettingsEqual()

Specified by:
areDialogAndNodeSettingsEqual in class NodeContainer

getGlobalTableRepository

HashMap<Integer,ContainerTable> getGlobalTableRepository()
Returns:
global table repository for this WFM.

assembleInputSpecs

void assembleInputSpecs(NodeID id,
                        PortObjectSpec[] inSpecs)
Fill array holding all input specs for the given node.

Parameters:
id - of node
inSpecs - return array for specs of all predecessors

printNodeSummary

public String printNodeSummary(NodeID prefix,
                               int indent)
Produce summary of node.

Parameters:
prefix - if containing node/workflow
indent - number of leading spaces
Returns:
string

toString

public String toString()

Overrides:
toString in class NodeContainer
Returns:
Node name with status information.

getNodeContainers

public Collection<NodeContainer> getNodeContainers()
Returns:
collection of NodeContainers in this WFM

getConnectionContainers

public Collection<ConnectionContainer> getConnectionContainers()
Returns:
collection of ConnectionContainer in this WFM

getNodeContainer

public NodeContainer getNodeContainer(NodeID id)
Parameters:
id - node ID
Returns:
NodeContainer for given ID

containsNodeContainer

public boolean containsNodeContainer(NodeID id)
Does the workflow contain a node with the argument id?

Parameters:
id - The id in question.
Returns:
true if there is node with the given id, false otherwise.

getNodeErrorMessages

public List<NodeMessage> getNodeErrorMessages()
Returns:
list of errors messages (list empty if none exist).

addListener

public void addListener(WorkflowListener listener)
Add listener to list.

Parameters:
listener - new listener

removeListener

public void removeListener(WorkflowListener listener)
Remove listener.

Parameters:
listener - listener to be removed

notifyJobManagerChangedListener

protected void notifyJobManagerChangedListener()

Overrides:
notifyJobManagerChangedListener in class NodeContainer

getCopyPersistor

protected NodeContainerPersistor getCopyPersistor(HashMap<Integer,ContainerTable> tableRep,
                                                  boolean preserveDeletableFlags)
Get a new persistor that is used to copy this node (copy&paste action).

Specified by:
getCopyPersistor in class NodeContainer
Parameters:
tableRep - Table repository of the destination.
preserveDeletableFlags - Whether the "isdeleteable" annotation should be copied also (false when individual nodes are copied but true when an entire meta node is copied).
Returns:
A new persistor for copying.

copyFromAndPasteHere

public NodeID[] copyFromAndPasteHere(WorkflowManager sourceManager,
                                     NodeID... nodeIDs)
Copies the nodes with the given ids from the argument workflow manager into this wfm instance. All nodes wil be reset (and configured id possible). Connections among the nodes are kept.

Parameters:
sourceManager - The wfm to copy from
nodeIDs - The node ids to copy (must exist in sourceManager)
Returns:
The new ids of the nodes in this wfm.

copy

public WorkflowPersistor copy(NodeID... nodeIDs)
Copy the nodes with the given ids.

Parameters:
nodeIDs - The nodes to copy (must exist).
Returns:
A workflow persistor hosting the node templates, ready to be used in the paste(WorkflowPersistor) method.

paste

public NodeID[] paste(WorkflowPersistor persistor)
Pastes the contents of the argument persistor into this wfm.

Parameters:
persistor - The persistor created with copy(NodeID...).
Returns:
The new node ids of the inserted nodes.

loadProject

public static WorkflowPersistor.WorkflowLoadResult loadProject(File directory,
                                                               ExecutionMonitor exec)
                                                        throws IOException,
                                                               InvalidSettingsException,
                                                               CanceledExecutionException
Throws:
IOException
InvalidSettingsException
CanceledExecutionException

createExecutionResult

public WorkflowExecutionResult createExecutionResult(ExecutionMonitor exec)
                                              throws CanceledExecutionException
Saves all internals that are necessary to mimic the computed result into a new execution result object. This method is called on node instances, which are, e.g. executed on a server and later on read back into a true KNIME instance (upon which #loadExecutionResult(NodeContainerExecutionResult, ExecutionMonitor, LoadResult) is called).

Specified by:
createExecutionResult in class NodeContainer
Parameters:
exec - For progress information (this method will copy port objects).
Returns:
A new execution result instance.
Throws:
CanceledExecutionException - If canceled.

loadExecutionResult

public void loadExecutionResult(NodeContainerExecutionResult result,
                                ExecutionMonitor exec,
                                WorkflowPersistor.LoadResult loadResult)
Load information from execution result. Subclasses will override this method and will call this implementation as super.loadEx....

Overrides:
loadExecutionResult in class NodeContainer
Parameters:
result - The execution result (contains port objects, messages, etc)
exec - For progress information (no cancelation supported)
loadResult - A load result that contains, e.g. error messages.

load

public WorkflowPersistor.WorkflowLoadResult load(File directory,
                                                 ExecutionMonitor exec,
                                                 boolean keepNodeMessages)
                                          throws IOException,
                                                 InvalidSettingsException,
                                                 CanceledExecutionException
Loads the workflow contained in the directory as node into this workflow instance. Loading a whole new project is usually done using loadProject(File, ExecutionMonitor).

Parameters:
directory - to load from
exec - For progress/cancellation (currently not supported)
keepNodeMessages - Whether to keep the messages that are associated with the nodes in the loaded workflow (mostly false but true when remotely computed results are loaded).
Returns:
A workflow load result, which also contains the loaded workflow.
Throws:
IOException - If errors reading the "important" files fails due to I/O problems (file not present, e.g.)
InvalidSettingsException - If parsing the "important" files fails.
CanceledExecutionException - If canceled.

loadContent

NodeID[] loadContent(NodeContainerPersistor nodePersistor,
                     Map<Integer,BufferedDataTable> tblRep,
                     FlowObjectStack ignoredStack,
                     ExecutionMonitor exec,
                     WorkflowPersistor.LoadResult loadResult,
                     boolean preserveNodeMessage)
               throws CanceledExecutionException
Restore content from persistor. This represents the second step when loading a workflow.

Specified by:
loadContent in class NodeContainer
Parameters:
nodePersistor - To load from.
tblRep - A table repository to restore BufferedDatTables
ignoredStack - Incoming FlowObjectStack.
exec - For progress
loadResult - Where to report errors/warnings to
preserveNodeMessage - Whether possible node messages in the persistor are to be preserved (parameter to configure method that is called during load).
Returns:
The list of nodes that were inserted, for single node containers the result is an empty array.
Throws:
CanceledExecutionException - If canceled.

save

public void save(File directory,
                 ExecutionMonitor exec,
                 boolean isSaveData)
          throws IOException,
                 CanceledExecutionException
Throws:
IOException
CanceledExecutionException

sweep

boolean sweep(boolean propagate)
Performs sanity check on workflow. This is necessary upon load.

Parameters:
propagate - Whether to also reflect state changes in our parent
Returns:
Whether everything was clean before (if false is returned, something was wrong).

isLocalWFM

protected boolean isLocalWFM()
Is this node a to be locally executed workflow. In contrast to remotely executed workflows, the nodes in the encapsulated workflow will be executed independently (each represented by an own job), whereas remote execution means that the entire workflow execution is one single job.

This method returns false for all single node container.

Specified by:
isLocalWFM in class NodeContainer
Returns:
The above described property.

setDirty

public void setDirty()
Mark this node container to be changed, that is, it needs to be saved.

Overrides:
setDirty in class NodeContainer

getNrInPorts

public int getNrInPorts()

Specified by:
getNrInPorts in class NodeContainer

getInPort

public WorkflowInPort getInPort(int index)

Specified by:
getInPort in class NodeContainer

getOutPort

public WorkflowOutPort getOutPort(int index)

Specified by:
getOutPort in class NodeContainer

getNrOutPorts

public int getNrOutPorts()

Specified by:
getNrOutPorts in class NodeContainer

setName

public void setName(String name)
Set new name of this workflow or null to reset the name (will then return the workflow directory in getName() or null if this flow has not been saved yet).

Parameters:
name - The new name or null

renameWorkflowDirectory

public boolean renameWorkflowDirectory(String newName)
Renames the underlying workflow directory to the new name.

Parameters:
newName - The name of the directory.
Returns:
Whether that was successful.
Throws:
IllegalStateException - If the worklow has not been saved yet (has no corresponding node directory).

getName

public String getName()
Get the name of the workflow. If none has been set, a name is derived from the workflow directory name. If no directory has been set, a static string is returned. This method never returns null.

Specified by:
getName in class NodeContainer

getNameField

String getNameField()
Returns:
the name set in the constructor or via setName(String). In comparison to getName() this method does not use the workflow directory name if no other name is set.

getNrNodeViews

public int getNrNodeViews()
Returns the number of views provided by the node implementation.

Specified by:
getNrNodeViews in class NodeContainer
Returns:
the number of views provided by the node implementation

getNodeView

public NodeView<NodeModel> getNodeView(int i)
Return the view with the specified index provided by the node.

Specified by:
getNodeView in class NodeContainer
Parameters:
i - the view to create
Returns:
a new view instance with index i provided by the node

getNodeViewName

public String getNodeViewName(int i)

Specified by:
getNodeViewName in class NodeContainer

loadSettings

void loadSettings(NodeSettingsRO settings)
            throws InvalidSettingsException

Overrides:
loadSettings in class NodeContainer
Throws:
InvalidSettingsException

saveSettings

void saveSettings(NodeSettingsWO settings)

Overrides:
saveSettings in class NodeContainer

areSettingsValid

boolean areSettingsValid(NodeSettingsRO settings)

Overrides:
areSettingsValid in class NodeContainer

getType

public NodeFactory.NodeType getType()

Specified by:
getType in class NodeContainer

getIcon

public URL getIcon()

Specified by:
getIcon in class NodeContainer

cleanup

void cleanup()
Method that's called when the node is discarded. The single node container overwrites this method and cleans the outport data of the node (deletes temp files).

Overrides:
cleanup in class NodeContainer

getNrWorkflowIncomingPorts

public int getNrWorkflowIncomingPorts()

getNrWorkflowOutgoingPorts

public int getNrWorkflowOutgoingPorts()

getWorkflowIncomingPort

public NodeOutPort getWorkflowIncomingPort(int i)

getWorkflowOutgoingPort

public NodeInPort getWorkflowOutgoingPort(int i)

setInPortsBarUIInfo

public void setInPortsBarUIInfo(UIInformation inPortsBarUIInfo)
Set UI information for workflow's input ports (typically aligned as a bar).

Parameters:
inPortsBarUIInfo - The new UI info.

setOutPortsBarUIInfo

public void setOutPortsBarUIInfo(UIInformation outPortsBarUIInfo)
Set UI information for workflow's output ports (typically aligned as a bar).

Parameters:
outPortsBarUIInfo - The new UI info.

getInPortsBarUIInfo

public UIInformation getInPortsBarUIInfo()
Get UI information for workflow input ports.

Returns:
the ui info or null if not set.
See Also:
setInPortsBarUIInfo(UIInformation)

getOutPortsBarUIInfo

public UIInformation getOutPortsBarUIInfo()
Get UI information for workflow output ports.

Returns:
the ui info or null if not set.
See Also:
setOutPortsBarUIInfo(UIInformation)

getWorkflowVariables

public List<FlowVariable> getWorkflowVariables()
Get read-only access on the current workflow variables.

Returns:
the current workflow variables, never null.

addWorkflowVariables

public void addWorkflowVariables(boolean skipReset,
                                 FlowVariable... newVars)
Set new workflow variables. All nodes within this workflow will have access to these variables. The method may change in future versions or removed entirely (bug 1937).

Parameters:
newVars - new variables to be set
skipReset - if false the workflow will be re-configured

removeWorkflowVariable

public void removeWorkflowVariable(String name)
Remove workflow variable of given name. The method may change in future versions or removed entirely (bug 1937).

Parameters:
name - of variable to be removed.


Copyright, 2003 - 2010. All rights reserved.
University of Konstanz, Germany.
Chair for Bioinformatics and Information Mining, Prof. Dr. Michael R. Berthold.
You may not modify, publish, transmit, transfer or sell, reproduce, create derivative works from, distribute, perform, display, or in any way exploit any of the content, in whole or in part, except as otherwise expressly permitted in writing by the copyright owner or as specified in the license file distributed with this product.