use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class ResourceCacheService method queryForMetacard.
private Optional<Metacard> queryForMetacard(String metacardId) {
Filter filter = frameworkProperties.getFilterBuilder().attribute(Metacard.ID).is().equalTo().text(metacardId);
QueryRequest queryRequest = new QueryRequestImpl(new QueryImpl(filter), true);
QueryResponse queryResponse = null;
try {
queryResponse = catalogFramework.query(queryRequest);
} catch (UnsupportedQueryException | SourceUnavailableException | FederationException e) {
LOGGER.error("Unable to lookup metacard for metacard id [{}].", metacardId);
return Optional.empty();
}
return queryResponse != null && queryResponse.getResults().size() == 1 ? Optional.of(queryResponse.getResults().get(0).getMetacard()) : Optional.empty();
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class ValidationQueryFactoryTest method testSearchErrorsAndNotWarnings.
@Test
public void testSearchErrorsAndNotWarnings() throws UnsupportedQueryException {
QueryImpl query = new QueryImpl(filterBuilder.attribute(Metacard.MODIFIED).is().equalTo().text("sample"));
QueryRequest returnQuery = validationQueryFactory.getQueryRequestWithValidationFilter(new QueryRequestImpl(query), true, false);
assertThat(filterAdapter.adapt(returnQuery.getQuery(), testValidationQueryDelegate), is(true));
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class ValidationQueryFactoryTest method testSearchInvalidAndNotShow.
@Test
public void testSearchInvalidAndNotShow() throws StopProcessingException, PluginExecutionException, UnsupportedQueryException {
QueryImpl query = new QueryImpl(filterBuilder.attribute(Validation.VALIDATION_WARNINGS).is().equalTo().text("sample"));
assertThat(filterAdapter.adapt(query, testValidationQueryDelegate), is(true));
QueryRequest sendQuery = new QueryRequestImpl(query);
QueryRequest returnQuery = validationQueryFactory.getQueryRequestWithValidationFilter(sendQuery, false, false);
assertThat(filterAdapter.adapt(returnQuery.getQuery(), testValidationQueryDelegate), is(true));
assertThat(sendQuery, is(returnQuery));
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class ValidationQueryFactoryTest method testSearchAnyAndShow.
@Test
public void testSearchAnyAndShow() throws StopProcessingException, PluginExecutionException, UnsupportedQueryException {
QueryImpl query = new QueryImpl(filterBuilder.attribute(Metacard.MODIFIED).is().equalTo().text("sample"));
assertThat(filterAdapter.adapt(query, testValidationQueryDelegate), is(false));
QueryRequest sendQuery = new QueryRequestImpl(query);
QueryRequest returnQuery = validationQueryFactory.getQueryRequestWithValidationFilter(sendQuery, true, true);
assertThat(filterAdapter.adapt(returnQuery.getQuery(), testValidationQueryDelegate), is(false));
assertThat(sendQuery, is(returnQuery));
}
use of ddf.catalog.operation.impl.QueryImpl in project ddf by codice.
the class SecurityLoggingPlugin method process.
@Override
public QueryRequest process(QueryRequest input) throws PluginExecutionException, StopProcessingException {
String additional = "";
Query query = input.getQuery();
if (query instanceof QueryImpl) {
additional = ((QueryImpl) query).getFilter().toString();
}
logOperation(CatalogOperationType.QUERY_REQUEST, input, additional);
return input;
}
Aggregations