Search in sources :

Example 36 with QueryType

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

the class CswSubscriptionEndpointTest method testCreateOrUpdateSubscriptionPersitanceFalse.

@Test
public void testCreateOrUpdateSubscriptionPersitanceFalse() throws Exception {
    ObjectFactory objectFactory = new ObjectFactory();
    GetRecordsType getRecordsType = createDefaultGetRecordsRequest().get202RecordsType();
    QueryType queryType = new QueryType();
    getRecordsType.setAbstractQuery(objectFactory.createQuery(queryType));
    cswSubscriptionEndpoint.createOrUpdateSubscription(getRecordsType, subscriptionId, false);
    verify(mockContext).registerService(eq(Subscription.class.getName()), any(Subscription.class), any(Dictionary.class));
}
Also used : Dictionary(java.util.Dictionary) ObjectFactory(net.opengis.cat.csw.v_2_0_2.ObjectFactory) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) Subscription(ddf.catalog.event.Subscription) CswSubscription(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.event.CswSubscription) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) Test(org.junit.Test)

Example 37 with QueryType

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

the class CswQueryFactoryTest method cqlSpatialQuery.

/**
     * Runs a binary Spatial CQL Query, verifying that the right filter class is generated based on CQL
     *
     * @param clz Class of filter to generate
     * @param cql CQL Query String
     * @throws UnsupportedQueryException
     * @throws SourceUnavailableException
     * @throws FederationException
     * @throws CswException
     */
private <N extends BinarySpatialOperator> void cqlSpatialQuery(Class<N> clz, String cql) throws UnsupportedQueryException, SourceUnavailableException, FederationException, CswException {
    GetRecordsType grr = createDefaultPostRecordsRequest();
    QueryType query = new QueryType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    query.setTypeNames(typeNames);
    QueryConstraintType constraint = new QueryConstraintType();
    constraint.setCqlText(cql);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    QueryImpl frameworkQuery = (QueryImpl) queryFactory.getQuery(grr).getQuery();
    assertThat(frameworkQuery.getFilter(), instanceOf(clz));
    @SuppressWarnings("unchecked") N spatial = (N) frameworkQuery.getFilter();
    assertThat(((LiteralExpressionImpl) spatial.getExpression2()).getValue(), is(polygon));
    assertThat(((AttributeExpressionImpl) spatial.getExpression1()).getPropertyName(), is(SPATIAL_TEST_ATTRIBUTE));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType)

Example 38 with QueryType

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

the class CswQueryFactoryTest method generateTemporalFilter.

private Filter generateTemporalFilter(JAXBElement<BinaryComparisonOpType> temporalOps) throws UnsupportedQueryException, SourceUnavailableException, FederationException, CswException {
    GetRecordsType grr = createDefaultPostRecordsRequest();
    QueryType query = new QueryType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    query.setTypeNames(typeNames);
    QueryConstraintType constraint = new QueryConstraintType();
    FilterType filter = new FilterType();
    filter.setComparisonOps(temporalOps);
    constraint.setFilter(filter);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    QueryImpl frameworkQuery = (QueryImpl) queryFactory.getQuery(grr).getQuery();
    return frameworkQuery.getFilter();
}
Also used : FilterType(net.opengis.filter.v_1_1_0.FilterType) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType)

Example 39 with QueryType

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

the class TestCswEndpoint method testPostGetRecordsHits.

@Test
public void testPostGetRecordsHits() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
    GetRecordsType grr = createDefaultPostRecordsRequest();
    grr.setResultType(ResultType.HITS);
    QueryType query = new QueryType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    query.setTypeNames(typeNames);
    QueryConstraintType constraint = new QueryConstraintType();
    constraint.setCqlText(CQL_CONTEXTUAL_LIKE_QUERY);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    when(catalogFramework.query(argument.capture())).thenReturn(getQueryResponse());
    CswRecordCollection collection = csw.getRecords(grr);
    assertThat(collection.getCswRecords(), is(empty()));
    assertThat(collection.getResultType(), is(ResultType.HITS));
}
Also used : QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType) Test(org.junit.Test)

Example 40 with QueryType

use of net.opengis.wfs.v_2_0_0.QueryType 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

QueryType (com.evolveum.prism.xml.ns._public.query_3.QueryType)57 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)41 Test (org.junit.Test)40 QueryImpl (ddf.catalog.operation.impl.QueryImpl)37 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)36 QName (javax.xml.namespace.QName)34 Test (org.testng.annotations.Test)32 JAXBElement (javax.xml.bind.JAXBElement)27 SearchFilterType (com.evolveum.prism.xml.ns._public.query_3.SearchFilterType)24 ArrayList (java.util.ArrayList)24 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)20 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)17 Matchers.anyString (org.mockito.Matchers.anyString)14 ObjectListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectListType)13 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)13 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)12 Task (com.evolveum.midpoint.task.api.Task)12 Holder (javax.xml.ws.Holder)12 GetFeatureType (ogc.schema.opengis.wfs.v_1_0_0.GetFeatureType)12 QueryType (ogc.schema.opengis.wfs.v_1_0_0.QueryType)12