use of org.knime.base.data.aggregation.NamedAggregationOperator in project knime-core by knime.
the class ColumnAggregationPanel method initialize.
/**
* Initializes the panel.
* @param type the {@link DataType} the methods should support
* @param methods the {@link List} of {@link NamedAggregationOperator}s
* that are initially used
* @param spec input {@link DataTableSpec}
* @since 2.7
*/
public void initialize(final DataType type, final List<NamedAggregationOperator> methods, final DataTableSpec spec) {
m_type = type;
// update the compatible methods list
final List<NamedAggregationOperator> methods2Use = new ArrayList<>(methods.size());
if (m_type != null) {
// remove selected methods that are not compatible with the new type
for (final NamedAggregationOperator method : methods) {
if (method.isCompatible(m_type)) {
methods2Use.add(method);
}
}
super.initialize(AggregationMethods.getCompatibleMethods(m_type, true), methods2Use, spec);
}
}
use of org.knime.base.data.aggregation.NamedAggregationOperator in project knime-core by knime.
the class ColumnAggregatorNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_aggregationCols.validateSettings(settings);
m_removeRetainedCols.validateSettings(settings);
m_removeAggregationCols.validateSettings(settings);
m_valueDelimiter.validateSettings(settings);
m_maxUniqueValues.validateSettings(settings);
if (!settings.containsKey(CFG_AGGREGATION_METHODS)) {
throw new InvalidSettingsException("Methods configuration not found");
}
// check for duplicate column names
final NodeSettingsRO subSettings = settings.getNodeSettings(ColumnAggregatorNodeModel.CFG_AGGREGATION_METHODS);
final List<NamedAggregationOperator> methods = NamedAggregationOperator.loadOperators(subSettings);
if (methods.isEmpty()) {
throw new InvalidSettingsException("Please select at least one aggregation method");
}
final Map<String, Integer> colNames = new HashMap<>(methods.size());
int colIdx = 1;
for (final NamedAggregationOperator method : methods) {
final Integer oldIdx = colNames.put(method.getName(), Integer.valueOf(colIdx));
if (oldIdx != null) {
throw new InvalidSettingsException("Duplicate column name '" + method.getName() + "' found in row " + oldIdx + " and " + colIdx);
}
colIdx++;
}
// validate the sub settings of all operators that require additional settings
NamedAggregationOperator.validateSettings(subSettings, methods);
}
Aggregations