use of org.knime.core.node.port.database.DatabasePortObjectSpec 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.database.DatabasePortObjectSpec in project knime-core by knime.
the class DBQueryNodeModel2 method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DatabasePortObjectSpec spec = (DatabasePortObjectSpec) inSpecs[0];
DatabaseQueryConnectionSettings conn = spec.getConnectionSettings(getCredentialsProvider());
String newQuery = parseQuery(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.DatabasePortObjectSpec in project knime-core by knime.
the class DBReaderConnectionNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
try {
// DatabaseQueryConnectionSettings conn = m_load.getQueryConnection();
if (m_conn == null) {
throw new InvalidSettingsException("No database connection available.");
}
final DatabaseQueryConnectionSettings conn = new DatabaseQueryConnectionSettings(m_conn, parseQuery(m_conn.getQuery()));
if (!conn.getRetrieveMetadataInConfigure()) {
return new PortObjectSpec[1];
}
DBReader load = conn.getUtility().getReader(conn);
DataTableSpec spec = load.getDataTableSpec(getCredentialsProvider());
if (spec == null) {
throw new InvalidSettingsException("No database connection available.");
}
DatabasePortObjectSpec dbSpec = new DatabasePortObjectSpec(spec, conn.createConnectionModel());
return new PortObjectSpec[] { dbSpec };
} catch (InvalidSettingsException ise) {
throw ise;
} catch (Throwable t) {
throw new InvalidSettingsException(t);
}
}
use of org.knime.core.node.port.database.DatabasePortObjectSpec in project knime-core by knime.
the class DBRowFilterNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] ports) throws NotConfigurableException {
DatabasePortObjectSpec dbSpec = (DatabasePortObjectSpec) ports[0];
final DataTableSpec[] specs;
if (dbSpec == null) {
specs = new DataTableSpec[] { null };
} else {
specs = new DataTableSpec[] { dbSpec.getDataTableSpec() };
}
m_column.loadSettingsFrom(settings, specs);
m_operator.loadSettingsFrom(settings, specs);
m_value.loadSettingsFrom(settings, specs);
}
use of org.knime.core.node.port.database.DatabasePortObjectSpec in project knime-core by knime.
the class DBRowFilterNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DatabasePortObjectSpec spec = (DatabasePortObjectSpec) inSpecs[0];
final String columnName = m_column.getStringValue();
if (columnName == null) {
throw new InvalidSettingsException("No filter column selected.");
}
if (!spec.getDataTableSpec().containsName(columnName)) {
throw new InvalidSettingsException("Can't filter according to " + "selected column \"" + columnName + "\".");
}
DatabaseQueryConnectionSettings conn = spec.getConnectionSettings(getCredentialsProvider());
String newQuery = createQuery(conn.getQuery(), conn.getUtility().getStatementManipulator());
conn = createDBQueryConnection(spec, newQuery);
return new PortObjectSpec[] { new DatabasePortObjectSpec(spec.getDataTableSpec(), conn.createConnectionModel()) };
}
Aggregations