Search in sources :

Example 86 with PortObject

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

the class GenericCatchNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
    if (!(inData[0] instanceof InactiveBranchPortObject)) {
        // main branch is active - no failure so far...
        return new PortObject[] { inData[0], FlowVariablePortObject.INSTANCE };
    }
    // main branch inactive, grab spec from alternative (default) input
    // and push error reasons on stack (they come from the ScopeObject
    // which will we removed after this node, closing the scope).
    FlowTryCatchContext ftcc = getFlowContext();
    if ((ftcc != null) && (ftcc.hasErrorCaught())) {
        pushFlowVariableString("FailingNode", ftcc.getNode());
        pushFlowVariableString("FailingNodeMessage", ftcc.getReason());
        pushFlowVariableString("FailingNodeStackTrace", ftcc.getStacktrace());
    } else if (m_alwaysPopulate.getBooleanValue()) {
        pushFlowVariableString("FailingNode", m_defaultVariable.getStringValue());
        pushFlowVariableString("FailingNodeMessage", m_defaultText.getStringValue());
        pushFlowVariableString("FailingNodeStackTrace", m_defaultStackTrace.getStringValue());
    }
    return new PortObject[] { inData[1], FlowVariablePortObject.INSTANCE };
}
Also used : InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) FlowTryCatchContext(org.knime.core.node.workflow.FlowTryCatchContext) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) PortObject(org.knime.core.node.port.PortObject) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject)

Example 87 with PortObject

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

the class DBQueryNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    DatabasePortObject dbObj = (DatabasePortObject) inData[0];
    CredentialsProvider cp = getCredentialsProvider();
    DatabaseQueryConnectionSettings conn = dbObj.getConnectionSettings(cp);
    String newQuery = createQuery(conn.getQuery());
    conn = createDBQueryConnection(dbObj.getSpec(), newQuery);
    DBReader load = conn.getUtility().getReader(conn);
    DataTableSpec outSpec = load.getDataTableSpec(cp);
    DatabasePortObjectSpec dbSpec = new DatabasePortObjectSpec(outSpec, conn.createConnectionModel());
    DatabasePortObject outObj = new DatabasePortObject(dbSpec);
    return new PortObject[] { outObj };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DataTableSpec(org.knime.core.data.DataTableSpec) DBReader(org.knime.core.node.port.database.reader.DBReader) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) CredentialsProvider(org.knime.core.node.workflow.CredentialsProvider) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Example 88 with PortObject

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

the class DBQueryNodeModel2 method execute.

/**
 * {@inheritDoc}
 */
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
    DatabasePortObject dbObj = (DatabasePortObject) inData[0];
    DatabaseQueryConnectionSettings conn = dbObj.getConnectionSettings(getCredentialsProvider());
    String newQuery = parseQuery(conn.getQuery());
    conn = createDBQueryConnection(dbObj.getSpec(), newQuery);
    DBReader load = conn.getUtility().getReader(conn);
    DataTableSpec outSpec = load.getDataTableSpec(getCredentialsProvider());
    DatabasePortObjectSpec dbSpec = new DatabasePortObjectSpec(outSpec, conn.createConnectionModel());
    DatabasePortObject outObj = new DatabasePortObject(dbSpec);
    return new PortObject[] { outObj };
}
Also used : DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) DatabaseQueryConnectionSettings(org.knime.core.node.port.database.DatabaseQueryConnectionSettings) DataTableSpec(org.knime.core.data.DataTableSpec) DBReader(org.knime.core.node.port.database.reader.DBReader) DatabasePortObjectSpec(org.knime.core.node.port.database.DatabasePortObjectSpec) DatabasePortObject(org.knime.core.node.port.database.DatabasePortObject) PortObject(org.knime.core.node.port.PortObject)

Example 89 with PortObject

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

the class WorkflowManager method continueExecutionOnLoad.

/**
 * @param nc The node container
 * @param persistor The persistor
 * @return true if load and execution was successful, false otherwise
 * @throws InvalidSettingsException If the settings are invalid
 * @throws NodeExecutionJobReconnectException If continuing the execution does fail
 */
boolean continueExecutionOnLoad(final NodeContainer nc, final NodeContainerPersistor persistor) throws InvalidSettingsException, NodeExecutionJobReconnectException {
    NodeContainerMetaPersistor metaPers = persistor.getMetaPersistor();
    NodeSettingsRO execJobSettings = metaPers.getExecutionJobSettings();
    NodeOutPort[] ports = assemblePredecessorOutPorts(nc.getID());
    PortObject[] inData = new PortObject[ports.length];
    boolean allDataAvailable = true;
    for (int i = 0; i < ports.length; i++) {
        if (ports[i] != null) {
            inData[i] = ports[i].getPortObject();
            // if connected but no data, set to false
            if (inData[i] == null) {
                allDataAvailable = false;
            }
        } else if (!nc.getInPort(i).getPortType().isOptional()) {
            // unconnected non-optional port ... abort
            allDataAvailable = false;
        }
    }
    if (allDataAvailable && nc.getInternalState().equals(EXECUTINGREMOTELY)) {
        nc.continueExecutionOnLoad(inData, execJobSettings);
        return true;
    }
    return false;
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO) FlowVariablePortObject(org.knime.core.node.port.flowvariable.FlowVariablePortObject) PortObject(org.knime.core.node.port.PortObject) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 90 with PortObject

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

the class VirtualSubNodeInputNodeModel method execute.

/**
 * {@inheritDoc}
 */
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
    PortObject[] dataFromParent = m_subNodeContainer.fetchInputDataFromParent();
    pushFlowVariables();
    PortObject[] resultData = new PortObject[dataFromParent.length - 1];
    for (int i = 1; i < dataFromParent.length; i++) {
        PortObject o = dataFromParent[i];
        resultData[i - 1] = o instanceof BufferedDataTable ? exec.createWrappedTable((BufferedDataTable) o) : o;
    }
    return resultData;
}
Also used : BufferedDataTable(org.knime.core.node.BufferedDataTable) InactiveBranchPortObject(org.knime.core.node.port.inactive.InactiveBranchPortObject) PortObject(org.knime.core.node.port.PortObject)

Aggregations

PortObject (org.knime.core.node.port.PortObject)173 BufferedDataTable (org.knime.core.node.BufferedDataTable)97 DataTableSpec (org.knime.core.data.DataTableSpec)68 PMMLPortObject (org.knime.core.node.port.pmml.PMMLPortObject)59 ColumnRearranger (org.knime.core.data.container.ColumnRearranger)39 InactiveBranchPortObject (org.knime.core.node.port.inactive.InactiveBranchPortObject)37 FlowVariablePortObject (org.knime.core.node.port.flowvariable.FlowVariablePortObject)35 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)34 IOException (java.io.IOException)33 DataRow (org.knime.core.data.DataRow)25 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)24 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)23 DataCell (org.knime.core.data.DataCell)20 FileStorePortObject (org.knime.core.data.filestore.FileStorePortObject)19 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)19 DatabasePortObject (org.knime.core.node.port.database.DatabasePortObject)18 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)16 ExecutionContext (org.knime.core.node.ExecutionContext)15 DataColumnSpec (org.knime.core.data.DataColumnSpec)14 InactiveBranchPortObjectSpec (org.knime.core.node.port.inactive.InactiveBranchPortObjectSpec)13