use of org.knime.base.node.io.database.groupby.dialog.DBAggregationFunctionProvider in project knime-core by knime.
the class DBColumnAggregationFunctionRow method loadFunctions.
/**
* Loads the functions and handles invalid aggregation functions graceful.
* @param settings {@link NodeSettingsRO}
* @param key the config key
* @param dbIdentifier the {@link AggregationFunctionProvider}
* @param tableSpec the input {@link DataTableSpec}
* @return {@link List} of {@link DBColumnAggregationFunctionRow}s
* @throws InvalidSettingsException if the settings are invalid
*/
public static List<DBColumnAggregationFunctionRow> loadFunctions(final NodeSettingsRO settings, final String key, final String dbIdentifier, final DataTableSpec tableSpec) throws InvalidSettingsException {
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("key must not be null");
}
if (dbIdentifier == null || dbIdentifier.isEmpty()) {
throw new IllegalArgumentException("dbIdentifier must not be empty");
}
if (settings == null || !settings.containsKey(key)) {
return Collections.EMPTY_LIST;
}
final DatabaseUtility utility = DatabaseUtility.getUtility(dbIdentifier);
DBAggregationFunctionProvider functionProvider = new DBAggregationFunctionProvider(utility);
final NodeSettingsRO root = settings.getNodeSettings(key);
final Set<String> settingsKeys = root.keySet();
final List<DBColumnAggregationFunctionRow> colAggrList = new ArrayList<>(settingsKeys.size());
for (String settingsKey : settingsKeys) {
final NodeSettingsRO cfg = root.getNodeSettings(settingsKey);
final String colName = cfg.getString(CNFG_COL_NAMES);
final DataType colType = cfg.getDataType(CNFG_COL_TYPES);
final DataColumnSpec colSpec = new DataColumnSpecCreator(colName, colType).createSpec();
DBAggregationFunction function = AbstractDBAggregationFunctionRow.loadFunction(tableSpec, functionProvider, cfg);
final DBColumnAggregationFunctionRow aggrFunctionRow = new DBColumnAggregationFunctionRow(colSpec, function);
colAggrList.add(aggrFunctionRow);
}
return colAggrList;
}
use of org.knime.base.node.io.database.groupby.dialog.DBAggregationFunctionProvider in project knime-core by knime.
the class DBDataTypeAggregationFunctionPanel method loadSettingsFrom.
/**
* @param settings the settings to read from
* @param dbIdentifier the database identifier
* @param spec initializes the component
* @throws InvalidSettingsException if the settings are invalid
*/
public void loadSettingsFrom(final NodeSettingsRO settings, final String dbIdentifier, final DataTableSpec spec) throws InvalidSettingsException {
final DatabaseUtility utility = DatabaseUtility.getUtility(dbIdentifier);
setAggregationFunctionProvider(new DBAggregationFunctionProvider(utility));
initialize(spec, DBDataTypeAggregationFunctionRow.loadFunctions(settings, m_key, dbIdentifier, spec));
}
use of org.knime.base.node.io.database.groupby.dialog.DBAggregationFunctionProvider in project knime-core by knime.
the class DBDataTypeAggregationFunctionRow method loadFunctions.
/**
* Loads the functions and handles invalid aggregation functions graceful.
* @param settings {@link NodeSettingsRO}
* @param key the config key
* @param dbIdentifier the {@link AggregationFunctionProvider}
* @param tableSpec the input {@link DataTableSpec}
* @return {@link List} of {@link DBDataTypeAggregationFunctionRow}s
* @throws InvalidSettingsException if the settings are invalid
*/
public static List<DBDataTypeAggregationFunctionRow> loadFunctions(final NodeSettingsRO settings, final String key, final String dbIdentifier, final DataTableSpec tableSpec) throws InvalidSettingsException {
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("key must not be null");
}
if (dbIdentifier == null || dbIdentifier.isEmpty()) {
throw new IllegalArgumentException("dbIdentifier must not be empty");
}
if (settings == null || !settings.containsKey(key)) {
return Collections.EMPTY_LIST;
}
final DatabaseUtility utility = DatabaseUtility.getUtility(dbIdentifier);
DBAggregationFunctionProvider functionProvider = new DBAggregationFunctionProvider(utility);
final NodeSettingsRO root = settings.getNodeSettings(key);
final Set<String> settingsKeys = root.keySet();
final List<DBDataTypeAggregationFunctionRow> colAggrList = new ArrayList<>(settingsKeys.size());
for (String settingsKey : settingsKeys) {
final NodeSettingsRO cfg = root.getNodeSettings(settingsKey);
final DataType dataType = cfg.getDataType(CNFG_DATA_TYPE);
DBAggregationFunction function = AbstractDBAggregationFunctionRow.loadFunction(tableSpec, functionProvider, cfg);
final DBDataTypeAggregationFunctionRow aggrFunctionRow = new DBDataTypeAggregationFunctionRow(dataType, function);
colAggrList.add(aggrFunctionRow);
}
return colAggrList;
}
Aggregations