Search in sources :

Example 1 with PropertyIsLike

use of org.opengis.filter.PropertyIsLike in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsFuzzy.

@Test
public void testVisitPropertyIsFuzzy() {
    visitor = new CswRecordMapperFilterVisitor(metacardType, mockMetacardTypeList);
    Expression val1 = factory.property("fooProperty");
    Expression val2 = factory.literal("fooLiteral");
    //PropertyIsFuzzy maps to a propertyIsLike filter with a fuzzy function
    GeotoolsFilterBuilder builder = new GeotoolsFilterBuilder();
    PropertyIsLike fuzzySearch = (PropertyIsLike) builder.attribute(val1.toString()).is().like().fuzzyText(val2.toString());
    PropertyIsLike visitedFilter = (PropertyIsLike) visitor.visit(fuzzySearch, null);
    assertThat(visitedFilter.getExpression(), is(instanceOf(FuzzyFunction.class)));
    assertThat(visitedFilter.getLiteral(), is(val2.toString()));
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) Expression(org.opengis.filter.expression.Expression) GeotoolsFilterBuilder(ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 2 with PropertyIsLike

use of org.opengis.filter.PropertyIsLike in project sldeditor by robward-scisys.

the class ExpressionPanelv2 method addFilter.

/**
 * Adds the filter.
 *
 * @param node the node
 * @return the filter
 */
private Filter addFilter(FilterNode node) {
    Filter filter = node.getFilter();
    FilterConfigInterface filterConfig = node.getFilterConfig();
    if (filter instanceof LogicFilterImpl) {
        List<Filter> filterList = new ArrayList<Filter>();
        createFilterList(node, filterList);
        return filterConfig.createLogicFilter(filterList);
    }
    List<Expression> parameterFilter = new ArrayList<Expression>();
    if (filter instanceof FidFilterImpl) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof BinaryTemporalOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof PropertyIsBetween) {
        createExpressionParameterList(node, 3, parameterFilter);
    } else if (filter instanceof PropertyIsNull) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof PropertyIsLike) {
        createExpressionParameterList(node, 6, parameterFilter);
    } else if (filter instanceof BinarySpatialOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof BinaryComparisonAbstract) {
        if (filter instanceof Not) {
            createExpressionParameterList(node, 1, parameterFilter);
        } else if (filter instanceof PropertyIsGreaterThan) {
            createExpressionParameterList(node, 2, parameterFilter);
        } else {
            createExpressionParameterList(node, 3, parameterFilter);
        }
    } else {
        return filter;
    }
    return filterConfig.createFilter(parameterFilter);
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) ArrayList(java.util.ArrayList) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Not(org.opengis.filter.Not) PropertyIsNull(org.opengis.filter.PropertyIsNull) Filter(org.opengis.filter.Filter) Expression(org.opengis.filter.expression.Expression) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) FidFilterImpl(org.geotools.filter.FidFilterImpl) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract) BinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan)

Example 3 with PropertyIsLike

use of org.opengis.filter.PropertyIsLike in project sldeditor by robward-scisys.

the class FilterPanelv2 method addFilter.

/**
 * Adds the filter.
 *
 * @param node the node
 * @return the filter
 */
private Filter addFilter(FilterNode node) {
    Filter filter = node.getFilter();
    FilterConfigInterface filterConfig = node.getFilterConfig();
    if (filter instanceof LogicFilterImpl) {
        List<Filter> filterList = new ArrayList<Filter>();
        createFilterList(node, filterList);
        return filterConfig.createLogicFilter(filterList);
    }
    List<Expression> parameterFilter = new ArrayList<Expression>();
    if (filter instanceof FidFilterImpl) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof BinaryTemporalOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof PropertyIsBetween) {
        createExpressionParameterList(node, 3, parameterFilter);
    } else if (filter instanceof PropertyIsNull) {
        createExpressionParameterList(node, 1, parameterFilter);
    } else if (filter instanceof PropertyIsLike) {
        createExpressionParameterList(node, 6, parameterFilter);
    } else if (filter instanceof BinarySpatialOperator) {
        createExpressionParameterList(node, 2, parameterFilter);
    } else if (filter instanceof BinaryComparisonAbstract) {
        if (filter instanceof Not) {
            createExpressionParameterList(node, 1, parameterFilter);
        } else if (filter instanceof PropertyIsGreaterThan) {
            createExpressionParameterList(node, 2, parameterFilter);
        } else {
            createExpressionParameterList(node, 3, parameterFilter);
        }
    } else {
        return filter;
    }
    return filterConfig.createFilter(parameterFilter);
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) ArrayList(java.util.ArrayList) FilterConfigInterface(com.sldeditor.filter.v2.function.FilterConfigInterface) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Not(org.opengis.filter.Not) PropertyIsNull(org.opengis.filter.PropertyIsNull) Filter(org.opengis.filter.Filter) Expression(org.opengis.filter.expression.Expression) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) FidFilterImpl(org.geotools.filter.FidFilterImpl) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) BinaryComparisonAbstract(org.geotools.filter.BinaryComparisonAbstract) BinarySpatialOperator(org.opengis.filter.spatial.BinarySpatialOperator) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan)

Example 4 with PropertyIsLike

use of org.opengis.filter.PropertyIsLike in project ddf by codice.

the class OpenSearchFilterVisitorTest method testPropertyIsLikeAnd.

@Test
public void testPropertyIsLikeAnd() {
    PropertyIsLike textLikeFilter = (PropertyIsLike) geotoolsFilterBuilder.attribute(SOME_ATTRIBUTE_NAME).is().like().text(TEST_STRING);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitor.visit(textLikeFilter, openSearchFilterVisitorObject);
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(textLikeFilter, openSearchFilterVisitorObject);
    assertThat(result.getContextualSearch(), allOf(is(notNullValue()), hasProperty("searchPhraseMap", hasEntry(OpenSearchConstants.SEARCH_TERMS, "test AND test"))));
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) Test(org.junit.Test)

Example 5 with PropertyIsLike

use of org.opengis.filter.PropertyIsLike in project ddf by codice.

the class OpenSearchFilterVisitorTest method testPropertyIsLikeNonSearchTerm.

@Test
public void testPropertyIsLikeNonSearchTerm() {
    PropertyIsLike textLikeFilter = (PropertyIsLike) geotoolsFilterBuilder.attribute(SOME_ATTRIBUTE_NAME).is().like().text(TEST_STRING);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    Map<String, String> searchPhraseMap = new HashMap<>();
    searchPhraseMap.put("anotherTerm", TEST_STRING);
    openSearchFilterVisitorObject.setContextualSearch(new ContextualSearch(SOME_ATTRIBUTE_NAME, searchPhraseMap, true));
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(textLikeFilter, openSearchFilterVisitorObject);
    assertThat(result.getContextualSearch(), allOf(is(notNullValue()), hasProperty("searchPhraseMap", hasEntry(OpenSearchConstants.SEARCH_TERMS, TEST_STRING))));
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) HashMap(java.util.HashMap) Matchers.hasToString(org.hamcrest.Matchers.hasToString) Test(org.junit.Test)

Aggregations

PropertyIsLike (org.opengis.filter.PropertyIsLike)13 Test (org.junit.Test)8 Filter (org.opengis.filter.Filter)7 Expression (org.opengis.filter.expression.Expression)6 ArrayList (java.util.ArrayList)5 LogicFilterImpl (org.geotools.filter.LogicFilterImpl)4 PropertyIsBetween (org.opengis.filter.PropertyIsBetween)4 PropertyIsNull (org.opengis.filter.PropertyIsNull)4 BinarySpatialOperator (org.opengis.filter.spatial.BinarySpatialOperator)4 BinaryTemporalOperator (org.opengis.filter.temporal.BinaryTemporalOperator)4 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)3 BinaryComparisonAbstract (org.geotools.filter.BinaryComparisonAbstract)3 Not (org.opengis.filter.Not)3 FilterConfigInterface (com.sldeditor.filter.v2.function.FilterConfigInterface)2 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)2 List (java.util.List)2 FidFilterImpl (org.geotools.filter.FidFilterImpl)2 PropertyIsGreaterThan (org.opengis.filter.PropertyIsGreaterThan)2 FilterName (com.sldeditor.filter.v2.function.FilterName)1 LineString (com.vividsolutions.jts.geom.LineString)1