use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class Unpivot2NodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
if (m_enableHilite.getBooleanValue()) {
final NodeSettings config = new NodeSettings("hilite_mapping");
((DefaultHiLiteMapper) m_trans.getMapper()).save(config);
config.saveToXML(new GZIPOutputStream(new FileOutputStream(new File(nodeInternDir, "hilite_mapping.xml.gz"))));
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class FixedPieDataModel method save2File.
/**
* @param directory the directory to write to
* @param exec the {@link ExecutionMonitor} to provide progress messages
* @throws IOException if a file exception occurs
* @throws CanceledExecutionException if the operation was canceled
*/
public void save2File(final File directory, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
if (exec != null) {
exec.setProgress(0.0, "Start saving histogram data model to file");
}
final File dataFile = new File(directory, CFG_DATA_FILE);
final FileOutputStream os = new FileOutputStream(dataFile);
final GZIPOutputStream dataOS = new GZIPOutputStream(os);
final Config config = new NodeSettings(CFG_DATA);
config.addString(CFG_PIE_COL, m_pieCol);
config.addBoolean(CFG_NUMERIC_PIE_COL, m_numericPieCol);
config.addString(CFG_AGGR_COL, m_aggrCol);
config.addBoolean(CFG_HILITING, supportsHiliting());
config.addBoolean(CFG_DETAILS, detailsAvailable());
config.addBoolean(CFG_IS_COLOR_COLUMN, m_isColorColumn);
if (exec != null) {
exec.setProgress(0.3, "Start saving sections...");
exec.checkCanceled();
}
final Config sectionsConf = config.addConfig(CFG_SECTIONS);
sectionsConf.addInt(CFG_SECTION_COUNT, m_sections.size());
int idx = 0;
for (final PieSectionDataModel section : m_sections) {
final ConfigWO sectionConf = sectionsConf.addConfig(CFG_SECTION + idx++);
section.save2File(sectionConf, exec);
}
if (exec != null) {
exec.setProgress(0.8, "Start saving missing section...");
exec.checkCanceled();
}
final ConfigWO missingSection = sectionsConf.addConfig(CFG_MISSING_SECTION);
m_missingSection.save2File(missingSection, exec);
config.saveToXML(dataOS);
dataOS.flush();
dataOS.close();
os.flush();
os.close();
if (exec != null) {
exec.setProgress(1.0, "Pie data model saved");
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class PolyRegLearnerDialog method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
DataTableSpec dataTableSpec = (DataTableSpec) specs[0];
try {
m_settings.loadSettingsInDialog(settings, dataTableSpec);
} catch (InvalidSettingsException ex) {
LinkedHashSet<String> defSelected = new LinkedHashSet<String>();
for (DataColumnSpec s : dataTableSpec) {
if (s.getType().isCompatible(DoubleValue.class)) {
defSelected.add(s.getName());
}
}
NodeSettings fakeSettings = PolyRegLearnerSettings.createFakeSettings("column filter", defSelected.toArray(new String[0]), new String[0], false);
DataColumnSpecFilterConfiguration conf = new DataColumnSpecFilterConfiguration("column filter");
conf.loadConfigurationInDialog(fakeSettings, dataTableSpec);
m_settings.getFilterConfiguration().loadConfigurationInDialog(fakeSettings, dataTableSpec);
// for the rest: ignore it, defaults are used instead
}
m_targetColumn.update(dataTableSpec, m_settings.getTargetColumn());
m_degree.getModel().setValue(m_settings.getDegree());
m_viewRows.getModel().setValue(m_settings.getMaxRowsForView());
m_colSelectionPanel.loadConfiguration(m_settings.getFilterConfiguration(), dataTableSpec);
m_colSelectionPanel.resetHiding();
m_colSelectionPanel.hideNames((DataColumnSpec) m_targetColumn.getSelectedItem());
m_missingValueHandlingIgnore.setSelected(m_settings.getMissingValueHandling().equals(MissingValueHandling.ignore));
m_missingValueHandlingFail.setSelected(m_settings.getMissingValueHandling().equals(MissingValueHandling.fail));
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class AccuracyScorerNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File internDir, final ExecutionMonitor exec) throws IOException {
NodeSettings set = new NodeSettings("scorer");
set.addInt("correctCount", m_viewData.getCorrectCount());
set.addInt("falseCount", m_viewData.getFalseCount());
set.addInt("nrRows", m_viewData.getNrRows());
set.addStringArray("values", m_viewData.getTargetValues());
final int targetValueCount = m_viewData.getTargetValues().length;
for (int i = 0; i < targetValueCount; i++) {
NodeSettingsWO sub = set.addNodeSettings(m_viewData.getTargetValues()[i]);
sub.addIntArray("scorerCount", m_viewData.getScorerCount()[i]);
NodeSettingsWO subSub = sub.addNodeSettings("hilightMap");
for (int j = 0; j < targetValueCount; j++) {
NodeSettingsWO sub3 = subSub.addNodeSettings(m_viewData.getTargetValues()[j]);
RowKey[] rowKeys = m_viewData.getKeyStore()[i][j].toArray(new RowKey[m_viewData.getKeyStore()[i][j].size()]);
sub3.addRowKeyArray("keyStore", rowKeys);
}
}
set.saveToXML(new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(new File(internDir, "internals.xml.gz")))));
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class EntropyCalculator method save.
/**
* Saves the structure of this objec to the target directory.
*
* @param dir to save to
* @param exec for progress/cancel
* @throws IOException if that fails
* @throws CanceledExecutionException if canceled
*/
public void save(final File dir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
File scorerFile = new File(dir, FILE_SCORER_TABLE);
DataContainer.writeToZip(m_scoreTable, scorerFile, exec);
File settingsFile = new File(dir, FILE_SETTINGS);
NodeSettings config = new NodeSettings(CFG_SETTINGS);
config.addDouble(CFG_ENTROPY, m_entropy);
config.addDouble(CFG_QUALITY, m_quality);
config.addInt(CFG_PAT_IN_CLUSTER, m_patternsInClusters);
config.addInt(CFG_PAT_IN_REFERENCE, m_patternsInReference);
config.addInt(CFG_NR_CLUSTER, m_nrClusters);
config.addInt(CFG_NR_REFERENCES, m_nrReference);
NodeSettingsWO subConfig = config.addNodeSettings(CFG_CLUSTERING_MAP);
for (Map.Entry<RowKey, Set<RowKey>> entry : m_clusteringMap.entrySet()) {
exec.checkCanceled();
RowKey key = entry.getKey();
Set<RowKey> values = entry.getValue();
NodeSettingsWO keySettings = subConfig.addNodeSettings(key.toString());
keySettings.addRowKey(key.toString(), key);
keySettings.addRowKeyArray(CFG_MAPPED_KEYS, values.toArray(new RowKey[values.size()]));
}
config.saveToXML(new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(settingsFile))));
}
Aggregations