Search in sources :

Example 51 with GetFeatureType

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);
}
Also used : XmlSchemaMessageBodyReaderWfs20(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.reader.XmlSchemaMessageBodyReaderWfs20) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) FeatureCollectionMessageBodyReaderWfs20(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.source.reader.FeatureCollectionMessageBodyReaderWfs20) Wfs20JaxbElementProvider(org.codice.ddf.spatial.ogc.wfs.v2_0_0.catalog.common.Wfs20JaxbElementProvider) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType)

Example 52 with GetFeatureType

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"));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Query(ddf.catalog.operation.Query) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) PointType(net.opengis.gml.v_3_1_1.PointType) DistanceBufferType(net.opengis.filter.v_1_1_0.DistanceBufferType) QueryType(net.opengis.wfs.v_1_1_0.QueryType) Test(org.junit.Test)

Example 53 with GetFeatureType

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));
    }
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryType(net.opengis.wfs.v_1_1_0.QueryType) Test(org.junit.Test)

Example 54 with GetFeatureType

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)));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryType(net.opengis.wfs.v_1_1_0.QueryType) PropertyIsLikeType(net.opengis.filter.v_1_1_0.PropertyIsLikeType) Test(org.junit.Test)

Example 55 with GetFeatureType

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"));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Query(ddf.catalog.operation.Query) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) PointType(net.opengis.gml.v_3_1_1.PointType) DistanceBufferType(net.opengis.filter.v_1_1_0.DistanceBufferType) QueryType(net.opengis.wfs.v_1_1_0.QueryType) Test(org.junit.Test)

Aggregations

QueryImpl (ddf.catalog.operation.impl.QueryImpl)58 Test (org.junit.Test)57 Filter (org.opengis.filter.Filter)34 GetFeatureType (net.opengis.wfs.v_2_0_0.GetFeatureType)32 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)31 QueryType (net.opengis.wfs.v_2_0_0.QueryType)21 ArrayList (java.util.ArrayList)19 GetFeatureType (ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType)19 QueryType (net.opengis.wfs.v_1_1_0.QueryType)17 Matchers.containsString (org.hamcrest.Matchers.containsString)15 SortByImpl (ddf.catalog.filter.impl.SortByImpl)12 QueryType (ogc.schema.opengis.wfs.v_1_0_0.QueryType)12 SortBy (org.opengis.filter.sort.SortBy)12 Query (ddf.catalog.operation.Query)9 QName (javax.xml.namespace.QName)9 MetacardMapper (org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper)8 Metacard (ddf.catalog.data.Metacard)5 UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)5 JAXBElement (javax.xml.bind.JAXBElement)5 SortByType (net.opengis.filter.v_2_0_0.SortByType)5