Search in sources :

Example 91 with SettingsModelString

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

the class MovingAggregationNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_winLength.validateSettings(settings);
    m_windowType.validateSettings(settings);
    m_cumulativeComputing.validateSettings(settings);
    m_handleMissings.validateSettings(settings);
    m_removeRetainedCols.validateSettings(settings);
    m_maxUniqueVals.validateSettings(settings);
    m_valueDelimiter.validateSettings(settings);
    final List<ColumnAggregator> aggregators = ColumnAggregator.loadColumnAggregators(settings);
    final List<DataTypeAggregator> typeAggregators = new LinkedList<>();
    final List<PatternAggregator> regexAggregators = new LinkedList<>();
    try {
        regexAggregators.addAll(PatternAggregator.loadAggregators(settings, CFG_PATTERN_AGGREGATORS));
        typeAggregators.addAll(DataTypeAggregator.loadAggregators(settings, CFG_DATA_TYPE_AGGREGATORS));
    } catch (InvalidSettingsException e) {
    // introduced in 2.11
    }
    if (aggregators.isEmpty() && regexAggregators.isEmpty() && typeAggregators.isEmpty()) {
        throw new IllegalArgumentException("Please select at least one aggregation option");
    }
    final String policyLabel = ((SettingsModelString) m_columnNamePolicy.createCloneWithValidatedValue(settings)).getStringValue();
    final ColumnNamePolicy namePolicy = ColumnNamePolicy.getPolicy4Label(policyLabel);
    try {
        GroupByNodeModel.checkDuplicateAggregators(namePolicy, aggregators);
    } catch (IllegalArgumentException e) {
        throw new InvalidSettingsException(e.getMessage());
    }
    final boolean removeAggrCols = ((SettingsModelBoolean) m_removeAggregationCols.createCloneWithValidatedValue(settings)).getBooleanValue();
    if (ColumnNamePolicy.KEEP_ORIGINAL_NAME.equals(namePolicy) && !removeAggrCols) {
        throw new InvalidSettingsException("'" + ColumnNamePolicy.KEEP_ORIGINAL_NAME.getLabel() + "' option only valid if aggregation columns are filtered");
    }
}
Also used : PatternAggregator(org.knime.base.data.aggregation.dialogutil.pattern.PatternAggregator) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) DataTypeAggregator(org.knime.base.data.aggregation.dialogutil.type.DataTypeAggregator) LinkedList(java.util.LinkedList) SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) ColumnNamePolicy(org.knime.base.node.preproc.groupby.ColumnNamePolicy) ColumnAggregator(org.knime.base.data.aggregation.ColumnAggregator) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 92 with SettingsModelString

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

the class FromDecisionTreeNodeDialog method createScoreDistribution.

/**
 * {@inheritDoc}
 */
@Override
protected void createScoreDistribution(final FromDecisionTreeSettings settings) {
    createNewGroup("Score distribution");
    setHorizontalPlacement(true);
    // Record count
    m_scorePmmlRecordCount = settings.getScorePmmlRecordCount();
    final SettingsModelBoolean scoreTableRecordCount = settings.getScoreTableRecordCount();
    final SettingsModelString scoreTableRecordCountPrefix = settings.getScoreTableRecordCountPrefix();
    addDialogComponent(new DialogComponentBoolean(m_scorePmmlRecordCount, "Provide score distibution record count in PMML"));
    addDialogComponent(new DialogComponentBoolean(scoreTableRecordCount, "Provide score distibution record count in table with column name prefix:"));
    addDialogComponent(new DialogComponentString(scoreTableRecordCountPrefix, ""));
    setHorizontalPlacement(false);
    setHorizontalPlacement(true);
    // Probability
    final SettingsModelBoolean scorePmmlProbability = settings.getScorePmmlProbability();
    final SettingsModelBoolean scoreTableProbability = settings.getScoreTableProbability();
    final SettingsModelString scoreTableProbabilityPrefix = settings.getScoreTableProbabilityPrefix();
    addDialogComponent(new DialogComponentBoolean(scorePmmlProbability, "Provide score distibution probability in PMML"));
    addDialogComponent(new DialogComponentBoolean(scoreTableProbability, "Provide score distibution probability in table with column name prefix:"));
    addDialogComponent(new DialogComponentString(scoreTableProbabilityPrefix, ""));
    m_scorePmmlRecordCount.addChangeListener(c -> scoreTableRecordCount.setEnabled(m_scorePmmlRecordCount.getBooleanValue()));
    m_scorePmmlRecordCount.addChangeListener(c -> scorePmmlProbability.setEnabled(m_scorePmmlRecordCount.getBooleanValue()));
    scoreTableRecordCount.addChangeListener(c -> scoreTableRecordCountPrefix.setEnabled(scoreTableRecordCount.isEnabled() && scoreTableRecordCount.getBooleanValue()));
    scorePmmlProbability.addChangeListener(c -> scoreTableProbability.setEnabled(scorePmmlProbability.isEnabled() && scorePmmlProbability.getBooleanValue()));
    scoreTableProbability.addChangeListener(c -> scoreTableProbabilityPrefix.setEnabled(scoreTableProbability.isEnabled() && scoreTableProbability.getBooleanValue()));
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) DialogComponentString(org.knime.core.node.defaultnodesettings.DialogComponentString) DialogComponentBoolean(org.knime.core.node.defaultnodesettings.DialogComponentBoolean) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 93 with SettingsModelString

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

the class PMMLRuleSetPredictorNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    SettingsModelString v = new SettingsModelString(CFGKEY_OUTPUT_COLUMN, DEFAULT_OUTPUT_COLUMN);
    v.loadSettingsFrom(settings);
    if (v.getStringValue().isEmpty()) {
        throw new InvalidSettingsException("Specify a non-empty column name as a result.");
    }
    // Nothing to validate for the add confidence setting.
    SettingsModelString u = new SettingsModelString(CFGKEY_CONFIDENCE_COLUMN, DEFAULT_CONFIDENCE_COLUN);
    u.loadSettingsFrom(settings);
    if (u.isEnabled() && u.getStringValue().isEmpty()) {
        throw new InvalidSettingsException("Specify a non-empty column name as a confidence.");
    }
    SettingsModelString r = createReplaceColumn();
    try {
        r.validateSettings(settings);
    } catch (InvalidSettingsException e) {
        m_replaceColumn.setStringValue(DEFAULT_REPLACE_COLUMN);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 94 with SettingsModelString

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

the class RowKeyNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    assert (settings != null);
    final SettingsModelBoolean replaceRowKeyModel = m_replaceKey.createCloneWithValidatedValue(settings);
    final SettingsModelBoolean appendRowKeyModel = m_appendRowKey.createCloneWithValidatedValue(settings);
    final SettingsModelString newRowKeyModel = m_newRowKeyColumn.createCloneWithValidatedValue(settings);
    final SettingsModelString newColNameModel = m_newColumnName.createCloneWithValidatedValue(settings);
    validateInput(null, appendRowKeyModel.getBooleanValue(), newColNameModel.getStringValue(), replaceRowKeyModel.getBooleanValue(), newRowKeyModel.getStringValue(), appendRowKeyModel.getBooleanValue());
}
Also used : SettingsModelBoolean(org.knime.core.node.defaultnodesettings.SettingsModelBoolean) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString)

Example 95 with SettingsModelString

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

the class DateTimeToStringNodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_colSelect.validateSettings(settings);
    m_isReplaceOrAppend.validateSettings(settings);
    m_suffix.validateSettings(settings);
    m_format.validateSettings(settings);
    m_locale.validateSettings(settings);
    try {
        LocaleUtils.toLocale(m_locale.getStringValue());
    } catch (IllegalArgumentException ex) {
        throw new InvalidSettingsException("Unsupported locale in setting (" + m_locale.getStringValue() + "): " + ex.getMessage(), ex);
    }
    final SettingsModelString formatClone = m_format.createCloneWithValidatedValue(settings);
    final String format = formatClone.getStringValue();
    if (format == null || format.length() == 0) {
        throw new InvalidSettingsException("Format must not be empty!");
    }
    try {
        DateTimeFormatter.ofPattern(formatClone.getStringValue());
    } catch (Exception e) {
        String msg = "Invalid date format: \"" + format + "\".";
        final String errMsg = e.getMessage();
        if (errMsg != null && !errMsg.isEmpty()) {
            msg += " Reason: " + errMsg;
        }
        throw new InvalidSettingsException(msg, e);
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) SettingsModelString(org.knime.core.node.defaultnodesettings.SettingsModelString) InvalidSettingsException(org.knime.core.node.InvalidSettingsException) CanceledExecutionException(org.knime.core.node.CanceledExecutionException) IOException(java.io.IOException) UnsupportedTemporalTypeException(java.time.temporal.UnsupportedTemporalTypeException)

Aggregations

SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)96 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)36 SettingsModelBoolean (org.knime.core.node.defaultnodesettings.SettingsModelBoolean)15 ChangeListener (javax.swing.event.ChangeListener)13 ChangeEvent (javax.swing.event.ChangeEvent)12 IOException (java.io.IOException)7 CanceledExecutionException (org.knime.core.node.CanceledExecutionException)7 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 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 File (java.io.File)3 DateTimeException (java.time.DateTimeException)3