use of org.xwiki.notifications.CompositeEventStatus in project xwiki-platform by xwiki.
the class DefaultCompositeEventStatusManager method getCompositeEventStatuses.
@Override
public List<CompositeEventStatus> getCompositeEventStatuses(List<CompositeEvent> compositeEvents, String entityId) throws Exception {
// Creating a list of all events to avoid multiple calls to getEventStatuses() and so multiple calls to the
// database.
List<Event> allEvents = new ArrayList<>();
// But maintain a mapping between eventId and their composite event status
Map<String, CompositeEventStatus> map = new HashMap<>();
for (CompositeEvent compositeEvent : compositeEvents) {
CompositeEventStatus compositeEventStatus = new CompositeEventStatus(compositeEvent);
for (Event event : compositeEvent.getEvents()) {
map.put(event.getId(), compositeEventStatus);
}
allEvents.addAll(compositeEvent.getEvents());
}
// Put the event statuses into the composite events statuses
for (EventStatus eventStatus : getEventStatuses(allEvents, entityId)) {
map.get(eventStatus.getEvent().getId()).add(eventStatus);
}
List<CompositeEventStatus> results = new ArrayList<>();
// Keep the same order than inputs
for (CompositeEvent event : compositeEvents) {
results.add(map.get(event.getEvents().get(0).getId()));
}
return results;
}
Aggregations