org.knime.base.node.util.exttool
Class ExtToolOutputNodeModel

java.lang.Object
  extended by org.knime.core.node.NodeModel
      extended by org.knime.base.node.util.exttool.ExtToolOutputNodeModel
All Implemented Interfaces:
Observer

public abstract class ExtToolOutputNodeModel
extends NodeModel
implements Observer

Implements a NodeModel for nodes that launch external commands. It provides methods to store the output of the external tool and to save and load this output. It comes with two views (ExtToolStderrNodeView and ExtToolStdoutNodeView) which will display the text then. It maintains two output buffers for each stream (output and error output). One for a successful execution (which will be cleared when the node is reset) (methods getExternalOutput() and getExternalErrorOutput()), and one buffer keeping the output of a failing execution (for debugging purposes), (methods getFailedExternalOutput() and getFailedExternalErrorOutput()). The output of a failing run will be shown in gray by the views, and will be preserved until the node is re-executed.

Author:
Kilian Thiel, University of Konstanz

Constructor Summary
ExtToolOutputNodeModel(PortType[] inPortTypes, PortType[] outPortTypes)
          Constructor for a node with data and model ports.
 
Method Summary
 List<String> getExternalErrorOutput()
           
 List<String> getExternalOutput()
           
 List<String> getFailedExternalErrorOutput()
           
 List<String> getFailedExternalOutput()
           
protected  void loadInternals(File nodeInternDir, ExecutionMonitor exec)
          Load internals into the derived NodeModel.
protected  void reset()
          Override this function in the derived model and reset your NodeModel.
protected  void saveInternals(File nodeInternDir, ExecutionMonitor exec)
          Save internals of the derived NodeModel.
protected  void setExternalErrorOutput(LinkedList<String> extErrout)
           
protected  void setExternalOutput(LinkedList<String> extOutput)
           
protected  void setFailedExternalErrorOutput(LinkedList<String> failedExtErrout)
           
protected  void setFailedExternalOutput(LinkedList<String> failedExtOutput)
           
 void update(Observable o, Object arg)
          
 
Methods inherited from class org.knime.core.node.NodeModel
addWarningListener, configure, configure, continueLoop, execute, execute, executeModel, getInHiLiteHandler, getLoopEndNode, getLoopStartNode, getNrInPorts, getNrOutPorts, getOutHiLiteHandler, getWarningMessage, loadValidatedSettingsFrom, notifyViews, notifyWarningListeners, peekFlowVariableDouble, peekFlowVariableInt, peekFlowVariableString, peekScopeVariableDouble, peekScopeVariableInt, peekScopeVariableString, pushFlowVariableDouble, pushFlowVariableInt, pushFlowVariableString, pushScopeVariableDouble, pushScopeVariableInt, pushScopeVariableString, removeWarningListener, saveSettingsTo, setInHiLiteHandler, setWarningMessage, stateChanged, validateSettings
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtToolOutputNodeModel

public ExtToolOutputNodeModel(PortType[] inPortTypes,
                              PortType[] outPortTypes)
Constructor for a node with data and model ports.

Parameters:
inPortTypes - types of the input ports
outPortTypes - types of the output ports
Method Detail

reset

protected void reset()
Override this function in the derived model and reset your NodeModel. All components should unregister themselves from any observables (at least from the hilite handler right now). All internally stored data structures should be released. User settings should not be deleted/reset though.

Specified by:
reset in class NodeModel

loadInternals

protected void loadInternals(File nodeInternDir,
                             ExecutionMonitor exec)
                      throws IOException,
                             CanceledExecutionException
Load internals into the derived NodeModel. This method is only called if the Node was executed. Read all your internal structures from the given file directory to create your internal data structure which is necessary to provide all node functionalities after the workflow is loaded, e.g. view content and/or hilite mapping.

Specified by:
loadInternals in class NodeModel
Parameters:
nodeInternDir - The directory to read from.
exec - Used to report progress and to cancel the load process.
Throws:
IOException - If an error occurs during reading from this dir.
CanceledExecutionException - If the loading has been canceled.
See Also:
NodeModel.saveInternals(File,ExecutionMonitor)

saveInternals

protected void saveInternals(File nodeInternDir,
                             ExecutionMonitor exec)
                      throws IOException,
                             CanceledExecutionException
Save internals of the derived NodeModel. This method is only called if the Node is executed. Write all your internal structures into the given file directory which are necessary to recreate this model when the workflow is loaded, e.g. view content and/or hilite mapping.

Specified by:
saveInternals in class NodeModel
Parameters:
nodeInternDir - The directory to write into.
exec - Used to report progress and to cancel the save process.
Throws:
IOException - If an error occurs during writing to this dir.
CanceledExecutionException - If the saving has been canceled.
See Also:
NodeModel.loadInternals(File,ExecutionMonitor)

getExternalOutput

public final List<String> getExternalOutput()
Returns:
a list of strings containing the lines generated by the external executable during execution for the standard output. The list could be empty, but never null.

getFailedExternalOutput

public final List<String> getFailedExternalOutput()
Returns:
a list of strings containing the lines generated by the previous failing execution. It is null if the previous execution succeeded. It will not be cleared by a reset. It will not be preserved during save.

getExternalErrorOutput

public final List<String> getExternalErrorOutput()
Returns:
a list of strings containing the lines generated by the external executable during execution for the standard error output. The list could be empty, but never null.

getFailedExternalErrorOutput

public final List<String> getFailedExternalErrorOutput()
Returns:
a list of strings containing the lines generated by the previous failing execution. It is null if the previous execution succeeded. It will not be cleared by a reset. It will not be preserved during save.

setExternalOutput

protected final void setExternalOutput(LinkedList<String> extOutput)
Parameters:
extOutput - the extOutput buffer list to set.

setFailedExternalOutput

protected final void setFailedExternalOutput(LinkedList<String> failedExtOutput)
Parameters:
failedExtOutput - the failedExtOutput buffer list to set.

setExternalErrorOutput

protected final void setExternalErrorOutput(LinkedList<String> extErrout)
Parameters:
extErrout - the extErrout buffer list to set. Must not be null.

setFailedExternalErrorOutput

protected final void setFailedExternalErrorOutput(LinkedList<String> failedExtErrout)
Parameters:
failedExtErrout - the failedExtErrout buffer list to set.

update

public void update(Observable o,
                   Object arg)

Specified by:
update in interface Observer


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.