use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class ColumnComparatorNodeDialogPane method createMismatchValue.
/**
* @return settings model for replacement value
*/
static SettingsModelString createMismatchValue() {
SettingsModelString model = new SettingsModelString("mismatch_value", "FALSE");
model.setEnabled(false);
return model;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class CrossJoinerNodeModel method createFirstRowIdsNameSettingsModel.
/**
* @param showFirstRowIdsSettingsModel the enable checker model.
* @return the column name for the first tables rowids
*/
static SettingsModelString createFirstRowIdsNameSettingsModel(final SettingsModelBoolean showFirstRowIdsSettingsModel) {
final SettingsModelString settingsModel = new SettingsModelString("CFG_FIRST_COLUMNNAME", "FirstRowIDs");
showFirstRowIdsSettingsModel.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(final ChangeEvent e) {
settingsModel.setEnabled(showFirstRowIdsSettingsModel.getBooleanValue());
}
});
settingsModel.setEnabled(showFirstRowIdsSettingsModel.getBooleanValue());
return settingsModel;
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class CAIMDiscretizationNodeModel method validateSettings.
/**
* This method validates the settings. That is:
* <ul>
* <li>The number of the class column must be an integer > 0</li>
* <li>The positive value <code>DataCell</code> must not be null</li>
* </ul>
*
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
SettingsModelString tmp = m_classColumnName.createCloneWithValidatedValue(settings);
String classifyColumn = tmp.getStringValue();
if (classifyColumn == null || classifyColumn.equals("")) {
throw new InvalidSettingsException("Discretization column not set");
}
SettingsModelFilterString tmpIncl = null;
try {
tmpIncl = m_includedColumnNames.createCloneWithValidatedValue(settings);
} catch (InvalidSettingsException ise) {
// new with 2.0
}
if (tmpIncl == null || tmpIncl.getIncludeList() == null || tmpIncl.getIncludeList().size() == 0) {
setWarningMessage(WARNING_NO_COLS_SELECTED);
}
m_sortInMemory.validateSettings(settings);
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class GroupByNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_groupByCols.validateSettings(settings);
// FIX bug 5040: potential problem with clone settings method when in-/exclude list contain same elements
final SettingsModelFilterString tmpSett = new SettingsModelFilterString(CFG_GROUP_BY_COLUMNS);
tmpSett.loadSettingsFrom(settings);
final List<String> groupByCols = tmpSett.getIncludeList();
m_maxUniqueValues.validateSettings(settings);
m_enableHilite.validateSettings(settings);
// with Knime 2.0 as well as the naming policy
try {
final List<ColumnAggregator> aggregators = ColumnAggregator.loadColumnAggregators(settings);
final List<DataTypeAggregator> typeAggregators = new LinkedList<>();
final List<PatternAggregator> patternAggregators = new LinkedList<>();
try {
patternAggregators.addAll(PatternAggregator.loadAggregators(settings, CFG_PATTERN_AGGREGATORS));
typeAggregators.addAll(DataTypeAggregator.loadAggregators(settings, CFG_DATA_TYPE_AGGREGATORS));
} catch (InvalidSettingsException e) {
// introduced in 2.11
}
if (groupByCols.isEmpty() && aggregators.isEmpty() && patternAggregators.isEmpty() && typeAggregators.isEmpty()) {
throw new IllegalArgumentException("Please select at least one group column or aggregation option");
}
ColumnNamePolicy namePolicy;
try {
final String policyLabel = ((SettingsModelString) m_columnNamePolicy.createCloneWithValidatedValue(settings)).getStringValue();
namePolicy = ColumnNamePolicy.getPolicy4Label(policyLabel);
} catch (final InvalidSettingsException e) {
namePolicy = compGetColumnNamePolicy(settings);
}
checkDuplicateAggregators(namePolicy, aggregators);
} catch (final InvalidSettingsException e) {
// these settings are prior Knime 2.0 and can't contain
// a column several times
} catch (final IllegalArgumentException e) {
throw new InvalidSettingsException(e.getMessage());
}
}
use of org.knime.core.node.defaultnodesettings.SettingsModelString in project knime-core by knime.
the class RoundDoubleNodeModel method validateSettings.
/**
* {@inheritDoc}
*/
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
m_filterDoubleColModel.validateSettings(settings);
m_numberPrecisionModel.validateSettings(settings);
m_appendColumnsModel.validateSettings(settings);
m_columnSuffixModel.validateSettings(settings);
m_roundingModeModel.validateSettings(settings);
try {
// added in 2.8
m_outputTypeModel.validateSettings(settings);
} catch (InvalidSettingsException ise) {
RoundDoubleNodeDialog.getOutputAsStringModel().validateSettings(settings);
}
m_numberModeModel.validateSettings(settings);
// additional sanity checks
StringBuffer errMsgBuffer = new StringBuffer();
boolean err = false;
// precision number has to be between 0 and inf
int precision = ((SettingsModelIntegerBounded) m_numberPrecisionModel.createCloneWithValidatedValue(settings)).getIntValue();
if (precision < MIN_PRECISION || precision > MAX_PRECISION) {
errMsgBuffer.append("Rounding precision has to be between " + MIN_PRECISION + " and " + MAX_PRECISION + "\n");
err = true;
}
// if rounded values have to be appended, check for valid column suffix
boolean append = ((SettingsModelBoolean) m_appendColumnsModel.createCloneWithValidatedValue(settings)).getBooleanValue();
if (append) {
String suffix = ((SettingsModelString) m_columnSuffixModel.createCloneWithValidatedValue(settings)).getStringValue();
if (suffix.length() <= 0) {
errMsgBuffer.append("Column suffix may not be empty if append " + "columns is set!\n");
err = true;
}
}
// rounding mode string needs to be a valid round mode
String roundingModeString = ((SettingsModelString) m_roundingModeModel.createCloneWithValidatedValue(settings)).getStringValue();
try {
RoundingMode.valueOf(roundingModeString);
} catch (Exception e) {
errMsgBuffer.append("Specified round mode is not valid!\n");
err = true;
}
// number mode string needs to be a valid number mode
String numberModeString = ((SettingsModelString) m_numberModeModel.createCloneWithValidatedValue(settings)).getStringValue();
try {
NumberMode.valueByDescription(numberModeString);
} catch (Exception e) {
errMsgBuffer.append("Specified number mode is not valid!\n");
err = true;
// throw exception when at least one settings is invalid
} finally {
if (err) {
throw new InvalidSettingsException(errMsgBuffer.toString());
}
}
}
Aggregations