Search in sources :

Example 56 with NodeSettingsWO

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

the class DBPatternAggregationFunctionRow method saveFunctions.

/**
 * @param settings {@link NodeSettingsWO}
 * @param key the config key
 * @param rows the {@link DBPatternAggregationFunctionRow}s to save
 */
public static void saveFunctions(final NodeSettingsWO settings, final String key, final List<DBPatternAggregationFunctionRow> rows) {
    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 (rows == null) {
        return;
    }
    final NodeSettingsWO root = settings.addNodeSettings(key);
    for (int i = 0, length = rows.size(); i < length; i++) {
        final NodeSettingsWO cfg = root.addNodeSettings("f_" + i);
        final DBPatternAggregationFunctionRow row = rows.get(i);
        final String inputPattern = row.getInputPattern();
        final boolean isRegex = row.isRegex();
        cfg.addString(CNFG_INPUT_PATTERN, inputPattern);
        cfg.addBoolean(CNFG_IS_REGEX, isRegex);
        DBAggregationFunction function = row.getFunction();
        AbstractDBAggregationFunctionRow.saveFunction(cfg, function);
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DBAggregationFunction(org.knime.core.node.port.database.aggregation.DBAggregationFunction)

Example 57 with NodeSettingsWO

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

the class DBTableCreatorConfiguration method saveSettingsForModel.

/**
 * Saves settings for NodeModel
 *
 * @param settings NodeSettingsWO instance to save settings to
 */
public void saveSettingsForModel(final NodeSettingsWO settings) {
    m_schemaSettingsModel.saveSettingsTo(settings);
    m_tableNameSettingsModel.saveSettingsTo(settings);
    m_tempTableSettingsModel.saveSettingsTo(settings);
    m_ifNotExistsSettingsModel.saveSettingsTo(settings);
    m_useDynamicSettingsModel.saveSettingsTo(settings);
    m_additionalOptionsModel.saveSettingsTo(settings);
    for (Entry<String, List<RowElement>> entry : m_tableMap.entrySet()) {
        final NodeSettingsWO root = settings.addNodeSettings(entry.getKey());
        int idx = 0;
        for (RowElement elem : entry.getValue()) {
            final NodeSettingsWO cfg = root.addNodeSettings(elem.getPrefix() + idx++);
            elem.saveSettingsTo(cfg);
        }
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) ArrayList(java.util.ArrayList) List(java.util.List) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 58 with NodeSettingsWO

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

the class KeyElement method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) {
    settings.addString(CFG_KEY_NAME, getName());
    NodeSettingsWO cfg = settings.addNodeSettings(CFG_KEY_COLUMNS);
    int idx = 0;
    for (DBColumn col : getColumns()) {
        cfg.addString(ColumnElement.DEFAULT_PREFIX + idx++, col.getName());
    }
    settings.addBoolean(CFG_KEY_PRIMARY, isPrimaryKey());
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DBColumn(org.knime.core.node.port.database.tablecreator.DBColumn)

Example 59 with NodeSettingsWO

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

the class ColProperty method saveToConfiguration.

/**
 * Writes all settings from this object into the passed configuration
 * object.
 *
 * @param cfg the configuration object to write the settings into
 */
public void saveToConfiguration(final NodeSettingsWO cfg) {
    if (cfg == null) {
        throw new NullPointerException("Can't save column property into" + "null config.");
    }
    cfg.addBoolean(CFGKEY_USERSETTINGS, m_userSettings);
    cfg.addString(CFGKEY_MISSVALUE, m_missValuePattern);
    cfg.addString(CFGKEY_FORMAT, m_formatParameter);
    cfg.addBoolean(CFGKEY_READVALS, m_readPossValsFromFile);
    cfg.addBoolean(CFGKEY_SKIP, m_skipColumn);
    // add the stuff from the ColumnSpec
    cfg.addString(CFGKEY_COLNAME, m_colSpec.getName());
    cfg.addDataType(CFGKEY_COLTYPE, m_colSpec.getType());
    Set<DataCell> posValues = m_colSpec.getDomain().getValues();
    if ((posValues != null) && (posValues.size() > 0)) {
        NodeSettingsWO pVCfg = cfg.addNodeSettings(CFGKEY_POSVALUES);
        int count = 0;
        for (DataCell cell : posValues) {
            pVCfg.addDataCell(CFGKEY_POSSVAL + count, cell);
            count++;
        }
    }
    if ((m_colSpec.getDomain().getLowerBound() != null) || (m_colSpec.getDomain().getUpperBound() != null)) {
        cfg.addDataCell(CFGKEY_LOWERBOUND, m_colSpec.getDomain().getLowerBound());
        cfg.addDataCell(CFGKEY_UPPERBOUND, m_colSpec.getDomain().getUpperBound());
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DataCell(org.knime.core.data.DataCell)

Example 60 with NodeSettingsWO

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

the class MissingValueHandling2ColSetting method saveIndividualsColSettings.

/**
 * Saves the individual settings to a config object.
 *
 * @param colSettings the settings to write, may include meta settings
 *            (ignored)
 * @param settings to write to
 */
protected static void saveIndividualsColSettings(final MissingValueHandling2ColSetting[] colSettings, final NodeSettingsWO settings) {
    NodeSettingsWO individuals = settings.addNodeSettings(CFG_INDIVIDUAL);
    for (int i = 0; i < colSettings.length; i++) {
        if (colSettings[i].isMetaConfig()) {
            continue;
        }
        String id = colSettings[i].getDisplayName();
        NodeSettingsWO subConfig = individuals.addNodeSettings(id);
        colSettings[i].saveSettings(subConfig);
    }
}
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