JS_KN
July 23, 2021, 8:56am
1
I have a node that retrieves some information and pushes it as a flow variable to the further workflow. This node does not do anything with data, so it has no use for input or output ports.
I can activate the flow variable ports at the top of the node and connect them to the remaining workflow, but I would like to have my flow output as an explicit and documentable output port of flow type, just like the standard configuration nodes. Is this possible for custom nodes?
Hi @JS_KN ,
Yes that is possible, you need to use the more generic constructor in NodeModel:
Arrays.fill(portTypes, BufferedDataTable.TYPE);
return portTypes;
}
/**
* Creates a new model with the given number (and types!) of input and
* output types.
* @param inPortTypes an array of non-null in-port types
* @param outPortTypes an array of non-null out-port types
*/
protected NodeModel(final PortType[] inPortTypes,
final PortType[] outPortTypes) {
// create logger
m_logger = NodeLogger.getLogger(this.getClass());
// init message listener array
m_warningListeners =
new CopyOnWriteArraySet<NodeModelWarningListener>();
// check port types of validity and store them
if (inPortTypes == null) {
Take a look at this example from knime-python:
private final SettingsModelString m_validationMethodModel = createEnvironmentValidationMethodModel();
private final SettingsModelString m_outputVariableNameModel = createOutputVariableNameModel();
private final SettingsModelBoolean m_preserveIncompleteEnvsModel = createPreserveIncompleteEnvsModel();
private final SettingsModelString m_sourceOsModel = createSourceOsModel();
public CondaEnvironmentPropagationNodeModel() {
super(new PortType[0], new PortType[]{FlowVariablePortObject.TYPE});
}
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) {
m_environmentNameModel.saveSettingsTo(settings);
m_packagesConfig.saveSettingsTo(settings);
m_validationMethodModel.saveSettingsTo(settings);
m_outputVariableNameModel.saveSettingsTo(settings);
m_preserveIncompleteEnvsModel.saveSettingsTo(settings);
m_sourceOsModel.saveSettingsTo(settings);
best,
Gabriel
4 Likes
system
Closed
July 30, 2021, 11:10am
4
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.