use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class FixedHistogramDataModel 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 is 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);
final ConfigWO xConf = config.addConfig(CFG_X_COL_SPEC);
m_xColSpec.save(xConf);
if (exec != null) {
exec.setProgress(0.1, "Binning column specification saved");
exec.setMessage("Start saving aggregation columns...");
}
config.addBoolean(CFG_NOMINAL, m_binNominal);
config.addString(CFG_AGGR_METHOD, m_aggrMethod.getActionCommand());
final Config aggrConf = config.addConfig(CFG_AGGR_COLS);
aggrConf.addInt(CFG_AGGR_COL_COUNTER, m_aggrColumns.size());
int idx = 0;
for (final ColorColumn col : m_aggrColumns) {
final ConfigWO aggrColConf = aggrConf.addConfig(CFG_COLOR_COL + idx++);
col.save2File(aggrColConf, exec);
}
if (exec != null) {
exec.setProgress(0.3, "Start saving bins...");
}
final ConfigWO binsConf = config.addConfig(CFG_BINS);
binsConf.addInt(CFG_BIN_COUNTER, m_bins.size());
idx = 0;
for (final BinDataModel bin : m_bins) {
final ConfigWO binConf = binsConf.addConfig(CFG_BIN + idx++);
bin.save2File(binConf, exec);
}
final ConfigWO missingBin = binsConf.addConfig(CFG_MISSING_BIN);
m_missingValueBin.save2File(missingBin, exec);
if (m_invalidValueBin != null) {
final ConfigWO invalidBin = binsConf.addConfig(CFG_INVALID_BIN);
m_invalidValueBin.save2File(invalidBin, exec);
}
if (exec != null) {
exec.setProgress(0.8, "Start saving element colors...");
}
final List<Color> rowColors = getRowColors();
final ConfigWO colorColsConf = config.addConfig(CFG_COLOR_COLS);
colorColsConf.addInt(CFG_ROW_COLOR_COUNTER, rowColors.size());
idx = 0;
for (final Color color : rowColors) {
colorColsConf.addInt(CFG_ROW_COLOR + idx++, color.getRGB());
}
config.saveToXML(dataOS);
dataOS.flush();
dataOS.close();
os.flush();
os.close();
if (exec != null) {
exec.setProgress(1.0, "Histogram data model saved");
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class AbstractHistogramNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) {
if (m_tableSpec == null) {
return;
}
try {
final File settingsFile = new File(nodeInternDir, CFG_TABLESPEC_FILE);
final FileOutputStream settingsOS = new FileOutputStream(settingsFile);
final NodeSettings settings = new NodeSettings(CFG_TABLESPEC_TAG);
m_tableSpec.save(settings);
settings.saveToXML(settingsOS);
if (!new File(nodeInternDir, CFG_DATA_DIR_NAME).mkdir()) {
throw new Exception("Unable to create internal data directory");
}
final File histoDataDir = new File(nodeInternDir, CFG_DATA_DIR_NAME);
// save the data of the implementation
saveHistogramInternals(histoDataDir, exec);
} catch (final Exception e) {
LOGGER.warn("Error while saving table specification: " + e.getMessage());
}
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class EndcaseNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
if (m_enableHiliting) {
final NodeSettings config = new NodeSettings("hilite_mapping");
((DefaultHiLiteMapper) m_hiliteTranslator.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 CreateTempDirectoryNodeModel method saveInternals.
/**
* {@inheritDoc}
*/
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
if (m_id != null) {
// added in 3.1
try (OutputStream w = new FileOutputStream(new File(nodeInternDir, INTERNAL_FILE_NAME))) {
NodeSettings s = new NodeSettings("temp-dir-node");
s.addString("temp-folder-id", m_id);
s.saveToXML(w);
}
}
// else this was a workflow saved in 2.x and then loaded and saved/converted in 3.1
}
use of org.knime.core.node.NodeSettings in project knime-core by knime.
the class InteractivePieDataModel method save2File.
/**
* @param dataDir the data directory to write to
* @param exec the {@link ExecutionMonitor}
* @throws IOException if the output file could not be created
* @throws CanceledExecutionException if the saving 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 settingOS = new GZIPOutputStream(os);
final Config config = new NodeSettings(CFG_SETTING);
config.addBoolean(CFG_HILITING, supportsHiliting());
config.addBoolean(CFG_DETAILS, detailsAvailable());
config.saveToXML(settingOS);
exec.checkCanceled();
final File dataFile = new File(dataDir, CFG_DATA_FILE);
DataContainer.writeToZip(m_data, dataFile, exec);
}
Aggregations