Search in sources :

Example 31 with Expression

use of org.opengis.filter.expression.Expression in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testSourceIdFilter.

@Test
public void testSourceIdFilter() {
    Expression val = factory.literal("source1");
    Expression val2 = factory.literal("source2");
    Expression sourceExpr = factory.property(Core.SOURCE_ID);
    PropertyIsEqualTo filter = factory.equal(sourceExpr, val, false);
    Filter filter2 = factory.equal(sourceExpr, val2, false);
    Filter likeFilter = factory.like(attrExpr, "something");
    Filter sourceFilter = factory.or(filter, filter2);
    Filter totalFilter = factory.and(sourceFilter, likeFilter);
    Object obj = totalFilter.accept(visitor, null);
    assertThat(obj, instanceOf(PropertyIsLike.class));
    PropertyIsLike duplicate = (PropertyIsLike) obj;
    assertThat(duplicate.getExpression(), is(attrExpr));
    assertThat(duplicate.getLiteral(), is("something"));
    assertThat(visitor.getSourceIds().size(), is(2));
}
Also used : PropertyIsLike(org.opengis.filter.PropertyIsLike) PropertyIsEqualTo(org.opengis.filter.PropertyIsEqualTo) Expression(org.opengis.filter.expression.Expression) Filter(org.opengis.filter.Filter) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 32 with Expression

use of org.opengis.filter.expression.Expression in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsLessThanOrEqualToTemporal.

@Ignore("not supported by solr provider")
@Test
public void testVisitPropertyIsLessThanOrEqualToTemporal() {
    Expression val = factory.literal(new Date());
    PropertyIsLessThanOrEqualTo filter = factory.lessOrEqual(created, val);
    Object obj = visitor.visit(filter, null);
    assertThat(obj, instanceOf(Or.class));
    Or duplicate = (Or) obj;
    for (Filter child : duplicate.getChildren()) {
        BinaryTemporalOperator binary = (BinaryTemporalOperator) child;
        assertThat(binary, anyOf(instanceOf(TEquals.class), instanceOf(Before.class)));
        assertThat(binary.getExpression1(), is(created));
        assertThat(binary.getExpression2(), is(val));
    }
}
Also used : BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Or(org.opengis.filter.Or) PropertyIsLessThanOrEqualTo(org.opengis.filter.PropertyIsLessThanOrEqualTo) Expression(org.opengis.filter.expression.Expression) Filter(org.opengis.filter.Filter) Date(java.util.Date) Ignore(org.junit.Ignore) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 33 with Expression

use of org.opengis.filter.expression.Expression in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsGreaterThan.

@Test
public void testVisitPropertyIsGreaterThan() {
    Expression val = factory.literal(8);
    PropertyIsGreaterThan filter = factory.greater(attrExpr, val);
    Object obj = visitor.visit(filter, null);
    assertThat(obj, instanceOf(PropertyIsGreaterThan.class));
    PropertyIsGreaterThan duplicate = (PropertyIsGreaterThan) obj;
    assertThat(duplicate.getExpression1(), is(attrExpr));
    assertThat(duplicate.getExpression2(), is(val));
}
Also used : Expression(org.opengis.filter.expression.Expression) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 34 with Expression

use of org.opengis.filter.expression.Expression in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsLessThanOrEqualTo.

@Test
public void testVisitPropertyIsLessThanOrEqualTo() {
    Expression val = factory.literal(8);
    PropertyIsLessThanOrEqualTo filter = factory.lessOrEqual(attrExpr, val);
    Object obj = visitor.visit(filter, null);
    assertThat(obj, instanceOf(PropertyIsLessThanOrEqualTo.class));
    PropertyIsLessThanOrEqualTo duplicate = (PropertyIsLessThanOrEqualTo) obj;
    assertThat(duplicate.getExpression1(), is(attrExpr));
    assertThat(duplicate.getExpression2(), is(val));
}
Also used : PropertyIsLessThanOrEqualTo(org.opengis.filter.PropertyIsLessThanOrEqualTo) Expression(org.opengis.filter.expression.Expression) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 35 with Expression

use of org.opengis.filter.expression.Expression in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsBetween.

@Test
public void testVisitPropertyIsBetween() {
    Expression lower = factory.literal(4);
    Expression upper = factory.literal(7);
    PropertyIsBetween filter = factory.between(attrExpr, lower, upper);
    PropertyIsBetween duplicate = (PropertyIsBetween) visitor.visit(filter, null);
    assertThat(duplicate.getExpression(), is(attrExpr));
    assertThat(duplicate.getLowerBoundary(), is(lower));
    assertThat(duplicate.getUpperBoundary(), is(upper));
}
Also used : Expression(org.opengis.filter.expression.Expression) PropertyIsBetween(org.opengis.filter.PropertyIsBetween) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Aggregations

Expression (org.opengis.filter.expression.Expression)38 Test (org.junit.Test)20 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)17 ArrayList (java.util.ArrayList)9 Date (java.util.Date)8 AttributeType (ddf.catalog.data.AttributeType)7 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)7 Filter (org.opengis.filter.Filter)7 Literal (org.opengis.filter.expression.Literal)5 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)4 Coordinate (com.vividsolutions.jts.geom.Coordinate)3 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)3 FuzzyFunction (ddf.catalog.impl.filter.FuzzyFunction)3 SpatialFilter (ddf.catalog.impl.filter.SpatialFilter)3 DefaultInstant (org.geotools.temporal.object.DefaultInstant)3 DefaultPeriod (org.geotools.temporal.object.DefaultPeriod)3 DefaultPosition (org.geotools.temporal.object.DefaultPosition)3 PropertyIsEqualTo (org.opengis.filter.PropertyIsEqualTo)3 PropertyIsLike (org.opengis.filter.PropertyIsLike)3 Function (org.opengis.filter.expression.Function)3