Search in sources :

Example 1 with PropertyIsEqualTo

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

the class MockQuery method addTypeFilter.

public void addTypeFilter(String type, String versions) {
    Filter filter = null;
    if (versions != null && !versions.isEmpty()) {
        String[] typeVersions = versions.split(",");
        List<Filter> typeVersionPairsFilters = new ArrayList<Filter>();
        for (String version : typeVersions) {
            PropertyIsEqualTo typeFilter = FILTER_FACTORY.equals(FILTER_FACTORY.property(Metacard.CONTENT_TYPE), FILTER_FACTORY.literal(type));
            PropertyIsEqualTo versionFilter = FILTER_FACTORY.equals(FILTER_FACTORY.property(Metacard.CONTENT_TYPE_VERSION), FILTER_FACTORY.literal(version));
            typeVersionPairsFilters.add(FILTER_FACTORY.and(typeFilter, versionFilter));
        }
        if (!typeVersionPairsFilters.isEmpty()) {
            filter = FILTER_FACTORY.or(typeVersionPairsFilters);
        } else {
            filter = FILTER_FACTORY.equals(FILTER_FACTORY.property(Metacard.CONTENT_TYPE), FILTER_FACTORY.literal(type));
        }
    } else {
        filter = FILTER_FACTORY.equals(FILTER_FACTORY.property(Metacard.CONTENT_TYPE), FILTER_FACTORY.literal(type));
    }
    if (filter != null) {
        filters.add(filter);
        this.filter = getFilter();
    }
}
Also used : PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) SpatialFilter(ddf.catalog.impl.filter.SpatialFilter) TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) SpatialDistanceFilter(ddf.catalog.impl.filter.SpatialDistanceFilter) Filter(org.opengis.filter.Filter) ArrayList(java.util.ArrayList)

Example 2 with PropertyIsEqualTo

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

the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsEqualTo.

@Test
public void testVisitPropertyIsEqualTo() {
    Expression val = factory.literal("foo");
    PropertyIsEqualTo filter = factory.equals(attrExpr, val);
    PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
    assertThat(duplicate.getExpression1(), is(attrExpr));
    assertThat(duplicate.getExpression2(), is(val));
    assertThat(duplicate.isMatchingCase(), is(true));
}
Also used : PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Expression(org.opengis.filter.expression.Expression) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 3 with PropertyIsEqualTo

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

the class TestPubSubOgcFilter method testContextualFeatureEvaluate.

@Test
@Ignore
public void testContextualFeatureEvaluate() throws TransformerException {
    SimpleFeature feature = generateSampleFeature();
    FilterFactory filterFactory = new FilterFactoryImpl();
    PropertyIsEqualTo filter = filterFactory.equal(filterFactory.property("name"), filterFactory.literal("FirstFeature"), true);
    printFilter(filter);
    assertTrue(filter.evaluate(feature));
}
Also used : PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) SimpleFeature(org.opengis.feature.simple.SimpleFeature) FilterFactory(org.opengis.filter.FilterFactory) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with PropertyIsEqualTo

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

the class UniqueValueRenderer method createFilter.

/**
 * Creates the filter.
 *
 * @param rule the rule
 * @param fieldsElement the fields element
 * @param fieldDelimiterElement the field delimiter element
 * @param value the value
 */
private void createFilter(Rule rule, JsonElement fieldsElement, JsonElement fieldDelimiterElement, String value) {
    if (fieldsElement == null)
        return;
    if (value == null) {
        rule.setElseFilter(true);
    } else {
        List<String> fieldList = new ArrayList<String>();
        JsonArray fieldArray = fieldsElement.getAsJsonArray();
        for (int fieldIndex = 0; fieldIndex < fieldArray.size(); fieldIndex++) {
            JsonElement jsonFieldElement = fieldArray.get(fieldIndex);
            if (jsonFieldElement != null) {
                JsonObject fieldObj = jsonFieldElement.getAsJsonObject();
                fieldList.add(fieldObj.get("name").getAsString());
            }
        }
        String[] values = null;
        if (fieldDelimiterElement != null) {
            values = value.split(fieldDelimiterElement.getAsString());
        } else {
            values = new String[1];
            values[0] = value;
        }
        List<Filter> filterList = new ArrayList<Filter>();
        int index = 0;
        while (index < values.length) {
            Expression fieldExpression = filterFactory.property(fieldList.get(index));
            Expression valueExpression = filterFactory.literal(values[index]);
            PropertyIsEqualTo filter = filterFactory.equals(fieldExpression, valueExpression);
            filterList.add(filter);
            index++;
        }
        Filter completeFilter = null;
        if (filterList.size() > 1) {
            completeFilter = filterFactory.and(filterList);
        } else if (filterList.size() == 1) {
            completeFilter = filterList.get(0);
        }
        rule.setFilter(completeFilter);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Filter(org.opengis.filter.Filter) Expression(org.opengis.filter.expression.Expression) JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) InternationalString(org.opengis.util.InternationalString)

Example 5 with PropertyIsEqualTo

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

the class CswRecordMapperFilterVisitorTest method testVisitPropertyIsEqualTo.

@Test
public void testVisitPropertyIsEqualTo() {
    Expression val = factory.literal("foo");
    PropertyIsEqualTo filter = factory.equals(attrExpr, val);
    PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
    assertThat(duplicate.getExpression1(), is(attrExpr));
    assertThat(duplicate.getExpression2(), is(val));
    assertThat(duplicate.isMatchingCase(), is(true));
}
Also used : PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Expression(org.opengis.filter.expression.Expression) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Aggregations

PropertyIsEqualTo (org.opengis.filter.PropertyIsEqualTo)18 Test (org.junit.Test)15 Expression (org.opengis.filter.expression.Expression)7 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)6 Filter (org.opengis.filter.Filter)5 Literal (org.opengis.filter.expression.Literal)4 ArrayList (java.util.ArrayList)3 Ignore (org.junit.Ignore)2 SimpleFeature (org.opengis.feature.simple.SimpleFeature)2 Function (org.opengis.filter.expression.Function)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 FilterDelegate (ddf.catalog.filter.FilterDelegate)1 LiteralImpl (ddf.catalog.filter.impl.LiteralImpl)1 PropertyIsEqualToLiteral (ddf.catalog.filter.impl.PropertyIsEqualToLiteral)1 PropertyNameImpl (ddf.catalog.filter.impl.PropertyNameImpl)1 GeotoolsFilterAdapterImpl (ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl)1 FuzzyFunction (ddf.catalog.impl.filter.FuzzyFunction)1