use of net.opengis.fes.x20.BinaryTemporalOpType in project ddf by codice.
the class TestWfsFilterDelegate method testDuringPropertyIsOfTemporalType.
@Test
public /**
* Doing a Absolute query from the search UI creates a During filter with the selected Begin and End date/times.
*
* Example During filter:
*
* <Filter>
* <During>
* <ValueReference>myFeatureProperty</ValueReference>
* <ns4:TimePeriod ns4:id="myFeatureType.1406219647420">
* <ns4:beginPosition>1974-08-01T16:29:45.430-07:00</ns4:beginPosition>
* <ns4:endPosition>2014-07-22T16:29:45.430-07:00</ns4:endPosition>
* </ns4:TimePeriod>
* </During>
* </Filter>
*
**/
void testDuringPropertyIsOfTemporalType() throws Exception {
SequentialTestMockHolder sequentialTestMockHolder = new SequentialTestMockHolder().invoke();
WfsFilterDelegate delegate = sequentialTestMockHolder.getDelegate();
String mockMetacardAttribute = sequentialTestMockHolder.getMockMetacardAttribute();
String mockFeatureProperty = sequentialTestMockHolder.getMockFeatureProperty();
String mockFeatureType = sequentialTestMockHolder.getMockFeatureType();
DateTime startDate = new DateTime(2014, 01, 01, 01, 01, 01, 123, DateTimeZone.forID("-07:00"));
DateTime endDate = new DateTime(2014, 01, 02, 01, 01, 01, 123, DateTimeZone.forID("-07:00"));
// Perform Test
FilterType filter = delegate.during(mockMetacardAttribute, startDate.toDate(), endDate.toDate());
//Verify
assertThat(filter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During"));
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) filter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.getValueReference(), is(mockFeatureProperty));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimePeriodType timePeriod = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
assertThat(timePeriod.getBeginPosition().getValue().get(0), is("2014-01-01T08:01:01Z"));
assertThat(timePeriod.getEndPosition().getValue().get(0), is("2014-01-02T08:01:01Z"));
assertThat("Strings matches expected pattern", timePeriod.getId().matches(getRegEx(mockFeatureType)), equalTo(true));
}
use of net.opengis.fes.x20.BinaryTemporalOpType in project ddf by codice.
the class TestWfsFilterDelegate method testRelativeTemporalOnlyQueryAfterUnsupported.
/**
* If the WFS server does not support an 'After' temporal query and supports a
* 'During' temporal query, the query should be translated into a 'During <date> to <now>'
*/
@Test
public void testRelativeTemporalOnlyQueryAfterUnsupported() {
setupMockMetacardType();
FilterType afterFilter = setupAfterFilterType();
FilterCapabilities duringFilterCapabilities = setupFilterCapabilities();
WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
List<FilterType> testFilters = new ArrayList<>();
testFilters.add(afterFilter);
List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(testFilters);
FilterType duringFilter = convertedFilters.get(0);
assertThat(duringFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During"));
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimePeriodType timePeriod = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
TimePositionType beginPositionType = timePeriod.getBeginPosition();
Date beginDate = timePositionTypeToDate(beginPositionType);
TimePositionType endPositionType = timePeriod.getEndPosition();
Date endDate = timePositionTypeToDate(endPositionType);
// Verify Date range is created correctly
assertThat(endDate.after(beginDate), is(true));
}
use of net.opengis.fes.x20.BinaryTemporalOpType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalAndOfSpatialTemporal.
/**
* Verifies that a temporal criteria can be AND'ed to other criteria.
*
* @throws Exception
*/
@Test
public void testLogicalAndOfSpatialTemporal() throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType spatialFilter = delegate.dwithin(Metacard.ANY_GEO, "POINT (30 10)", Double.valueOf(1000));
FilterType temporalFilter = delegate.during(mockProperty, new DateTime().minusDays(365).toDate(), new DateTime().minusDays(10).toDate());
List<FilterType> filtersToBeAnded = new ArrayList<>(Arrays.asList(spatialFilter, temporalFilter));
//Perform Test
FilterType filter = delegate.and(filtersToBeAnded);
//Verify AND op used
if (filter.getLogicOps() == null) {
fail("No AND/OR element found in the generated FilterType.");
}
assertEquals(LOGICAL_AND_NAME, filter.getLogicOps().getName().toString());
BinaryLogicOpType logicOpType = (BinaryLogicOpType) filter.getLogicOps().getValue();
//Verify two items were AND'ed
assertEquals(2, logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().size());
//Verify first is spatial, second is temporal
assertTrue(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(0).getValue() instanceof DistanceBufferType);
assertTrue(logicOpType.getComparisonOpsOrSpatialOpsOrTemporalOps().get(1).getValue() instanceof BinaryTemporalOpType);
}
use of net.opengis.fes.x20.BinaryTemporalOpType in project ddf by codice.
the class WfsFilterDelegate method createBinaryTemporalOpType.
private BinaryTemporalOpType createBinaryTemporalOpType(String property, String type, String date) {
BinaryTemporalOpType binaryTemporalOpType = filterObjectFactory.createBinaryTemporalOpType();
binaryTemporalOpType.setValueReference(property);
binaryTemporalOpType.setExpression(gml320ObjectFactory.createTimeInstant(createTimeInstantType(type, date)));
return binaryTemporalOpType;
}
use of net.opengis.fes.x20.BinaryTemporalOpType in project ddf by codice.
the class WfsFilterDelegateTest method testRelativeTemporalOnlyQueryAfterUnsupported.
/**
* If the WFS server does not support an 'After' temporal query and supports a 'During' temporal
* query, the query should be translated into a 'During <date> to <now>'
*/
@Test
public void testRelativeTemporalOnlyQueryAfterUnsupported() {
setupMockMetacardType();
FilterType afterFilter = setupAfterFilterType();
FilterCapabilities duringFilterCapabilities = setupFilterCapabilities();
WfsFilterDelegate duringDelegate = new WfsFilterDelegate(mockFeatureMetacardType, duringFilterCapabilities, GeospatialUtil.EPSG_4326_URN, mockMapper, GeospatialUtil.LAT_LON_ORDER);
List<FilterType> testFilters = new ArrayList<>();
testFilters.add(afterFilter);
List<FilterType> convertedFilters = duringDelegate.applyTemporalFallbacks(testFilters);
FilterType duringFilter = convertedFilters.get(0);
assertThat(duringFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}During"));
BinaryTemporalOpType binaryTemporalOpType = (BinaryTemporalOpType) duringFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimePeriodType timePeriod = (TimePeriodType) binaryTemporalOpType.getExpression().getValue();
TimePositionType beginPositionType = timePeriod.getBeginPosition();
Date beginDate = timePositionTypeToDate(beginPositionType);
TimePositionType endPositionType = timePeriod.getEndPosition();
Date endDate = timePositionTypeToDate(endPositionType);
// Verify Date range is created correctly
assertThat(endDate.after(beginDate), is(true));
}
Aggregations