Search in sources :

Example 56 with DataColumnSpecFilterConfiguration

use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.

the class EditNumericDomainConfiguration method loadConfigurationInModel.

/**
 * Loads the configuration for the model.
 *
 * @param settings the settings to load
 * @throws InvalidSettingsException if the settings are invalid
 */
void loadConfigurationInModel(final NodeSettingsRO settings) throws InvalidSettingsException {
    m_lowerBound = settings.getDouble(MIN_KEY);
    m_upperBound = settings.getDouble(MAX_KEY);
    m_domainOverflowPolicy = toDomainHandler(settings.getString(DOMAIN_OVERFLOW_POLICY_KEY));
    DataColumnSpecFilterConfiguration dataColumnSpecFilterConfiguration = createDoubleSpecFilterConfig();
    dataColumnSpecFilterConfiguration.loadConfigurationInModel(settings);
    m_columnspecFilterConfig = dataColumnSpecFilterConfiguration;
}
Also used : DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration)

Example 57 with DataColumnSpecFilterConfiguration

use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.

the class ColCombine2NodeDialog method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    DataColumnSpecFilterConfiguration conf = ColCombine2NodeModel.createDCSFilterConfiguration();
    m_filterPanel.saveConfiguration(conf);
    conf.saveConfiguration(settings);
    String delimiter = m_delimTextField.getText();
    settings.addString(ColCombine2NodeModel.CFG_DELIMITER_STRING, delimiter);
    String newColName = m_appendColNameField.getText();
    if (m_spec.containsName(newColName)) {
        throw new InvalidSettingsException("Name of appended column already exists: " + newColName);
    }
    settings.addString(ColCombine2NodeModel.CFG_NEW_COLUMN_NAME, newColName);
    boolean isQuoting = m_quoteCharRadioButton.isSelected();
    settings.addBoolean(ColCombine2NodeModel.CFG_IS_QUOTING, isQuoting);
    if (isQuoting) {
        String quoteFieldText = (String) m_quoteCharField.getValue();
        if (quoteFieldText == null || quoteFieldText.trim().length() == 0) {
            throw new InvalidSettingsException("Quote field is empty");
        }
        if (quoteFieldText.length() > 1) {
            throw new InvalidSettingsException("Quote field must only contain single character");
        }
        Character quote = quoteFieldText.charAt(0);
        settings.addChar(ColCombine2NodeModel.CFG_QUOTE_CHAR, quote);
        settings.addBoolean(ColCombine2NodeModel.CFG_IS_QUOTING_ALWAYS, m_quoteAlwaysChecker.isSelected());
    } else {
        String replace = m_replaceDelimStringField.getText();
        settings.addString(ColCombine2NodeModel.CFG_REPLACE_DELIMITER_STRING, replace);
    }
}
Also used : DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 58 with DataColumnSpecFilterConfiguration

use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.

the class ColCombine2NodeModel method validateSettings.

/**
 * {@inheritDoc}
 */
@Override
protected void validateSettings(final NodeSettingsRO settings) throws InvalidSettingsException {
    DataColumnSpecFilterConfiguration conf = createDCSFilterConfiguration();
    conf.loadConfigurationInModel(settings);
    String newColName = settings.getString(CFG_NEW_COLUMN_NAME);
    if (newColName == null || newColName.trim().length() == 0) {
        throw new InvalidSettingsException("Name of new column must not be empty");
    }
    String delim = settings.getString(CFG_DELIMITER_STRING);
    if (delim == null) {
        throw new InvalidSettingsException("Delimiter must not be null");
    }
    delim = trimDelimString(delim);
    boolean isQuote = settings.getBoolean(CFG_IS_QUOTING);
    if (isQuote) {
        char quote = settings.getChar(CFG_QUOTE_CHAR);
        if (Character.isWhitespace(quote)) {
            throw new InvalidSettingsException("Can't use white space as quote char");
        }
        if (delim.contains(Character.toString(quote))) {
            throw new InvalidSettingsException("Delimiter String \"" + delim + "\" must not contain quote character ('" + quote + "')");
        }
        settings.getBoolean(CFG_IS_QUOTING_ALWAYS);
    } else {
        String replace = settings.getString(CFG_REPLACE_DELIMITER_STRING);
        if ((delim.length() > 0) && (replace.contains(delim))) {
            throw new InvalidSettingsException("Replacement string \"" + replace + "\" must not contain delimiter string \"" + delim + "\"");
        }
    }
}
Also used : DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration) InvalidSettingsException(org.knime.core.node.InvalidSettingsException)

Example 59 with DataColumnSpecFilterConfiguration

use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.

the class CategoryToNumberNodeDialogPane method loadSettingsFrom.

/**
 * {@inheritDoc}
 */
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final PortObjectSpec[] specs) throws NotConfigurableException {
    DataTableSpec spec = (DataTableSpec) specs[0];
    m_settings.loadSettingsForDialog(settings, spec);
    DataColumnSpecFilterConfiguration config = m_settings.getFilterConfiguration();
    m_filterPanel.loadConfiguration(config, spec);
    m_appendColums.setSelected(m_settings.getAppendColumns());
    m_columnSuffix.setText(m_settings.getColumnSuffix());
    m_columnSuffix.setEnabled(m_appendColums.isSelected());
    m_startIndex.setValue(m_settings.getStartIndex());
    m_increment.setValue(m_settings.getIncrement());
    m_maxCategories.setValue(m_settings.getMaxCategories());
    if (!m_settings.getDefaultValue().isMissing()) {
        IntValue value = (IntValue) m_settings.getDefaultValue();
        m_defaultValue.setText(Integer.toString(value.getIntValue()));
    } else {
        m_defaultValue.setText("");
    }
    if (!m_settings.getMapMissingTo().isMissing()) {
        IntValue value = (IntValue) m_settings.getMapMissingTo();
        m_mapMissingTo.setText(Integer.toString(value.getIntValue()));
    } else {
        m_mapMissingTo.setText("");
    }
}
Also used : DataTableSpec(org.knime.core.data.DataTableSpec) DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration) IntValue(org.knime.core.data.IntValue)

Example 60 with DataColumnSpecFilterConfiguration

use of org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration in project knime-core by knime.

the class CategoryToNumberNodeDialogPane method saveSettingsTo.

/**
 * {@inheritDoc}
 */
@Override
protected void saveSettingsTo(final NodeSettingsWO settings) throws InvalidSettingsException {
    DataColumnSpecFilterConfiguration config = CategoryToNumberNodeModel.createDCSFilterConfiguration();
    m_filterPanel.saveConfiguration(config);
    m_settings.setFilterConfiguration(config);
    m_settings.setAppendColumns(m_appendColums.isSelected());
    m_settings.setColumnSuffix(m_columnSuffix.getText());
    m_settings.setStartIndex((Integer) m_startIndex.getValue());
    m_settings.setIncrement((Integer) m_increment.getValue());
    m_settings.setMaxCategories((Integer) m_maxCategories.getValue());
    if (!m_defaultValue.getText().trim().isEmpty()) {
        int value = Integer.valueOf(m_defaultValue.getText());
        m_settings.setDefaultValue(new IntCell(value));
    } else {
        m_settings.setDefaultValue(DataType.getMissingCell());
    }
    if (!m_mapMissingTo.getText().trim().isEmpty()) {
        int value = Integer.valueOf(m_mapMissingTo.getText());
        m_settings.setMapMissingTo(new IntCell(value));
    } else {
        m_settings.setMapMissingTo(DataType.getMissingCell());
    }
    m_settings.saveSettings(settings);
}
Also used : DataColumnSpecFilterConfiguration(org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration) IntCell(org.knime.core.data.def.IntCell)

Aggregations

DataColumnSpecFilterConfiguration (org.knime.core.node.util.filter.column.DataColumnSpecFilterConfiguration)75 DataTableSpec (org.knime.core.data.DataTableSpec)15 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)14 NotConfigurableException (org.knime.core.node.NotConfigurableException)9 ChangeEvent (javax.swing.event.ChangeEvent)4 ChangeListener (javax.swing.event.ChangeListener)4 DataColumnSpec (org.knime.core.data.DataColumnSpec)4 SettingsModelString (org.knime.core.node.defaultnodesettings.SettingsModelString)4 DatabaseConnectionSettings (org.knime.core.node.port.database.DatabaseConnectionSettings)4 EnforceOption (org.knime.core.node.util.filter.NameFilterConfiguration.EnforceOption)4 DatabaseConnectionPortObjectSpec (org.knime.core.node.port.database.DatabaseConnectionPortObjectSpec)2 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 Solver (org.knime.base.node.mine.regression.logistic.learner4.LogRegLearnerSettings.Solver)1 BinNaming (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.BinNaming)1 EqualityMethod (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.EqualityMethod)1 Method (org.knime.base.node.preproc.autobinner3.AutoBinnerLearnSettings.Method)1 DoubleValue (org.knime.core.data.DoubleValue)1 IntValue (org.knime.core.data.IntValue)1