use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class TokenizerSettings method addDelimitersFromConfiguration.
/*
* trys to add all delimiters defined in the passed configuration object. It
* expects the config to contain delimiters only. if anything illegal is
* defined in there, it is going to print an error message and is ignoring
* it.
*/
private void addDelimitersFromConfiguration(final NodeSettingsRO allDelims) {
for (String delimKey : allDelims.keySet()) {
// they should all start with "Delim"...
if (delimKey.indexOf(CFGKEY_DELIMCFG) != 0) {
LOGGER.warn("Illegal delimiter configuration '" + delimKey + "' (wrong prefix). Ignoring it!");
continue;
}
NodeSettingsRO delimSettings;
try {
delimSettings = allDelims.getNodeSettings(delimKey);
} catch (InvalidSettingsException ice) {
// we've checked the type before...
assert false;
LOGGER.warn("Illegal delimiter configuration '" + delimKey + "'. Ignoring it!");
continue;
}
try {
// try constructing and adding it
Delimiter delim = new Delimiter(delimSettings);
addDelimiterPattern(delim);
} catch (InvalidSettingsException ice) {
LOGGER.warn(ice.getMessage() + "Ignoring '" + delimKey + "'!");
continue;
} catch (IllegalArgumentException iae) {
LOGGER.error("Error delimiter configuration '" + delimKey + "'.");
LOGGER.error(iae.getMessage());
LOGGER.error("Ignoring delimiter!");
continue;
}
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class DBNumericBinnerConfig method loadValidatedSettingsFrom.
/**
* Loads validated settings from the {@link NodeSettings}.
*
* @param settings the {@link NodeSettings} object
* @throws InvalidSettingsException if the settings are invalid
*/
public void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
m_columnToBins.clear();
m_columnToAppended.clear();
final String[] columns = settings.getStringArray(CFG_NUMERIC_COLUMNS, new String[0]);
for (int i = 0; i < columns.length; i++) {
final NodeSettingsRO column = settings.getNodeSettings(columns[i]);
final String[] bins = column.keySet().toArray(new String[0]);
final NumericBin[] binnings = new NumericBin[bins.length];
for (int j = 0; j < bins.length; j++) {
final NodeSettingsRO bin = column.getNodeSettings(bins[j]);
binnings[j] = new NumericBin(bin);
}
m_columnToBins.put(columns[i], binnings);
final String appended = settings.getString(columns[i] + CFG_IS_APPENDED, null);
m_columnToAppended.put(columns[i], appended);
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class BinnerNodeModel method loadValidatedSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadValidatedSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
m_columnToBins.clear();
m_columnToAppended.clear();
String[] columns = settings.getStringArray(NUMERIC_COLUMNS, new String[0]);
for (int i = 0; i < columns.length; i++) {
NodeSettingsRO column = settings.getNodeSettings(columns[i].toString());
Set<String> bins = column.keySet();
Bin[] binnings = new Bin[bins.size()];
int s = 0;
for (String binKey : bins) {
NodeSettingsRO bin = column.getNodeSettings(binKey);
binnings[s] = new NumericBin(bin);
s++;
}
m_columnToBins.put(columns[i], binnings);
String appended = settings.getString(columns[i].toString() + IS_APPENDED, null);
m_columnToAppended.put(columns[i], appended);
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class MVSettings method loadSettings.
/**
* Loads the settings from a read only node settings object.
* @param settings the settings
* @param repair if true, missing factories are replaced by the do nothing factory, else an exception is thrown
* @return the missing value handling settings
* @throws InvalidSettingsException when the settings cannot be retrieved
*/
public String loadSettings(final NodeSettingsRO settings, final boolean repair) throws InvalidSettingsException {
if (!settings.containsKey(COL_SETTINGS_CFG) || !settings.containsKey(DT_SETTINGS_CFG)) {
return null;
}
StringBuffer warning = new StringBuffer();
m_columnSettings.clear();
m_generalSettings.clear();
NodeSettingsRO colSettings = settings.getNodeSettings(COL_SETTINGS_CFG);
for (String key : colSettings.keySet()) {
MVColumnSettings colSet = new MVColumnSettings(getHandlerFactoryManager());
String w = colSet.loadSettings(colSettings.getNodeSettings(key), repair);
if (w != null) {
if (warning.length() > 0) {
warning.append("\n");
}
warning.append(w);
}
this.m_columnSettings.add(colSet);
}
NodeSettingsRO dtSettings = settings.getNodeSettings(DT_SETTINGS_CFG);
for (String key : dtSettings.keySet()) {
MVIndividualSettings dtSetting = new MVIndividualSettings(getHandlerFactoryManager());
String w = dtSetting.loadSettings(dtSettings.getNodeSettings(key), repair);
if (w != null) {
if (warning.length() > 0) {
warning.append("\n");
}
warning.append(w);
}
this.m_generalSettings.put(key, dtSetting);
}
if (warning.length() == 0) {
return null;
} else {
return warning.toString();
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class CreateBitVectorNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File internDir, final ExecutionMonitor exec) throws IOException {
File f = new File(internDir, FILE_NAME);
FileInputStream fis = new FileInputStream(f);
NodeSettingsRO internSettings = NodeSettings.loadFromXML(fis);
try {
m_nrOfProcessedRows = internSettings.getInt(INT_CFG_ROWS);
m_totalNrOf0s = internSettings.getInt(INT_CFG_NR_ZEROS);
m_totalNrOf1s = internSettings.getInt(INT_CFG_NR_ONES);
} catch (InvalidSettingsException ise) {
throw new IOException(ise.getMessage());
}
}
Aggregations