Search in sources :

Example 91 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project ddf by codice.

the class CswQueryFactoryTest method cqlSpatialRelativeQuery.

/**
     * Runs a relative 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 DistanceBufferOperator> void cqlSpatialRelativeQuery(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));
    assertThat(spatial.getDistanceUnits(), is(UomOgcMapping.METRE.name()));
    assertThat(spatial.getDistance(), is(EXPECTED_GEO_DISTANCE));
}
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 92 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project ddf by codice.

the class CswQueryFactoryTest method testPostGetRecordsContextualCQLQuery.

@Test
public void testPostGetRecordsContextualCQLQuery() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
    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_CONTEXTUAL_LIKE_QUERY);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    QueryRequest queryRequest = queryFactory.getQuery(grr);
    QueryImpl frameworkQuery = (QueryImpl) queryRequest.getQuery();
    assertThat(frameworkQuery.getFilter(), instanceOf(PropertyIsLike.class));
    PropertyIsLike like = (PropertyIsLike) frameworkQuery.getFilter();
    assertThat(like.getLiteral(), is(CQL_CONTEXTUAL_PATTERN));
    assertThat(((AttributeExpressionImpl) like.getExpression()).getPropertyName(), is(CQL_FRAMEWORK_TEST_ATTRIBUTE));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) PropertyIsLike(org.opengis.filter.PropertyIsLike) QueryRequest(ddf.catalog.operation.QueryRequest) 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) Test(org.junit.Test)

Example 93 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project ddf by codice.

the class CswQueryFactoryTest method cqlTemporalQuery.

@SuppressWarnings("unchecked")
private <N extends BinaryTemporalOperator> void cqlTemporalQuery(String expectedAttr, String cqlSpatialDwithinQuery, Class<N>[] classes) 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(cqlSpatialDwithinQuery);
    query.setConstraint(constraint);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    QueryImpl frameworkQuery = (QueryImpl) queryFactory.getQuery(grr).getQuery();
    N temporal = null;
    if (classes.length > 1) {
        assertThat(frameworkQuery.getFilter(), instanceOf(Or.class));
        int i = 0;
        for (Filter filter : ((Or) frameworkQuery.getFilter()).getChildren()) {
            assertThat(filter, instanceOf(classes[i++]));
            temporal = (N) filter;
        }
    } else {
        assertThat(frameworkQuery.getFilter(), instanceOf(classes[0]));
        temporal = (N) frameworkQuery.getFilter();
    }
    assertThat(((AttributeExpressionImpl) temporal.getExpression1()).getPropertyName(), is(expectedAttr));
}
Also used : Or(org.opengis.filter.Or) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) GetRecordsType(net.opengis.cat.csw.v_2_0_2.GetRecordsType) JAXBElement(javax.xml.bind.JAXBElement) QueryConstraintType(net.opengis.cat.csw.v_2_0_2.QueryConstraintType) Disjoint(org.opengis.filter.spatial.Disjoint) QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) QueryType(net.opengis.cat.csw.v_2_0_2.QueryType)

Example 94 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project ddf by codice.

the class CswQueryFactoryTest method createDefaultPostRecordsRequest.

/**
     * Creates default GetRecordsType POST request, with no sections specified
     *
     * @return Vanilla valid GetRecordsType object
     */
private GetRecordsType createDefaultPostRecordsRequest() {
    GetRecordsType grr = new GetRecordsType();
    grr.setOutputFormat(CswConstants.OUTPUT_FORMAT_XML);
    grr.setOutputSchema(CswConstants.CSW_OUTPUT_SCHEMA);
    QueryType query = new QueryType();
    List<QName> typeNames = new ArrayList<>();
    typeNames.add(new QName(CswConstants.CSW_OUTPUT_SCHEMA, VALID_TYPE, VALID_PREFIX));
    query.setTypeNames(typeNames);
    JAXBElement<QueryType> jaxbQuery = new JAXBElement<>(cswQnameOutPutSchema, QueryType.class, query);
    grr.setAbstractQuery(jaxbQuery);
    return grr;
}
Also used : 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)

Example 95 with QueryType

use of net.opengis.cat.csw.v_2_0_2.QueryType in project ddf by codice.

the class CswQueryFactoryTest method ogcSpatialRelativeQuery.

/**
     * Runs a binary Spatial OGC Query, verifying that the right filter class is generated based on OGC Filter
     *
     * @param spatialOps BinarySpatialOps query
     * @throws UnsupportedQueryException
     * @throws SourceUnavailableException
     * @throws FederationException
     * @throws CswException
     */
private <N extends DistanceBufferOperator> void ogcSpatialRelativeQuery(Class<N> clz, JAXBElement<DistanceBufferType> spatialOps) 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.setSpatialOps(spatialOps);
    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();
    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 : 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)

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