use of org.codice.alliance.nsili.common.GIAS.Event 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");
}
}
use of org.codice.alliance.nsili.common.GIAS.Event in project alliance by codice.
the class StandingQueryMgrImpl method init.
protected void init() {
NamedEventType startEventType = NamedEventType.from_int(NamedEventType._START_EVENT);
Event startEvent = new Event("START_EVENT", startEventType, "");
NamedEventType stopEventType = NamedEventType.from_int(NamedEventType._STOP_EVENT);
Event stopEvent = new Event("STOP_EVENT", stopEventType, "");
NamedEventType frequencyEventType = NamedEventType.from_int(NamedEventType._FREQUENCY_EVENT);
Event frequencyEvent = new Event("FREQUENCY_EVENT", frequencyEventType, "");
eventTypes = new Event[] { startEvent, stopEvent, frequencyEvent };
}
Aggregations