Search in sources :

Example 1 with BqsConverter

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;
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) Filter(org.opengis.filter.Filter) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) SubmitQueryRequestImpl(org.codice.alliance.nsili.endpoint.requests.SubmitQueryRequestImpl) BqsConverter(org.codice.alliance.nsili.common.BqsConverter)

Example 2 with BqsConverter

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);
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryResponseImpl(ddf.catalog.operation.impl.QueryResponseImpl) QueryRequest(ddf.catalog.operation.QueryRequest) Filter(org.opengis.filter.Filter) QueryResponse(ddf.catalog.operation.QueryResponse) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) SubmitStandingQueryRequestImpl(org.codice.alliance.nsili.endpoint.requests.SubmitStandingQueryRequestImpl) BqsConverter(org.codice.alliance.nsili.common.BqsConverter) Result(ddf.catalog.data.Result)

Example 3 with BqsConverter

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;
}
Also used : WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) SubmitQueryRequest(org.codice.alliance.nsili.common.GIAS.SubmitQueryRequest) ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) BqsConverter(org.codice.alliance.nsili.common.BqsConverter) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive) SubmitQueryRequestImpl(org.codice.alliance.nsili.endpoint.requests.SubmitQueryRequestImpl)

Aggregations

BqsConverter (org.codice.alliance.nsili.common.BqsConverter)3 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)2 SubmitQueryRequestImpl (org.codice.alliance.nsili.endpoint.requests.SubmitQueryRequestImpl)2 Filter (org.opengis.filter.Filter)2 Result (ddf.catalog.data.Result)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 QueryResponse (ddf.catalog.operation.QueryResponse)1 QueryResponseImpl (ddf.catalog.operation.impl.QueryResponseImpl)1 SubmitQueryRequest (org.codice.alliance.nsili.common.GIAS.SubmitQueryRequest)1 SubmitStandingQueryRequestImpl (org.codice.alliance.nsili.endpoint.requests.SubmitStandingQueryRequestImpl)1 ObjectAlreadyActive (org.omg.PortableServer.POAPackage.ObjectAlreadyActive)1 ServantAlreadyActive (org.omg.PortableServer.POAPackage.ServantAlreadyActive)1 WrongPolicy (org.omg.PortableServer.POAPackage.WrongPolicy)1