Search in sources :

Example 16 with ColumnAggregator

use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.

the class AggregationColumnPanel method excludeColsChange.

/**
 * @param excludeColNames the name of all columns that should be
 * excluded from the aggregation panel
 */
public void excludeColsChange(final Collection<String> excludeColNames) {
    final Set<String> excludeColNameSet = new HashSet<>(excludeColNames);
    final List<DataColumnSpec> newList = new LinkedList<>();
    // include all columns that are not in the exclude list
    for (final DataColumnSpec colSpec : m_avAggrColSpecs) {
        if (!excludeColNameSet.contains(colSpec.getName())) {
            newList.add(colSpec);
        }
    }
    final List<ColumnAggregator> oldAggregators = getTableModel().getRows();
    final List<ColumnAggregator> newAggregators = new LinkedList<>();
    for (final ColumnAggregator aggregator : oldAggregators) {
        if (!excludeColNameSet.contains(aggregator.getOriginalColName())) {
            newAggregators.add(aggregator);
        }
    }
    initialize(newList, newAggregators, getInputTableSpec());
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 17 with ColumnAggregator

use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.

the class AggregationColumnPanel method initialize.

/**
 * Initializes the panel.
 * @param spec the {@link DataTableSpec} of the input table
 * @param colAggrs the {@link List} of {@link ColumnAggregator}s that are
 * initially used
 */
public void initialize(final DataTableSpec spec, final List<ColumnAggregator> colAggrs) {
    m_avAggrColSpecs.clear();
    final List<DataColumnSpec> listElements = new LinkedList<>();
    for (final DataColumnSpec colSpec : spec) {
        m_avAggrColSpecs.add(colSpec);
        listElements.add(colSpec);
    }
    // remove all invalid column aggregator
    final List<ColumnAggregator> colAggrs2Use = new ArrayList<>(colAggrs.size());
    for (final ColumnAggregator colAggr : colAggrs) {
        final DataColumnSpec colSpec = spec.getColumnSpec(colAggr.getOriginalColName());
        final boolean valid;
        if (colSpec != null && colSpec.getType().equals(colAggr.getOriginalDataType())) {
            valid = true;
        } else {
            valid = false;
        }
        colAggr.setValid(valid);
        colAggrs2Use.add(colAggr);
    }
    initialize(listElements, colAggrs2Use, spec);
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList)

Example 18 with ColumnAggregator

use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.

the class AggregationColumnTableModel method removeColumns.

/**
 * @param colNames the names of the columns to remove
 */
@Deprecated
protected void removeColumns(final Collection<String> colNames) {
    if (colNames == null || colNames.isEmpty()) {
        return;
    }
    final Set<String> colNameSet = new HashSet<>(colNames);
    final Collection<ColumnAggregator> colAggr2Remove = new LinkedList<>();
    for (final ColumnAggregator colAggr : getRows()) {
        if (colNameSet.contains(colAggr.getOriginalColName())) {
            colAggr2Remove.add(colAggr);
        }
    }
    remove(colAggr2Remove);
}
Also used : ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 19 with ColumnAggregator

use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.

the class AggregationColumnPanel method excludeColsChange.

/**
 * @param excludeColNames the name of all columns that should be
 * excluded from the aggregation panel
 */
public void excludeColsChange(final Collection<String> excludeColNames) {
    final Set<String> excludeColNameSet = new HashSet<>(excludeColNames);
    final List<DataColumnSpec> newList = new LinkedList<>();
    // include all columns that are not in the exclude list
    for (final DataColumnSpec colSpec : m_avAggrColSpecs) {
        if (!excludeColNameSet.contains(colSpec.getName())) {
            newList.add(colSpec);
        }
    }
    final List<ColumnAggregator> oldAggregators = getTableModel().getRows();
    final List<ColumnAggregator> newAggregators = new LinkedList<>();
    for (final ColumnAggregator aggregator : oldAggregators) {
        if (!excludeColNameSet.contains(aggregator.getOriginalColName())) {
            newAggregators.add(aggregator);
        }
    }
    initialize(newList, newAggregators, getInputTableSpec());
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Example 20 with ColumnAggregator

use of org.knime.base.data.aggregation.ColumnAggregator in project knime-core by knime.

the class AggregationColumnTableModel method addColumn.

/**
 * @param specs the {@link DataColumnSpec}s of the columns to add
 * @see #add(List)
 */
@Deprecated
protected void addColumn(final DataColumnSpec... specs) {
    if (specs == null || specs.length < 1) {
        return;
    }
    final List<ColumnAggregator> aggregators = new ArrayList<>(specs.length);
    for (final DataColumnSpec spec : specs) {
        final AggregationMethod defaultMethod = AggregationMethods.getDefaultMethod(spec);
        aggregators.add(new ColumnAggregator(spec, defaultMethod));
    }
    add(aggregators);
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) ArrayList(java.util.ArrayList)

Aggregations

ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)33 DataColumnSpec (org.knime.core.data.DataColumnSpec)14 HashSet (java.util.HashSet)9 LinkedList (java.util.LinkedList)9 ArrayList (java.util.ArrayList)8 AggregationMethod (org.knime.base.data.aggregation.AggregationMethod)8 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)5 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)5 DataCell (org.knime.core.data.DataCell)4 DataRow (org.knime.core.data.DataRow)4 DataTableSpec (org.knime.core.data.DataTableSpec)4 RowKey (org.knime.core.data.RowKey)4 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)4 GlobalSettings (org.knime.base.data.aggregation.GlobalSettings)3 PatternAggregator (org.knime.base.data.aggregation.dialogutil.pattern.PatternAggregator)3 DataTypeAggregator (org.knime.base.data.aggregation.dialogutil.type.DataTypeAggregator)3 GroupByTable (org.knime.base.node.preproc.groupby.GroupByTable)3 DataType (org.knime.core.data.DataType)3 DefaultRow (org.knime.core.data.def.DefaultRow)3 BufferedDataContainer (org.knime.core.node.BufferedDataContainer)3