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