Search in sources :

Example 46 with NodeSettingsRO

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

the class CorrelationOperator method loadSettingsFrom.

@Override
public void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec spec) throws NotConfigurableException {
    try {
        NodeSettingsRO colSettings = settings.getNodeSettings(COLUMN_SETTINGS);
        super.loadSettingsFrom(colSettings, spec);
        NodeSettingsRO corrSettings = settings.getNodeSettings(CORRELATION_SETTINGS);
        final DataTableSpec[] specs = new DataTableSpec[] { spec };
        getDialogComponent().loadSettingsFrom(corrSettings, specs);
    } catch (InvalidSettingsException e) {
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 47 with NodeSettingsRO

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

the class CorrelationOperator method validateSettings.

@Override
public void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    NodeSettingsRO colSettings = settings.getNodeSettings(COLUMN_SETTINGS);
    super.validateSettings(colSettings);
    NodeSettingsRO corrSettings = settings.getNodeSettings(CORRELATION_SETTINGS);
    m_settings.validateSettings(corrSettings);
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 48 with NodeSettingsRO

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

the class ScorerNodeModel method loadInternals.

/**
 * {@inheritDoc}
 */
@Override
protected void loadInternals(final File internDir, final ExecutionMonitor exec) throws IOException {
    // load internal values
    File fSett = new File(internDir, FILE_NAME_INTERNAL_SETT);
    if (fSett.exists() && fSett.canRead()) {
        NodeSettingsRO sett = NodeSettings.loadFromXML(new FileInputStream(fSett));
        try {
            m_correctCount = sett.getInt(CFG_CORRECT_COUNT);
            m_falseCount = sett.getInt(CFG_FALSE_COUNT);
            m_nrRows = sett.getInt(CFG_NUMBER_ROWS);
        } catch (InvalidSettingsException ise) {
            IOException ioe = new IOException();
            ioe.initCause(ise);
            throw ioe;
        }
    } else {
        throw new IOException("Could not load scorer internals. " + "File does not exist or can't be read: " + fSett);
    }
    // load scored table
    File fTable = new File(internDir, FILE_NAME_INTERNAL_RESULT);
    m_lastResult = DataContainer.readFromZip(fTable);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 49 with NodeSettingsRO

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

the class ColSetting method loadIndividualColSetting.

/**
 * Helper that individual settings from a config object, used in NodeDialog.
 *
 * @param settings to load from
 * @param spec ignored, used here to differ from method that is used by
 *            {@link org.knime.core.node.NodeModel}
 * @return individual settings
 */
protected static ColSetting[] loadIndividualColSetting(final NodeSettingsRO settings, final DataTableSpec spec) {
    // avoid checkstyle complain
    assert (spec == spec);
    Map<String, ColSetting> individHash = new LinkedHashMap<String, ColSetting>();
    if (settings.containsKey(CFG_INDIVIDUAL)) {
        NodeSettingsRO subConfig;
        try {
            subConfig = settings.getNodeSettings(CFG_INDIVIDUAL);
            Map<String, ColSetting> subDefaults = loadSubConfigs(subConfig);
            individHash.putAll(subDefaults);
        } catch (InvalidSettingsException ise) {
            LOGGER.debug("Error loading subconfig: " + CFG_INDIVIDUAL, ise);
        }
    }
    return individHash.values().toArray(new ColSetting[0]);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO) LinkedHashMap(java.util.LinkedHashMap)

Example 50 with NodeSettingsRO

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

the class ColSetting method loadIndividualColSetting.

/**
 * Helper that load individual settings from a config object, used in
 * NodeModel.
 *
 * @param settings to load from
 * @return individual settings
 * @throws InvalidSettingsException if errors occur
 */
protected static ColSetting[] loadIndividualColSetting(final NodeSettingsRO settings) throws InvalidSettingsException {
    NodeSettingsRO subConfig = settings.getNodeSettings(CFG_INDIVIDUAL);
    Map<String, ColSetting> map = loadSubConfigs(subConfig);
    return map.values().toArray(new ColSetting[0]);
}
Also used : NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Aggregations

NodeSettingsRO (org.knime.core.node.NodeSettingsRO)208 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)125 File (java.io.File)49 FileInputStream (java.io.FileInputStream)47 IOException (java.io.IOException)43 InputStream (java.io.InputStream)22 LinkedHashMap (java.util.LinkedHashMap)20 NodeSettings (org.knime.core.node.NodeSettings)20 BufferedInputStream (java.io.BufferedInputStream)19 ArrayList (java.util.ArrayList)16 GZIPInputStream (java.util.zip.GZIPInputStream)15 DataTableSpec (org.knime.core.data.DataTableSpec)14 Map (java.util.Map)11 ReferencedFile (org.knime.core.internal.ReferencedFile)11 BufferedDataTable (org.knime.core.node.BufferedDataTable)10 HashMap (java.util.HashMap)9 DataColumnSpec (org.knime.core.data.DataColumnSpec)9 RowKey (org.knime.core.data.RowKey)9 DataType (org.knime.core.data.DataType)8 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)8