Search in sources :

Example 1 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsGreaterThanTemporal.

@Test
public void testVisitPropertyIsGreaterThanTemporal() {
    Expression val = factory.literal(new Date(System.currentTimeMillis() - 1000));
    Expression test = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, "TestDate", CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    PropertyIsGreaterThan filter = factory.greater(test, val);
    Object obj = visitor.visit(filter, null);
    assertThat(obj, instanceOf(During.class));
    During duplicate = (During) obj;
    assertThat(duplicate.getExpression1(), is(test));
    assertThat(duplicate.getExpression2(), is(val));
}
Also used : NameImpl(org.geotools.feature.NameImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) Date(java.util.Date) During(org.opengis.filter.temporal.During) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 2 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testOverlaps.

@Test
public void testOverlaps() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(TEMPORAL_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    TOverlaps overlapsFilter = new TOverlapsImpl(duringFilter.getExpression1(), duringFilter.getExpression2());
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(overlapsFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), allOf(is(notNullValue()), hasProperty("startDate", is(START_DATE)), hasProperty("endDate", is(END_DATE))));
}
Also used : TOverlaps(org.opengis.filter.temporal.TOverlaps) During(org.opengis.filter.temporal.During) TOverlapsImpl(org.geotools.filter.temporal.TOverlapsImpl) Test(org.junit.Test)

Example 3 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testMultipleFiltersWhereOneFilterIsIgnored.

/**
 * Test that other {@link Filter}s are still visited when a {@link Filter} is ignored. The {@link
 * Filter}s in this test are the same as {@link #testMultipleFilters} except that the temporal
 * criteria is from {@link #testNotModifiedTemporalFilter()}.
 */
@Test
public void testMultipleFiltersWhereOneFilterIsIgnored() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(SOME_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    Contains containsFilter = (Contains) geotoolsFilterBuilder.attribute(SPATIAL_ATTRIBUTE_NAME).containing().wkt(WKT_POLYGON);
    And andFilter = geotoolsFilterBuilder.allOf(duringFilter, containsFilter);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(andFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), is(nullValue()));
    assertThat(result.getGeometrySearches(), contains(hasToString(is(WKT_POLYGON))));
}
Also used : And(org.opengis.filter.And) Contains(org.opengis.filter.spatial.Contains) During(org.opengis.filter.temporal.During) Test(org.junit.Test)

Example 4 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testOverlapsOrNest.

@Test
public void testOverlapsOrNest() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(TEMPORAL_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    TOverlaps overlapsFilter = new TOverlapsImpl(duringFilter.getExpression1(), duringFilter.getExpression2());
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.OR);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(overlapsFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), is(nullValue()));
}
Also used : TOverlaps(org.opengis.filter.temporal.TOverlaps) During(org.opengis.filter.temporal.During) TOverlapsImpl(org.geotools.filter.temporal.TOverlapsImpl) Test(org.junit.Test)

Example 5 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testNotModifiedTemporalFilter.

/**
 * Temporal {@link Filter}s for attributes other than {@value TEMPORAL_ATTRIBUTE_NAME} should be
 * ignored.
 */
@Test
public void testNotModifiedTemporalFilter() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(SOME_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(duringFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), is(nullValue()));
}
Also used : During(org.opengis.filter.temporal.During) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 During (org.opengis.filter.temporal.During)12 Date (java.util.Date)3 TOverlapsImpl (org.geotools.filter.temporal.TOverlapsImpl)3 TOverlaps (org.opengis.filter.temporal.TOverlaps)3 And (org.opengis.filter.And)2 Contains (org.opengis.filter.spatial.Contains)2 FilterBuilder (ddf.catalog.filter.FilterBuilder)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 TemporalFilter (ddf.catalog.impl.filter.TemporalFilter)1 QName (javax.xml.namespace.QName)1 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)1 NameImpl (org.geotools.feature.NameImpl)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)1 InOrder (org.mockito.InOrder)1 Filter (org.opengis.filter.Filter)1 FilterVisitor (org.opengis.filter.FilterVisitor)1 PropertyIsGreaterThan (org.opengis.filter.PropertyIsGreaterThan)1 Expression (org.opengis.filter.expression.Expression)1