Search in sources :

Example 6 with InvalidAggregationFunction

use of org.knime.core.node.port.database.aggregation.InvalidAggregationFunction in project knime-core by knime.

the class AggregationMethodDecorator method loadMethod.

/**
 * @param tableSpec optional input {@link DataTableSpec}
 * @param cfg {@link NodeSettingsRO} to read from
 * @return the {@link AggregationFunction}
 * @throws InvalidSettingsException if the settings of the function are invalid
 * @since 2.11
 */
public static AggregationMethod loadMethod(final DataTableSpec tableSpec, final NodeSettingsRO cfg) throws InvalidSettingsException {
    final String functionId = cfg.getString(CNFG_AGGR_METHODS);
    final AggregationMethod function = AggregationMethods.getMethod4Id(functionId);
    if (function instanceof InvalidAggregationFunction) {
        final String errMsg = "Exception while loading aggregation method. " + ((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();
                LOGGER.error(errMsg);
            }
        }
    }
    return function;
}
Also used : InvalidAggregationFunction(org.knime.core.node.port.database.aggregation.InvalidAggregationFunction) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NotConfigurableException(org.knime.core.node.NotConfigurableException)

Aggregations

InvalidAggregationFunction (org.knime.core.node.port.database.aggregation.InvalidAggregationFunction)6 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)4 AggregationFunction (org.knime.core.node.port.database.aggregation.AggregationFunction)3 DBAggregationFunction (org.knime.core.node.port.database.aggregation.DBAggregationFunction)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 DBColumnAggregationFunctionRow (org.knime.base.node.io.database.groupby.dialog.column.DBColumnAggregationFunctionRow)2 DataColumnSpec (org.knime.core.data.DataColumnSpec)2 DataTableSpec (org.knime.core.data.DataTableSpec)2 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)2 SettingsModelFilterString (org.knime.core.node.defaultnodesettings.SettingsModelFilterString)2 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)2 PortObjectSpec (org.knime.core.node.port.PortObjectSpec)2 DatabasePortObjectSpec (org.knime.core.node.port.database.DatabasePortObjectSpec)2 DatabaseQueryConnectionSettings (org.knime.core.node.port.database.DatabaseQueryConnectionSettings)2 Component (java.awt.Component)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 LinkedList (java.util.LinkedList)1 Pattern (java.util.regex.Pattern)1