Search in sources :

Example 26 with AggregationMethod

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

the class AggregationColumnPanel method getMethods4SelectedItems.

/**
 * @return a label list of all supported methods for the currently
 * selected rows
 */
protected List<Entry<String, List<AggregationMethod>>> getMethods4SelectedItems() {
    final int[] selectedColumns = getSelectedRows();
    final Set<DataType> types = new HashSet<>(selectedColumns.length);
    for (final int row : selectedColumns) {
        final ColumnAggregator aggregator = getTableModel().getRow(row);
        types.add(aggregator.getOriginalDataType());
    }
    final DataType superType = CollectionCellFactory.getElementType(types.toArray(new DataType[0]));
    final List<Entry<String, List<AggregationMethod>>> list = AggregationMethods.getCompatibleMethodGroupList(superType);
    return list;
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) Entry(java.util.Map.Entry) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) DataType(org.knime.core.data.DataType) HashSet(java.util.HashSet)

Example 27 with AggregationMethod

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

the class GroupByNodeModel method compCreateColumnAggregators.

/**
 * Compatibility method used for compatibility to versions prior Knime 2.0.
 * Method to get the aggregation methods for the versions with only one
 * method for numerical and one for nominal columns.
 *
 * @param spec
 *            the {@link DataTableSpec}
 * @param excludeCols
 *            the name of all columns to be excluded
 * @param numeric
 *            the name of the numerical aggregation method
 * @param nominal
 *            the name of the nominal aggregation method
 * @return {@link Collection} of the {@link ColumnAggregator}s
 */
private static List<ColumnAggregator> compCreateColumnAggregators(final DataTableSpec spec, final List<String> excludeCols, final String numeric, final String nominal) {
    final AggregationMethod numericMethod = AggregationMethods.getMethod4Id(numeric);
    final AggregationMethod nominalMethod = AggregationMethods.getMethod4Id(nominal);
    final Set<String> groupCols = new HashSet<>(excludeCols);
    final List<ColumnAggregator> colAg = new LinkedList<>();
    for (int colIdx = 0, length = spec.getNumColumns(); colIdx < length; colIdx++) {
        final DataColumnSpec colSpec = spec.getColumnSpec(colIdx);
        if (!groupCols.contains(colSpec.getName())) {
            final AggregationMethod method = AggregationMethods.getAggregationMethod(colSpec, numericMethod, nominalMethod);
            colAg.add(new ColumnAggregator(colSpec, method, method.inclMissingCells()));
        }
    }
    return colAg;
}
Also used : AggregationMethod(org.knime.base.data.aggregation.AggregationMethod) DataColumnSpec(org.knime.core.data.DataColumnSpec) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) SettingsModelFilterString(org.knime.core.node.defaultnodesettings.SettingsModelFilterString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) LinkedList(java.util.LinkedList) HashSet(java.util.HashSet)

Aggregations

AggregationMethod (org.knime.base.data.aggregation.AggregationMethod)27 ColumnAggregator (org.knime.base.data.aggregation.ColumnAggregator)8 ArrayList (java.util.ArrayList)6 Entry (java.util.Map.Entry)4 DataType (org.knime.core.data.DataType)4 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 DataColumnSpec (org.knime.core.data.DataColumnSpec)3 Component (java.awt.Component)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 List (java.util.List)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)2 Container (java.awt.Container)1 Frame (java.awt.Frame)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 JTable (javax.swing.JTable)1 AggregationOperator (org.knime.base.data.aggregation.AggregationOperator)1