Search in sources :

Example 1 with QueryLifeSpan

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

the class SampleNsiliClient method testStandingQueryMgr.

public void testStandingQueryMgr() throws Exception {
    if (standingQueryMgr != null) {
        LOGGER.info("----------------------");
        LOGGER.info("Standing Query Manager Test");
        Event[] events = standingQueryMgr.get_event_descriptions();
        if (events != null) {
            Arrays.stream(events).forEach(event -> LOGGER.info("Event: {}\n Name: {}\n Desc: {}", event.event_type.value(), event.event_name, event.event_description));
        }
        LifeEvent start = new LifeEvent();
        java.util.Date startDate = new java.util.Date();
        start.at(ResultDAGConverter.getAbsTime(startDate));
        LifeEvent end = new LifeEvent();
        final long ONE_YEAR_IN_MS = TimeUnit.DAYS.toMillis(365);
        long endTime = System.currentTimeMillis() + ONE_YEAR_IN_MS;
        java.util.Date endDate = new java.util.Date();
        endDate.setTime(endTime);
        end.at(ResultDAGConverter.getAbsTime(endDate));
        LifeEvent[] frequency = new LifeEvent[1];
        LifeEvent freqOne = new LifeEvent();
        Time time = new Time((short) 0, (short) 0, 30.0f);
        freqOne.rt(time);
        frequency[0] = freqOne;
        QueryLifeSpan queryLifeSpan = new QueryLifeSpan(start, end, frequency);
        NameValue[] props = new NameValue[0];
        String callbackId = UUID.randomUUID().toString();
        try {
            standingQueryRequest = standingQueryMgr.submit_standing_query(STANDING_ALL_QUERY, getResultAttributes(), getSortableAttributes(), queryLifeSpan, props);
            standingQueryRequest.set_user_info(ALLIANCE);
            standingQueryRequest.set_number_of_hits(200);
            TestNsiliStandingQueryCallback nsiliCallback = new TestNsiliStandingQueryCallback(standingQueryRequest);
            final String ENCODING = "ISO-8859-1";
            try {
                poa.activate_object_with_id(callbackId.getBytes(Charset.forName(ENCODING)), nsiliCallback);
            } catch (ServantAlreadyActive | ObjectAlreadyActive | WrongPolicy e) {
                LOGGER.error("Order : Unable to activate callback object, already active : {}", NsilCorbaExceptionUtil.getExceptionDetails(e), e);
            }
            org.omg.CORBA.Object obj = poa.create_reference_with_id(callbackId.getBytes(Charset.forName(ENCODING)), CallbackHelper.id());
            Callback callback = CallbackHelper.narrow(obj);
            String standingQueryCallbackId = standingQueryRequest.register_callback(callback);
            nsiliCallback.setCallbackID(standingQueryCallbackId);
            standingQueryCallbacks.add(nsiliCallback);
            LOGGER.info("Registered NSILI Callback: {}", standingQueryCallbackId);
            LOGGER.info("Standing Query Submitted");
        } catch (Exception e) {
            LOGGER.debug("Error submitting standing query: ", NsilCorbaExceptionUtil.getExceptionDetails(e));
            throw (e);
        }
    } else {
        LOGGER.info("StandingQueryMgr is not initialized, unable to test");
    }
}
Also used : ObjectAlreadyActive(org.omg.PortableServer.POAPackage.ObjectAlreadyActive) Time(org.codice.alliance.nsili.common.UCO.Time) AbsTime(org.codice.alliance.nsili.common.UCO.AbsTime) Date(org.codice.alliance.nsili.common.UCO.Date) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) MalformedURLException(java.net.MalformedURLException) CertificateException(java.security.cert.CertificateException) NameValue(org.codice.alliance.nsili.common.UCO.NameValue) WrongPolicy(org.omg.PortableServer.POAPackage.WrongPolicy) Callback(org.codice.alliance.nsili.common.CB.Callback) QueryLifeSpan(org.codice.alliance.nsili.common.GIAS.QueryLifeSpan) Event(org.codice.alliance.nsili.common.GIAS.Event) LifeEvent(org.codice.alliance.nsili.common.GIAS.LifeEvent) LifeEvent(org.codice.alliance.nsili.common.GIAS.LifeEvent) ServantAlreadyActive(org.omg.PortableServer.POAPackage.ServantAlreadyActive)

Example 2 with QueryLifeSpan

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

the class StandingQueryMgrImplTest method testSubmitStandingQuery.

@Test
public void testSubmitStandingQuery() throws InvalidInputParameter, SystemFault, ProcessingFault {
    String[] resultAttributes = new String[0];
    SortAttribute[] sortAttributes = new SortAttribute[0];
    LifeEvent start = new LifeEvent();
    start.at(LifeEventType.ABSOLUTE_TIME, new AbsTime(new Date((short) 2016, (short) 05, (short) 01), new Time((short) 00, (short) 00, (short) 00)));
    LifeEvent stop = new LifeEvent();
    stop.at(LifeEventType.ABSOLUTE_TIME, new AbsTime(new Date((short) 2050, (short) 05, (short) 01), new Time((short) 00, (short) 00, (short) 00)));
    LifeEvent frequency1 = new LifeEvent();
    frequency1.rt(LifeEventType.RELATIVE_TIME, new Time((short) 00, (short) 01, (short) 00));
    LifeEvent[] frequency = new LifeEvent[] { frequency1 };
    QueryLifeSpan lifeSpan = new QueryLifeSpan(start, stop, frequency);
    Query query = new Query(NsiliConstants.NSIL_ALL_VIEW, bqsQuery);
    SubmitStandingQueryRequest request = standingQueryMgr.submit_standing_query(query, resultAttributes, sortAttributes, lifeSpan, new NameValue[0]);
    assertThat(request, notNullValue());
}
Also used : SubmitStandingQueryRequest(org.codice.alliance.nsili.common.GIAS.SubmitStandingQueryRequest) AbsTime(org.codice.alliance.nsili.common.UCO.AbsTime) SortAttribute(org.codice.alliance.nsili.common.GIAS.SortAttribute) Query(org.codice.alliance.nsili.common.GIAS.Query) QueryLifeSpan(org.codice.alliance.nsili.common.GIAS.QueryLifeSpan) LifeEvent(org.codice.alliance.nsili.common.GIAS.LifeEvent) Time(org.codice.alliance.nsili.common.UCO.Time) AbsTime(org.codice.alliance.nsili.common.UCO.AbsTime) Date(org.codice.alliance.nsili.common.UCO.Date) Test(org.junit.Test)

Example 3 with QueryLifeSpan

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

the class SubmitStandingQueryRequestImplTest method setupStandingQueryRequest.

private void setupStandingQueryRequest() throws InvalidInputParameter, SystemFault, ProcessingFault, WrongPolicy, ServantAlreadyActive, ObjectAlreadyActive {
    Query query = getQuery();
    String[] resultAttributes = new String[0];
    SortAttribute[] sortAttributes = new SortAttribute[0];
    QueryLifeSpan lifespan = getEmptyLifespan();
    NameValue[] properties = new NameValue[0];
    // Set artificially low for for test cases.
    long defaultUpdateFrequencyMsec = 2000;
    int maxPendingResults = 10000;
    long maxWaitToStartTimeMsecs = TimeUnit.MINUTES.toMillis(5);
    standingQueryRequest = new SubmitStandingQueryRequestImpl(query, resultAttributes, sortAttributes, lifespan, properties, mockFramework, filterBuilder, defaultUpdateFrequencyMsec, null, maxPendingResults, true, false, maxWaitToStartTimeMsecs);
    standingQueryRequest.register_callback(mockCallback2);
    String managerId = UUID.randomUUID().toString();
    rootPOA.activate_object_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), standingQueryRequest);
    rootPOA.create_reference_with_id(managerId.getBytes(Charset.forName(NsiliEndpoint.ENCODING)), CreationMgrHelper.id());
}
Also used : NameValue(org.codice.alliance.nsili.common.UCO.NameValue) Query(org.codice.alliance.nsili.common.GIAS.Query) SortAttribute(org.codice.alliance.nsili.common.GIAS.SortAttribute) QueryLifeSpan(org.codice.alliance.nsili.common.GIAS.QueryLifeSpan) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SubmitStandingQueryRequestImpl(org.codice.alliance.nsili.endpoint.requests.SubmitStandingQueryRequestImpl)

Aggregations

QueryLifeSpan (org.codice.alliance.nsili.common.GIAS.QueryLifeSpan)3 LifeEvent (org.codice.alliance.nsili.common.GIAS.LifeEvent)2 Query (org.codice.alliance.nsili.common.GIAS.Query)2 SortAttribute (org.codice.alliance.nsili.common.GIAS.SortAttribute)2 AbsTime (org.codice.alliance.nsili.common.UCO.AbsTime)2 Date (org.codice.alliance.nsili.common.UCO.Date)2 NameValue (org.codice.alliance.nsili.common.UCO.NameValue)2 Time (org.codice.alliance.nsili.common.UCO.Time)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 Callback (org.codice.alliance.nsili.common.CB.Callback)1 Event (org.codice.alliance.nsili.common.GIAS.Event)1 SubmitStandingQueryRequest (org.codice.alliance.nsili.common.GIAS.SubmitStandingQueryRequest)1 SubmitStandingQueryRequestImpl (org.codice.alliance.nsili.endpoint.requests.SubmitStandingQueryRequestImpl)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1