use of net.opengis.filter.v_1_1_0.FilterType in project ddf by codice.
the class CswQueryFactoryTest method generateTemporalFilter.
private Filter generateTemporalFilter(JAXBElement<BinaryComparisonOpType> temporalOps) throws UnsupportedQueryException, SourceUnavailableException, FederationException, CswException {
GetRecordsType grr = createDefaultPostRecordsRequest();
QueryType query = new QueryType();
List<QName> typeNames = new ArrayList<>();
typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
query.setTypeNames(typeNames);
QueryConstraintType constraint = new QueryConstraintType();
FilterType filter = new FilterType();
filter.setComparisonOps(temporalOps);
constraint.setFilter(filter);
query.setConstraint(constraint);
JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
QueryImpl frameworkQuery = (QueryImpl) queryFactory.getQuery(grr).getQuery();
return frameworkQuery.getFilter();
}
use of net.opengis.filter.v_1_1_0.FilterType in project ddf by codice.
the class TestWfsFilterDelegate method testAbsoluteTemporalOnlyQueryDuringUnSupported.
/**
* If the WFS server does not support an 'After' and 'Before' temporal query,
* and supports a 'During' temporal query, the query should be translated
* into 'During <after> to <before>'
*/
@Test
public void testAbsoluteTemporalOnlyQueryDuringUnSupported() {
setupMockMetacardType();
FilterType afterFilter = setupAfterFilterType();
FilterType beforeFilter = setupBeforeFilterType();
WfsFilterDelegate delegate = setupTemporalFilterDelegate();
// Get After Filter Date
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 afterDate = timePositionTypeToDate(beginPositionType);
// Get Before Filter Date
binaryTemporalOpType = (BinaryTemporalOpType) beforeFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
timePeriod = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
TimePositionType endPositionType = timePeriod.getTimePosition();
Date beforeDate = timePositionTypeToDate(endPositionType);
List<FilterType> testFilters = new ArrayList<>();
testFilters.add(afterFilter);
testFilters.add(beforeFilter);
List<FilterType> convertedFilters = delegate.applyTemporalFallbacks(testFilters);
FilterType resultAfterFilter = convertedFilters.get(0);
FilterType resultBeforeFilter = convertedFilters.get(1);
assertThat(resultAfterFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}After"));
assertThat(resultBeforeFilter.getTemporalOps().getName().toString(), is("{http://www.opengis.net/fes/2.0}Before"));
// Get Resulting After Filter Date
binaryTemporalOpType = (BinaryTemporalOpType) resultAfterFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
TimeInstantType timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
beginPositionType = timePeriodType.getTimePosition();
Date beginDate = timePositionTypeToDate(beginPositionType);
// Get Resulting Before Filter Date
binaryTemporalOpType = (BinaryTemporalOpType) resultBeforeFilter.getTemporalOps().getValue();
assertThat(binaryTemporalOpType.isSetValueReference(), is(true));
assertThat(binaryTemporalOpType.isSetExpression(), is(true));
timePeriodType = (TimeInstantType) binaryTemporalOpType.getExpression().getValue();
endPositionType = timePeriodType.getTimePosition();
Date endDate = timePositionTypeToDate(endPositionType);
// Verify Date range is created correctly
assertThat(endDate.after(beginDate), is(true));
assertThat(endDate.equals(beforeDate), is(true));
assertThat(beginDate.equals(afterDate), is(true));
}
use of net.opengis.filter.v_1_1_0.FilterType in project ddf by codice.
the class TestWfsFilterDelegate method testDisjointFilter.
@Test
public void testDisjointFilter() throws SAXException, IOException, JAXBException {
WfsFilterDelegate delegate = setupFilterDelegate(SPATIAL_OPERATORS.Disjoint.toString());
FilterType filter = delegate.disjoint(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertXMLEqual(MockWfsServer.getDisjointXmlFilter(), getXmlFromMarshaller(filter));
}
use of net.opengis.filter.v_1_1_0.FilterType in project ddf by codice.
the class TestWfsFilterDelegate method testLogicalCombinatorsOneItem.
private void testLogicalCombinatorsOneItem(String methName) throws Exception {
String mockProperty = "myPropertyName";
String mockType = "myType";
WfsFilterDelegate delegate = mockFeatureMetacardCreateDelegate(mockProperty, mockType);
FilterType compFilter1 = delegate.propertyIsLike(Metacard.ANY_TEXT, LITERAL, true);
List<FilterType> filtersToCombine = new ArrayList<>();
filtersToCombine.add(compFilter1);
Method method = WfsFilterDelegate.class.getMethod(methName, List.class);
FilterType filter = (FilterType) method.invoke(delegate, filtersToCombine);
// Only one filter was provided to combinator so only that filter is returned as not
// enough filters to combine together
assertNull(filter.getLogicOps());
PropertyIsLikeType compOpsType1 = (PropertyIsLikeType) filter.getComparisonOps().getValue();
String valRef1 = fetchPropertyIsLikeExpression(compOpsType1, VALUE_REFERENCE);
assertThat(valRef1, is(mockProperty));
String literal1 = fetchPropertyIsLikeExpression(compOpsType1, LITERAL);
assertThat(literal1, is(LITERAL));
}
use of net.opengis.filter.v_1_1_0.FilterType in project ddf by codice.
the class TestWfsFilterDelegate method testIntersectsLonLat.
@Test
public void testIntersectsLonLat() throws SAXException, IOException, JAXBException {
List<String> gmlProps = new ArrayList<>();
gmlProps.add(MOCK_GEOM);
when(mockFeatureMetacardType.getGmlProperties()).thenReturn(gmlProps);
when(mockFeatureMetacardType.getAttributeDescriptor(MOCK_GEOM)).thenReturn(new FeatureAttributeDescriptor(MOCK_GEOM, MOCK_GEOM, true, false, false, false, BasicTypes.STRING_TYPE));
SpatialOperatorType operator = new SpatialOperatorType();
operator.setName(SPATIAL_OPERATORS.Intersects.toString());
FilterCapabilities capabilities = MockWfsServer.getFilterCapabilities();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().clear();
capabilities.getSpatialCapabilities().getSpatialOperators().getSpatialOperator().add(operator);
WfsFilterDelegate delegate = new WfsFilterDelegate(mockFeatureMetacardType, capabilities, GeospatialUtil.EPSG_4326_URN, null, GeospatialUtil.LON_LAT_ORDER);
FilterType filter = delegate.intersects(Metacard.ANY_GEO, POLYGON);
assertTrue(filter.getSpatialOps().getValue() instanceof BinarySpatialOpType);
assertFalse(filter.isSetLogicOps());
assertXMLEqual(MockWfsServer.getIntersectsLonLatXmlFilter(), getXmlFromMarshaller(filter));
}
Aggregations