use of org.knime.core.node.port.database.aggregation.DBAggregationFunction in project knime-core by knime.
the class DBPatternAggregationFunctionPanel method createRow.
/**
* {@inheritDoc}
*/
@Override
protected DBPatternAggregationFunctionRow createRow(final String pattern) {
final AggregationFunctionProvider<DBAggregationFunction> provider = getTableModel().getAggregationFunctionProvider();
final DBAggregationFunction defaultFunction = provider.getDefaultFunction(StringCell.TYPE);
return new DBPatternAggregationFunctionRow(".*", true, defaultFunction);
}
use of org.knime.core.node.port.database.aggregation.DBAggregationFunction in project knime-core by knime.
the class DBPatternAggregationFunctionPanel method createAggregationSection.
/**
* Adds the aggregation method section to the given menu.
* This section allows the user to set an aggregation method for
* all selected columns.
* @param menu the menu to append the aggregation section
*/
private void createAggregationSection(final JPopupMenu menu) {
if (getSelectedRows().length <= 0) {
final JMenuItem noneSelected = new JMenuItem("Select a column to change method");
noneSelected.setEnabled(false);
menu.add(noneSelected);
return;
}
final List<DBAggregationFunction> methodList = getTableModel().getAggregationFunctionProvider().getFunctions(true);
// we need no sub menu for a single group
for (final DBAggregationFunction method : methodList) {
final JMenuItem methodItem = new JMenuItem(method.getLabel());
methodItem.setToolTipText(method.getDescription());
methodItem.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
changeAggregationMethod(method.getId());
}
});
menu.add(methodItem);
}
}
use of org.knime.core.node.port.database.aggregation.DBAggregationFunction in project knime-core by knime.
the class DBDataTypeAggregationFunctionPanel method createRow.
/**
* {@inheritDoc}
*/
@Override
protected DBDataTypeAggregationFunctionRow createRow(final DataType type) {
AggregationFunctionProvider<DBAggregationFunction> provider = getTableModel().getAggregationFunctionProvider();
final DBAggregationFunction defaultFunction;
if (provider != null) {
defaultFunction = provider.getDefaultFunction(type);
} else {
defaultFunction = new CountDBAggregationFunction.Factory().createInstance();
}
return new DBDataTypeAggregationFunctionRow(type, defaultFunction);
}
use of org.knime.core.node.port.database.aggregation.DBAggregationFunction in project knime-core by knime.
the class DBDataTypeAggregationFunctionPanel method createAggregationSection.
/**
* Adds the aggregation method section to the given menu.
* This section allows the user to set an aggregation method for
* all selected columns.
* @param menu the menu to append the aggregation section
*/
private void createAggregationSection(final JPopupMenu menu) {
if (getSelectedRows().length <= 0) {
final JMenuItem noneSelected = new JMenuItem("Select a row to change method");
noneSelected.setEnabled(false);
menu.add(noneSelected);
return;
}
final List<DBAggregationFunction> methodList = getMethods4SelectedItems();
// we need no sub menu for a single group
for (final DBAggregationFunction method : methodList) {
final JMenuItem methodItem = new JMenuItem(method.getLabel());
methodItem.setToolTipText(method.getDescription());
methodItem.addActionListener(new ActionListener() {
/**
* {@inheritDoc}
*/
@Override
public void actionPerformed(final ActionEvent e) {
changeAggregationMethod(method.getId());
}
});
menu.add(methodItem);
}
}
use of org.knime.core.node.port.database.aggregation.DBAggregationFunction in project knime-core by knime.
the class AbstractDBAggregationFunctionRow method loadFunction.
/**
* @param tableSpec optional input {@link DataTableSpec}
* @param functionProvider the {@link DBAggregationFunctionProvider}
* @param cfg {@link NodeSettingsRO} to read from
* @return the {@link DBAggregationFunction}
* @throws InvalidSettingsException if the settings of the function are invalid
*/
public static DBAggregationFunction loadFunction(final DataTableSpec tableSpec, final DBAggregationFunctionProvider functionProvider, final NodeSettingsRO cfg) throws InvalidSettingsException {
final String functionId = cfg.getString(CNFG_AGGR_COL_SECTION);
DBAggregationFunction function = functionProvider.getFunction(functionId);
if (function instanceof InvalidAggregationFunction) {
final String errMsg = "Exception while loading database aggregation functions. " + ((InvalidAggregationFunction) function).getErrorMessage();
LOGGER.warn(errMsg);
} else {
if (function.hasOptionalSettings()) {
try {
final NodeSettingsRO subSettings = cfg.getNodeSettings("functionSettings");
if (tableSpec != null) {
// this method is called from the dialog
function.loadSettingsFrom(subSettings, tableSpec);
} else {
// this method is called from the node model where we do not
// have the DataTableSpec
function.loadValidatedSettings(subSettings);
}
} catch (Exception e) {
final String errMsg = "Exception while loading settings for aggreation function '" + function.getId() + "', reason: " + e.getMessage();
function = new InvalidDBAggregationFunction(functionId, errMsg, null);
LOGGER.error(errMsg);
}
}
}
return function;
}
Aggregations