use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class RowFilter2PortNodeModel method loadOrValidateSettingsFrom.
private void loadOrValidateSettingsFrom(final NodeSettingsRO settings, final boolean verifyOnly) throws InvalidSettingsException {
IRowFilter tmpFilter = null;
if (settings.containsKey(CFGFILTER)) {
NodeSettingsRO filterCfg = settings.getNodeSettings(CFGFILTER);
tmpFilter = RowFilterFactory.createRowFilter(filterCfg);
} else {
throw new InvalidSettingsException("Row Filter config contains no" + " row filter.");
}
if (verifyOnly) {
return;
}
// take over settings
m_rowFilter = tmpFilter;
return;
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class DBPatternAggregationFunctionRow 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 DBPatternAggregationFunctionRow}s
* @throws InvalidSettingsException if the settings are invalid
*/
public static List<DBPatternAggregationFunctionRow> 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<DBPatternAggregationFunctionRow> colAggrList = 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 DBAggregationFunction function = AbstractDBAggregationFunctionRow.loadFunction(tableSpec, functionProvider, cfg);
final DBPatternAggregationFunctionRow aggrFunctionRow = new DBPatternAggregationFunctionRow(inputPattern, isRegex, function);
colAggrList.add(aggrFunctionRow);
}
return colAggrList;
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class DBTableCreatorConfiguration method loadSettingsForRowElements.
/**
* A helper method to load settings for all RowElements
*
* @param cfgKey key used to retrieve the RowElement list from the map
* @param settings NodeSettingsRO instance to load from
* @throws InvalidSettingsException
*/
private void loadSettingsForRowElements(final String cfgKey, final NodeSettingsRO settings) throws InvalidSettingsException {
final NodeSettingsRO root = settings.getNodeSettings(cfgKey);
List<RowElement> elements = m_tableMap.get(cfgKey);
elements.clear();
for (String settingsKey : root.keySet()) {
final NodeSettingsRO cfg = root.getNodeSettings(settingsKey);
final RowElement elem = createRowElement(cfgKey, cfg);
if (elem != null) {
elements.add(elem);
}
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class KeyElement method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings) {
try {
final String name = settings.getString(CFG_KEY_NAME);
// Load all columns
final NodeSettingsRO cfg = settings.getNodeSettings(CFG_KEY_COLUMNS);
final Set<DBColumn> dbColumns = new LinkedHashSet<>();
for (String settingsKey : cfg.keySet()) {
final String colName = cfg.getString(settingsKey);
DBColumn col = new DBColumn(colName, "", false);
dbColumns.add(col);
}
final boolean primaryKey = settings.getBoolean(CFG_KEY_PRIMARY);
m_key = new DBKey(name, dbColumns, primaryKey);
} catch (InvalidSettingsException ex) {
// Do nothing if no settings are found
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class DBWriterDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
// get workflow credentials
m_loginPane.loadSettingsFrom(settings, specs, getCredentialsProvider());
// table name
m_table.setText(settings.getString(DBWriterNodeModel.KEY_TABLE_NAME, ""));
// append data flag
m_append.setSelected(settings.getBoolean(DBWriterNodeModel.KEY_APPEND_DATA, true));
m_insertNullForMissing.setSelected(settings.getBoolean(DBWriterNodeModel.KEY_INSERT_NULL_FOR_MISSING_COLS, false));
m_insertNullForMissing.setEnabled(m_append.isSelected());
// introduced in KNIME 3.3.1 default behavior was not failing e.g. false
m_failOnError.setSelected(settings.getBoolean(DBWriterNodeModel.KEY_FAIL_ON_ERROR, false));
// load SQL Types for each column
try {
NodeSettingsRO typeSett = settings.getNodeSettings(DBWriterNodeModel.CFG_SQL_TYPES);
m_typePanel.loadSettingsFrom(typeSett, (DataTableSpec) specs[0]);
} catch (InvalidSettingsException ise) {
m_typePanel.loadSettingsFrom(null, (DataTableSpec) specs[0]);
}
// load batch size
final int batchSize = settings.getInt(DBWriterNodeModel.KEY_BATCH_SIZE, DatabaseConnectionSettings.BATCH_WRITE_SIZE);
m_batchSize.setText(Integer.toString(batchSize));
if ((specs.length > 1) && (specs[1] instanceof DatabaseConnectionPortObjectSpec)) {
m_loginPane.setVisible(false);
} else {
m_loginPane.setVisible(true);
}
}
Aggregations