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 };
}
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 };
}
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 };
}
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;
}
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;
}
Aggregations