Search in sources :

Example 56 with GetFeatureType

use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.

the class WfsSourceTest method testGmlImport.

@Test
public void testGmlImport() throws Exception {
    mapSchemaToFeatures(GML_IMPORT_SCHEMA, ONE_FEATURE);
    setUpMocks(Collections.singletonList("BBOX"), SRS_NAME, ONE_FEATURE, ONE_FEATURE);
    Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
    QueryImpl intersectQuery = new QueryImpl(intersectFilter);
    intersectQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
    source.query(new QueryRequestImpl(intersectQuery));
    verify(mockWfs, times(2)).getFeature(captor.capture());
    ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
    assertMaxFeatures(getFeatureType, intersectQuery);
    assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
    QueryType query = getFeatureType.getQuery().get(0);
    assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
    assertThat(query.getFilter().isSetSpatialOps(), is(true));
    assertThat(query.getFilter().getSpatialOps().getValue(), is(instanceOf(SpatialOpsType.class)));
}
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) Test(org.junit.Test)

Example 57 with GetFeatureType

use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.

the class WfsSourceTest method testQueryTwoFeaturesWithMixedPropertyNames.

@Test
public void testQueryTwoFeaturesWithMixedPropertyNames() throws Exception {
    mapSchemaToSingleFeature(ONE_TEXT_PROPERTY_SCHEMA_PERSON, 0);
    mapSchemaToSingleFeature(ONE_TEXT_PROPERTY_SCHEMA_DOG, 1);
    setUpMocks(null, null, TWO_FEATURES, TWO_FEATURES);
    Filter orderPersonFilter = builder.attribute(ORDER_PERSON).is().like().text(LITERAL);
    Filter mctFeature1Filter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
    Filter feature1Filter = builder.allOf(Arrays.asList(orderPersonFilter, mctFeature1Filter));
    Filter orderDogFilter = builder.attribute(ORDER_DOG).is().like().text(LITERAL);
    Filter mctFeature2Filter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(1).getLocalPart());
    Filter feature2Filter = builder.allOf(Arrays.asList(orderDogFilter, 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);
    getFeatureType.getQuery().sort(QUERY_TYPE_COMPARATOR);
    assertThat(TWO_FEATURES, is(getFeatureType.getQuery().size()));
    // Feature 1
    QueryType query = getFeatureType.getQuery().get(0);
    assertThat(query.getTypeName().get(0), equalTo(sampleFeatures.get(0)));
    // this should only have 1 filter which is a comparison
    assertThat(query.getFilter().isSetComparisonOps(), is(true));
    assertThat(query.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
    PropertyIsLikeType pilt = (PropertyIsLikeType) query.getFilter().getComparisonOps().getValue();
    assertThat(pilt, notNullValue());
    assertThat(ORDER_PERSON, is(pilt.getPropertyName().getContent().get(0)));
    // Feature 2
    QueryType query2 = getFeatureType.getQuery().get(1);
    assertThat(query2.getTypeName().get(0), is(sampleFeatures.get(1)));
    // this should only have 1 filter which is a comparison
    assertThat(query2.getFilter().isSetComparisonOps(), is(true));
    assertThat(query2.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
    PropertyIsLikeType pilt2 = (PropertyIsLikeType) query2.getFilter().getComparisonOps().getValue();
    assertThat(ORDER_DOG, is(pilt2.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 58 with GetFeatureType

use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.

the class WfsSourceTest method testTwoIntersectQuery.

@Test
public void testTwoIntersectQuery() throws Exception {
    mapSchemaToFeatures(TWO_GML_PROPERTY_SCHEMA, ONE_FEATURE);
    setUpMocks(Arrays.asList("Intersects", "BBOX"), SRS_NAME, ONE_FEATURE, ONE_FEATURE);
    Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
    QueryImpl intersectQuery = new QueryImpl(intersectFilter);
    intersectQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
    source.query(new QueryRequestImpl(intersectQuery));
    verify(mockWfs, times(2)).getFeature(captor.capture());
    ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
    assertMaxFeatures(getFeatureType, intersectQuery);
    assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
    QueryType query = getFeatureType.getQuery().get(0);
    assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
    // The Text Properties should be ORed
    assertThat(query.getFilter(), notNullValue());
    assertThat(query.getFilter().isSetLogicOps(), is(true));
    assertThat(query.getFilter().getLogicOps().getValue(), is(instanceOf(LogicOpsType.class)));
}
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) Test(org.junit.Test)

Example 59 with GetFeatureType

use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.

the class WfsSourceTest method testBboxQuery.

@Test
public void testBboxQuery() throws Exception {
    mapSchemaToFeatures(ONE_GML_PROPERTY_SCHEMA, ONE_FEATURE);
    setUpMocks(Collections.singletonList("BBOX"), SRS_NAME, ONE_FEATURE, ONE_FEATURE);
    Filter intersectFilter = builder.attribute(Metacard.ANY_GEO).is().intersecting().wkt(POLYGON_WKT);
    QueryImpl intersectQuery = new QueryImpl(intersectFilter);
    intersectQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
    source.query(new QueryRequestImpl(intersectQuery));
    verify(mockWfs, times(2)).getFeature(captor.capture());
    ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
    assertMaxFeatures(getFeatureType, intersectQuery);
    assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
    QueryType query = getFeatureType.getQuery().get(0);
    assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
    assertThat(query.getFilter().isSetSpatialOps(), is(true));
    assertThat(query.getFilter().getSpatialOps().getValue(), is(instanceOf(SpatialOpsType.class)));
}
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) Test(org.junit.Test)

Example 60 with GetFeatureType

use of net.opengis.wfs.v_1_1_0.GetFeatureType in project ddf by codice.

the class WfsSourceTest method testTypeNameHasNoPrefix.

@Test
public void testTypeNameHasNoPrefix() throws Exception {
    // Setup
    final String TITLE = "title";
    final String searchPhrase = "*";
    final int pageSize = 1;
    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), 3, false, false, 3);
    QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
    query.setPageSize(pageSize);
    SortBy sortBy = new SortByImpl(TITLE, SortOrder.DESCENDING);
    query.setSortBy(sortBy);
    // Perform test
    GetFeatureType featureType = source.buildGetFeatureRequest(query);
    // Validate
    List<JAXBElement<?>> queryList = featureType.getAbstractQueryExpression();
    for (JAXBElement<?> queryType : queryList) {
        Object val = queryType.getValue();
        QueryType queryTypeVal = (QueryType) val;
        assertThat(queryTypeVal.getTypeNames().get(0), containsString("SampleFeature"));
        assertThat(queryTypeVal.getTypeNames().get(0), is(not(containsString("Prefix"))));
        assertThat(queryTypeVal.getTypeNames().get(0), is(not(containsString(":"))));
    }
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) SortByImpl(ddf.catalog.filter.impl.SortByImpl) SortBy(org.opengis.filter.sort.SortBy) Matchers.containsString(org.hamcrest.Matchers.containsString) JAXBElement(javax.xml.bind.JAXBElement) QueryType(net.opengis.wfs.v_2_0_0.QueryType) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType) 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