use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class DBColumnFilterNodeModel 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());
ColumnRearranger colre = new ColumnRearranger(dbObj.getSpec().getDataTableSpec());
colre.keepOnly(m_filter.getIncludeList().toArray(new String[0]));
final DataTableSpec resultSpec = colre.createSpec();
final String newQuery = createQuery(conn, resultSpec);
conn = createDBQueryConnection(dbObj.getSpec(), newQuery);
DatabasePortObjectSpec outSpec = new DatabasePortObjectSpec(resultSpec, conn.createConnectionModel());
DatabasePortObject outObj = new DatabasePortObject(outSpec);
return new PortObject[] { outObj };
}
use of org.knime.core.node.port.PortObject in project knime-core by knime.
the class TableRowToImageNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inObjects, final ExecutionContext exec) throws Exception {
BufferedDataTable inTable = (BufferedDataTable) inObjects[0];
// check for empty table
if (inTable.size() == 0) {
throw new IllegalArgumentException("Input table is empty.");
}
// warn if more than one row
if (inTable.size() > 1) {
setWarningMessage("Input data table has more than one rows! " + "Using first row only.");
}
String column = m_imageColSettingsModel.getStringValue();
DataTableSpec inSpec = inTable.getDataTableSpec();
int columnIndex = inSpec.findColumnIndex(column);
if (columnIndex < 0) {
columnIndex = findImageColumnIndex(inSpec);
}
ImagePortObjectSpec imagePortObjectSpec = new ImagePortObjectSpec(inSpec.getColumnSpec(columnIndex).getType());
final RowIterator it = inTable.iterator();
while (it.hasNext()) {
DataRow row = it.next();
DataCell cell = row.getCell(columnIndex);
if (!cell.isMissing()) {
ImageContent ic = ((ImageValue) cell).getImageContent();
return new PortObject[] { new ImagePortObject(ic, imagePortObjectSpec) };
} else {
setWarningMessage("Found missing image cell, skipping it...");
}
}
throw new IllegalArgumentException("Input table contains only missing cells.");
}
use of org.knime.core.node.port.PortObject 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.PortObject 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.PortObject 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 };
}
Aggregations