use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class AggregationColumnTableModel method setValue.
/**
* {@inheritDoc}
*/
@Override
public void setValue(final Object aValue, final int row, final int columnIdx) {
if (aValue == null) {
return;
}
if (aValue instanceof AggregationMethod) {
assert columnIdx == 1;
final AggregationMethod newMethod = (AggregationMethod) aValue;
updateMethod(row, newMethod);
}
}
use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class AggregationColumnTableModel method updateMethod.
/**
* @param row the row to update
* @param method the {@link AggregationMethod} to use
*/
private void updateMethod(final int row, final AggregationMethod method) {
final ColumnAggregator old = getRow(row);
if (old.getMethodTemplate().getId().equals(method.getId())) {
// check if the method has changed
return;
}
// create a new operator each time it is updated to guarantee that
// each column has its own operator instance
AggregationMethod methodClone = AggregationMethods.getMethod4Id(method.getId());
final ColumnAggregator newRow = new ColumnAggregator(old.getOriginalColSpec(), methodClone, old.inclMissingCells());
newRow.setValid(old.isValid());
updateRow(row, newRow);
}
use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class PatternAggregator method loadAggregators.
/**
* Creates a {@link List} with all {@link PatternAggregator}s that were
* stored in the settings.
*
* @param settings the settings object to read from
* @param key the unique settings key
* @param spec {@link DataTableSpec} of the input table if available
* @return {@link List} with the {@link PatternAggregator}s
* @throws InvalidSettingsException if the settings are invalid
*/
public static List<PatternAggregator> loadAggregators(final NodeSettingsRO settings, final String key, final DataTableSpec spec) throws InvalidSettingsException {
if (settings == null) {
throw new IllegalArgumentException("settings must not be null");
}
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("key must not be empty");
}
if (!settings.containsKey(key)) {
return Collections.EMPTY_LIST;
}
final NodeSettingsRO root = settings.getNodeSettings(key);
final Set<String> settingsKeys = root.keySet();
final List<PatternAggregator> aggrList = new ArrayList<>(settingsKeys.size());
for (String settingsKey : settingsKeys) {
final NodeSettingsRO cfg = root.getNodeSettings(settingsKey);
final String inputPattern = cfg.getString(CNFG_INPUT_PATTERN);
final boolean isRegex = cfg.getBoolean(CNFG_IS_REGEX);
final boolean inclMissing = cfg.getBoolean(CNFG_INCL_MISSING_VALS);
final AggregationMethod method = AggregationMethodDecorator.loadMethod(spec, cfg);
aggrList.add(new PatternAggregator(inputPattern, isRegex, method, inclMissing));
}
return aggrList;
}
use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class DataTypeAggregationTableModel method updateMethod.
/**
* @param row the row to update
* @param method the {@link AggregationMethod} to use
*/
private void updateMethod(final int row, final AggregationMethod method) {
final DataTypeAggregator old = getRow(row);
if (old.getMethodTemplate().getId().equals(method.getId())) {
// check if the method has changed
return;
}
// create a new operator each time it is updated to guarantee that
// each column has its own operator instance
final AggregationMethod methodClone = AggregationMethods.getMethod4Id(method.getId());
final DataTypeAggregator newRow = new DataTypeAggregator(old.getDataType(), methodClone, old.inclMissingCells());
newRow.setValid(old.isValid());
updateRow(row, newRow);
}
use of org.knime.base.data.aggregation.AggregationMethod in project knime-core by knime.
the class AbstractAggregationMethodTableCellEditor method getTableCellEditorComponent.
/**
* {@inheritDoc}
*/
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
final DataType type = getDataType(table, value, isSelected, row, column);
final AggregationMethod selectedMethod = getSelectedAggregationMethod(table, value, isSelected, row, column);
final List<AggregationMethod> compatibleMethods = getCompatibleMethods(type);
if (type != null) {
getBox().update(type, compatibleMethods, selectedMethod);
}
return super.getTableCellEditorComponent(table, value, isSelected, row, column);
}
Aggregations