Search in sources :

Example 31 with NodeSettings

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

the class UngroupNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    if (m_enableHilite.getBooleanValue()) {
        final NodeSettings config = new NodeSettings("hilite_mapping");
        final DefaultHiLiteMapper mapper = (DefaultHiLiteMapper) m_trans.getMapper();
        if (mapper != null) {
            // the mapper is null if the node produces an empty data table
            mapper.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 32 with NodeSettings

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

the class ValueCounterNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    if (m_settings.hiliting()) {
        NodeSettings s = new NodeSettings("Hiliting");
        ((DefaultHiLiteMapper) m_translator.getMapper()).save(s);
        File f = new File(nodeInternDir, "Hiliting.conf.gz");
        OutputStream out = new GZIPOutputStream(new BufferedOutputStream(new FileOutputStream(f)));
        s.saveToXML(out);
        out.close();
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) GZIPOutputStream(java.util.zip.GZIPOutputStream) BufferedOutputStream(java.io.BufferedOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) GZIPOutputStream(java.util.zip.GZIPOutputStream) FileOutputStream(java.io.FileOutputStream) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) File(java.io.File) BufferedOutputStream(java.io.BufferedOutputStream)

Example 33 with NodeSettings

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

the class EndifNodeModel 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 34 with NodeSettings

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

the class TestWorkflowLoopReset method testChangeConfigInExecutedLoop.

@Test
public void testChangeConfigInExecutedLoop() throws Exception {
    NodeSettings s = new NodeSettings("groupByModel");
    WorkflowManager m = getManager();
    m.saveNodeSettings(m_groupByInLoopNode3, s);
    executeAllAndWait();
    m.loadNodeSettings(m_groupByInLoopNode3, s);
    checkState(m_groupByInLoopNode3, InternalNodeContainerState.CONFIGURED);
    checkState(m_loopEndNode4, InternalNodeContainerState.CONFIGURED);
    checkState(m_loopStartNode2, InternalNodeContainerState.CONFIGURED);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) Test(org.junit.Test)

Example 35 with NodeSettings

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

the class TestWizardExec_Loop_Simple method testWizardStepThrough.

@Test
public void testWizardStepThrough() throws Exception {
    final WorkflowManager wfm = getManager();
    assertTrue("should have new wizard execution", WebResourceController.hasWizardExecution(wfm));
    checkState(m_tableCreateNode1, InternalNodeContainerState.CONFIGURED);
    WizardExecutionController wizardController = wfm.getWizardExecutionController();
    wizardController.stepFirst();
    waitWhile(wfm, new WizardHold(wfm));
    assertTrue("should have steps", wizardController.hasCurrentWizardPage());
    checkState(m_subnodeQueryStringBool15, InternalNodeContainerState.EXECUTED);
    // outside loop
    WizardPageContent currentWizardPage = wizardController.getCurrentWizardPage();
    // TODO: load something real
    wizardController.loadValuesIntoCurrentPage(Collections.<String, String>emptyMap());
    // TODO check IDs
    // assertEquals(m_subnodeQueryStringBool15.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(wfm));
    checkState(wfm, InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC, InternalNodeContainerState.UNCONFIGURED_MARKEDFOREXEC);
    checkState(m_subnodeQueryStringBool15, InternalNodeContainerState.EXECUTED);
    checkState(m_subnodeInLOOPQueryInt14, InternalNodeContainerState.EXECUTED);
    assertTrue("should have steps (loop iteration 0)", wizardController.hasCurrentWizardPage());
    // inside loop 1st time
    currentWizardPage = wizardController.getCurrentWizardPage();
    // assertEquals(m_subnodeInLOOPQueryInt14.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(wfm));
    checkState(m_subnodeInLOOPQueryInt14, InternalNodeContainerState.EXECUTED);
    checkState(m_loopEnd11, InternalNodeContainerState.CONFIGURED_MARKEDFOREXEC);
    assertTrue("should have steps (loop iteration 1)", wizardController.hasCurrentWizardPage());
    // inside loop 2nd time
    currentWizardPage = wizardController.getCurrentWizardPage();
    // assertEquals(m_subnodeInLOOPQueryInt14.toString(), currentWizardPage.getPageNodeID());
    wizardController.stepNext();
    waitWhile(wfm, new WizardHold(wfm));
    assertFalse("should have no more pages", wizardController.hasCurrentWizardPage());
    checkState(wfm, InternalNodeContainerState.EXECUTED);
    NodeSettings settings = new NodeSettings("test");
    wizardController.save(settings);
    int[] prompted = settings.getIntArray("promptedSubnodeIDs");
    assertTrue("should have saved prompted node ids (15) to settings", Arrays.equals(new int[] { 15 }, prompted));
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) WizardPageContent(org.knime.core.node.workflow.WebResourceController.WizardPageContent) Test(org.junit.Test)

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