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;
}
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;
}
Aggregations