use of org.knime.core.node.port.flowvariable.FlowVariablePortObject in project knime-core by knime.
the class TableColumnToVariableNodeModel method execute.
/**
* {@inheritDoc}
*/
@Override
protected PortObject[] execute(final PortObject[] inData, final ExecutionContext exec) throws Exception {
if (inData[0] instanceof BufferedDataTable) {
final BufferedDataTable table = (BufferedDataTable) inData[0];
final int colIndex = table.getSpec().findColumnIndex(m_column.getStringValue());
assert colIndex >= 0 : colIndex;
for (DataRow dataRow : table) {
DataCell cell = dataRow.getCell(colIndex);
if (cell.isMissing()) {
if (m_ignoreMissing.getBooleanValue()) {
continue;
}
throw new Exception("Missing value in column (" + m_column.getColumnName() + ") in row: " + dataRow.getKey());
}
if (cell instanceof IntValue) {
final IntValue iv = (IntValue) cell;
pushFlowVariableInt(dataRow.getKey().getString(), iv.getIntValue());
} else if (cell instanceof DoubleValue) {
final DoubleValue dv = (DoubleValue) cell;
pushFlowVariableDouble(dataRow.getKey().getString(), dv.getDoubleValue());
} else if (cell instanceof StringValue) {
final StringValue sv = (StringValue) cell;
pushFlowVariableString(dataRow.getKey().getString(), sv.getStringValue());
}
}
}
return new FlowVariablePortObject[] { FlowVariablePortObject.INSTANCE };
}
Aggregations