use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class RowKeyNodeModel2 method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
if (m_enableHilite.getBooleanValue()) {
final NodeSettings config = new NodeSettings("hilite_mapping");
final DefaultHiLiteMapper mapper = (DefaultHiLiteMapper) m_hilite.getMapper();
if (mapper != null) {
mapper.save(config);
}
config.saveToXML(new FileOutputStream(new File(nodeInternDir, INTERNALS_FILE_NAME)));
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class BoxPlotNodeModel method loadInternals.
/**
* {@inheritDoc}
*/
@Override
protected void loadInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
try {
File f = new File(nodeInternDir, FILE_NAME);
FileInputStream fis = new FileInputStream(f);
NodeSettingsRO settings = NodeSettings.loadFromXML(fis);
m_statistics = new LinkedHashMap<DataColumnSpec, double[]>();
m_mildOutliers = new LinkedHashMap<String, Map<Double, Set<RowKey>>>();
m_extremeOutliers = new LinkedHashMap<String, Map<Double, Set<RowKey>>>();
int nrOfCols = settings.getInt(CFG_NR_COLS);
for (int i = 0; i < nrOfCols; i++) {
NodeSettings subSetting = (NodeSettings) settings.getConfig(CFG_COL + i);
DataColumnSpec spec = DataColumnSpec.load(subSetting);
double[] stats = settings.getDoubleArray(CFG_STATS + spec.getName());
m_statistics.put(spec, stats);
loadOutliers(settings, spec);
}
File data = new File(nodeInternDir, ARRAY_FILE);
ContainerTable table = DataContainer.readFromZip(data);
m_array = new DefaultDataArray(table, 1, 2, exec);
} catch (Exception e) {
LOGGER.warn(e);
throw new IOException(e.getMessage());
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class BoxPlotNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
try {
NodeSettings settings = new NodeSettings(FILE_NAME);
settings.addInt(CFG_NR_COLS, m_statistics.size());
int i = 0;
for (DataColumnSpec spec : m_statistics.keySet()) {
NodeSettings colSetting = (NodeSettings) settings.addConfig(CFG_COL + i++);
spec.save(colSetting);
}
for (Map.Entry<DataColumnSpec, double[]> entry : m_statistics.entrySet()) {
String cfgName = entry.getKey().getName();
settings.addDoubleArray(CFG_STATS + cfgName, entry.getValue());
// mild outliers
Map<Double, Set<RowKey>> mildOutliers = m_mildOutliers.get(cfgName);
double[] mild = new double[mildOutliers.size()];
Config mildKeysSubConfig = settings.addConfig(CFG_MILD + CFG_ROW + cfgName);
int j = 0;
for (Map.Entry<Double, Set<RowKey>> mildEntry : mildOutliers.entrySet()) {
mild[j] = mildEntry.getKey();
// save method -> savely store string from now on
String[] keys = new String[mildEntry.getValue().size()];
int rk = 0;
for (RowKey key : mildEntry.getValue()) {
keys[rk] = key.getString();
rk++;
}
mildKeysSubConfig.addStringArray(CFG_MILD + CFG_ROW + cfgName + j, keys);
j++;
}
settings.addDoubleArray(CFG_MILD + cfgName, mild);
// settings.addDataCellArray(CFG_MILD + CFG_ROW + cfgName, mildKeys);
Map<Double, Set<RowKey>> extremeOutliers = m_extremeOutliers.get(cfgName);
double[] extreme = new double[extremeOutliers.size()];
int ext = 0;
Config extKeysSubConfig = settings.addConfig(CFG_EXTREME + CFG_ROW + cfgName);
for (Map.Entry<Double, Set<RowKey>> extrEntry : extremeOutliers.entrySet()) {
extreme[ext] = extrEntry.getKey();
// save method -> save store strings from now on
String[] keys = new String[extrEntry.getValue().size()];
int rk = 0;
for (RowKey key : extrEntry.getValue()) {
keys[rk] = key.getString();
rk++;
}
extKeysSubConfig.addStringArray(CFG_EXTREME + CFG_ROW + cfgName + ext, keys);
ext++;
}
settings.addDoubleArray(CFG_EXTREME + cfgName, extreme);
// settings.addDataCellArray(CFG_EXTREME + CFG_ROW + cfgName,
// extremeKeys);
}
File f = new File(nodeInternDir, FILE_NAME);
FileOutputStream fos = new FileOutputStream(f);
settings.saveToXML(fos);
File dataFile = new File(nodeInternDir, ARRAY_FILE);
DataContainer.writeToZip(m_array, dataFile, exec);
} catch (IOException e) {
LOGGER.warn(e);
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class TypeSelectionConfiguration method saveSettings.
/**
* {@inheritDoc}
*/
@Override
public void saveSettings(final NodeSettingsWO settings) {
settings.addInt("numberOfPanels", m_panelList.size());
List<DropPaneConfig> values = Arrays.asList(m_panelList.values().toArray(new DropPaneConfig[m_panelList.size()]));
Collections.sort(values);
for (int i = 0; i < values.size(); i++) {
DropPaneConfig dpc = values.get(i);
PaneConfigurationDialog p = dpc.getDialog();
NodeSettings n = new NodeSettings("dialogSettings_" + i);
p.saveSettings(n);
settings.addNodeSettings(n);
settings.addString("panelIndex_" + i, dpc.getSelectionAsString());
// settings.addInt("panelIndex" + i, p.getIndex());
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class EqualSizeSamplingNodeModel method configure.
/**
* {@inheritDoc}
*/
@Override
protected DataTableSpec[] configure(final DataTableSpec[] inSpecs) throws InvalidSettingsException {
if (m_configuration == null) {
EqualSizeSamplingConfiguration c = new EqualSizeSamplingConfiguration();
try {
c.loadConfigurationInDialog(new NodeSettings("empty"), inSpecs[0]);
} catch (NotConfigurableException e) {
throw new InvalidSettingsException("Can't auto-guess settings: " + "No nominal column in input");
}
m_configuration = c;
setWarningMessage("Auto-guessing \"" + c.getClassColumn() + "\" as selected nominal class column");
}
String classColumn = m_configuration.getClassColumn();
DataColumnSpec col = inSpecs[0].getColumnSpec(classColumn);
if (col == null) {
throw new InvalidSettingsException("No column \"" + classColumn + "\" in input data");
}
if (!col.getType().isCompatible(NominalValue.class)) {
throw new InvalidSettingsException("Class column \"" + classColumn + "\" is not a nominal attribute");
}
return new DataTableSpec[] { inSpecs[0] };
}
Aggregations