use of net.opengis.cat.csw.v_2_0_2.QueryConstraintType 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;
Filter queryFilter = ((QueryImpl) frameworkQuery.getFilter()).getFilter();
if (classes.length > 1) {
assertThat(queryFilter, instanceOf(Or.class));
int i = 0;
for (Filter filter : ((Or) queryFilter).getChildren()) {
assertThat(filter, instanceOf(classes[i++]));
temporal = (N) filter;
}
} else {
assertThat(queryFilter, instanceOf(classes[0]));
temporal = (N) queryFilter;
}
assertThat(((AttributeExpressionImpl) temporal.getExpression1()).getPropertyName(), is(expectedAttr));
}
use of net.opengis.cat.csw.v_2_0_2.QueryConstraintType 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();
Filter queryFilter = ((QueryImpl) frameworkQuery.getFilter()).getFilter();
assertThat(queryFilter, instanceOf(clz));
@SuppressWarnings("unchecked") N spatial = (N) queryFilter;
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));
}
use of net.opengis.cat.csw.v_2_0_2.QueryConstraintType 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();
Filter queryFilter = ((QueryImpl) frameworkQuery.getFilter()).getFilter();
assertThat(queryFilter, instanceOf(PropertyIsLike.class));
PropertyIsLike like = (PropertyIsLike) queryFilter;
assertThat(like.getLiteral(), is(CQL_CONTEXTUAL_PATTERN));
assertThat(((AttributeExpressionImpl) like.getExpression()).getPropertyName(), is(CQL_FRAMEWORK_TEST_ATTRIBUTE));
}
use of net.opengis.cat.csw.v_2_0_2.QueryConstraintType in project ddf by codice.
the class CswQueryFactoryTest method testPostGetRecordsDistributedSearchSpecificSources.
@SuppressWarnings("unchecked")
@Test
public void testPostGetRecordsDistributedSearchSpecificSources() throws CswException, UnsupportedQueryException, SourceUnavailableException, FederationException {
GetRecordsType grr = createDefaultPostRecordsRequest();
DistributedSearchType distributedSearch = new DistributedSearchType();
distributedSearch.setHopCount(BigInteger.TEN);
grr.setDistributedSearch(distributedSearch);
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_FEDERATED_QUERY);
query.setConstraint(constraint);
JAXBElement<QueryType> jaxbQuery = new JAXBElement(cswQnameOutPutSchema, QueryType.class, query);
grr.setAbstractQuery(jaxbQuery);
QueryRequest queryRequest = queryFactory.getQuery(grr);
assertThat(queryRequest.isEnterprise(), is(false));
assertThat(queryRequest.getSourceIds(), contains("source1"));
}
use of net.opengis.cat.csw.v_2_0_2.QueryConstraintType 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();
Filter queryFilter = ((QueryImpl) frameworkQuery.getFilter()).getFilter();
assertThat(queryFilter, instanceOf(clz));
@SuppressWarnings("unchecked") N spatial = (N) queryFilter;
assertThat(((LiteralExpressionImpl) spatial.getExpression2()).getValue(), is(polygon));
assertThat(((AttributeExpressionImpl) spatial.getExpression1()).getPropertyName(), is(SPATIAL_TEST_ATTRIBUTE));
}
Aggregations