Search in sources :

Example 1 with NodeConfigureHelper

use of org.knime.core.node.NodeConfigureHelper in project knime-core by knime.

the class SingleNodeContainer method callNodeConfigure.

/**
 * Calls configure in the node, whereby it also updates the settings in case the node is driven by flow variables.
 * It also allows the current job manager to modify the output specs according to its  settings
 * (in case it modifies the node's output).
 *
 * <p>This method is KNIME private API and is called from the framework and the streaming executor (which is why
 * it has public scope).
 *
 * @param inSpecs the input specs to node configure
 * @param keepNodeMessage see {@link SingleNodeContainer#configure(PortObjectSpec[], boolean)}
 * @return true of configure succeeded.
 * @since 2.12
 * @noreference This method is not intended to be referenced by clients.
 */
public final boolean callNodeConfigure(final PortObjectSpec[] inSpecs, final boolean keepNodeMessage) {
    final NodeExecutionJobManager jobMgr = findJobManager();
    NodeConfigureHelper nch = new NodeConfigureHelper() {

        private Map<String, FlowVariable> m_exportedSettingsVariables;

        /**
         * {@inheritDoc}
         */
        @Override
        public void preConfigure() throws InvalidSettingsException {
            m_exportedSettingsVariables = applySettingsUsingFlowObjectStack();
        }

        /**
         * {inheritDoc}
         */
        @Override
        public PortObjectSpec[] postConfigure(final PortObjectSpec[] inObjSpecs, final PortObjectSpec[] nodeModelOutSpecs) throws InvalidSettingsException {
            if (!m_exportedSettingsVariables.isEmpty()) {
                FlowObjectStack outgoingFlowObjectStack = getOutgoingFlowObjectStack();
                ArrayList<FlowVariable> reverseOrder = new ArrayList<FlowVariable>(m_exportedSettingsVariables.values());
                Collections.reverse(reverseOrder);
                for (FlowVariable v : reverseOrder) {
                    outgoingFlowObjectStack.push(v);
                }
            }
            return jobMgr.configure(inObjSpecs, nodeModelOutSpecs);
        }
    };
    NodeContext.pushContext(this);
    try {
        return performConfigure(inSpecs, nch, keepNodeMessage);
    } finally {
        NodeContext.removeLastContext();
    }
}
Also used : PortObjectSpec(org.knime.core.node.port.PortObjectSpec) ArrayList(java.util.ArrayList) NodeConfigureHelper(org.knime.core.node.NodeConfigureHelper) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 NodeConfigureHelper (org.knime.core.node.NodeConfigureHelper)1 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)1