use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBJoinerNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
exec.setMessage("Retrieving metadata from database");
DatabasePortObject dbObjectLeft = (DatabasePortObject) inData[0];
DatabasePortObject dbObjectRight = (DatabasePortObject) inData[1];
DatabasePortObject outObject = new DatabasePortObject(createDbOutSpec(dbObjectLeft.getSpec(), dbObjectRight.getSpec()));
return new PortObject[] { outObject };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBReaderConnectionNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
// DatabaseQueryConnectionSettings conn = m_load.getQueryConnection();
DatabaseQueryConnectionSettings conn = new DatabaseQueryConnectionSettings(m_conn, parseQuery(m_conn.getQuery()));
DBReader load = conn.getUtility().getReader(conn);
DataTableSpec spec = load.getDataTableSpec(getCredentialsProvider());
DatabasePortObject dbObj = new DatabasePortObject(new DatabasePortObjectSpec(spec, conn.createConnectionModel()));
return new PortObject[] { dbObj };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBRowFilterNodeModel 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 = createQuery(conn.getQuery(), conn.getUtility().getStatementManipulator());
conn = createDBQueryConnection(dbObj.getSpec(), newQuery);
DatabasePortObject outObj = new DatabasePortObject(new DatabasePortObjectSpec(dbObj.getSpec().getDataTableSpec(), conn.createConnectionModel()));
return new PortObject[] { outObj };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class SQLExtractNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
DatabasePortObject dbIn = (DatabasePortObject) inData[0];
String query = dbIn.getConnectionSettings(getCredentialsProvider()).getQuery();
final String flowVarName = m_flowVariableName.getStringValue();
pushFlowVariableString(flowVarName, query);
// Create a table with the SQL query in a StringCell
DataContainer container = exec.createDataContainer(createSpec(flowVarName));
container.addRowToTable(new DefaultRow(RowKey.createRowKey(0), new StringCell(query)));
container.close();
BufferedDataTable outTable = (BufferedDataTable) container.getTable();
return new PortObject[] { FlowVariablePortObject.INSTANCE, outTable };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBApplyBinnerNodeModel method createDatabasePortObject.
private DatabasePortObject createDatabasePortObject(final DatabasePortObjectSpec inSpec, DatabaseQueryConnectionSettings connectionSettings, final PMMLPortObject pmmlPortObject) throws InvalidSettingsException {
final StatementManipulator statementManipulator = connectionSettings.getUtility().getStatementManipulator();
String newQuery = createQuery(connectionSettings.getQuery(), statementManipulator, inSpec.getDataTableSpec(), pmmlPortObject);
connectionSettings = createDBQueryConnection(inSpec, newQuery);
DatabaseQueryConnectionSettings querySettings = new DatabaseQueryConnectionSettings(connectionSettings, newQuery);
DBReader reader = querySettings.getUtility().getReader(querySettings);
try {
DatabasePortObjectSpec databasePortObjectSpec = new DatabasePortObjectSpec(reader.getDataTableSpec(getCredentialsProvider()), connectionSettings.createConnectionModel());
DatabasePortObject databasePortObject = new DatabasePortObject(databasePortObjectSpec);
return databasePortObject;
} catch (SQLException e) {
throw new InvalidSettingsException("Failure during query generation. Error: " + e.getMessage());
}
}
Aggregations