Search in sources :

Example 71 with NodeSettingsWO

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

the class ClusterNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    NodeSettings internalSettings = new NodeSettings("kMeans");
    internalSettings.addInt(CFG_DIMENSION, m_dimension);
    internalSettings.addInt(CFG_IGNORED_COLS, m_nrIgnoredColumns);
    internalSettings.addIntArray(CFG_COVERAGE, m_viewData.clusterCoverage());
    for (int i = 0; i < m_nrOfClusters.getIntValue(); i++) {
        internalSettings.addDoubleArray(CFG_CLUSTER + i, m_viewData.clusters()[i]);
    }
    internalSettings.addStringArray(CFG_FEATURE_NAMES, m_viewData.featureNames());
    if (m_enableHilite.getBooleanValue()) {
        NodeSettingsWO mapSet = internalSettings.addNodeSettings(CFG_HILITEMAPPING);
        ((DefaultHiLiteMapper) m_translator.getMapper()).save(mapSet);
    }
    File f = new File(internDir, SETTINGS_FILE_NAME);
    FileOutputStream out = new FileOutputStream(f);
    internalSettings.saveToXML(out);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) FileOutputStream(java.io.FileOutputStream) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) File(java.io.File)

Example 72 with NodeSettingsWO

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

the class ClusterNode method saveToXML.

/**
 * Saves the tree structure into the config. Stores the distance, the rowy
 * key (if its a leaf) and the left and right child.
 *
 * @param settings the config to save to.
 */
public void saveToXML(final NodeSettingsWO settings) {
    // each node stores its distance
    settings.addDouble(CFG_DISTANCE, m_dist);
    settings.addBoolean(CFG_LEAF, m_isLeaf);
    // if leaf node store the referring data point
    if (isLeaf()) {
        // TODO: store the whole data row
        settings.addInt(CFG_ROW_IDX, m_rowIdx);
    }
    // and the left and the right child
    NodeSettingsWO left = (NodeSettingsWO) settings.addConfig(CFG_LEFTCHILD);
    NodeSettingsWO right = (NodeSettingsWO) settings.addConfig(CFG_RIGHTCHILD);
    if (getFirstSubnode() != null && getSecondSubnode() != null) {
        getFirstSubnode().saveToXML(left);
        getSecondSubnode().saveToXML(right);
    }
}
Also used : NodeSettingsWO(org.knime.core.node.NodeSettingsWO)

Example 73 with NodeSettingsWO

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

the class WorkflowManager method loadSettings.

/**
 * {@inheritDoc}
 */
@Override
void loadSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    super.loadSettings(settings);
    NodeSettingsRO modelSettings = settings.getNodeSettings("model");
    Map<NodeID, QuickFormInputNode> nodes = findNodes(QuickFormInputNode.class, false);
    for (Entry<NodeID, QuickFormInputNode> entry : nodes.entrySet()) {
        NodeID id = entry.getKey();
        String nodeID = Integer.toString(id.getIndex());
        if (modelSettings.containsKey(nodeID)) {
            NodeSettingsRO conf = modelSettings.getNodeSettings(nodeID);
            QuickFormInputNode qfin = entry.getValue();
            NodeSettingsWO oldSettings = new NodeSettings(nodeID);
            qfin.getConfiguration().getValueConfiguration().saveValue(oldSettings);
            if (!conf.equals(oldSettings)) {
                // FIXME: likely not here but in the WFM...
                // not needed (actually nodes not work) because WFM itself
                // was reset completely if any one of the settings change.
                // SingleNodeContainer snc = (SingleNodeContainer)this.getNodeContainer(id);
                // snc.reset();
                @SuppressWarnings("unchecked") AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration> config = (AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration>) qfin.getConfiguration();
                if (config != null) {
                    config.getValueConfiguration().loadValueInModel(conf);
                    saveNodeSettingsToDefault(id);
                }
            // see above: not needed
            // this.configureNodeAndSuccessors(id, true);
            }
        }
    }
}
Also used : AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) NodeSettings(org.knime.core.node.NodeSettings) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode)

Example 74 with NodeSettingsWO

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

the class WorkflowManager method saveSettings.

/**
 * {@inheritDoc}
 */
@Override
void saveSettings(final NodeSettingsWO settings) {
    super.saveSettings(settings);
    // TODO: as we don't have a node model associated with the wfm, we must
    // do the same thing a dialog does when saving settings (it assumes
    // existance of a node).
    // Node.SettingsLoaderAndWriter l = new Node.SettingsLoaderAndWriter();
    // NodeSettings model = new NodeSettings("field_ignored");
    // NodeSettings variables;
    // l.setModelSettings(model);
    // l.setVariablesSettings(variables);
    // l.save(settings);
    NodeSettingsWO modelSettings = settings.addNodeSettings("model");
    for (Map.Entry<NodeID, QuickFormInputNode> e : findNodes(QuickFormInputNode.class, false).entrySet()) {
        String nodeID = Integer.toString(e.getKey().getIndex());
        NodeSettingsWO subSettings = modelSettings.addNodeSettings(nodeID);
        @SuppressWarnings("unchecked") AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration> config = (AbstractQuickFormConfiguration<AbstractQuickFormValueInConfiguration>) e.getValue().getConfiguration();
        if (config != null) {
            config.getValueConfiguration().saveValue(subSettings);
        }
    }
    SingleNodeContainerSettings s = new SingleNodeContainerSettings();
    NodeContainerSettings ncSet = new NodeContainerSettings();
    ncSet.save(settings);
    s.save(settings);
}
Also used : AbstractQuickFormValueInConfiguration(org.knime.core.quickform.AbstractQuickFormValueInConfiguration) AbstractQuickFormConfiguration(org.knime.core.quickform.AbstractQuickFormConfiguration) NodeSettingsWO(org.knime.core.node.NodeSettingsWO) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) SingleNodeContainerSettings(org.knime.core.node.workflow.SingleNodeContainer.SingleNodeContainerSettings) QuickFormInputNode(org.knime.core.quickform.in.QuickFormInputNode) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap)

Example 75 with NodeSettingsWO

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

the class AbstractQuickFormConfiguration method saveSettingsTo.

/**
 * Save config to argument.
 * @param settings To save to.
 */
public void saveSettingsTo(final NodeSettingsWO settings) {
    settings.addString("label", m_label);
    settings.addString("description", m_description);
    settings.addString("variableName", m_variableName);
    settings.addInt("weight", m_weight);
    settings.addBoolean("hide_in_wizard", m_hideInWizard);
    NodeSettingsWO valueSet = settings.addNodeSettings("value");
    getValueConfiguration().saveValue(valueSet);
}
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