Search in sources :

Example 51 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.

the class SingleNodeContainer method configure.

// ////////////////////////////////
// Handle State Transitions
// ////////////////////////////////
/**
 * Configure underlying node and update state accordingly.
 *
 * @param inObjectSpecs input table specifications
 * @param keepNodeMessage If true the previous message is kept (unless an error needs to be shown)
 * @return true if output specs have changed.
 * @throws IllegalStateException in case of illegal entry state.
 */
final boolean configure(final PortObjectSpec[] inObjectSpecs, final boolean keepNodeMessage) {
    synchronized (m_nodeMutex) {
        final NodeMessage oldMessage = getNodeMessage();
        // remember old specs
        PortObjectSpec[] prevSpecs = new PortObjectSpec[getNrOutPorts()];
        for (int i = 0; i < prevSpecs.length; i++) {
            prevSpecs[i] = getOutPort(i).getPortObjectSpec();
        }
        boolean prevInactivity = isInactive();
        // perform action
        switch(getInternalState()) {
            case IDLE:
                if (callNodeConfigure(inObjectSpecs, keepNodeMessage)) {
                    setInternalState(InternalNodeContainerState.CONFIGURED);
                } else {
                    setInternalState(InternalNodeContainerState.IDLE);
                }
                break;
            case UNCONFIGURED_MARKEDFOREXEC:
                if (callNodeConfigure(inObjectSpecs, keepNodeMessage)) {
                    setInternalState(InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
                } else {
                    setInternalState(InternalNodeContainerState.UNCONFIGURED_MARKEDFOREXEC);
                }
                break;
            case CONFIGURED:
                // m_node.reset();
                boolean success = callNodeConfigure(inObjectSpecs, keepNodeMessage);
                if (success) {
                    setInternalState(InternalNodeContainerState.CONFIGURED);
                } else {
                    // m_node.reset();
                    setInternalState(InternalNodeContainerState.IDLE);
                }
                break;
            case CONFIGURED_MARKEDFOREXEC:
                // these are dangerous - otherwise re-queued loop-ends are
                // reset!
                // m_node.reset();
                success = callNodeConfigure(inObjectSpecs, keepNodeMessage);
                if (success) {
                    setInternalState(InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
                } else {
                    // m_node.reset();
                    setInternalState(InternalNodeContainerState.UNCONFIGURED_MARKEDFOREXEC);
                }
                break;
            case // this should only happen during load
            EXECUTINGREMOTELY:
                success = callNodeConfigure(inObjectSpecs, keepNodeMessage);
                if (!success) {
                    setInternalState(InternalNodeContainerState.IDLE);
                }
                break;
            default:
                throwIllegalStateException();
        }
        if (keepNodeMessage) {
            setNodeMessage(NodeMessage.merge(oldMessage, getNodeMessage()));
        }
        // fake a state change to make sure it's displayed properly
        if (prevInactivity != isInactive()) {
            InternalNodeContainerState oldSt = this.getInternalState();
            setInternalState(InternalNodeContainerState.IDLE.equals(oldSt) ? InternalNodeContainerState.CONFIGURED : InternalNodeContainerState.IDLE);
            setInternalState(oldSt);
            return true;
        }
        // compare old and new specs
        for (int i = 0; i < prevSpecs.length; i++) {
            PortObjectSpec newSpec = getOutPort(i).getPortObjectSpec();
            if (newSpec != null) {
                if (!newSpec.equals(prevSpecs[i])) {
                    return true;
                }
            } else if (prevSpecs[i] != null) {
                // newSpec is null!
                return true;
            }
        }
        // all specs & inactivity stayed the same!
        return false;
    }
}
Also used : PortObjectSpec(org.knime.core.node.port.PortObjectSpec)

Example 52 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.

the class Node method setOutPortObjects.

/**
 * Called after execute in order to put the computed result into the
 * outports. It will do a sequence of sanity checks whether the argument
 * is valid (non-null, correct type, etc.)
 * @param newOutData The computed output data
 * @param tolerateNullOutports used e.g. when loop is continued (outports may not yet be available)
 * @param tolerateDifferentSpecs used e.g. when re-executing a node (table may be different from configure)
 * @return Whether that is successful (false in case of incompatible port objects)
 */
private boolean setOutPortObjects(final PortObject[] newOutData, final boolean tolerateNullOutports, final boolean tolerateDifferentSpecs) {
    CheckUtils.checkArgumentNotNull(newOutData, "Port object array is null");
    if (newOutData.length != getNrOutPorts()) {
        throw new IndexOutOfBoundsException("Array is expected to be of " + "length " + getNrOutPorts() + ": " + newOutData.length);
    }
    // check for compatible output PortObjects
    for (int i = 0; i < newOutData.length; i++) {
        PortType thisType = m_outputs[i].type;
        if (newOutData[i] == null && !tolerateNullOutports) {
            createErrorMessageAndNotify("Output at port " + i + " is null");
            return false;
        }
        if (newOutData[i] != null) {
            if (newOutData[i] instanceof InactiveBranchPortObject) {
            // allow PO coming from inactive branch
            // TODO ensure model was skipped during configure?
            } else if (!thisType.getPortObjectClass().isInstance(newOutData[i])) {
                createErrorMessageAndNotify("Invalid output port object at port " + i);
                LOGGER.error("  (Wanted: " + thisType.getPortObjectClass().getName() + ", " + "actual: " + newOutData[i].getClass().getName() + ")");
                return false;
            }
            PortObjectSpec spec;
            try {
                spec = newOutData[i].getSpec();
            } catch (Throwable t) {
                createErrorMessageAndNotify("PortObject \"" + newOutData[i].getClass().getName() + "\" threw " + t.getClass().getSimpleName() + " on #getSpec() ", t);
                return false;
            }
            if (spec == null) {
                createErrorMessageAndNotify("Implementation Error: PortObject \"" + newOutData[i].getClass().getName() + "\" must not" + " have null spec (output port " + i + ").");
                return false;
            }
        }
    }
    for (int p = 0; p < getNrOutPorts(); p++) {
        if (newOutData[p] instanceof BufferedDataTable) {
            BufferedDataTable thisTable = (BufferedDataTable) newOutData[p];
            DataTableSpec portSpec = (DataTableSpec) (m_outputs[p].spec);
            DataTableSpec newPortSpec = thisTable.getDataTableSpec();
            if ((portSpec != null) && !tolerateDifferentSpecs) {
                if (!portSpec.equalStructure(newPortSpec)) {
                    // this used to be an ERROR but is now more frequently encountered due to file reader nodes
                    // caching their output spec to avoid in I/O in #configure
                    final String warningMsg = "DataSpec generated by configure does not match spec after execution.";
                    LOGGER.coding(warningMsg);
                    createWarningMessageAndNotify(warningMsg);
                }
            }
            BufferedDataTable t = thisTable;
            t.setOwnerRecursively(this);
            m_outputs[p].object = t;
            m_outputs[p].summary = t.getSummary();
            m_outputs[p].spec = newPortSpec;
        } else {
            m_outputs[p].object = newOutData[p];
            if (newOutData[p] != null) {
                m_outputs[p].spec = newOutData[p].getSpec();
                m_outputs[p].summary = newOutData[p].getSummary();
            } else {
                m_outputs[p].summary = null;
            }
        }
    }
    return true;
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) PortType(org.knime.core.node.port.PortType)

Example 53 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.

the class Node method createNodeExecutionResult.

/**
 * Creates an execution result containing all calculated values in a
 * execution. The returned value is suitable to be used in
 * {@link #loadDataAndInternals(
 * NodeContentPersistor, ExecutionMonitor, LoadResult)}.
 * If this node is not executed, it will assign null values to the fields
 * in the returned execution result.
 * @param exec For progress information.
 * @return A new execution result containing the values being calculated.
 * @throws CanceledExecutionException If canceled
 */
public NodeExecutionResult createNodeExecutionResult(final ExecutionMonitor exec) throws CanceledExecutionException {
    NodeExecutionResult result = new NodeExecutionResult();
    result.setWarningMessage(m_model.getWarningMessage());
    if (hasContent()) {
        File internTempDir;
        try {
            internTempDir = FileUtil.createTempDir("knime_node_internDir");
            exec.setMessage("Saving internals");
            saveInternals(internTempDir, exec.createSubProgress(0.0));
            result.setNodeInternDir(new ReferencedFile(internTempDir));
        } catch (IOException ioe) {
            LOGGER.error("Unable to save internals", ioe);
        }
    }
    if (m_internalHeldPortObjects != null) {
        PortObject[] internalHeldPortObjects = Arrays.copyOf(m_internalHeldPortObjects, m_internalHeldPortObjects.length);
        result.setInternalHeldPortObjects(internalHeldPortObjects);
    }
    PortObject[] pos = new PortObject[getNrOutPorts()];
    PortObjectSpec[] poSpecs = new PortObjectSpec[getNrOutPorts()];
    for (int i = 0; i < pos.length; i++) {
        PortObject po = getOutputObject(i);
        if (po != null) {
            pos[i] = po;
            poSpecs[i] = po.getSpec();
        }
    }
    result.setPortObjects(pos);
    result.setPortObjectSpecs(poSpecs);
    // Add the outgoing flow variables to the execution result
    FlowObjectStack outgoingStack = m_model.getOutgoingFlowObjectStack();
    List<FlowVariable> nodeFlowVars = outgoingStack.getAvailableFlowVariables().values().stream().filter(f -> f.getScope().equals(FlowVariable.Scope.Flow)).collect(Collectors.toList());
    // the bottom most element should remain at the bottom of the stack
    Collections.reverse(nodeFlowVars);
    result.setFlowVariables(nodeFlowVars);
    return result;
}
Also used : WizardNode(org.knime.core.node.wizard.WizardNode) ScopeEndNode(org.knime.core.node.workflow.ScopeEndNode) NodeType(org.knime.core.node.NodeFactory.NodeType) Arrays(java.util.Arrays) NodeCreationConfiguration(org.knime.core.node.context.NodeCreationConfiguration) BufferedInputStream(java.io.BufferedInputStream) RowKey(org.knime.core.data.RowKey) NodeMessageEvent(org.knime.core.node.workflow.NodeMessageEvent) ReferencedFile(org.knime.core.internal.ReferencedFile) FileStoreUtil(org.knime.core.data.filestore.FileStoreUtil) IWriteFileStoreHandler(org.knime.core.data.filestore.internal.IWriteFileStoreHandler) IDataRepository(org.knime.core.data.IDataRepository) InteractiveNode(org.knime.core.node.interactive.InteractiveNode) StringUtils(org.apache.commons.lang3.StringUtils) ExecutionEnvironment(org.knime.core.node.workflow.ExecutionEnvironment) ByteArrayInputStream(java.io.ByteArrayInputStream) Map(java.util.Map) ModifiableNodeCreationConfiguration(org.knime.core.node.context.ModifiableNodeCreationConfiguration) FlowTryCatchContext(org.knime.core.node.workflow.FlowTryCatchContext) ContainerTable(org.knime.core.data.container.ContainerTable) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortType(org.knime.core.node.port.PortType) PrintWriter(java.io.PrintWriter) PortObjectZipOutputStream(org.knime.core.node.port.PortObjectZipOutputStream) VirtualSubNodeInputNodeModel(org.knime.core.node.workflow.virtual.subnode.VirtualSubNodeInputNodeModel) Set(java.util.Set) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) Collectors(java.util.stream.Collectors) InterruptibleNodeModel(org.knime.core.node.interrupt.InterruptibleNodeModel) List(java.util.List) HiLiteHandler(org.knime.core.node.property.hilite.HiLiteHandler) Optional(java.util.Optional) InteractiveNodeFactoryExtension(org.knime.core.node.interactive.InteractiveNodeFactoryExtension) CheckUtils(org.knime.core.node.util.CheckUtils) PortObject(org.knime.core.node.port.PortObject) PortObjectZipInputStream(org.knime.core.node.port.PortObjectZipInputStream) NodeMessage(org.knime.core.node.workflow.NodeMessage) Rectangle(java.awt.Rectangle) FileStorePortObject(org.knime.core.data.filestore.FileStorePortObject) NodeMessageListener(org.knime.core.node.workflow.NodeMessageListener) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ValueControlledDialogPane(org.knime.core.node.dialog.ValueControlledDialogPane) DataTableSpec(org.knime.core.data.DataTableSpec) LoopEndNode(org.knime.core.node.workflow.LoopEndNode) NodeExecutionJobManagerPool(org.knime.core.node.util.NodeExecutionJobManagerPool) FlowVariable(org.knime.core.node.workflow.FlowVariable) ArrayUtils(org.apache.commons.lang3.ArrayUtils) SplitType(org.knime.core.node.workflow.NodeContainer.NodeContainerSettings.SplitType) AtomicReference(java.util.concurrent.atomic.AtomicReference) PortObjectSpecZipInputStream(org.knime.core.node.port.PortObjectSpecZipInputStream) ArrayList(java.util.ArrayList) PortTypeRegistry(org.knime.core.node.port.PortTypeRegistry) CredentialsProvider(org.knime.core.node.workflow.CredentialsProvider) PortUtil(org.knime.core.node.port.PortUtil) ViewUtils(org.knime.core.node.util.ViewUtils) LoadResult(org.knime.core.node.workflow.WorkflowPersistor.LoadResult) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) LinkedHashSet(java.util.LinkedHashSet) FlowObjectStack(org.knime.core.node.workflow.FlowObjectStack) ScopeStartNode(org.knime.core.node.workflow.ScopeStartNode) StringWriter(java.io.StringWriter) DeferredFileOutputStream(org.apache.commons.io.output.DeferredFileOutputStream) InteractiveView(org.knime.core.node.interactive.InteractiveView) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowScopeContext(org.knime.core.node.workflow.FlowScopeContext) IOException(java.io.IOException) InactiveBranchConsumer(org.knime.core.node.port.inactive.InactiveBranchConsumer) FileInputStream(java.io.FileInputStream) PortObjectSpecZipOutputStream(org.knime.core.node.port.PortObjectSpecZipOutputStream) WizardNodeFactoryExtension(org.knime.core.node.wizard.WizardNodeFactoryExtension) NodeContext(org.knime.core.node.workflow.NodeContext) File(java.io.File) ViewContent(org.knime.core.node.interactive.ViewContent) KnowsRowCountTable(org.knime.core.node.BufferedDataTable.KnowsRowCountTable) Element(org.w3c.dom.Element) NodeExecutionResult(org.knime.core.node.workflow.execresult.NodeExecutionResult) LoopStartNode(org.knime.core.node.workflow.LoopStartNode) NodeID(org.knime.core.node.workflow.NodeID) DataContainerException(org.knime.core.data.container.DataContainerException) WorkflowDataRepository(org.knime.core.node.workflow.WorkflowDataRepository) FileUtil(org.knime.core.util.FileUtil) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator) IFileStoreHandler(org.knime.core.data.filestore.internal.IFileStoreHandler) ValueControlledNode(org.knime.core.node.dialog.ValueControlledNode) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) FlowLoopContext(org.knime.core.node.workflow.FlowLoopContext) Collections(java.util.Collections) InputStream(java.io.InputStream) PortObjectHolder(org.knime.core.node.port.PortObjectHolder) NodeExecutionResult(org.knime.core.node.workflow.execresult.NodeExecutionResult) FlowObjectStack(org.knime.core.node.workflow.FlowObjectStack) IOException(java.io.IOException) ReferencedFile(org.knime.core.internal.ReferencedFile) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) ReferencedFile(org.knime.core.internal.ReferencedFile) File(java.io.File) PortObject(org.knime.core.node.port.PortObject) FileStorePortObject(org.knime.core.data.filestore.FileStorePortObject) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) FlowVariable(org.knime.core.node.workflow.FlowVariable)

Example 54 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.

the class Node method configure.

/**
 * Allows passing an object that may modify the specs created by the
 * {@link NodeModel}, for example in case the node is wrapped and the
 * output is modified.
 *
 * @param rawInSpecs table specs from the predecessors
 * @param configureHelper object called after node model calculated output
 *            specs
 * @return true if configure finished successfully.
 * @noreference This method is not intended to be referenced by clients.
 */
public boolean configure(final PortObjectSpec[] rawInSpecs, final NodeConfigureHelper configureHelper) {
    boolean success = false;
    LOGGER.assertLog(NodeContext.getContext() != null, "No node context available, please check call hierarchy and fix it");
    synchronized (m_configureLock) {
        // reset message object
        clearNodeMessageAndNotify();
        // copy input port object specs, ignoring the 0-variable port:
        PortObjectSpec[] inSpecs = Arrays.copyOfRange(rawInSpecs, 1, rawInSpecs.length);
        // clean output spec
        for (int p = 0; p < m_outputs.length; p++) {
            // update data table spec
            m_outputs[p].spec = null;
        }
        PortObjectSpec[] newOutSpec = new PortObjectSpec[getNrOutPorts() - 1];
        try {
            // check the inspecs against null
            for (int i = 0; i < inSpecs.length; i++) {
                if (inSpecs[i] == null) {
                    if (m_inputs[i + 1].getType().isOptional()) {
                    // ignore, unconnected optional input
                    } else {
                        return false;
                    }
                // TODO: did we really need a warning here??
                // throw new InvalidSettingsException(
                // "Node is not executable until all predecessors "
                // + "are configured and/or executed.");
                }
            }
            // check if the node is part of a skipped branch and return
            // appropriate specs without actually configuring the node.
            // Note that we must also check the incoming variable port!
            boolean isInactive = false;
            if (!isInactiveBranchConsumer()) {
                for (int i = 0; i < rawInSpecs.length; i++) {
                    if (rawInSpecs[i] instanceof InactiveBranchPortObjectSpec) {
                        isInactive = true;
                        break;
                    }
                }
            } else {
                FlowLoopContext flc = getFlowObjectStack().peek(FlowLoopContext.class);
                if (flc != null && flc.isInactiveScope()) {
                    isInactive = true;
                }
            }
            if (isInactive) {
                for (int j = 0; j < m_outputs.length; j++) {
                    m_outputs[j].spec = InactiveBranchPortObjectSpec.INSTANCE;
                }
                if (success) {
                    LOGGER.debug("Configure skipped. (" + getName() + " in inactive branch.)");
                }
                return true;
            }
            if (configureHelper != null) {
                configureHelper.preConfigure();
            }
            // call configure model to create output table specs
            // guaranteed to return non-null, correct-length array
            newOutSpec = invokeNodeModelConfigure(inSpecs);
            if (configureHelper != null) {
                newOutSpec = configureHelper.postConfigure(inSpecs, newOutSpec);
            }
            // find out if we are in the middle of executing a loop and this is a LoopEnd node
            boolean isIntermediateRunningLoop = false;
            if (isModelCompatibleTo(LoopEndNode.class)) {
                if ((getLoopContext() != null) && !getPauseLoopExecution()) {
                    FlowLoopContext flc = m_model.getFlowObjectStack().peek(FlowLoopContext.class);
                    if ((flc != null) && (flc.getIterationIndex() > 0)) {
                        // don't treat first iteration as "in the middle":
                        isIntermediateRunningLoop = true;
                    }
                }
            }
            if (!isIntermediateRunningLoop) {
                // update data table specs
                for (int p = 0; p < newOutSpec.length; p++) {
                    m_outputs[p + 1].spec = newOutSpec[p];
                }
            } else {
                // on the loop end node (avoids costly configure calls on remainder of workflow).
                for (int p = 0; p < newOutSpec.length; p++) {
                    if (newOutSpec[p] instanceof DataTableSpec) {
                        // remove domain before assigning spec to outputs
                        DataTableSpecCreator dtsCreator = new DataTableSpecCreator((DataTableSpec) newOutSpec[p]);
                        dtsCreator.dropAllDomains();
                        m_outputs[p + 1].spec = dtsCreator.createSpec();
                    } else {
                        // no domain to clean in PortObjectSpecs
                        m_outputs[p + 1].spec = newOutSpec[p];
                    }
                }
            }
            m_outputs[0].spec = FlowVariablePortObjectSpec.INSTANCE;
            success = true;
        } catch (InvalidSettingsException ise) {
            Throwable cause = ise.getCause();
            if (cause == null) {
                createWarningMessageAndNotify(ise.getMessage());
            } else {
                createWarningMessageAndNotify(ise.getMessage(), ise);
            }
        } catch (Throwable t) {
            String error = "Configure failed (" + t.getClass().getSimpleName() + "): " + t.getMessage();
            createErrorMessageAndNotify(error, t);
        }
    }
    if (success) {
        LOGGER.debug("Configure succeeded. (" + this.getName() + ")");
    }
    return success;
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) DataTableSpecCreator(org.knime.core.data.DataTableSpecCreator) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) FlowLoopContext(org.knime.core.node.workflow.FlowLoopContext)

Example 55 with PortObjectSpec

use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.

the class FileNodePersistor method loadPort.

void loadPort(final Node node, final ReferencedFile portDir, final NodeSettingsRO settings, final ExecutionMonitor exec, final int portIdx, final Map<Integer, BufferedDataTable> loadTblRep, final WorkflowDataRepository dataRepository) throws IOException, InvalidSettingsException, CanceledExecutionException {
    final String specClass = settings.getString("port_spec_class");
    final String objectClass = loadPortObjectClassName(settings);
    PortType designatedType = node.getOutputType(portIdx);
    PortObjectSpec spec = null;
    PortObject object = null;
    // this cannot be simplified as BDT must be loaded as BDT even if
    // the port type is not BDT (but general PortObject)
    boolean isBDT = (BufferedDataTable.TYPE.getPortObjectClass().getName().equals(objectClass) && BufferedDataTable.TYPE.getPortObjectSpecClass().getName().equals(specClass)) || designatedType.equals(BufferedDataTable.TYPE);
    // an InactiveBranchPortObjectSpec can be put into any port!
    boolean isInactive = InactiveBranchPortObjectSpec.class.getName().equals(specClass);
    if (isBDT && !isInactive) {
        if (specClass != null && !specClass.equals(BufferedDataTable.TYPE.getPortObjectSpecClass().getName())) {
            throw new IOException("Actual spec class \"" + specClass + "\", expected \"" + BufferedDataTable.TYPE.getPortObjectSpecClass().getName() + "\"");
        }
        if (objectClass != null && !objectClass.equals(BufferedDataTable.TYPE.getPortObjectClass().getName())) {
            throw new IOException("Actual object class \"" + objectClass + "\", expected \"" + BufferedDataTable.TYPE.getPortObjectClass().getName() + "\"");
        }
        if (objectClass != null) {
            object = loadBufferedDataTable(portDir, exec, loadTblRep, dataRepository);
            ((BufferedDataTable) object).setOwnerRecursively(node);
            spec = ((BufferedDataTable) object).getDataTableSpec();
        } else if (specClass != null) {
            spec = BufferedDataTable.loadSpec(portDir);
        }
    } else {
        object = loadPortObject(portDir, settings, exec, dataRepository).orElse(null);
        spec = object != null ? object.getSpec() : null;
    }
    if (spec != null) {
        if (!designatedType.getPortObjectSpecClass().isInstance(spec) && !isInactive) {
            throw new IOException("Actual port spec type (\"" + spec.getClass().getSimpleName() + "\") does not match designated one (\"" + designatedType.getPortObjectSpecClass().getSimpleName() + "\")");
        }
    }
    String summary = null;
    if (object != null) {
        if (!designatedType.getPortObjectClass().isInstance(object) && !isInactive) {
            throw new IOException("Actual port object type (\"" + object.getClass().getSimpleName() + "\") does not match designated one (\"" + designatedType.getPortObjectClass().getSimpleName() + "\")");
        }
        summary = settings.getString("port_object_summary", null);
        if (summary == null) {
            summary = object.getSummary();
        }
    }
    setPortObjectSpec(portIdx, spec);
    setPortObject(portIdx, object);
    setPortObjectSummary(portIdx, summary);
}
Also used : InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) InactiveBranchPortObjectSpec(org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec) PortObjectSpec(org.knime.core.node.port.PortObjectSpec) FlowVariablePortObjectSpec(org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec) IOException(java.io.IOException) PortObject(org.knime.core.node.port.PortObject) FileStorePortObject(org.knime.core.data.filestore.FileStorePortObject) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) PMMLPortObject(org.knime.core.node.port.pmml.PMMLPortObject) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) PortType(org.knime.core.node.port.PortType)

Aggregations

PortObjectSpec (org.knime.core.node.port.PortObjectSpec)139 DataTableSpec (org.knime.core.data.DataTableSpec)93 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)86 PMMLPortObjectSpec (org.knime.core.node.port.pmml.PMMLPortObjectSpec)35 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)30 DataColumnSpec (org.knime.core.data.DataColumnSpec)29 FlowVariablePortObjectSpec (org.knime.core.node.port.flowvariable.FlowVariablePortObjectSpec)25 IOException (java.io.IOException)24 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)24 InactiveBranchPortObjectSpec (org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec)24 PortObject (org.knime.core.node.port.PortObject)19 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)16 InactiveBranchPortObject (org.knime.core.node.port.inactive.InactiveBranchPortObject)16 PMMLPortObjectSpecCreator (org.knime.core.node.port.pmml.PMMLPortObjectSpecCreator)14 FileStorePortObject (org.knime.core.data.filestore.FileStorePortObject)13 File (java.io.File)12 ArrayList (java.util.ArrayList)12 DatabasePortObjectSpec (org.knime.core.node.port.database.DatabasePortObjectSpec)12 DatabaseQueryConnectionSettings (org.knime.core.node.port.database.DatabaseQueryConnectionSettings)12 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)12