Search in sources :

Example 21 with NodeSettings

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

the class TreeEnsembleClassificationLearnerNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException, CanceledExecutionException {
    File file;
    ExecutionMonitor sub;
    if (m_oldStyleEnsembleModel_deprecated != null) {
        // old workflow (<2.10) loaded and saved ...
        file = new File(nodeInternDir, INTERNAL_TREES_FILE);
        OutputStream out = new GZIPOutputStream(new FileOutputStream(file));
        sub = exec.createSubProgress(0.2);
        m_oldStyleEnsembleModel_deprecated.save(out, sub);
        out.close();
    }
    if (m_hiliteRowSample != null) {
        file = new File(nodeInternDir, INTERNAL_DATASAMPLE_FILE);
        sub = exec.createSubProgress(0.2);
        DataContainer.writeToZip(m_hiliteRowSample, file, sub);
    }
    if (m_viewMessage != null) {
        file = new File(nodeInternDir, INTERNAL_INFO_FILE);
        NodeSettings sets = new NodeSettings("ensembleData");
        sets.addString("view_warning", m_viewMessage);
        sets.saveToXML(new FileOutputStream(file));
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) GZIPOutputStream(java.util.zip.GZIPOutputStream) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) GZIPOutputStream(java.util.zip.GZIPOutputStream) FileOutputStream(java.io.FileOutputStream) ExecutionMonitor(org.knime.core.node.ExecutionMonitor) File(java.io.File)

Example 22 with NodeSettings

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

the class SorterNodeModelTest method setUp.

/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    m_snm = new SorterNodeModel();
    m_settings = new NodeSettings("Sorter");
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) Before(org.junit.Before)

Example 23 with NodeSettings

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

the class CreateTempDirectoryConfiguration method loadInDialog.

void loadInDialog(final NodeSettingsRO settings) {
    m_baseName = settings.getString("baseName", "knime_tc_");
    m_variableName = settings.getString("variableName", "temp_path");
    m_deleteOnReset = settings.getBoolean("deleteOnReset", true);
    NodeSettingsRO pairs;
    try {
        pairs = settings.getNodeSettings("variable_name_pairs");
    } catch (InvalidSettingsException ise) {
        pairs = new NodeSettings("empty");
    }
    Set<String> keySet = pairs.keySet();
    List<VarNameFileNamePair> pairList = new ArrayList<VarNameFileNamePair>();
    m_pairs = new VarNameFileNamePair[keySet.size()];
    for (String key : keySet) {
        try {
            NodeSettingsRO p = pairs.getNodeSettings(key);
            String varName = p.getString("variableName");
            String fileName = p.getString("fileName");
            if (varName != null && fileName != null) {
                pairList.add(new VarNameFileNamePair(varName, fileName));
            }
        } catch (InvalidSettingsException ise) {
        // ignore
        }
    }
    m_pairs = pairList.toArray(new VarNameFileNamePair[pairList.size()]);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ArrayList(java.util.ArrayList) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 24 with NodeSettings

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

the class CrosstabNodeModel method saveInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void saveInternals(final File nodeInternDir, final ExecutionMonitor exec) throws IOException {
    if (m_settings.getEnableHiliting()) {
        final NodeSettings config = new NodeSettings("hilite_mapping");
        final DefaultHiLiteMapper mapper = (DefaultHiLiteMapper) m_hilite.getMapper();
        if (mapper != null) {
            mapper.save(config);
        }
        config.saveToXML(new FileOutputStream(new File(nodeInternDir, INTERNALS_FILE_NAME)));
    }
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) FileOutputStream(java.io.FileOutputStream) DefaultHiLiteMapper(org.knime.core.node.property.hilite.DefaultHiLiteMapper) File(java.io.File)

Example 25 with NodeSettings

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

the class DataTableSpecCreatorTest method testAllPropertiesAndSaveLoad.

@Test
public void testAllPropertiesAndSaveLoad() throws Exception {
    DataColumnSpec[] cols1 = createColumnSpecs(5, "ColName");
    DataTableSpecCreator creator = new DataTableSpecCreator();
    creator.addColumns(cols1);
    String name = "expected name 'ae-";
    creator.setName(name);
    creator.putProperties(Collections.<String, String>emptyMap());
    creator.putProperties(Collections.singletonMap("key1", "value1"));
    creator.putProperty("key2", "value2");
    DataTableSpec spec = creator.createSpec();
    Map<String, String> properties = spec.getProperties();
    Assert.assertEquals(properties.get("key1"), "value1");
    Assert.assertEquals(properties.get("key2"), "value2");
    NodeSettings config = new NodeSettings("dummy");
    spec.save(config);
    DataTableSpec load = DataTableSpec.load(config);
    Map<String, String> loadProperties = load.getProperties();
    Assert.assertEquals(loadProperties.get("key1"), "value1");
    Assert.assertEquals(loadProperties.get("key2"), "value2");
    Assert.assertEquals(spec, load);
}
Also used : NodeSettings(org.knime.core.node.NodeSettings) 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