use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.
the class TableColumnToVariableNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
if (inSpecs[0] instanceof DataTableSpec) {
final DataTableSpec spec = (DataTableSpec) inSpecs[0];
if (m_column.getColumnName().equals(DEFAULT_COLUMN)) {
errorOrDefault(spec, "No column selected");
}
final int colIndex = spec.findColumnIndex(m_column.getStringValue());
if (colIndex < 0) {
String errorMessage = "Wrong column name, not in input: " + m_column.getStringValue() + " in: " + spec;
errorOrDefault(spec, errorMessage);
}
} else {
throw new InvalidSettingsException("Wrong input type: " + inSpecs[0]);
}
return new PortObjectSpec[] { FlowVariablePortObjectSpec.INSTANCE };
}
use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.
the class DBColumnFilterNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DatabasePortObjectSpec spec = (DatabasePortObjectSpec) inSpecs[0];
StringBuilder buf = new StringBuilder();
for (String column : m_filter.getIncludeList()) {
if (!spec.getDataTableSpec().containsName(column)) {
buf.append("\"" + column + "\" ");
}
}
if (buf.length() > 0) {
throw new InvalidSettingsException("Not all columns available in " + "input spec: " + buf.toString());
}
DatabaseQueryConnectionSettings conn = spec.getConnectionSettings(getCredentialsProvider());
ColumnRearranger colre = new ColumnRearranger(spec.getDataTableSpec());
colre.keepOnly(m_filter.getIncludeList().toArray(new String[0]));
final DataTableSpec resultSpec = colre.createSpec();
final String newQuery = createQuery(conn, resultSpec);
conn = createDBQueryConnection(spec, newQuery);
return new PortObjectSpec[] { new DatabasePortObjectSpec(resultSpec, conn.createConnectionModel()) };
}
use of org.knime.core.node.port.PortObjectSpec in project knime-core by knime.
the class TableRowToImageNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DataTableSpec inSpec = (DataTableSpec) inSpecs[0];
String column = m_imageColSettingsModel.getStringValue();
int columnIndex = inSpec.findColumnIndex(column);
if (columnIndex < 0) {
columnIndex = findImageColumnIndex(inSpec);
if (columnIndex >= 0) {
setWarningMessage("Found image column '" + inSpec.getColumnSpec(columnIndex).getName() + "'.");
}
}
if (columnIndex < 0) {
String error = column == null ? "No image column in input" : "No such image column in input table: " + column;
throw new InvalidSettingsException(error);
}
DataColumnSpec columnSpec = inSpec.getColumnSpec(columnIndex);
if (!columnSpec.getType().isCompatible(ImageValue.class)) {
throw new InvalidSettingsException("Column \"" + column + "\" does not contain images");
}
return new PortObjectSpec[] { new ImagePortObjectSpec(columnSpec.getType()) };
}
use of org.knime.core.node.port.PortObjectSpec 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.PortObjectSpec in project knime-core by knime.
the class DBSorterNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected PortObjectSpec[] configure(final PortObjectSpec[] inSpecs) throws InvalidSettingsException {
DatabasePortObjectSpec spec = (DatabasePortObjectSpec) inSpecs[0];
for (String columnName : m_columns) {
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