use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBGroupByNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
exec.setMessage("Retrieving metadata from database");
DatabasePortObject dbObject = (DatabasePortObject) inData[0];
DatabasePortObject outObject = new DatabasePortObject(createDbOutSpec(dbObject.getSpec(), false));
return new PortObject[] { outObject };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBPivotNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
exec.setMessage("Retrieving metadata from database");
final DatabasePortObject dbObject = (DatabasePortObject) inData[0];
final DatabasePortObject outObject = new DatabasePortObject(createDbOutSpec(dbObject.getSpec(), exec));
return new PortObject[] { outObject };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBSorterNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected final PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws CanceledExecutionException, Exception {
exec.setMessage("Retrieving metadata from database");
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 SQLInjectNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
exec.setMessage("Retrieving metadata from database");
final String varName = m_flowVariableName.getStringValue();
if (varName == null) {
throw new InvalidSettingsException("No flow variable for the SQL statement selected");
}
final String sql = peekFlowVariableString(varName);
if (sql == null) {
throw new InvalidSettingsException("The selected flow variable is not assigned");
}
DatabaseConnectionPortObject dbIn = (DatabaseConnectionPortObject) inData[0];
DatabaseConnectionSettings inSettings = dbIn.getConnectionSettings(getCredentialsProvider());
// Attach the SQL query
DatabaseQueryConnectionSettings outSettings = new DatabaseQueryConnectionSettings(inSettings, sql);
// Probe the database to see how the result table looks like
DBReader load = outSettings.getUtility().getReader(outSettings);
DataTableSpec tableSpec = load.getDataTableSpec(getCredentialsProvider());
DatabasePortObjectSpec outSpec = new DatabasePortObjectSpec(tableSpec, outSettings.createConnectionModel());
return new PortObject[] { new DatabasePortObject(outSpec) };
}
use of org.knime.core.node.port.database.DatabasePortObject in project knime-core by knime.
the class DBAutoBinnerNodeModel 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);
DatabaseReaderConnection conn = new DatabaseReaderConnection(querySettings);
DatabasePortObjectSpec databasePortObjectSpec = null;
try {
databasePortObjectSpec = new DatabasePortObjectSpec(conn.getDataTableSpec(getCredentialsProvider()), connectionSettings.createConnectionModel());
} catch (SQLException e) {
throw new InvalidSettingsException("Failure during query generation. Error: " + e.getMessage());
}
DatabasePortObject databasePortObject = new DatabasePortObject(databasePortObjectSpec);
return databasePortObject;
}
Aggregations