use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class ClusterNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
NodeSettings internalSettings = new NodeSettings("kMeans");
internalSettings.addInt(CFG_DIMENSION, m_dimension);
internalSettings.addInt(CFG_IGNORED_COLS, m_nrIgnoredColumns);
internalSettings.addIntArray(CFG_COVERAGE, m_viewData.clusterCoverage());
for (int i = 0; i < m_nrOfClusters.getIntValue(); i++) {
internalSettings.addDoubleArray(CFG_CLUSTER + i, m_viewData.clusters()[i]);
}
internalSettings.addStringArray(CFG_FEATURE_NAMES, m_viewData.featureNames());
if (m_enableHilite.getBooleanValue()) {
NodeSettingsWO mapSet = internalSettings.addNodeSettings(CFG_HILITEMAPPING);
((DefaultHiLiteMapper) m_translator.getMapper()).save(mapSet);
}
File f = new File(internDir, SETTINGS_FILE_NAME);
FileOutputStream out = new FileOutputStream(f);
internalSettings.saveToXML(out);
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class ClusterNode method saveToXML.
/**
* Saves the tree structure into the config. Stores the distance, the rowy
* key (if its a leaf) and the left and right child.
*
* @param settings the config to save to.
*/
public void saveToXML(final NodeSettingsWO settings) {
// each node stores its distance
settings.addDouble(CFG_DISTANCE, m_dist);
settings.addBoolean(CFG_LEAF, m_isLeaf);
// if leaf node store the referring data point
if (isLeaf()) {
// TODO: store the whole data row
settings.addInt(CFG_ROW_IDX, m_rowIdx);
}
// and the left and the right child
NodeSettingsWO left = (NodeSettingsWO) settings.addConfig(CFG_LEFTCHILD);
NodeSettingsWO right = (NodeSettingsWO) settings.addConfig(CFG_RIGHTCHILD);
if (getFirstSubnode() != null && getSecondSubnode() != null) {
getFirstSubnode().saveToXML(left);
getSecondSubnode().saveToXML(right);
}
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class WorkflowManager method loadSettings.
/**
* {@inheritDoc}
*/
@Override
void loadSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
super.loadSettings(settings);
NodeSettingsRO modelSettings = settings.getNodeSettings("model");
Map<NodeID, QuickFormInputNode> nodes = findNodes(QuickFormInputNode.class, false);
for (Entry<NodeID, QuickFormInputNode> entry : nodes.entrySet()) {
NodeID id = entry.getKey();
String nodeID = Integer.toString(id.getIndex());
if (modelSettings.containsKey(nodeID)) {
NodeSettingsRO conf = modelSettings.getNodeSettings(nodeID);
QuickFormInputNode qfin = entry.getValue();
NodeSettingsWO oldSettings = new NodeSettings(nodeID);
qfin.getConfiguration().getValueConfiguration().saveValue(oldSettings);
if (!conf.equals(oldSettings)) {
// FIXME: likely not here but in the WFM...
// not needed (actually nodes not work) because WFM itself
// was reset completely if any one of the settings change.
// SingleNodeContainer snc = (SingleNodeContainer)this.getNodeContainer(id);
// snc.reset();
@SuppressWarnings("unchecked") AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration> config = (AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration>) qfin.getConfiguration();
if (config != null) {
config.getValueConfiguration().loadValueInModel(conf);
saveNodeSettingsToDefault(id);
}
// see above: not needed
// this.configureNodeAndSuccessors(id, true);
}
}
}
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class WorkflowManager method saveSettings.
/**
* {@inheritDoc}
*/
@Override
void saveSettings(final NodeSettingsWO settings) {
super.saveSettings(settings);
// TODO: as we don't have a node model associated with the wfm, we must
// do the same thing a dialog does when saving settings (it assumes
// existance of a node).
// Node.SettingsLoaderAndWriter l = new Node.SettingsLoaderAndWriter();
// NodeSettings model = new NodeSettings("field_ignored");
// NodeSettings variables;
// l.setModelSettings(model);
// l.setVariablesSettings(variables);
// l.save(settings);
NodeSettingsWO modelSettings = settings.addNodeSettings("model");
for (Map.Entry<NodeID, QuickFormInputNode> e : findNodes(QuickFormInputNode.class, false).entrySet()) {
String nodeID = Integer.toString(e.getKey().getIndex());
NodeSettingsWO subSettings = modelSettings.addNodeSettings(nodeID);
@SuppressWarnings("unchecked") AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration> config = (AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration>) e.getValue().getConfiguration();
if (config != null) {
config.getValueConfiguration().saveValue(subSettings);
}
}
SingleNodeContainerSettings s = new SingleNodeContainerSettings();
NodeContainerSettings ncSet = new NodeContainerSettings();
ncSet.save(settings);
s.save(settings);
}
use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.
the class AbstractQuickFormConfiguration method saveSettingsTo.
/**
* Save config to argument.
* @param settings To save to.
*/
public void saveSettingsTo(final NodeSettingsWO settings) {
settings.addString("label", m_label);
settings.addString("description", m_description);
settings.addString("variableName", m_variableName);
settings.addInt("weight", m_weight);
settings.addBoolean("hide_in_wizard", m_hideInWizard);
NodeSettingsWO valueSet = settings.addNodeSettings("value");
getValueConfiguration().saveValue(valueSet);
}
Aggregations