use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.
the class WfsSource method initProviders.
private List<? extends Object> initProviders() {
// We need to tell the JAXBElementProvider to marshal the GetFeatureType
// class as an element
// because it is missing the @XmlRootElement Annotation
JAXBElementProvider<GetFeatureType> provider = new Wfs20JaxbElementProvider<>();
Map<String, String> jaxbClassMap = new HashMap<>();
// Ensure a namespace is used when the GetFeature request is generated
String expandedName = new QName(Wfs20Constants.WFS_2_0_NAMESPACE, Wfs20Constants.GET_FEATURE).toString();
jaxbClassMap.put(GetFeatureType.class.getName(), expandedName);
provider.setJaxbElementClassMap(jaxbClassMap);
provider.setMarshallAsJaxbElement(true);
featureCollectionReader = new FeatureCollectionMessageBodyReaderWfs20();
return Arrays.asList(provider, new XmlSchemaMessageBodyReaderWfs20(), featureCollectionReader);
}
use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testQueryLatLonCoordinateOrder.
@Test
public void testQueryLatLonCoordinateOrder() throws Exception {
mapSchemaToFeatures(ONE_GML_PROPERTY_SCHEMA, ONE_FEATURE);
setUpMocks(Collections.singletonList("DWithin"), SRS_NAME, ONE_FEATURE, ONE_FEATURE);
source.setPollInterval(1);
final Map<String, Object> configuration = ImmutableMap.<String, Object>builder().put("wfsUrl", "http://localhost/wfs").put("coordinateOrder", LAT_LON_ORDER).put("forceSpatialFilter", "NO_FILTER").put("allowRedirects", false).put("disableCnCheck", false).put("pollInterval", 1).put("disableSorting", false).put("supportsStartIndex", false).put("forceAllGeometryOperands", false).build();
source.refresh(configuration);
final Filter withinFilter = builder.attribute(Metacard.ANY_GEO).is().withinBuffer().wkt(POINT_WKT, 10.0);
final Query withinQuery = new QueryImpl(withinFilter);
final ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(withinQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
assertThat(getFeatureType.getQuery(), hasSize(1));
final QueryType query = getFeatureType.getQuery().get(0);
assertThat(query.getFilter().getSpatialOps().getValue(), is(instanceOf(DistanceBufferType.class)));
final DistanceBufferType distanceBufferType = (DistanceBufferType) query.getFilter().getSpatialOps().getValue();
assertThat(distanceBufferType.getGeometry().getValue(), is(instanceOf(PointType.class)));
final PointType pointType = (PointType) distanceBufferType.getGeometry().getValue();
assertThat(pointType.getCoordinates().getValue(), is("-10.0,30.0"));
}
use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testSortingNoSortBy.
@Test
public void testSortingNoSortBy() throws Exception {
// Setup
mapSchemaToFeatures(ONE_TEXT_PROPERTY_SCHEMA_PERSON, ONE_FEATURE);
setUpMocks(null, null, ONE_FEATURE, ONE_FEATURE);
final QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text("literal"));
propertyIsLikeQuery.setPageSize(1);
final ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(propertyIsLikeQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
final ExtendedGetFeatureType getResults = captor.getAllValues().get(1);
assertThat(getResults.getResultType(), is(ResultTypeType.RESULTS));
for (final ExtendedGetFeatureType getFeatureType : captor.getAllValues()) {
assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
final QueryType queryType = getFeatureType.getQuery().get(0);
assertThat(queryType.isSetSortBy(), is(false));
}
}
use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testQueryTwoFeaturesOneInvalid.
@Test
public void testQueryTwoFeaturesOneInvalid() throws Exception {
mapSchemaToSingleFeature(TWO_TEXT_PROPERTY_SCHEMA, 0);
mapSchemaToSingleFeature(ONE_TEXT_PROPERTY_SCHEMA_PERSON, 1);
setUpMocks(null, null, TWO_FEATURES, TWO_FEATURES);
Filter orderDogFilter = builder.attribute(ORDER_DOG).is().like().text(LITERAL);
Filter mctFeature1Filter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
Filter feature1Filter = builder.allOf(Arrays.asList(orderDogFilter, mctFeature1Filter));
Filter fakeFilter = builder.attribute("FAKE").is().like().text(LITERAL);
Filter mctFeature2Filter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(1).getLocalPart());
Filter feature2Filter = builder.allOf(Arrays.asList(fakeFilter, mctFeature2Filter));
Filter totalFilter = builder.anyOf(Arrays.asList(feature1Filter, feature2Filter));
QueryImpl inQuery = new QueryImpl(totalFilter);
inQuery.setPageSize(MAX_FEATURES);
ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(inQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
assertMaxFeatures(getFeatureType, inQuery);
List<QueryType> filterQueries = getFeatureType.getQuery().stream().filter(QueryType::isSetFilter).collect(Collectors.toList());
assertThat(filterQueries, hasSize(ONE_FEATURE));
QueryType query = filterQueries.get(0);
assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
// The Text Properties should be ORed
assertThat(query.getFilter().isSetComparisonOps(), is(true));
assertThat(query.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
PropertyIsLikeType pilt = (PropertyIsLikeType) query.getFilter().getComparisonOps().getValue();
assertThat(ORDER_DOG, is(pilt.getPropertyName().getContent().get(0)));
}
use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.
the class WfsSourceTest method testQueryLonLatCoordinateOrder.
@Test
public void testQueryLonLatCoordinateOrder() throws Exception {
mapSchemaToFeatures(ONE_GML_PROPERTY_SCHEMA, ONE_FEATURE);
setUpMocks(Collections.singletonList("DWithin"), SRS_NAME, ONE_FEATURE, ONE_FEATURE);
source.setPollInterval(1);
final Map<String, Object> configuration = ImmutableMap.<String, Object>builder().put("wfsUrl", "http://localhost/wfs").put("coordinateOrder", LON_LAT_ORDER).put("forceSpatialFilter", "NO_FILTER").put("allowRedirects", false).put("disableCnCheck", false).put("pollInterval", 1).put("disableSorting", false).put("supportsStartIndex", false).put("forceAllGeometryOperands", false).build();
source.refresh(configuration);
final Filter withinFilter = builder.attribute(Metacard.ANY_GEO).is().withinBuffer().wkt(POINT_WKT, 10.0);
final Query withinQuery = new QueryImpl(withinFilter);
final ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
source.query(new QueryRequestImpl(withinQuery));
verify(mockWfs, times(2)).getFeature(captor.capture());
ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
assertThat(getFeatureType.getQuery(), hasSize(1));
final QueryType query = getFeatureType.getQuery().get(0);
assertThat(query.getFilter().getSpatialOps().getValue(), is(instanceOf(DistanceBufferType.class)));
final DistanceBufferType distanceBufferType = (DistanceBufferType) query.getFilter().getSpatialOps().getValue();
assertThat(distanceBufferType.getGeometry().getValue(), is(instanceOf(PointType.class)));
final PointType pointType = (PointType) distanceBufferType.getGeometry().getValue();
assertThat(pointType.getCoordinates().getValue(), is("30.0,-10.0"));
}
Aggregations