Search in sources :

Example 6 with GetFeatureType

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

the class TestWfsSource method testTwoFeatureTypesQuery.

@Test
public void testTwoFeatureTypesQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, TWO_FEATURES, null);
    QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL));
    propertyIsLikeQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs).getFeature(captor.capture());
    GetFeatureType getFeatureType = captor.getValue();
    assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
    assertTrue(getFeatureType.getQuery().size() == TWO_FEATURES);
    Collections.sort(getFeatureType.getQuery(), QUERY_TYPE_COMPARATOR);
    QueryType query = getFeatureType.getQuery().get(0);
    assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
    assertTrue(query.getFilter().isSetComparisonOps());
    assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
    QueryType query2 = getFeatureType.getQuery().get(1);
    assertTrue(query2.getTypeName().equals(sampleFeatures.get(1)));
    assertTrue(query2.getFilter().isSetComparisonOps());
    assertTrue(query2.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryType(ogc.schema.opengis.wfs.v_1_0_0.QueryType) PropertyIsLikeType(ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) Test(org.junit.Test)

Example 7 with GetFeatureType

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

the class TestWfsSource method testAndQuery.

@Test
public void testAndQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, ONE_FEATURE, null);
    Filter propertyIsLikeFilter = builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL);
    Filter contentTypeFilter = builder.attribute(Metacard.ANY_TEXT).is().like().text(sampleFeatures.get(0).getLocalPart());
    QueryImpl propertyIsLikeQuery = new QueryImpl(builder.allOf(propertyIsLikeFilter, contentTypeFilter));
    propertyIsLikeQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs).getFeature(captor.capture());
    GetFeatureType getFeatureType = captor.getValue();
    assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
    assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
    QueryType query = getFeatureType.getQuery().get(0);
    assertTrue(query.getTypeName().equals(sampleFeatures.get(0)));
    assertTrue(query.getFilter().isSetLogicOps());
    assertTrue(query.getFilter().getLogicOps().getValue() instanceof BinaryLogicOpType);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) BinaryLogicOpType(ogc.schema.opengis.filter.v_1_0_0.BinaryLogicOpType) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryType(ogc.schema.opengis.wfs.v_1_0_0.QueryType) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) Test(org.junit.Test)

Example 8 with GetFeatureType

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

the class TestWfsSource method testContentTypeQuery.

@Test
public void testContentTypeQuery() throws UnsupportedQueryException, WfsException, SecurityServiceException {
    setUp(ONE_TEXT_PROPERTY_SCHEMA, null, null, ONE_FEATURE, null);
    Filter propertyIsLikeFilter = builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL);
    Filter contentTypeFilter = builder.attribute(Metacard.CONTENT_TYPE).is().like().text(sampleFeatures.get(0).getLocalPart());
    QueryImpl propertyIsLikeQuery = new QueryImpl(builder.allOf(propertyIsLikeFilter, contentTypeFilter));
    propertyIsLikeQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<GetFeatureType> captor = ArgumentCaptor.forClass(GetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs).getFeature(captor.capture());
    GetFeatureType getFeatureType = captor.getValue();
    assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
    assertTrue(getFeatureType.getQuery().size() == ONE_FEATURE);
    QueryType query = getFeatureType.getQuery().get(0);
    assertTrue(query.getTypeName().equals(// SAMPLE_FEATURE[0]));
    sampleFeatures.get(0)));
    assertTrue(query.getFilter().isSetComparisonOps());
    assertTrue(query.getFilter().getComparisonOps().getValue() instanceof PropertyIsLikeType);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) QueryType(ogc.schema.opengis.wfs.v_1_0_0.QueryType) PropertyIsLikeType(ogc.schema.opengis.filter.v_1_0_0.PropertyIsLikeType) GetFeatureType(ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType) Test(org.junit.Test)

Example 9 with GetFeatureType

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

the class TestWfsSource method testSearchByMultipleTypes.

@Test
public void testSearchByMultipleTypes() throws Exception {
    //Setup
    int pageSize = 10;
    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, 10, false);
    Filter filter0 = builder.attribute(Metacard.CONTENT_TYPE).is().equalTo().text(SAMPLE_FEATURE_NAME + "8");
    Filter filter1 = builder.attribute(Metacard.CONTENT_TYPE).is().equalTo().text(SAMPLE_FEATURE_NAME + "9");
    Filter filter2 = builder.attribute(Metacard.ANY_TEXT).is().like().text("*");
    Filter typeSearchFilters = builder.anyOf(filter0, filter1);
    QueryImpl query = new QueryImpl(builder.allOf(filter2, typeSearchFilters));
    query.setPageSize(pageSize);
    //Execute
    GetFeatureType featureType = source.buildGetFeatureRequest(query);
    int numTypes = featureType.getAbstractQueryExpression().size();
    //Validate
    assertEquals(2, numTypes);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) GetFeatureType(net.opengis.wfs.v_2_0_0.GetFeatureType) Test(org.junit.Test)

Example 10 with GetFeatureType

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

the class TestWfsSource method testSortingAscendingNoFeaturePropertyMappingSortingSupported.

/**
     * Verify that the SortBy is NOT set.  In this case, there is no mapping for the incoming sort property of TEMPORAL so no SortBy should be set.
     * <p/>
     * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
     * <ns5:GetFeature startIndex="1" count="1" service="WFS" version="2.0.0" xmlns:ns2="http://www.opengis.net/ows/1.1" xmlns="http://www.opengis.net/fes/2.0" xmlns:ns4="http://www.opengis.net/gml" xmlns:ns3="http://www.w3.org/1999/xlink" xmlns:ns5="http://www.opengis.net/wfs/2.0">
     * <ns5:Query typeNames="SampleFeature0" handle="SampleFeature0">
     * <Filter>
     * <PropertyIsLike wildCard="*" singleChar="?" escapeChar="!">
     * <Literal>*</Literal>
     * <ValueReference>title</ValueReference>
     * </PropertyIsLike>
     * </Filter>
     * </ns5:Query>
     * </ns5:GetFeature>
     */
@Test
public void testSortingAscendingNoFeaturePropertyMappingSortingSupported() throws Exception {
    // Setup
    final String searchPhrase = "*";
    final String mockFeatureType = "{http://example.com}" + SAMPLE_FEATURE_NAME + 0;
    final int pageSize = 1;
    WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, 1, false, false, 0);
    MetacardMapper mockMetacardMapper = mock(MetacardMapper.class);
    when(mockMetacardMapper.getFeatureType()).thenReturn(mockFeatureType);
    List<MetacardMapper> mappers = new ArrayList<MetacardMapper>(1);
    mappers.add(mockMetacardMapper);
    source.setMetacardToFeatureMapper(mappers);
    QueryImpl query = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text(searchPhrase));
    query.setPageSize(pageSize);
    SortBy sortBy = new SortByImpl(Result.TEMPORAL, SortOrder.ASCENDING);
    query.setSortBy(sortBy);
    // Perform Test
    GetFeatureType featureType = source.buildGetFeatureRequest(query);
    // Verify
    QueryType queryType = (QueryType) featureType.getAbstractQueryExpression().get(0).getValue();
    assertFalse(queryType.isSetAbstractSortingClause());
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) SortByImpl(ddf.catalog.filter.impl.SortByImpl) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) QueryType(net.opengis.wfs.v_2_0_0.QueryType) MetacardMapper(org.codice.ddf.spatial.ogc.wfs.catalog.mapper.MetacardMapper) 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