use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class BitVectorGeneratorNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File internDir, final ExecutionMonitor exec) throws IOException {
NodeSettings internSettings = new NodeSettings(FILE_NAME);
internSettings.addInt(INT_CFG_ROWS, m_nrOfProcessedRows);
internSettings.addInt(INT_CFG_NR_ZEROS, m_totalNrOf0s);
internSettings.addInt(INT_CFG_NR_ONES, m_totalNrOf1s);
File f = new File(internDir, FILE_NAME);
FileOutputStream fos = new FileOutputStream(f);
internSettings.saveToXML(fos);
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class TreeEnsembleRegressionLearnerNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
File file;
ExecutionMonitor sub;
if (m_oldStyleEnsembleModel_deprecated != null) {
// old workflow (<2.10) loaded and saved ...
file = new File(nodeInternDir, INTERNAL_TREES_FILE);
OutputStream out = new GZIPOutputStream(new FileOutputStream(file));
sub = exec.createSubProgress(0.2);
m_oldStyleEnsembleModel_deprecated.save(out, sub);
out.close();
}
if (m_hiliteRowSample != null) {
file = new File(nodeInternDir, INTERNAL_DATASAMPLE_FILE);
sub = exec.createSubProgress(0.2);
DataContainer.writeToZip(m_hiliteRowSample, file, sub);
}
if (m_viewMessage != null) {
file = new File(nodeInternDir, INTERNAL_INFO_FILE);
NodeSettings sets = new NodeSettings("ensembleData");
sets.addString("view_warning", m_viewMessage);
sets.saveToXML(new FileOutputStream(file));
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class SorterNodeModelTest method testSaveSettingsTo.
/**
* Test method for {@link org.knime.base.node.preproc.sorter.SorterNodeModel#saveSettingsTo(...)}.
*/
@Test
public final void testSaveSettingsTo() throws InvalidSettingsException {
Assert.assertFalse(m_settings.containsKey(SorterNodeModel.INCLUDELIST_KEY));
Assert.assertFalse(m_settings.containsKey(SorterNodeModel.SORTORDER_KEY));
Assert.assertFalse(m_settings.containsKey(SorterNodeModel.SORTINMEMORY_KEY));
// save empty
m_snm.saveSettingsTo(m_settings);
// populate settings
boolean[] sortOrder = { true, false };
m_settings.addBooleanArray(SorterNodeModel.SORTORDER_KEY, sortOrder);
String[] inclCols = { "TestCol1", "TestCol2" };
m_settings.addStringArray(SorterNodeModel.INCLUDELIST_KEY, inclCols);
boolean sortInMemory = false;
m_settings.addBoolean(SorterNodeModel.SORTINMEMORY_KEY, sortInMemory);
m_snm.validateSettings(m_settings);
m_snm.loadValidatedSettingsFrom(m_settings);
NodeSettings newsettings = new NodeSettings("Sorter");
m_snm.saveSettingsTo(newsettings);
boolean[] sortOrderTest = newsettings.getBooleanArray(SorterNodeModel.SORTORDER_KEY);
Assert.assertTrue(sortOrderTest[0]);
Assert.assertFalse(sortOrderTest[1]);
Assert.assertEquals(2, sortOrderTest.length);
String[] inclColsTest = newsettings.getStringArray(SorterNodeModel.INCLUDELIST_KEY);
Assert.assertArrayEquals(inclCols, inclColsTest);
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class ConditionalBoxPlotNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
try {
NodeSettings settings = new NodeSettings("conditionalBoxPlotInternals");
settings.addInt("nrOfCols", m_statistics.size());
int i = 0;
for (DataColumnSpec spec : m_statistics.keySet()) {
NodeSettings colSetting = (NodeSettings) settings.addConfig("col" + (i++));
spec.save(colSetting);
}
if (m_numColSpec != null) {
m_numColSpec.save(settings.addConfig("numColSpec"));
}
for (Map.Entry<DataColumnSpec, double[]> entry : m_statistics.entrySet()) {
String colName = entry.getKey().getName();
settings.addDoubleArray("stats" + colName, entry.getValue());
Map<Double, Set<RowKey>> mildOutliers = m_mildOutliers.get(colName);
double[] mild = new double[mildOutliers.size()];
int mildIndex = 0;
for (Map.Entry<Double, Set<RowKey>> mEnt : mildOutliers.entrySet()) {
RowKey[] keys = mEnt.getValue().toArray(new RowKey[mEnt.getValue().size()]);
String[] mildKeys = new String[keys.length];
mild[mildIndex] = mEnt.getKey();
for (int j = 0; j < keys.length; j++) {
mildKeys[j] = keys[j].getString();
}
settings.addStringArray("mildKeys" + colName + mildIndex, mildKeys);
mildIndex++;
}
settings.addDoubleArray("mild" + colName, mild);
Map<Double, Set<RowKey>> extremeOutliers = m_extremeOutliers.get(colName);
double[] extr = new double[extremeOutliers.size()];
int extrIndex = 0;
for (Map.Entry<Double, Set<RowKey>> eEnt : extremeOutliers.entrySet()) {
RowKey[] keys = eEnt.getValue().toArray(new RowKey[eEnt.getValue().size()]);
String[] extrKeys = new String[keys.length];
extr[extrIndex] = eEnt.getKey();
for (int j = 0; j < keys.length; j++) {
extrKeys[j] = keys[j].getString();
}
settings.addStringArray("extremeKeys" + colName + extrIndex, extrKeys);
extrIndex++;
}
settings.addDoubleArray("extreme" + colName, extr);
}
File f = new File(nodeInternDir, "conditionalBoxPlotInternals");
FileOutputStream fos = new FileOutputStream(f);
settings.saveToXML(fos);
File dataFile = new File(nodeInternDir, "conditionalBoxPlotDataFile");
DataContainer.writeToZip(m_dataArray, dataFile, exec);
} catch (Exception e) {
throw new IOException("Unable to save internals: " + e.getMessage(), e);
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class InteractiveHistogramDataModel method save2File.
/**
* @param dataDir the data directory to write to
* @param exec the {@link ExecutionMonitor}
* @throws IOException if the file can't be created
* @throws CanceledExecutionException if the process was canceled
*/
public void save2File(final File dataDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
final File settingFile = new File(dataDir, CFG_SETTING_FILE);
final FileOutputStream os = new FileOutputStream(settingFile);
final GZIPOutputStream dataOS = new GZIPOutputStream(os);
final Config config = new NodeSettings(CFG_SETTING);
final List<Color> rowColors = getRowColors();
final ConfigWO colorColsConf = config.addConfig(CFG_COLOR_COLS);
colorColsConf.addInt(CFG_ROW_COLOR_COUNTER, rowColors.size());
int idx = 0;
for (final Color color : rowColors) {
colorColsConf.addInt(CFG_ROW_COLOR + idx++, color.getRGB());
}
config.saveToXML(dataOS);
exec.checkCanceled();
final File dataFile = new File(dataDir, CFG_DATA_FILE);
DataContainer.writeToZip(m_data, dataFile, exec);
}
Aggregations