Search in sources :

Example 6 with HitCountRequest

use of org.codice.alliance.nsili.common.GIAS.HitCountRequest in project alliance by codice.

the class NsiliSource method getHitCount.

/**
 * Obtains the number of hits that the given query has received from the server.
 *
 * @param query - a BQS query
 * @param properties - a list of properties for the query
 * @return - the hit count
 */
private int getHitCount(org.codice.alliance.nsili.common.GIAS.Query query, NameValue[] properties) {
    IntHolder intHolder = new IntHolder();
    try {
        synchronized (queryLockObj) {
            HitCountRequest hitCountRequest = catalogMgr.hit_count(query, properties);
            hitCountRequest.complete(intHolder);
        }
    } catch (ProcessingFault | SystemFault | InvalidInputParameter e) {
        LOGGER.debug("{} : Unable to get hit count for query. : {}", getId(), NsilCorbaExceptionUtil.getExceptionDetails(e), e);
    }
    LOGGER.debug("{} :  Received {} hit(s) from query.", getId(), intHolder.value);
    return intHolder.value;
}
Also used : SystemFault(org.codice.alliance.nsili.common.UCO.SystemFault) IntHolder(org.omg.CORBA.IntHolder) InvalidInputParameter(org.codice.alliance.nsili.common.UCO.InvalidInputParameter) ProcessingFault(org.codice.alliance.nsili.common.UCO.ProcessingFault) HitCountRequest(org.codice.alliance.nsili.common.GIAS.HitCountRequest)

Example 7 with HitCountRequest

use of org.codice.alliance.nsili.common.GIAS.HitCountRequest in project alliance by codice.

the class NsiliSourceTest method getMockCatalogMgr.

private CatalogMgr getMockCatalogMgr() throws Exception {
    SubmitQueryRequest submitQueryRequest = mock(SubmitQueryRequest.class);
    HitCountRequest hitCountRequest = mock(HitCountRequest.class);
    doReturn(State.COMPLETED).when(hitCountRequest).complete(any(IntHolder.class));
    Status status = new Status();
    status.completion_state = State.COMPLETED;
    doReturn(status).when(hitCountRequest).get_status();
    when(hitCountRequest.complete(any(IntHolder.class))).thenAnswer((InvocationOnMock invocationOnMock) -> {
        IntHolder intHolder = (IntHolder) invocationOnMock.getArguments()[0];
        intHolder.value = 12;
        return State.COMPLETED;
    });
    when(submitQueryRequest.complete_DAG_results(any(DAGListHolder.class))).thenAnswer((InvocationOnMock invocationOnMock) -> {
        DAGListHolder dagListHolder = (DAGListHolder) invocationOnMock.getArguments()[0];
        dagListHolder.value = getMockDAGArray();
        return State.COMPLETED;
    });
    doReturn(submitQueryRequest).when(catalogMgr).submit_query(any(Query.class), any(String[].class), any(SortAttribute[].class), any(NameValue[].class));
    doReturn(hitCountRequest).when(catalogMgr).hit_count(any(Query.class), any(NameValue[].class));
    return catalogMgr;
}
Also used : Status(org.codice.alliance.nsili.common.UCO.Status) SubmitQueryRequest(org.codice.alliance.nsili.common.GIAS.SubmitQueryRequest) Query(org.codice.alliance.nsili.common.GIAS.Query) InvocationOnMock(org.mockito.invocation.InvocationOnMock) IntHolder(org.omg.CORBA.IntHolder) HitCountRequest(org.codice.alliance.nsili.common.GIAS.HitCountRequest) DAGListHolder(org.codice.alliance.nsili.common.UCO.DAGListHolder)

Example 8 with HitCountRequest

use of org.codice.alliance.nsili.common.GIAS.HitCountRequest in project alliance by codice.

the class CatalogMgrImplTest method testHitCount.

@Test
public void testHitCount() throws InvalidInputParameter, SystemFault, ProcessingFault {
    catalogMgr.set_default_timeout(AccessManagerImpl.DEFAULT_TIMEOUT);
    HitCountRequest hitCountRequest = catalogMgr.hit_count(testQuery, null);
    IntHolder hitHolder = new IntHolder();
    assertThat(hitCountRequest, notNullValue());
    hitCountRequest.complete(hitHolder);
    assertThat(hitHolder.value, greaterThan(0));
}
Also used : IntHolder(org.omg.CORBA.IntHolder) HitCountRequest(org.codice.alliance.nsili.common.GIAS.HitCountRequest) Test(org.junit.Test)

Aggregations

HitCountRequest (org.codice.alliance.nsili.common.GIAS.HitCountRequest)8 IntHolder (org.omg.CORBA.IntHolder)6 SubmitQueryRequest (org.codice.alliance.nsili.common.GIAS.SubmitQueryRequest)2 DAGListHolder (org.codice.alliance.nsili.common.UCO.DAGListHolder)2 InvalidInputParameter (org.codice.alliance.nsili.common.UCO.InvalidInputParameter)2 ProcessingFault (org.codice.alliance.nsili.common.UCO.ProcessingFault)2 SystemFault (org.codice.alliance.nsili.common.UCO.SystemFault)2 Test (org.junit.Test)2 ObjectAlreadyActive (org.omg.PortableServer.POAPackage.ObjectAlreadyActive)2 ServantAlreadyActive (org.omg.PortableServer.POAPackage.ServantAlreadyActive)2 WrongPolicy (org.omg.PortableServer.POAPackage.WrongPolicy)2 Metacard (ddf.catalog.data.Metacard)1 Result (ddf.catalog.data.Result)1 ResultImpl (ddf.catalog.data.impl.ResultImpl)1 SourceResponseImpl (ddf.catalog.operation.impl.SourceResponseImpl)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 Future (java.util.concurrent.Future)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 Query (org.codice.alliance.nsili.common.GIAS.Query)1