Search in sources :

Example 1 with BinaryTemporalOperator

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

the class CswQueryFactoryTest method ogcOrdTemporalQuery.

/**
     * Runs an Or'd query of multiple binary Temporal OGC Query, verifying that the right filter
     * class is generated based on OGC Filter
     *
     * @param temporalOps The Temporal query, in terms of a binary comparison
     * @throws UnsupportedQueryException
     * @throws SourceUnavailableException
     * @throws FederationException
     * @throws CswException
     */
@SuppressWarnings("unchecked")
private void ogcOrdTemporalQuery(JAXBElement<BinaryComparisonOpType> temporalOps) throws UnsupportedQueryException, SourceUnavailableException, FederationException, CswException {
    Filter filter = generateTemporalFilter(temporalOps);
    assertThat(filter, instanceOf(Or.class));
    Or ordTemporal = (Or) filter;
    List<Filter> temporalFilters = ordTemporal.getChildren();
    List<Class<? extends BinaryTemporalOperator>> classes = new ArrayList<>();
    for (Filter temporal : temporalFilters) {
        assertThat(temporal, instanceOf(BinaryTemporalOperator.class));
        classes.add((Class<? extends BinaryTemporalOperator>) temporal.getClass());
    }
}
Also used : BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Or(org.opengis.filter.Or) Filter(org.opengis.filter.Filter) ArrayList(java.util.ArrayList)

Example 2 with BinaryTemporalOperator

use of org.opengis.filter.temporal.BinaryTemporalOperator 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 3 with BinaryTemporalOperator

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

the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsGreaterThanOrEqualToTemporal.

@Ignore("not supported by solr provider")
@Test
public void testVisitPropertyIsGreaterThanOrEqualToTemporal() {
    Expression val = factory.literal(new Date());
    PropertyIsGreaterThanOrEqualTo filter = factory.greaterOrEqual(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(After.class)));
        assertThat(binary.getExpression1(), is(created));
        assertThat(binary.getExpression2(), is(val));
    }
}
Also used : PropertyIsGreaterThanOrEqualTo(org.opengis.filter.PropertyIsGreaterThanOrEqualTo) BinaryTemporalOperator(org.opengis.filter.temporal.BinaryTemporalOperator) Or(org.opengis.filter.Or) 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)

Aggregations

Filter (org.opengis.filter.Filter)3 Or (org.opengis.filter.Or)3 BinaryTemporalOperator (org.opengis.filter.temporal.BinaryTemporalOperator)3 Date (java.util.Date)2 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 Expression (org.opengis.filter.expression.Expression)2 ArrayList (java.util.ArrayList)1 PropertyIsGreaterThanOrEqualTo (org.opengis.filter.PropertyIsGreaterThanOrEqualTo)1 PropertyIsLessThanOrEqualTo (org.opengis.filter.PropertyIsLessThanOrEqualTo)1