use of org.knime.core.node.port.database.DatabaseQueryConnectionSettings in project knime-core by knime.
the class DBQueryNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DatabasePortObjectSpec spec = (DatabasePortObjectSpec) inSpecs[0];
DatabaseQueryConnectionSettings conn = spec.getConnectionSettings(getCredentialsProvider());
String newQuery = createQuery(conn.getQuery());
conn = createDBQueryConnection(spec, newQuery);
if (!conn.getRetrieveMetadataInConfigure()) {
return new PortObjectSpec[1];
}
try {
DBReader reader = conn.getUtility().getReader(conn);
DataTableSpec outSpec = reader.getDataTableSpec(getCredentialsProvider());
DatabasePortObjectSpec dbSpec = new DatabasePortObjectSpec(outSpec, conn.createConnectionModel());
return new PortObjectSpec[] { dbSpec };
} catch (Throwable t) {
throw new InvalidSettingsException(t);
}
}
use of org.knime.core.node.port.database.DatabaseQueryConnectionSettings 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.DatabaseQueryConnectionSettings 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.DatabaseQueryConnectionSettings in project knime-core by knime.
the class DBReaderNodeModel method getResultSpec.
/**
* @param inSpecs input spec
* @return the {@link DataTableSpec} of the result table
* @throws InvalidSettingsException if the connection settings are invalid
* @throws SQLException if the query is invalid
*/
protected DataTableSpec getResultSpec(final PortObjectSpec[] inSpecs) throws InvalidSettingsException, SQLException {
String query = parseQuery(m_settings.getQuery());
DatabaseQueryConnectionSettings connSettings;
if (hasDatabaseInputConnection(inSpecs)) {
DatabaseConnectionPortObjectSpec connSpec = (DatabaseConnectionPortObjectSpec) inSpecs[getNrInPorts() - 1];
connSettings = new DatabaseQueryConnectionSettings(connSpec.getConnectionSettings(getCredentialsProvider()), query);
} else {
connSettings = new DatabaseQueryConnectionSettings(m_settings, query);
}
DBReader reader = connSettings.getUtility().getReader(connSettings);
final DataTableSpec resultSpec = reader.getDataTableSpec(getCredentialsProvider());
return resultSpec;
}
use of org.knime.core.node.port.database.DatabaseQueryConnectionSettings in project knime-core by knime.
the class DBReaderNodeModel method loadConnectionSettings.
/**
* @param dbPortObject
* @return
* @throws InvalidSettingsException
*/
protected DBReader loadConnectionSettings(final PortObject dbPortObject) throws InvalidSettingsException {
String query = parseQuery(m_settings.getQuery());
DatabaseQueryConnectionSettings connSettings;
if ((dbPortObject instanceof DatabaseConnectionPortObject)) {
DatabaseConnectionPortObject dbObj = (DatabaseConnectionPortObject) dbPortObject;
connSettings = new DatabaseQueryConnectionSettings(dbObj.getConnectionSettings(getCredentialsProvider()), query);
} else {
connSettings = new DatabaseQueryConnectionSettings(m_settings, query);
}
final DBReader load = connSettings.getUtility().getReader(new DatabaseQueryConnectionSettings(connSettings, query));
return load;
}
Aggregations