Search in sources :

Example 21 with CloseableRowIterator

use of org.knime.core.data.container.CloseableRowIterator in project GenericKnimeNodes by genericworkflownodes.

the class ColumnToListNodeModel method execute.

@Override
protected BufferedDataTable[] execute(BufferedDataTable[] inData, ExecutionContext exec) throws Exception {
    BufferedDataContainer cont = exec.createDataContainer(outspec[0]);
    List<DataCell> cells = new ArrayList<DataCell>();
    CloseableRowIterator iter = inData[0].iterator();
    while (iter.hasNext()) {
        cells.add(iter.next().getCell(0));
    }
    ListCell lc = CollectionCellFactory.createListCell(cells);
    DataRow row = new DefaultRow("Row 1", lc);
    cont.addRowToTable(row);
    cont.close();
    return new BufferedDataTable[] { cont.getTable() };
}
Also used : BufferedDataContainer(org.knime.core.node.BufferedDataContainer) ListCell(org.knime.core.data.collection.ListCell) ArrayList(java.util.ArrayList) BufferedDataTable(org.knime.core.node.BufferedDataTable) DataCell(org.knime.core.data.DataCell) CloseableRowIterator(org.knime.core.data.container.CloseableRowIterator) DefaultRow(org.knime.core.data.def.DefaultRow) DataRow(org.knime.core.data.DataRow)

Aggregations

CloseableRowIterator (org.knime.core.data.container.CloseableRowIterator)21 DataRow (org.knime.core.data.DataRow)13 BufferedDataTable (org.knime.core.node.BufferedDataTable)12 DataCell (org.knime.core.data.DataCell)8 DataTableSpec (org.knime.core.data.DataTableSpec)6 ArrayList (java.util.ArrayList)5 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)4 Color (java.awt.Color)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 TreeSet (java.util.TreeSet)2 DataColumnSpec (org.knime.core.data.DataColumnSpec)2 DefaultRow (org.knime.core.data.def.DefaultRow)2 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)2 Interpreter (bsh.Interpreter)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 IOException (java.io.IOException)1 BitSet (java.util.BitSet)1 Collection (java.util.Collection)1