Search in sources :

Example 81 with NodeSettingsRO

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

the class TypeFilterConfigurationImpl method loadConfigurationInDialog.

/**
 * Loads the configuration from the given settings object. Sets defaults if invalid.
 * @param settings Settings object containing the configuration.
 * @param tableSpec The column specs to find the available types.
 */
void loadConfigurationInDialog(final NodeSettingsRO settings, final DataTableSpec tableSpec) {
    m_selections.clear();
    NodeSettingsRO typeListSettings;
    try {
        typeListSettings = settings.getNodeSettings(CFG_TYPELIST);
        for (String key : typeListSettings.keySet()) {
            m_selections.put(key, typeListSettings.getBoolean(key, false));
        }
    } catch (InvalidSettingsException e) {
    // ignore
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 82 with NodeSettingsRO

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

the class NameFilterConfiguration method loadConfigurationInModel.

/**
 * Load config from argument.
 *
 * <p>Subclasses should not define another method with similar signature and then
 * call that new method to read from the passed NodeSettings object but instead overwrite
 * {@link #loadConfigurationInModelChild(NodeSettingsRO)}.
 *
 * @param settings To load from.
 * @throws InvalidSettingsException If inconsistent/missing.
 */
public final void loadConfigurationInModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    NodeSettingsRO subSettings = settings.getNodeSettings(m_configRootName);
    String type = subSettings.getString(KEY_FILTER_TYPE);
    if (type == null || !verifyType(type)) {
        throw new InvalidSettingsException("Invalid type: " + type);
    }
    m_type = type;
    m_enforceOption = EnforceOption.parse(subSettings.getString(KEY_ENFORCE_OPTION));
    m_includeList = subSettings.getStringArray(KEY_INCLUDED_NAMES);
    m_excludeList = subSettings.getStringArray(KEY_EXCLUDED_NAMES);
    try {
        NodeSettingsRO configSettings = subSettings.getNodeSettings(PatternFilterConfiguration.TYPE);
        m_patternConfig.loadConfigurationInModel(configSettings);
    } catch (InvalidSettingsException e) {
        if (PatternFilterConfiguration.TYPE.equals(m_type)) {
            throw e;
        }
    // Otherwise leave at default settings as pattern matcher is not active (might be prior 2.9)
    }
    loadConfigurationInModelChild(subSettings);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 83 with NodeSettingsRO

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

the class SettingsModelColumnName method loadSettingsForDialog.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsForDialog(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    final boolean oldUseRowID = m_useRowID;
    try {
        final NodeSettingsRO subSettings = settings.getNodeSettings(m_configName);
        final boolean useRowId = subSettings.getBoolean(CFG_ROWID);
        final boolean rowIDChanged = setUseRowID(useRowId);
        final String oldStringVal = super.getStringValue();
        super.loadSettingsForDialog(subSettings, specs);
        final String newStringVal = super.getStringValue();
        boolean stringValChanged;
        if (oldStringVal == null) {
            stringValChanged = newStringVal != null;
        } else {
            stringValChanged = !oldStringVal.equals(newStringVal);
        }
        if (rowIDChanged && !stringValChanged) {
            // If the column name has changed
            // the notifyChangeListener method is called from the
            // updateStringValue method by calling the setStringValue method
            notifyChangeListeners();
        }
    } catch (final InvalidSettingsException iae) {
        // if the argument is not accepted: keep the old value.
        m_useRowID = oldUseRowID;
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 84 with NodeSettingsRO

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

the class SettingsModelDoubleRange method loadSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    try {
        NodeSettingsRO mySettings = settings.getNodeSettings(m_configName);
        setRange(mySettings.getDouble("MIN"), mySettings.getDouble("MAX"));
    } catch (InvalidSettingsException ise) {
        throw new InvalidSettingsException(getClass().getSimpleName() + " - " + m_configName + ": " + ise.getMessage());
    } catch (IllegalArgumentException iae) {
        throw new InvalidSettingsException(getClass().getSimpleName() + " - " + m_configName + ": " + iae.getMessage());
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) NodeSettingsRO(org.knime.core.node.NodeSettingsRO)

Example 85 with NodeSettingsRO

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

the class SettingsModelDoubleRange method validateSettingsForModel.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettingsForModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    double min;
    double max;
    try {
        NodeSettingsRO mySettings = settings.getNodeSettings(m_configName);
        min = mySettings.getDouble("MIN");
        max = mySettings.getDouble("MAX");
    } catch (InvalidSettingsException ise) {
        throw new InvalidSettingsException(getClass().getSimpleName() + " - " + m_configName + ": " + ise.getMessage());
    }
    if (min > max) {
        throw new InvalidSettingsException("min>max in " + getClass().getSimpleName() + " - " + m_configName);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) 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