Search in sources :

Example 21 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class ColumnFuntionSettings method validateSettings.

/**
 * @param settings the {@link NodeSettingsRO} to read the settings from
 * @throws InvalidSettingsException if the settings are invalid
 */
public void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    final String val = ((SettingsModelString) m_column.createCloneWithValidatedValue(settings)).getStringValue();
    validateColumn(val);
}
Also used : SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 22 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class NumericScorerSettings method createFlowPrefixModel.

/**
 * @param useNamePrefixModel TODO
 * @return A new {@link SettingsModelString} for the flow variable prefix
 */
private SettingsModelString createFlowPrefixModel(final SettingsModelBoolean useNamePrefixModel) {
    final SettingsModelString result = new SettingsModelString("name prefix for flowvars", "");
    useNamePrefixModel.addChangeListener(new ChangeListener() {

        /**
         * {@inheritDoc}
         */
        @Override
        public void stateChanged(final ChangeEvent e) {
            result.setEnabled(useNamePrefixModel.getBooleanValue());
        }
    });
    result.setEnabled(useNamePrefixModel.getBooleanValue());
    return result;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 23 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class NaiveBayesLearnerNodeModel2 method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    final SettingsModelString colName = m_classifyColumnName.createCloneWithValidatedValue(settings);
    if (colName == null || colName.getStringValue() == null || colName.getStringValue().trim().length() < 1) {
        throw new InvalidSettingsException("No class column selected");
    }
    final SettingsModelIntegerBounded maxNoOfNomVals = m_maxNoOfNominalVals.createCloneWithValidatedValue(settings);
    if (maxNoOfNomVals.getIntValue() < 0) {
        throw new InvalidSettingsException("Maximum number of unique nominal values should be a positive number");
    }
    m_pmmlCompatible.validateSettings(settings);
    m_threshold.validateSettings(settings);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelIntegerBounded(org.knime.core.node.defaultnodesettings.SettingsModelIntegerBounded) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 24 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class HierarchicalClusterNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_numClustersForOutput.validateSettings(settings);
    m_distFunctionName.validateSettings(settings);
    m_selectedColumns.validateSettings(settings);
    m_cacheDistances.validateSettings(settings);
    SettingsModelString linkageType = m_linkageType.createCloneWithValidatedValue(settings);
    // check linkage method
    boolean valid = false;
    for (Linkage link : Linkage.values()) {
        if (link.name().equals(linkageType.getStringValue())) {
            valid = true;
            break;
        }
    }
    if (!valid) {
        throw new InvalidSettingsException("Linkage Type must either be " + Linkage.SINGLE + ", " + Linkage.AVERAGE + " or " + Linkage.COMPLETE);
    }
    settings.getBoolean(USE_CACHE_KEY, false);
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 25 with SettingsModelString

use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.

the class DecisionTreeLearnerNodeModel2 method validateSettings.

/**
 * This method validates the settings. That is:
 * <ul>
 * <li>The number of the class column must be an integer &gt; 0</li>
 * <li>The positive value <code>DataCell</code> must not be null</li>
 * </ul>
 * {@inheritDoc}
 *
 * @see NodeModel#validateSettings(NodeSettingsRO)
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    SettingsModelString classifyColumn = m_classifyColumn.createCloneWithValidatedValue(settings);
    if (classifyColumn.getStringValue() == null || classifyColumn.getStringValue().equals("")) {
        throw new InvalidSettingsException("Classification column not set.");
    }
    m_averageSplitpoint.validateSettings(settings);
    m_binaryNominalSplitMode.validateSettings(settings);
    m_pruningMethod.validateSettings(settings);
    try {
        m_reducedErrorPruning.validateSettings(settings);
    } catch (InvalidSettingsException ise) {
    // add with KNIME 2.8
    }
    m_numberRecordsStoredForView.validateSettings(settings);
    // m_pruningConfidenceThreshold.validateSettings(settings);
    m_minNumberRecordsPerNode.validateSettings(settings);
    m_splitQualityMeasureType.validateSettings(settings);
    m_maxNumNominalsForCompleteComputation.validateSettings(settings);
    m_parallelProcessing.validateSettings(settings);
    // added in v2.5.3, bug 3124
    if (settings.containsKey(KEY_FILTER_NOMINAL_VALUES_FROM_PARENT)) {
        m_filterNominalValuesFromParent.validateSettings(settings);
    }
    /* Added with 2.5 to avoid running out of heap space with columns
         * that have too many nominal values. */
    if (settings.containsKey(KEY_SKIP_COLUMNS)) {
        m_skipColumns.validateSettings(settings);
    }
    /* Added with 2.8 to include missing values strategy and no true child strategy. */
    if (settings.containsKey(KEY_NOTRUECHILD) && settings.containsKey(KEY_MISSINGSTRATEGY)) {
        m_noTrueChild.validateSettings(settings);
        // added true child with missing values, so when one of them is in, both are in
        m_missingValues.validateSettings(settings);
    }
    /* Added with 3.2 to allow the specification of the first column to split on */
    if (settings.containsKey(KEY_USE_FIRST_SPLIT_COL)) {
        m_useFirstSplitCol.validateSettings(settings);
        m_firstSplitCol.validateSettings(settings);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Aggregations

SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)99 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)39 SettingsModelBoolean (org.knime.core.node.defaultnodesettings.SettingsModelBoolean)15 ChangeListener (javax.swing.event.ChangeListener)13 ChangeEvent (javax.swing.event.ChangeEvent)12 IOException (java.io.IOException)8 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)8 DialogComponentString (org.knime.core.node.defaultnodesettings.DialogComponentString)7 Duration (java.time.Duration)5 Period (java.time.Period)5 DateTimeParseException (java.time.format.DateTimeParseException)5 SettingsModelDateTime (org.knime.time.util.SettingsModelDateTime)5 File (java.io.File)4 LocalDate (java.time.LocalDate)4 LocalDateTime (java.time.LocalDateTime)4 ZonedDateTime (java.time.ZonedDateTime)4 Temporal (java.time.temporal.Temporal)4 TemporalAmount (java.time.temporal.TemporalAmount)4 DateTimeType (org.knime.time.util.DateTimeType)4 DateTimeException (java.time.DateTimeException)3