use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class TimeMissingValueHandlingColSetting method loadMetaColSettings.
/**
* Helper that load meta settings from a config object, used in NodeModel.
*
* @param settings to load from
* @return meta settings
* @throws InvalidSettingsException if errors occur
*/
static TimeMissingValueHandlingColSetting[] loadMetaColSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
NodeSettingsRO subConfig = settings.getNodeSettings(CFG_META);
Map<String, TimeMissingValueHandlingColSetting> map = loadSubConfigs(subConfig);
return map.values().toArray(new TimeMissingValueHandlingColSetting[0]);
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class TimeMissingValueHandlingColSetting method loadSubConfigs.
/**
* Get ColSetting objects in a map, mapping name to ColSetting.
*/
private static Map<String, TimeMissingValueHandlingColSetting> loadSubConfigs(final NodeSettingsRO settings) throws InvalidSettingsException {
LinkedHashMap<String, TimeMissingValueHandlingColSetting> result = new LinkedHashMap<String, TimeMissingValueHandlingColSetting>();
for (String key : settings.keySet()) {
NodeSettingsRO subConfig = settings.getNodeSettings(key);
TimeMissingValueHandlingColSetting local = new TimeMissingValueHandlingColSetting();
try {
local.loadSettings(subConfig);
} catch (InvalidSettingsException ise) {
throw new InvalidSettingsException("Unable to load sub config for key '" + key + "'", ise);
}
result.put(key, local);
}
return result;
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class Statistics2Table method load.
/**
* Load a new statistic table by the given settings object.
* @param sett to load this table from
* @return a new statistic table
* @throws InvalidSettingsException if the settings are corrupt
*/
public static Statistics2Table load(final NodeSettingsRO sett) throws InvalidSettingsException {
DataTableSpec spec = DataTableSpec.load(sett.getConfig("spec"));
Map<DataCell, Integer>[] nominalValues = new Map[spec.getNumColumns()];
for (int c = 0; c < nominalValues.length; c++) {
String name = spec.getColumnSpec(c).getName();
if (!sett.containsKey(name)) {
nominalValues[c] = null;
} else {
nominalValues[c] = new LinkedHashMap<DataCell, Integer>();
NodeSettingsRO subSett = sett.getNodeSettings(name);
for (String key : subSett.keySet()) {
NodeSettingsRO nomSett = subSett.getNodeSettings(key);
nominalValues[c].put(nomSett.getDataCell("key"), nomSett.getInt("value"));
}
}
}
double[] min = sett.getDoubleArray("minimum");
double[] max = sett.getDoubleArray("maximum");
double[] mean = sett.getDoubleArray("mean");
double[] var = sett.getDoubleArray("variance");
double[] median = sett.getDoubleArray("median");
double[] missings = sett.getDoubleArray("missings");
double[] sums = sett.getDoubleArray("sums");
// added with 2.7, fallback -1
int rowCount = sett.getInt("row_count", -1);
return new Statistics2Table(spec, min, max, mean, median, var, sums, missings, nominalValues, rowCount);
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class VariableToTableSettings method loadSettingsFrom.
/**
* Loads settings.
*
* @param settings to load from
* @throws InvalidSettingsException if settings not present
*/
public void loadSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
m_variablesOfInterest.clear();
m_includeAll = settings.getBoolean("all", false);
NodeSettingsRO sub = settings.getNodeSettings("variables");
if (sub == null) {
throw new InvalidSettingsException("No settings available");
}
for (String key : sub.keySet()) {
NodeSettingsRO sub2 = sub.getNodeSettings(key);
String name = sub2.getString("name");
String typeS = sub2.getString("type");
if (name == null || typeS == null) {
throw new InvalidSettingsException("Name and type must not be null.");
}
FlowVariable.Type type;
try {
type = FlowVariable.Type.valueOf(typeS);
} catch (IllegalArgumentException iae) {
throw new InvalidSettingsException("Can't parse type: " + typeS);
}
m_variablesOfInterest.add(new Pair<String, FlowVariable.Type>(name, type));
}
}
use of org.knime.core.node.NodeSettingsRO in project knime-core by knime.
the class BitVectorGeneratorNodeModel 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