public EventInfoListDocument getEvents(final Long iid, final int startIdx, final int count) throws ManagementException { // TODO: this is a bit of hack, if there are two events with exactly the // same timestamp, we can have more events returned then requested. List<String> timeline; try { timeline = getEventTimeline("iid="+iid,null); } catch (Exception ex) { throw new ManagementException("Unable to retrieve timeline.", ex); } if (startIdx >= timeline.size()) return EventInfoListDocument.Factory.newInstance(); timeline = timeline.subList(startIdx,Math.min(timeline.size(),startIdx+count)); String startdt = timeline.get(0); String enddt = timeline.get(timeline.size()-1); return listEvents("iid="+iid,"timestamp>="+startdt +" " +"timestamp<="+enddt,0); }
aEventList = EventInfoListDocument.Factory.newInstance(); anActivitiesWithEventsOrdered.setEventInfoList(aEventList); aEventList = anActivitiesWithEventsOrdered.getEventInfoList();
/** * return the ActivityInfoWithEventsDocument object for a particular event * Then take it and fill it with particular event info * Note - this must be used after fillActivityInfo method, else aInfo will return a null ref. * * @param event Activity Event * @return updated element due to event input */ private ActivityInfoWithEventsDocument lookup(ActivityEvent event) { ActivityInfoWithEventsDocument actEvtInfoDoc = activitiesWithEvents.get(event.getActivityId()); ActivityInfoDocument aInfo = actEvtInfoDoc.getActivityInfoDoc(); EventInfoListDocument aEventList = actEvtInfoDoc.getEventInfoList(); if (aEventList == null) { aEventList = EventInfoListDocument.Factory.newInstance(); actEvtInfoDoc.setEventInfoList(aEventList); aEventList = actEvtInfoDoc.getEventInfoList(); } TEventInfo eventInfo; if (aEventList.getEventInfoList() == null) { TEventInfoList eventInfoList = aEventList.addNewEventInfoList(); eventInfo = eventInfoList.addNewEventInfo(); } else { eventInfo = aEventList.getEventInfoList().addNewEventInfo(); } fillEventInfo(eventInfo, event); addActivitiesWithEventOrdered(event, new ActivityInfoWithEventsDocument(aInfo, aEventList)); return activitiesWithEvents.get(event.getActivityId()); }
public EventInfoListDocument listEvents(String instanceFilter, String eventFilter, int maxCount) { final InstanceFilter ifilter = new InstanceFilter(instanceFilter, null, 0); final BpelEventFilter efilter = new BpelEventFilter(eventFilter, maxCount); EventInfoListDocument eid = EventInfoListDocument.Factory.newInstance(); final TEventInfoList eil = eid.addNewEventInfoList(); dbexec(new BpelDatabase.Callable<Object>() { public Object run(BpelDAOConnection session) throws Exception { List<BpelEvent> events = session.bpelEventQuery(ifilter, efilter); for (BpelEvent event : events) { TEventInfo tei = eil.addNewEventInfo(); fillEventInfo(tei, event); } return null; } }); return eid; }