use of org.codice.alliance.nsili.common.BqsConverter in project alliance by codice.
the class CatalogMgrImpl method getResultCount.
protected long getResultCount(Query aQuery) {
long resultCount = 0;
BqsConverter bqsConverter = new BqsConverter(filterBuilder, removeSourceLibrary);
Filter parsedFilter = bqsConverter.convertBQSToDDF(aQuery);
// Always need to ask for the DEFAULT_TAG or we get non-resource metacards
Filter resourceFilter = filterBuilder.allOf(parsedFilter, filterBuilder.attribute(Metacard.TAGS).is().like().text(Metacard.DEFAULT_TAG));
if (!LibraryImpl.queryContainsStatus(aQuery.bqs_query)) {
parsedFilter = filterBuilder.anyOf(resourceFilter, filterBuilder.allOf(parsedFilter, filterBuilder.attribute(Metacard.TAGS).is().like().text(MetacardVersion.VERSION_TAG), filterBuilder.attribute(MetacardVersion.VERSION_TAGS).is().like().text(Metacard.DEFAULT_TAG), filterBuilder.attribute(MetacardVersion.ACTION).is().like().text(MetacardVersion.Action.DELETED.getKey())));
}
QueryImpl catalogQuery = new QueryImpl(parsedFilter);
if (defaultTimeout > 0) {
catalogQuery.setTimeoutMillis(defaultTimeout * 1000);
}
catalogQuery.setPageSize(1);
QueryRequestImpl catalogQueryRequest = null;
if (querySources == null || querySources.isEmpty()) {
catalogQueryRequest = new QueryRequestImpl(catalogQuery);
} else {
catalogQueryRequest = new QueryRequestImpl(catalogQuery, false, querySources, null);
}
try {
QueryCountCallable queryCallable = new QueryCountCallable(catalogQueryRequest);
resultCount = NsiliEndpoint.getGuestSubject().execute(queryCallable);
} catch (Exception e) {
LOGGER.debug("Unable to query catalog", e);
}
return resultCount;
}
use of org.codice.alliance.nsili.common.BqsConverter in project alliance by codice.
the class SubmitStandingQueryRequestImplTest method setupMocks.
private void setupMocks() throws Exception {
List<Result> results = getTestResults();
BqsConverter bqsConverter = new BqsConverter(filterBuilder, true);
Filter filter = bqsConverter.convertBQSToDDF(getQuery());
ddf.catalog.operation.Query query = new QueryImpl(filter);
QueryResponse testResult = new QueryResponseImpl(new QueryRequestImpl(query), results, results.size());
when(mockFramework.query(any(QueryRequest.class))).thenReturn(testResult);
}
use of org.codice.alliance.nsili.common.BqsConverter in project alliance by codice.
the class CatalogMgrImpl method submit_query.
@Override
public SubmitQueryRequest submit_query(Query aQuery, String[] result_attributes, SortAttribute[] sort_attributes, NameValue[] properties) throws ProcessingFault, InvalidInputParameter, SystemFault {
BqsConverter bqsConverter = new BqsConverter(filterBuilder, removeSourceLibrary);
SubmitQueryRequestImpl submitQueryRequest = new SubmitQueryRequestImpl(aQuery, filterBuilder, bqsConverter, catalogFramework, querySources);
submitQueryRequest.set_number_of_hits(maxNumResults);
submitQueryRequest.setTimeout(defaultTimeout);
submitQueryRequest.setOutgoingValidationEnabled(outgoingValidationEnabled);
submitQueryRequest.setResultAttributes(result_attributes);
String queryId = UUID.randomUUID().toString();
try {
poa.activate_object_with_id(queryId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), submitQueryRequest);
} catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
LOGGER.debug("submit_query : Unable to activate submitQueryRequest object.", e);
}
org.omg.CORBA.Object obj = poa.create_reference_with_id(queryId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), SubmitQueryRequestHelper.id());
SubmitQueryRequest queryRequest = SubmitQueryRequestHelper.narrow(obj);
return queryRequest;
}
Aggregations