Search in sources :

Example 36 with NodeSettings

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

the class NameFilterConfigurationTest method testSomeMissing.

@Test
public void testSomeMissing() throws Exception {
    NameFilterConfiguration conf = createConfiguration(EnforceOption.EnforceExclusion);
    testSomeMissing(conf);
    NodeSettings s = new NodeSettings("foobar");
    conf.saveConfiguration(s);
    conf = new NameFilterConfiguration("ignored");
    conf.loadConfigurationInModel(s);
    testSomeMissing(conf);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) Test(org.junit.Test)

Example 37 with NodeSettings

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

the class Bug4754_settingsValidationBeforeReset method testLoadBogusIntoNativeNode.

/**
 * Try to load invalid settings into native node.
 * @throws Exception ...
 */
@Test
public void testLoadBogusIntoNativeNode() throws Exception {
    WorkflowManager manager = getManager();
    checkStateOfMany(InternalNodeContainerState.CONFIGURED, m_tableCreator_1, m_rowSampler_4, m_tableChecker_5);
    NodeSettings s = new NodeSettings("native-node");
    manager.saveNodeSettings(m_rowSampler_4, s);
    NodeSettings bogusSettings = new NodeSettings("native-node");
    s.copyTo(bogusSettings);
    breakFirstIntSettings(bogusSettings);
    executeAllAndWait();
    checkState(manager, InternalNodeContainerState.EXECUTED);
    try {
        manager.loadNodeSettings(m_rowSampler_4, bogusSettings);
        fail("not expected to reach this point");
    } catch (InvalidSettingsException ise) {
    // expected
    }
    checkStateOfMany(InternalNodeContainerState.EXECUTED, m_tableCreator_1, m_rowSampler_4, m_tableChecker_5);
    reset(m_tableCreator_1);
    executeAllAndWait();
    checkState(manager, InternalNodeContainerState.EXECUTED);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Test(org.junit.Test)

Example 38 with NodeSettings

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

the class Bug4754_settingsValidationBeforeReset method testLoadBogusIntoMetaNode.

/**
 **Disabled** as meta nodes do no reasonable settings validation yet. Currently no bug open to "fix" it as
 * the old quickform nodes in conjunction with meta nodes are likely not be deprecated in the future.
 * @throws Exception ...
 */
@Test
public void testLoadBogusIntoMetaNode() throws Exception {
    Assume.assumeTrue("No settings validation in metanodes (yet)", false);
    WorkflowManager manager = getManager();
    checkStateOfMany(InternalNodeContainerState.CONFIGURED, m_tableCreator_1, m_metaNode_2, m_tableChecker_5);
    NodeSettings s = new NodeSettings("meta-node");
    manager.saveNodeSettings(m_metaNode_2, s);
    NodeSettings bogusSettings = new NodeSettings("meta-node");
    s.copyTo(bogusSettings);
    executeAllAndWait();
    checkState(manager, InternalNodeContainerState.EXECUTED);
    try {
        manager.loadNodeSettings(m_metaNode_2, bogusSettings);
        fail("not expected to reach this point");
    } catch (InvalidSettingsException ise) {
    // expected
    }
    checkStateOfMany(InternalNodeContainerState.EXECUTED, m_tableCreator_1, m_metaNode_2, m_tableChecker_5);
    reset(m_tableCreator_1);
    executeAllAndWait();
    checkState(manager, InternalNodeContainerState.EXECUTED);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) Test(org.junit.Test)

Example 39 with NodeSettings

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

the class AppendedRowsNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    if (m_enableHiliting) {
        final NodeSettings config = new NodeSettings("hilite_mapping");
        ((DefaultHiLiteMapper) m_hiliteTranslator.getMapper()).save(config);
        config.saveToXML(new GZIPOutputStream(new FileOutputStream(new File(nodeInternDir, "hilite_mapping.xml.gz"))));
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) GZIPOutputStream(java.util.zip.GZIPOutputStream) FileOutputStream(java.io.FileOutputStream) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) File(java.io.File)

Example 40 with NodeSettings

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

the class BasisFunctionLearnerNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File internDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    assert (m_modelInfo != null);
    // save model info
    exec.checkCanceled();
    exec.setProgress(0.1, "Saving model information");
    File file = new File(internDir, MODEL_INFO_FILE_NAME);
    m_modelInfo.saveToXML(new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(file))));
    // save hilite mapping
    exec.checkCanceled();
    exec.setProgress(0.5, "Saving hilite mapping");
    NodeSettings mapSettings = new NodeSettings(HILITE_MAPPING_FILE_NAME);
    DefaultHiLiteMapper mapper = (DefaultHiLiteMapper) m_translator.getMapper();
    mapper.save(mapSettings);
    File mappingFile = new File(internDir, HILITE_MAPPING_FILE_NAME);
    mapSettings.saveToXML(new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(mappingFile))));
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) GZIPOutputStream(java.util.zip.GZIPOutputStream) FileOutputStream(java.io.FileOutputStream) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper)

Aggregations

NodeSettings (org.knime.core.node.NodeSettings)156 File (java.io.File)58 FileOutputStream (java.io.FileOutputStream)57 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)37 GZIPOutputStream (java.util.zip.GZIPOutputStream)27 NodeSettingsRO (org.knime.core.node.NodeSettingsRO)17 Test (org.junit.Test)16 NodeSettingsWO (org.knime.core.node.NodeSettingsWO)16 DefaultHiLiteMapper (org.knime.core.node.property.hilite.DefaultHiLiteMapper)16 IOException (java.io.IOException)14 OutputStream (java.io.OutputStream)12 ExecutionMonitor (org.knime.core.node.ExecutionMonitor)11 BufferedOutputStream (java.io.BufferedOutputStream)9 Map (java.util.Map)8 RowKey (org.knime.core.data.RowKey)8 Config (org.knime.core.node.config.Config)8 LinkedHashMap (java.util.LinkedHashMap)7 DataTableSpec (org.knime.core.data.DataTableSpec)7 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)6 ArrayList (java.util.ArrayList)5