Search in sources :

Example 81 with QueryType

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

the class WfsSourceTest method testPropertyIsLikeQuery.

@Test
public void testPropertyIsLikeQuery() throws Exception {
    mapSchemaToFeatures(ONE_TEXT_PROPERTY_SCHEMA_PERSON, ONE_FEATURE);
    setUpMocks(null, null, ONE_FEATURE, ONE_FEATURE);
    QueryImpl propertyIsLikeQuery = new QueryImpl(builder.attribute(Metacard.ANY_TEXT).is().like().text("literal"));
    propertyIsLikeQuery.setPageSize(MAX_FEATURES);
    ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs, times(2)).getFeature(captor.capture());
    ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
    assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
    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().isSetComparisonOps(), is(true));
    assertThat(query.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
}
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 82 with QueryType

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

the class WfsSourceTest method testIntersectQuery.

@Test
public void testIntersectQuery() throws Exception {
    mapSchemaToFeatures(ONE_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)));
    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 83 with QueryType

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

the class WfsSourceTest method assertFeature.

private void assertFeature(ExtendedGetFeatureType getFeatureType, boolean sortingEnabled, String sortProperty, String sortOrder) {
    assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
    final QueryType queryType = getFeatureType.getQuery().get(0);
    if (sortingEnabled) {
        assertThat(queryType.isSetSortBy(), is(true));
        assertThat(queryType.getSortBy().getSortProperty().size(), is(1));
        assertThat(queryType.getSortBy().getSortProperty().get(0).getPropertyName().getContent().size(), is(1));
        assertThat(queryType.getSortBy().getSortProperty().get(0).getPropertyName().getContent().get(0), is(sortProperty));
        assertThat(queryType.getSortBy().getSortProperty().get(0).getSortOrder().value(), is(sortOrder));
    } else {
        assertThat(queryType.isSetSortBy(), is(false));
    }
}
Also used : QueryType(net.opengis.wfs.v_1_1_0.QueryType)

Example 84 with QueryType

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

the class WfsSourceTest method testAndQuery.

@Test
public void testAndQuery() throws Exception {
    mapSchemaToFeatures(ONE_TEXT_PROPERTY_SCHEMA_PERSON, ONE_FEATURE);
    setUpMocks(null, null, ONE_FEATURE, ONE_FEATURE);
    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<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs, times(2)).getFeature(captor.capture());
    ExtendedGetFeatureType getFeatureType = captor.getAllValues().get(1);
    assertMaxFeatures(getFeatureType, propertyIsLikeQuery);
    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().isSetLogicOps(), is(true));
    assertThat(query.getFilter().getLogicOps().getValue(), is(instanceOf(BinaryLogicOpType.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 85 with QueryType

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

the class WfsSourceTest method testQuerySendsHitsRequestBeforeResultsRequest.

@Test
public void testQuerySendsHitsRequestBeforeResultsRequest() throws Exception {
    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(MAX_FEATURES);
    final ArgumentCaptor<ExtendedGetFeatureType> captor = ArgumentCaptor.forClass(ExtendedGetFeatureType.class);
    source.query(new QueryRequestImpl(propertyIsLikeQuery));
    verify(mockWfs, times(2)).getFeature(captor.capture());
    final ExtendedGetFeatureType getHits = captor.getAllValues().get(0);
    assertThat(getHits.getResultType(), is(ResultTypeType.HITS));
    assertThat(getHits.getMaxFeatures(), is(nullValue()));
    final ExtendedGetFeatureType getResults = captor.getAllValues().get(1);
    assertThat(getResults.getResultType(), is(ResultTypeType.RESULTS));
    assertMaxFeatures(getResults, propertyIsLikeQuery);
    for (final ExtendedGetFeatureType getFeatureType : captor.getAllValues()) {
        assertThat(getFeatureType.getQuery().size(), is(ONE_FEATURE));
        final QueryType query = getFeatureType.getQuery().get(0);
        assertThat(query.getTypeName().get(0), is(sampleFeatures.get(0)));
        assertThat(query.getFilter().isSetComparisonOps(), is(true));
        assertThat(query.getFilter().getComparisonOps().getValue(), is(instanceOf(PropertyIsLikeType.class)));
    }
}
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)

Aggregations

QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)91 Test (org.junit.Test)89 QueryImpl (ddf.catalog.operation.impl.QueryImpl)71 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)67 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)58 Test (org.testng.annotations.Test)52 QName (javax.xml.namespace.QName)50 JAXBElement (javax.xml.bind.JAXBElement)44 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)38 ArrayList (java.util.ArrayList)37 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)34 Filter (org.opengis.filter.Filter)32 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)23 SortBy (org.opengis.filter.sort.SortBy)22 QueryConstraintType (net.opengis.cat.csw.v_2_0_2.QueryConstraintType)21 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)21 SortByImpl (ddf.catalog.filter.impl.SortByImpl)20 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)19 CswException (org.codice.ddf.spatial.ogc.csw.catalog.common.CswException)19 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)18