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");
}
}
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()));
}
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);
}
}
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());
}
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);
}
}
Aggregations