Search in sources :

Example 76 with NodeSettingsWO

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

the class FlowVariable method save.

/**
 * Saves this flow variable to a settings object. This method writes
 * directly into the argument object (no creating of intermediate child).
 * @param settings To save to.
 */
void save(final NodeSettingsWO settings) {
    settings.addString("name", getName());
    settings.addString("class", getType().name());
    switch(getType()) {
        case INTEGER:
            settings.addInt("value", getIntValue());
            break;
        case DOUBLE:
            settings.addDouble("value", getDoubleValue());
            break;
        case STRING:
            settings.addString("value", getStringValue());
            break;
        case CREDENTIALS:
            NodeSettingsWO subSettings = settings.addNodeSettings("value");
            m_valueCredentials.save(subSettings);
            break;
        default:
            assert false : "Unknown variable type: " + getType();
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 77 with NodeSettingsWO

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

the class MetaNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    for (Map.Entry<NodeID, MetaNodeDialogNode> e : m_nodes.entrySet()) {
        final NodeID key = e.getKey();
        if (e.getValue() instanceof QuickFormInputNode) {
            AbstractQuickFormConfiguration config = ((QuickFormInputNode) e.getValue()).getConfiguration();
            AbstractQuickFormValueInConfiguration valueConfig = config.createValueConfiguration();
            QuickFormConfigurationPanel value = m_quickFormInputNodePanels.get(key);
            value.saveSettings(valueConfig);
            NodeSettingsWO subSettings = settings.addNodeSettings((Integer.toString(key.getIndex())));
            valueConfig.saveValue(subSettings);
        } else if (e.getValue() instanceof DialogNode) {
            DialogNode dialogNode = (DialogNode) e.getValue();
            DialogNodePanel nodePanel = m_dialogNodePanels.get(key);
            DialogNodeValue nodeValue = nodePanel.getNodeValue();
            final String parameterName = SubNodeContainer.getDialogNodeParameterName(dialogNode, key);
            if (nodeValue != null) {
                NodeSettingsWO subSettings = settings.addNodeSettings((parameterName));
                nodeValue.saveToNodeSettings(subSettings);
            }
        }
    }
}
Also used : AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) QuickFormConfigurationPanel(org.knime.core.quickform.QuickFormConfigurationPanel) DialogNode(org.knime.core.node.dialog.DialogNode) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) DialogNodeValue(org.knime.core.node.dialog.DialogNodeValue) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DialogNodePanel(org.knime.core.node.dialog.DialogNodePanel)

Example 78 with NodeSettingsWO

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

the class ObsoleteMetaNodeFileWorkflowPersistor method loadSettingsForConnections.

/**
 * {@inheritDoc}
 */
@Override
protected NodeSettingsRO loadSettingsForConnections(final NodeSettingsRO set) throws InvalidSettingsException {
    NodeSettingsRO original = super.loadSettingsForConnections(set);
    if (!m_metaNodeType.equals(MetaNodeType.LOOPER)) {
        return original;
    }
    // looper nodes have two more connections (meta-in and out), faking them
    NodeSettings fake = new NodeSettings(original.getKey());
    original.copyTo(fake);
    String wfmInKey;
    int i = 0;
    do {
        wfmInKey = "workflow_connection" + i;
    } while (fake.containsKey(wfmInKey));
    NodeSettingsWO wfmIn = fake.addNodeSettings(wfmInKey);
    // ID is not read anyway...
    wfmIn.addInt("ID", Integer.MAX_VALUE - 1);
    wfmIn.addInt("sourceID", -1);
    wfmIn.addInt("sourcePort", 0);
    wfmIn.addInt("targetID", m_dataInNodeIDs[0]);
    wfmIn.addInt("targetPort", 0);
    String wfmOutKey;
    do {
        wfmOutKey = "workflow_connection" + i++;
    } while (fake.containsKey(wfmOutKey));
    NodeSettingsWO wfmOut = fake.addNodeSettings(wfmOutKey);
    // ID is not read ...
    wfmOut.addInt("ID", Integer.MAX_VALUE - 2);
    wfmOut.addInt("sourceID", m_dataOutNodeIDs[0]);
    wfmOut.addInt("sourcePort", 0);
    wfmOut.addInt("targetID", -1);
    wfmOut.addInt("targetPort", 0);
    return fake;
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 79 with NodeSettingsWO

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

the class ObsoleteMetaNodeFileWorkflowPersistor method loadOutPortsSetting.

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

Example 80 with NodeSettingsWO

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

the class SubNodeContainer method performSaveModelSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("rawtypes")
void performSaveModelSettingsTo(final NodeSettings modelSettings) {
    Map<NodeID, DialogNode> nodes = m_wfm.findNodes(DialogNode.class, false);
    for (Map.Entry<NodeID, DialogNode> entry : nodes.entrySet()) {
        final DialogNode dialogNode = entry.getValue();
        final String parameterName = getDialogNodeParameterName(dialogNode, entry.getKey());
        final DialogNodeValue dialogValue = dialogNode.getDialogValue();
        if (dialogValue != null) {
            NodeSettingsWO subSettings = modelSettings.addNodeSettings(parameterName);
            dialogValue.saveToNodeSettings(subSettings);
        }
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO) DialogNode(org.knime.core.node.dialog.DialogNode) MetaNodeDialogNode(org.knime.core.node.dialog.MetaNodeDialogNode) DialogNodeValue(org.knime.core.node.dialog.DialogNodeValue) Map(java.util.Map) HashMap(java.util.HashMap)

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