use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class FixedWidthColProperty method saveToConfiguration.
/**
* @param cfg the settings object where we save our properties
*/
public void saveToConfiguration(final NodeSettingsWO cfg) {
if (cfg == null) {
throw new NullPointerException("Can't save column property into null config.");
}
cfg.addInt(CFGKEY_COLWIDTH, m_width);
cfg.addBoolean(CFGKEY_INCLUDE, m_include);
cfg.addString(CFGKEY_MISSVALPAT, m_missingValuePattern);
cfg.addString(CFGKEY_FORMAT, m_formatParameter);
// add the stuff from the ColumnSpec
cfg.addString(CFGKEY_COLNAME, m_colSpec.getName());
cfg.addDataType(CFGKEY_COLTYPE, m_colSpec.getType());
Set<DataCell> posValues = m_colSpec.getDomain().getValues();
if ((posValues != null) && (posValues.size() > 0)) {
NodeSettingsWO pVCfg = cfg.addNodeSettings(CFGKEY_POSVALUES);
int count = 0;
for (DataCell cell : posValues) {
pVCfg.addDataCell(CFGKEY_POSSVAL + count, cell);
count++;
}
}
if ((m_colSpec.getDomain().getLowerBound() != null) || (m_colSpec.getDomain().getUpperBound() != null)) {
cfg.addDataCell(CFGKEY_LOWERBOUND, m_colSpec.getDomain().getLowerBound());
cfg.addDataCell(CFGKEY_UPPERBOUND, m_colSpec.getDomain().getUpperBound());
}
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class Statistics3Table method save.
/**
* Saves this object to the given settings object.
*
* @param sett this object is saved to
*/
public void save(final NodeSettingsWO sett) {
m_spec.save(sett.addConfig("spec"));
sett.addDataCellArray("minimumCells", m_minCells);
sett.addDataCellArray("maximumCells", m_maxCells);
sett.addDataCellArray("minimumNonInf", m_minNonInfValues);
sett.addDataCellArray("maximumNonInf", m_maxNonInfValues);
sett.addDoubleArray("mean", m_meanValues);
sett.addDoubleArray("variance", m_varianceValues);
sett.addDoubleArray("median", m_median);
sett.addIntArray("missings", m_missingValueCnt);
sett.addIntArray("nans", m_nanValueCnt);
sett.addIntArray("posInfs", m_posInfinityValueCnt);
sett.addIntArray("negInfs", m_negInfinityValueCnt);
sett.addDoubleArray("sums", m_sum);
sett.addDoubleArray("skewness", m_skewness);
sett.addDoubleArray("kurtosis", m_kurtosis);
sett.addInt("row_count", m_rowCount);
for (int c = 0; c < m_nominalValues.size(); c++) {
if (m_nominalValues.get(c) != null) {
NodeSettingsWO subSett = sett.addNodeSettings(m_spec.getColumnSpec(c).getName());
for (Map.Entry<DataCell, Integer> e : m_nominalValues.get(c).entrySet()) {
NodeSettingsWO nomSett = subSett.addNodeSettings(e.getKey().toString());
nomSett.addDataCell("key", e.getKey());
nomSett.addInt("value", e.getValue());
}
}
}
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class PatternAggregator method saveAggregators.
/**
* @param settings the settings object to write to
* @param key the unique settings key
* @param aggregators the {@link PatternAggregator} objects to save
*/
public static void saveAggregators(final NodeSettingsWO settings, final String key, final Collection<PatternAggregator> aggregators) {
if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("key must not be empty");
}
if (settings == null) {
throw new NullPointerException("settings must not be null");
}
if (aggregators == null) {
return;
}
final NodeSettingsWO root = settings.addNodeSettings(key);
int idx = 0;
for (PatternAggregator aggr : aggregators) {
final NodeSettingsWO cfg = root.addNodeSettings("f_" + idx++);
cfg.addString(CNFG_INPUT_PATTERN, aggr.getInputPattern());
cfg.addBoolean(CNFG_IS_REGEX, aggr.m_isRegex);
cfg.addBoolean(CNFG_INCL_MISSING_VALS, aggr.inclMissingCells());
AggregationMethodDecorator.saveMethod(cfg, aggr.getMethodTemplate());
}
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class CorrelationOperator method saveSettingsTo.
@Override
public void saveSettingsTo(final NodeSettingsWO settings) {
NodeSettingsWO colSettings = settings.addNodeSettings(COLUMN_SETTINGS);
super.saveSettingsTo(colSettings);
NodeSettingsWO corrSettings = settings.addNodeSettings(CORRELATION_SETTINGS);
m_settings.saveSettingsTo(corrSettings);
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class ColumnAggregator method saveColumnAggregators.
/**
* @param settings the settings object to write to
* @param key the unique settings key or <code>null</code> if the default should be used
* @param aggregators the {@link ColumnAggregator} objects to save
* @since 2.11
*/
public static void saveColumnAggregators(final NodeSettingsWO settings, final String key, final List<ColumnAggregator> aggregators) {
if (settings == null) {
throw new NullPointerException("settings must not be null");
}
if (aggregators == null) {
throw new NullPointerException("aggregators must not be null");
}
final String[] colNames = new String[aggregators.size()];
final String[] aggrMethods = new String[aggregators.size()];
final boolean[] inclMissingVals = new boolean[aggregators.size()];
final DataType[] types = new DataType[aggregators.size()];
final Config cnfg;
if (key == null || key.isEmpty()) {
cnfg = settings.addConfig(CNFG_AGGR_COL_SECTION);
} else {
cnfg = settings.addConfig(key);
}
final NodeSettingsWO operatorSettings = settings.addNodeSettings(CNFG_OPERATOR_SETTINGS);
final Map<String, MutableInteger> idMap = new HashMap<>();
for (int i = 0, length = aggregators.size(); i < length; i++) {
final ColumnAggregator colAggr = aggregators.get(i);
colNames[i] = colAggr.getOriginalColName();
final AggregationMethod method = colAggr.getMethodTemplate();
aggrMethods[i] = colAggr.getId();
types[i] = colAggr.getOriginalDataType();
inclMissingVals[i] = colAggr.inclMissingCells();
if (colAggr.hasOptionalSettings()) {
try {
final NodeSettingsWO operatorSetting = operatorSettings.addNodeSettings(createSettingsKey(idMap, colAggr));
method.saveSettingsTo(operatorSetting);
} catch (Exception e) {
LOGGER.error("Exception while saving settings for aggreation operator '" + colAggr.getId() + "', reason: " + e.getMessage());
}
}
}
cnfg.addStringArray(CNFG_COL_NAMES, colNames);
cnfg.addDataTypeArray(CNFG_COL_TYPES, types);
cnfg.addStringArray(CNFG_AGGR_METHODS, aggrMethods);
cnfg.addBooleanArray(CNFG_INCL_MISSING_VALS, inclMissingVals);
}
Aggregations