use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class PolyRegLearnerSettings method loadSettingsFrom.
/**
* Loads the settings from the node settings object.
*
* @param settings the node settings
*
* @throws InvalidSettingsException if one of the settings is missing
*/
public void loadSettingsFrom(final NodeSettingsRO settings) throws InvalidSettingsException {
m_degree = settings.getInt("degree");
m_targetColumn = settings.getString("targetColumn");
m_maxRowsForView = settings.getInt("maxViewRows");
// added v2.1
boolean includeAll = settings.getBoolean("includeAll", false);
// added in 2.10
m_missingValueHandling = MissingValueHandling.valueOf(settings.getString(CFG_MISSING_VALUE_HANDLING, MissingValueHandling.ignore.name()));
if (settings.containsKey("selectedColumns")) {
// removed in 2.10
String[] included = settings.getStringArray("selectedColumns");
// we were able to load the old settings
String[] excluded = new String[0];
// but convert to new:
NodeSettings fakeSettings = createFakeSettings(m_filterConfiguration.getConfigRootName(), included, excluded, includeAll);
// added in 2.10
m_filterConfiguration.loadConfigurationInModel(fakeSettings);
} else {
// no previous config: we should use the new config
// added in 2.10
NodeSettingsRO filterSettings = settings.getNodeSettings(m_filterConfiguration.getConfigRootName());
NodeSettingsRO dtSettings = filterSettings.getNodeSettings("datatype");
NodeSettingsRO tlSettings = dtSettings.getNodeSettings("typelist");
if (!tlSettings.keySet().contains(DoubleValue.class.getName())) {
NodeSettings fakeSettings = createFakeSettings(m_filterConfiguration.getConfigRootName(), new String[0], new String[0], false);
m_filterConfiguration.loadConfigurationInModel(fakeSettings);
} else {
m_filterConfiguration.loadConfigurationInModel(settings);
}
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class PolyRegLearnerSettings method createFakeSettings.
/**
* Creates a fake configuration to help migrating the old configuration.
*
* @param configName Name of the {@link NodeSettings} to create.
* @param included The included column names.
* @param excluded The excluded column names.
* @param includeAll Should we include all columns that are not in the exclude list ({@code true}), or use the include list ({@code false})?
* @return The fake {@link NodeSettings}.
*/
static NodeSettings createFakeSettings(final String configName, final String[] included, final String[] excluded, final boolean includeAll) {
NodeSettings fakeSettings = new NodeSettings("FakeRoot");
NodeSettings filterSettings = (NodeSettings) fakeSettings.addNodeSettings(configName);
filterSettings.addString("filter-type", "STANDARD");
filterSettings.addStringArray("included_names", included);
filterSettings.addStringArray("excluded_names", excluded);
filterSettings.addString("enforce_option", (includeAll ? EnforceOption.EnforceExclusion : EnforceOption.EnforceInclusion).name());
NodeSettings datatypeSettings = (NodeSettings) filterSettings.addNodeSettings("datatype");
NodeSettingsWO typelist = datatypeSettings.addNodeSettings("typelist");
typelist.addBoolean(DoubleValue.class.getName(), true);
return fakeSettings;
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class NumericScorerNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
NodeSettings set = new NodeSettings("scorer");
set.addDouble(R2, m_rSquare);
set.addDouble(MEAN_ABS_ERROR, m_meanAbsError);
set.addDouble(MEAN_SQUARED_ERROR, m_meanSquaredError);
set.addDouble(RMSD, m_rmsd);
set.addDouble(MEAN_SIGNED_DIFFERENCE, m_meanSignedDifference);
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 HierarchicalClusterNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
File dataFile = new File(nodeInternDir, CFG_H_CLUST_DATA);
DataContainer.writeToZip(m_dataArray, dataFile, exec);
File distFile = new File(nodeInternDir, CFG_DIST_DATA);
DataContainer.writeToZip(m_fusionTable, distFile, exec);
NodeSettings settings = new NodeSettings(CFG_HCLUST);
// no data -> no clustering nodes
if (m_rootNode != null) {
m_rootNode.saveToXML(settings);
}
File f = new File(nodeInternDir, CFG_HCLUST);
FileOutputStream fos = new FileOutputStream(f);
settings.saveToXML(fos);
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class CreateBitVectorNodeModel 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);
}
Aggregations