Search in sources :

Example 1 with RangeRowFilter

use of org.knime.base.node.preproc.filter.row.rowfilter.RangeRowFilter in project knime-core by knime.

the class ColumnRowFilterPanel method createFilter.

/**
 * {@inheritDoc}
 */
@Override
public IRowFilter createFilter(final boolean include) throws InvalidSettingsException {
    if (hasErrors()) {
        throw new InvalidSettingsException(getErrMsg());
    }
    String colName = getSelectedColumnName();
    if ((colName == null) || (colName.length() == 0)) {
        setErrMsg("Select a valid column");
        validate();
        throw new InvalidSettingsException(getErrMsg());
    }
    boolean deepFiltering = getDeepFiltering();
    if (m_useRange.isSelected()) {
        DataCell loBound = getLowerBoundCell();
        DataCell hiBound = getUpperBoundCell();
        if ((loBound == null) && (hiBound == null)) {
            setErrMsg("Enter at least one valid range boundary");
            validate();
            throw new InvalidSettingsException(getErrMsg());
        }
        return new RangeRowFilter(colName, include, deepFiltering, loBound, hiBound);
    }
    if (m_useRegExpr.isSelected()) {
        String regExpr = (String) m_regExpr.getEditor().getItem();
        if (regExpr.length() <= 0) {
            setErrMsg("Enter a valid pattern to match");
            validate();
            throw new InvalidSettingsException(getErrMsg());
        }
        return new StringCompareRowFilter(regExpr, colName, include, deepFiltering, m_caseSensitive.isSelected(), m_hasWildCards.isSelected(), m_isRegExpr.isSelected());
    }
    if (m_useMissValue.isSelected()) {
        return new MissingValueRowFilter(colName, include, deepFiltering);
    }
    throw new InvalidSettingsException("Internal Error. " + "Please change some settings and try again. Sorry");
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) RangeRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.RangeRowFilter) StringCompareRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.StringCompareRowFilter) MissingValueRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.MissingValueRowFilter) DataCell(org.knime.core.data.DataCell)

Example 2 with RangeRowFilter

use of org.knime.base.node.preproc.filter.row.rowfilter.RangeRowFilter in project knime-core by knime.

the class ColumnRowFilterPanel method loadSettingsFromFilter.

/**
 * {@inheritDoc}
 */
@Override
public void loadSettingsFromFilter(final IRowFilter filter) throws InvalidSettingsException {
    // accept ColValFilterOldObsolete for backward compatibility
    if (filter instanceof ColValFilterOldObsolete) {
        loadSettingsFromColValFilter((ColValFilterOldObsolete) filter);
    } else {
        if (!(filter instanceof AttrValueRowFilter)) {
            throw new InvalidSettingsException("Column value row filter " + "panel can only load settings from a range filter, " + "an attribute value filter.");
        }
        AttrValueRowFilter avFilter = (AttrValueRowFilter) filter;
        String colName = avFilter.getColName();
        if (colName != null) {
            m_colCombo.setSelectedColumn(colName);
        }
        m_deepFiltering.setSelected(avFilter.getDeepFiltering());
        updateDeepFiltering();
        if (filter instanceof StringCompareRowFilter) {
            StringCompareRowFilter f = (StringCompareRowFilter) filter;
            m_useRegExpr.setSelected(true);
            m_regExpr.setSelectedItem(f.getPattern());
            m_isRegExpr.setSelected(f.getIsRegExpr());
            m_hasWildCards.setSelected(f.getHasWildcards());
            m_caseSensitive.setSelected(f.getCaseSensitive());
        } else if (filter instanceof RangeRowFilter) {
            RangeRowFilter f = (RangeRowFilter) filter;
            m_useRange.setSelected(true);
            String upper = "";
            String lower = "";
            if (f.getUpperBound() != null) {
                upper = f.getUpperBound().toString();
            }
            if (f.getLowerBound() != null) {
                lower = f.getLowerBound().toString();
            }
            m_upperBound.setText(upper);
            m_lowerBound.setText(lower);
        } else if (filter instanceof MissingValueRowFilter) {
            m_useMissValue.setSelected(true);
        } else {
            // attribute value filter.
            assert false;
        }
    }
}
Also used : InvalidSettingsException(org.knime.core.node.InvalidSettingsException) ColValFilterOldObsolete(org.knime.base.node.preproc.filter.row.rowfilter.ColValFilterOldObsolete) RangeRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.RangeRowFilter) StringCompareRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.StringCompareRowFilter) AttrValueRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter) MissingValueRowFilter(org.knime.base.node.preproc.filter.row.rowfilter.MissingValueRowFilter)

Aggregations

MissingValueRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.MissingValueRowFilter)2 RangeRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.RangeRowFilter)2 StringCompareRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.StringCompareRowFilter)2 InvalidSettingsException (org.knime.core.node.InvalidSettingsException)2 AttrValueRowFilter (org.knime.base.node.preproc.filter.row.rowfilter.AttrValueRowFilter)1 ColValFilterOldObsolete (org.knime.base.node.preproc.filter.row.rowfilter.ColValFilterOldObsolete)1 DataCell (org.knime.core.data.DataCell)1