use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class TestWfsSource method testPagingPageSizeNegative.
/**
* Verify that, per DDF Query API Javadoc, if the startIndex is negative, the WfsSource throws
* an UnsupportedQueryException.
*
* @throws WfsException, SecurityServiceException
* @throws TransformerConfigurationException
* @throws UnsupportedQueryException
*/
@Test(expected = UnsupportedQueryException.class)
public void testPagingPageSizeNegative() throws WfsException, SecurityServiceException, TransformerConfigurationException, UnsupportedQueryException {
//Setup
int pageSize = -4;
int startIndex = 0;
WfsSource source = getWfsSource(ONE_TEXT_PROPERTY_SCHEMA, MockWfsServer.getFilterCapabilities(), GeospatialUtil.EPSG_4326_URN, 10, false);
Filter filter = builder.attribute(Metacard.ANY_TEXT).is().like().text(LITERAL);
Query query = new QueryImpl(filter, startIndex, pageSize, null, false, 0);
//Execute
GetFeatureType featureType = source.buildGetFeatureRequest(query);
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class SolrCache method query.
@Override
public List<Metacard> query(Filter filter) throws UnsupportedQueryException {
QueryRequest queryRequest = new QueryRequestImpl(new QueryImpl(filter), true);
SourceResponse response = solrClientAdaptor.getSolrMetacardClient().query(queryRequest);
return getMetacardsFromResponse(response);
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class CacheQueryFactory method getQueryRequestWithSourcesFilter.
QueryRequest getQueryRequestWithSourcesFilter(QueryRequest input) {
QueryRequest queryWithSources = input;
if (input.getSourceIds() != null) {
List<Filter> sourceFilters = new ArrayList<>();
for (String sourceId : input.getSourceIds()) {
sourceFilters.add(builder.attribute(StringUtils.removeEnd(SolrCache.METACARD_SOURCE_NAME, SchemaFields.TEXT_SUFFIX)).is().equalTo().text(sourceId));
}
QueryImpl sourceQuery = new QueryImpl(builder.allOf(input.getQuery(), builder.anyOf(sourceFilters)));
sourceQuery.setPageSize(input.getQuery().getPageSize());
sourceQuery.setStartIndex(input.getQuery().getStartIndex());
sourceQuery.setSortBy(input.getQuery().getSortBy());
sourceQuery.setTimeoutMillis(input.getQuery().getTimeoutMillis());
queryWithSources = new QueryRequestImpl(sourceQuery, input.isEnterprise(), input.getSourceIds(), input.getProperties());
}
return queryWithSources;
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class CachingFederationStrategy method getModifiedQuery.
private Query getModifiedQuery(Query originalQuery, int numberOfSources, int offset, int pageSize) {
Query query;
// If offset is not specified, our offset is 1
if (offset > 1 && numberOfSources > 1) {
final int modifiedOffset = 1;
int modifiedPageSize = computeModifiedPageSize(offset, pageSize);
LOGGER.debug("Creating new query for federated sources to query each source from {} " + "to {}.", modifiedOffset, modifiedPageSize);
LOGGER.debug("original offset: {}", offset);
LOGGER.debug("original page size: {}", pageSize);
LOGGER.debug("modified offset: {}", modifiedOffset);
LOGGER.debug("modified page size: {}", modifiedPageSize);
/**
* Federated sources always query from offset of 1. When all query results are received
* from all federated sources and merged together - then the offset is applied.
*
*/
query = new QueryImpl(originalQuery, modifiedOffset, modifiedPageSize, originalQuery.getSortBy(), originalQuery.requestsTotalResultsCount(), originalQuery.getTimeoutMillis());
} else {
query = originalQuery;
}
return query;
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class DuplicationValidator method query.
private SourceResponse query(Set<Attribute> attributes, String originalId) {
final Filter filter = filterBuilder.allOf(filterBuilder.anyOf(buildFilters(attributes)), filterBuilder.not(filterBuilder.attribute(Metacard.ID).is().equalTo().text(originalId)));
LOGGER.debug("filter {}", filter);
QueryImpl query = new QueryImpl(filter);
query.setRequestsTotalResultsCount(false);
QueryRequest request = new QueryRequestImpl(query);
SourceResponse response = null;
try {
response = catalogFramework.query(request);
} catch (FederationException | SourceUnavailableException | UnsupportedQueryException e) {
LOGGER.debug("Query failed ", e);
}
return response;
}
Aggregations