Search in sources :

Example 51 with NodeSettingsWO

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

the class FileWorkflowPersistor method saveInPort.

protected static void saveInPort(final NodeSettingsWO settings, final WorkflowManager wm, final int portIndex) {
    WorkflowInPort inport = wm.getInPort(portIndex);
    settings.addInt("index", portIndex);
    settings.addString("name", inport.getPortName());
    NodeSettingsWO portTypeSettings = settings.addNodeSettings("type");
    inport.getPortType().save(portTypeSettings);
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 52 with NodeSettingsWO

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

the class ObsoleteMetaNodeFileWorkflowPersistor method loadInPortsSetting.

/**
 * {@inheritDoc}
 */
@Override
protected NodeSettingsRO loadInPortsSetting(final NodeSettingsRO settings) throws InvalidSettingsException {
    NodeSettings template = new NodeSettings("inports");
    for (int i = 0; i < m_dataInNodeIDs.length; i++) {
        NodeSettingsWO sub = template.addNodeSettings("data_" + i);
        sub.addInt("index", i);
        sub.addInt("node", m_dataInNodeIDs[i]);
        sub.addString("type", "data");
    }
    return template;
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 53 with NodeSettingsWO

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

the class DBWriterDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    m_loginPane.saveSettingsTo(settings, getCredentialsProvider());
    settings.addString(DBWriterNodeModel.KEY_TABLE_NAME, m_table.getText().trim());
    settings.addBoolean(DBWriterNodeModel.KEY_APPEND_DATA, m_append.isSelected());
    settings.addBoolean(DBWriterNodeModel.KEY_INSERT_NULL_FOR_MISSING_COLS, m_insertNullForMissing.isSelected());
    // introduced in KNIME 3.3.1 legacy behavior is not failing e.g. false
    settings.addBoolean(DBWriterNodeModel.KEY_FAIL_ON_ERROR, m_failOnError.isSelected());
    // save SQL Types for each column
    NodeSettingsWO typeSett = settings.addNodeSettings(DBWriterNodeModel.CFG_SQL_TYPES);
    m_typePanel.saveSettingsTo(typeSett);
    // save batch size
    final String strBatchSite = m_batchSize.getText().trim();
    if (strBatchSite.isEmpty()) {
        throw new InvalidSettingsException("Batch size must not be empty.");
    }
    try {
        final int intBatchSize = Integer.parseInt(strBatchSite);
        settings.addInt(DBWriterNodeModel.KEY_BATCH_SIZE, intBatchSize);
    } catch (final NumberFormatException nfe) {
        throw new InvalidSettingsException("Can't parse batch size \"" + strBatchSite + "\", reason: " + nfe.getMessage(), nfe);
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 54 with NodeSettingsWO

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

the class DBWriterNodeModel method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) {
    m_conn.saveConnection(settings);
    settings.addString(KEY_TABLE_NAME, m_tableName);
    settings.addBoolean(KEY_APPEND_DATA, m_append);
    settings.addBoolean(KEY_INSERT_NULL_FOR_MISSING_COLS, m_insertNullForMissingCols);
    settings.addBoolean(KEY_FAIL_ON_ERROR, m_failOnError);
    // save SQL Types mapping
    NodeSettingsWO typeSett = settings.addNodeSettings(CFG_SQL_TYPES);
    for (Map.Entry<String, String> e : m_types.entrySet()) {
        typeSett.addString(e.getKey(), e.getValue());
    }
    // save batch size
    settings.addInt(KEY_BATCH_SIZE, m_batchSize);
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 55 with NodeSettingsWO

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

the class DBColumnAggregationFunctionRow method saveFunctions.

/**
 * @param settings {@link NodeSettingsWO}
 * @param key the config key
 * @param rows the {@link DBColumnAggregationFunctionRow}s to save
 */
public static void saveFunctions(final NodeSettingsWO settings, final String key, final List<DBColumnAggregationFunctionRow> 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 DBColumnAggregationFunctionRow row = rows.get(i);
        DataColumnSpec spec = row.getColumnSpec();
        cfg.addString(CNFG_COL_NAMES, spec.getName());
        cfg.addDataType(CNFG_COL_TYPES, spec.getType());
        AbstractDBAggregationFunctionRow.saveFunction(cfg, row.getFunction());
    }
}
Also used : DataColumnSpec(org.knime.core.data.DataColumnSpec) 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