Search in sources :

Example 41 with NodeSettingsWO

use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.

the class DBColumnRenameNodeModel method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) {
    if (m_config != null) {
        final NodeSettingsWO subSettings = settings.addNodeSettings(CFG_SUB_CONFIG);
        m_config.save(subSettings);
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 42 with NodeSettingsWO

use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.

the class DataTypeAggregator method saveAggregators.

/**
 * @param settings the settings object to write to
 * @param key the unique settings key
 * @param aggregators the {@link DataTypeAggregator} objects to save
 */
public static void saveAggregators(final NodeSettingsWO settings, final String key, final Collection<DataTypeAggregator> aggregators) {
    if (key == null || key.isEmpty()) {
        throw new IllegalArgumentException("key must not be empty");
    }
    if (settings == null) {
        throw new NullPointerException("settings must not be null");
    }
    if (aggregators == null) {
        throw new NullPointerException("cols must not be null");
    }
    final NodeSettingsWO root = settings.addNodeSettings(key);
    int idx = 0;
    for (DataTypeAggregator aggr : aggregators) {
        final NodeSettingsWO cfg = root.addNodeSettings("f_" + idx++);
        cfg.addDataType(CNFG_DATA_TYPE, aggr.getDataType());
        cfg.addBoolean(CNFG_INCL_MISSING_VALS, aggr.inclMissingCells());
        AggregationMethodDecorator.saveMethod(cfg, aggr.getMethodTemplate());
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 43 with NodeSettingsWO

use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.

the class SettingsModelAggregationMethod method saveSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsForModel(final NodeSettingsWO settings) {
    final NodeSettingsWO subSettings = settings.addNodeSettings(m_configName);
    subSettings.addString(CFG_METHOD_ID, m_method.getId());
    subSettings.addBoolean(CFG_INCL_MISSING, m_method.inclMissingCells());
    subSettings.addString(CFG_VALUE_SEPARATOR, m_valueDelimiter);
    subSettings.addInt(CFG_MAX_UNIQUE_VALUES, m_maxUniqueValues);
    if (m_method.hasOptionalSettings()) {
        final NodeSettingsWO methodSettings = subSettings.addNodeSettings(CFG_METHOD_SETTINGS);
        m_method.saveSettingsTo(methodSettings);
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 44 with NodeSettingsWO

use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.

the class HiLiteCollectorNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    NodeSettings sett = new NodeSettings(KEY_ANNOTATIONS);
    RowKey[] cells = m_annotationMap.keySet().toArray(new RowKey[m_annotationMap.size()]);
    sett.addRowKeyArray("row_keys", cells);
    for (RowKey cell : cells) {
        NodeSettingsWO subSett = sett.addNodeSettings(cell.toString());
        for (Map.Entry<Integer, String> e : m_annotationMap.get(cell).entrySet()) {
            subSett.addString(e.getKey().toString(), e.getValue());
        }
    }
    File f = new File(nodeInternDir, KEY_ANNOTATIONS);
    sett.saveToXML(new FileOutputStream(f));
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) RowKey(org.knime.core.data.RowKey) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) FileOutputStream(java.io.FileOutputStream) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) File(java.io.File)

Example 45 with NodeSettingsWO

use of org.knime.core.node.NodeSettingsWO in project knime-core by knime.

the class TokenizerSettings method saveToConfiguration.

/**
 * Saves all settings into a <code>NodeSettings</code> object. Using the cfg
 * object to construct a new FileTokenizerSettings object should lead to an
 * object identical to this.
 *
 * @param cfg the config object the settings are stored into.
 */
public void saveToConfiguration(final NodeSettingsWO cfg) {
    if (cfg == null) {
        throw new NullPointerException("Can't save 'file " + "tokenizer settings' to null config!");
    }
    // save delimiters first
    NodeSettingsWO subCfg = cfg.addNodeSettings(CFGKEY_DELIMS);
    saveDelimitersToConfiguration(subCfg);
    // save quotes next
    subCfg = cfg.addNodeSettings(CFGKEY_QUOTES);
    saveQuotesToConfiguration(subCfg);
    // also, save comments
    subCfg = cfg.addNodeSettings(CFGKEY_COMMENTS);
    saveCommentsToConfiguration(subCfg);
    // do the whitespaces
    subCfg = cfg.addNodeSettings(CFGKEY_WHITES);
    saveWhitesToConfiguration(subCfg);
    // add the linecontinuatino character if defined
    String lineCont = getLineContinuationCharacter();
    if (lineCont != null) {
        assert lineCont.length() == 1;
        cfg.addChar(CFGKEY_LINECONT, lineCont.charAt(0));
    }
    // add the flag for combining multiple delimiters
    cfg.addBoolean(CFGKEY_COMBMULTI, getCombineMultipleDelimiters());
    cfg.addLong(CFGKEY_SKIPLINES, m_skipFirstLines);
    cfg.addBoolean(CFGKEY_LFINQUOTES, m_allowLFinQuotes);
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Aggregations

NodeSettingsWO (org.knime.core.node.NodeSettingsWO)111 NodeSettings (org.knime.core.node.NodeSettings)16 Map (java.util.Map)11 File (java.io.File)9 FileOutputStream (java.io.FileOutputStream)9 LinkedHashMap (java.util.LinkedHashMap)9 HashMap (java.util.HashMap)8 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)8 RowKey (org.knime.core.data.RowKey)6 DataCell (org.knime.core.data.DataCell)5 BufferedOutputStream (java.io.BufferedOutputStream)4 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)4 HashSet (java.util.HashSet)3 GZIPOutputStream (java.util.zip.GZIPOutputStream)3 DataRow (org.knime.core.data.DataRow)3 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)3 AbstractQuickFormConfiguration (org.knime.core.quickform.AbstractQuickFormConfiguration)3 AbstractQuickFormValueInConfiguration (org.knime.core.quickform.AbstractQuickFormValueInConfiguration)3 QuickFormInputNode (org.knime.core.quickform.in.QuickFormInputNode)3 MutableInteger (org.knime.core.util.MutableInteger)3