Search in sources :

Example 1 with OutColumnList

use of org.knime.core.node.util.dialog.field.FieldList.OutColumnList in project knime-core by knime.

the class OutFieldsTable method getOutColFields.

/**
 * Get the field definitions representing output columns.
 *
 * @return fields representing output columns.
 */
public OutColumnList getOutColFields() {
    OutColumnList outCols = new OutColumnList();
    for (int r = 0; r < m_model.getRowCount(); r++) {
        if (!m_model.validateValues(r)) {
            // there are errors in this row
            continue;
        }
        Object fieldTypeValue = getFieldType(r);
        if (null == fieldTypeValue) {
            continue;
        }
        boolean isColumn = fieldTypeValue.equals(FieldType.Column);
        if (isColumn) {
            OutColumnField outCol = new OutColumnField();
            outCol.setReplaceExisting((Boolean) m_model.getValueAt(r, Column.REPLACE_EXISTING));
            Object colColValue = m_model.getValueAt(r, Column.COLUMN);
            if (colColValue instanceof DataColumnSpec) {
                DataColumnSpec colSpec = (DataColumnSpec) colColValue;
                outCol.setKnimeName(colSpec.getName());
            } else if (colColValue instanceof String) {
                outCol.setKnimeName(colColValue.toString());
            } else {
                continue;
            }
            Object dataTypeValue = m_model.getValueAt(r, Column.DATA_TYPE);
            boolean isArray = (Boolean) m_model.getValueAt(r, Column.IS_COLLECTION);
            if (dataTypeValue instanceof DataType) {
                DataType type = (DataType) dataTypeValue;
                if (isArray) {
                    type = ListCell.getCollectionType(type);
                }
                outCol.setKnimeType(type);
            } else {
                continue;
            }
            outCols.add(outCol);
        }
    }
    return outCols;
}
Also used : OutColumnField(org.knime.core.node.util.dialog.field.OutColumnField) DataColumnSpec(org.knime.core.data.DataColumnSpec) DataType(org.knime.core.data.DataType) EventObject(java.util.EventObject) OutColumnList(org.knime.core.node.util.dialog.field.FieldList.OutColumnList)

Aggregations

EventObject (java.util.EventObject)1 DataColumnSpec (org.knime.core.data.DataColumnSpec)1 DataType (org.knime.core.data.DataType)1 OutColumnList (org.knime.core.node.util.dialog.field.FieldList.OutColumnList)1 OutColumnField (org.knime.core.node.util.dialog.field.OutColumnField)1