Search in sources :

Example 46 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class TestWfsFilterDelegate method testUnsupportedFilterType.

private void testUnsupportedFilterType(Method spatialOpMeth, SPATIAL_OPERATORS failType) throws InvocationTargetException, IllegalAccessException {
    WfsFilterDelegate delegate = setupFilterDelegate(failType.toString());
    FilterType filter = (FilterType) spatialOpMeth.invoke(delegate, Metacard.ANY_GEO, POLYGON);
    assertNull(filter);
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType)

Example 47 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class TestWfsFilterDelegate method testRelativeTemporalOnlyQueryAfterSupported.

/**
     * If the WFS server does support an 'After' temporal query and supports a
     * 'During' temporal query, the query should remain an 'After' query
     */
@Test
public void testRelativeTemporalOnlyQueryAfterSupported() {
    setupMockMetacardType();
    FilterType afterFilter = setupAfterFilterType();
    assertThat(afterFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}After"));
    BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) afterFilter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimeInstantType timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    TimePositionType beginPositionType = timePeriod.getTimePosition();
    Date beginDate = timePositionTypeToDate(beginPositionType);
    Date endDate = new Date();
    // Verify Date range is created correctly
    assertThat(endDate.after(beginDate), is(true));
}
Also used : TimeInstantType(net.opengis.gml.v_3_2_1.TimeInstantType) FilterType(net.opengis.filter.v_2_0_0.FilterType) BinaryTemporalOpType(net.opengis.filter.v_2_0_0.BinaryTemporalOpType) TimePositionType(net.opengis.gml.v_3_2_1.TimePositionType) Date(java.util.Date) Test(org.junit.Test)

Example 48 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class TestWfsFilterDelegate method testSequentialPropertyIsOfTemporalType.

private void testSequentialPropertyIsOfTemporalType(String methName, String temporalOpName) throws Exception {
    SequentialTestMockHolder sequentialTestMockHolder = new SequentialTestMockHolder().invoke();
    WfsFilterDelegate delegate = sequentialTestMockHolder.getDelegate();
    String mockMetacardAttribute = sequentialTestMockHolder.getMockMetacardAttribute();
    String mockFeatureProperty = sequentialTestMockHolder.getMockFeatureProperty();
    String mockFeatureType = sequentialTestMockHolder.getMockFeatureType();
    DateTime date = new DateTime().minusDays(365);
    // Perform Test
    Method method = WfsFilterDelegate.class.getMethod(methName, String.class, Date.class);
    FilterType filter = (FilterType) method.invoke(delegate, mockMetacardAttribute, date.toDate());
    //Verify
    assertThat(filter.getTemporalOps().getName().toString(), is(temporalOpName));
    BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) filter.getTemporalOps().getValue();
    assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
    assertThat(binaryTemporalOpType.getValueReference(), is(mockFeatureProperty));
    assertThat(binaryTemporalOpType.isSetExpression(), is(true));
    TimeInstantType timeInstant = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
    assertThat(timeInstant.getTimePosition().getValue().get(0), is(ISODateTimeFormat.dateTimeNoMillis().withZone(DateTimeZone.UTC).print(date)));
    assertThat("Strings matches expected pattern", timeInstant.getId().matches(getRegEx(mockFeatureType)), equalTo(true));
}
Also used : TimeInstantType(net.opengis.gml.v_3_2_1.TimeInstantType) FilterType(net.opengis.filter.v_2_0_0.FilterType) Method(java.lang.reflect.Method) DateTime(org.joda.time.DateTime) BinaryTemporalOpType(net.opengis.filter.v_2_0_0.BinaryTemporalOpType)

Example 49 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class TestWfsFilterDelegate method testLogicalOrNoLogicalSupport.

@Test(expected = UnsupportedOperationException.class)
public void testLogicalOrNoLogicalSupport() throws Exception {
    WfsFilterDelegate delegate = makeDelegateForLogicalSupportTests();
    FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    FilterType compFilter2 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
    List<FilterType> filtersToBeOred = new ArrayList<>();
    filtersToBeOred.add(compFilter1);
    filtersToBeOred.add(compFilter2);
    //Perform Test
    FilterType filter = delegate.or(filtersToBeOred);
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 50 with FilterType

use of net.opengis.filter.v_2_0_0.FilterType in project ddf by codice.

the class TestWfsFilterDelegate method testBeyondFilter.

@Test
public void testBeyondFilter() throws JAXBException, SAXException, IOException {
    WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.Beyond.toString());
    FilterType filter = delegate.beyond(Metacard.ANY_GEO, POLYGON, DISTANCE);
    assertTrue(filter.isSetSpatialOps());
    assertTrue(filter.getSpatialOps().getValue() instanceof DistanceBufferType);
    assertXMLEqual(MockWfsServer.getBeyondXmlFilter(), getXmlFromMarshaller(filter));
}
Also used : FilterType(net.opengis.filter.v_2_0_0.FilterType) DistanceBufferType(net.opengis.filter.v_2_0_0.DistanceBufferType) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)212 FilterType (net.opengis.filter.v_1_1_0.FilterType)209 FilterType (net.opengis.filter.v_2_0_0.FilterType)58 ArrayList (java.util.ArrayList)50 JAXBElement (javax.xml.bind.JAXBElement)12 CswSourceConfiguration (org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration)12 BinaryTemporalOpType (net.opengis.filter.v_2_0_0.BinaryTemporalOpType)11 FeatureAttributeDescriptor (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureAttributeDescriptor)11 QName (javax.xml.namespace.QName)10 BinarySpatialOpType (net.opengis.filter.v_2_0_0.BinarySpatialOpType)10 LineString (com.vividsolutions.jts.geom.LineString)9 Date (java.util.Date)9 DistanceBufferType (net.opengis.filter.v_2_0_0.DistanceBufferType)9 UnaryLogicOpType (net.opengis.filter.v_2_0_0.UnaryLogicOpType)9 DateTime (org.joda.time.DateTime)8 Method (java.lang.reflect.Method)7 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)7 FilterCapabilities (net.opengis.filter.v_2_0_0.FilterCapabilities)7 TimePeriodType (net.opengis.gml.v_3_2_1.TimePeriodType)7 TimePositionType (net.opengis.gml.v_3_2_1.TimePositionType)7