/* (non-Javadoc) * @see org.sakaiproject.sitestats.api.event.EventRegistry#getEventName(java.lang.String) */ public String getEventName(String eventId) { Locale currentUserLocale = getCurrentUserLocale(); EventLocaleKey key = new EventLocaleKey(eventId, currentUserLocale.toString()); if (eventNamesCache.containsKey(key.toString())) { return (String) eventNamesCache.get(key.toString()); } else { String eventName = null; try { String prefix = eventIdToEPPrefix.get(eventId); Statisticable s = M_epm.getProviderByPrefixAndCapability(prefix, Statisticable.class); Map<String, String> eventIdNamesMap = s.getEventNames(currentUserLocale); if (eventIdNamesMap != null) { for (String thisEventId : eventIdNamesMap.keySet()) { EventLocaleKey thisCacheKey = new EventLocaleKey(thisEventId, currentUserLocale.toString()); String thisEventName = eventIdNamesMap.get(thisEventId); eventNamesCache.put(thisCacheKey.toString(), thisEventName); if (thisEventId.equals(eventId)) { eventName = thisEventName; } } LOG.debug( "Cached event names for EB prefix '" + prefix + "', locale: " + currentUserLocale); } } catch (Exception e) { eventName = null; } return eventName; } }
private void processStatisticableProvider(Statisticable provider) { String entityPrefix = provider.getEntityPrefix(); String entityToolId = provider.getAssociatedToolId(); String[] entityEventIds = provider.getEventKeys(); // Build tool for Event Registry (List<ToolInfo>) ToolInfo tool = new ToolInfo(entityToolId); tool.setSelected(true); for (String eventId : entityEventIds) { EventInfo event = new EventInfo(eventId); event.setSelected(true); // Add to eventID -> entityProfider_prefix mapping eventIdToEPPrefix.put(eventId, entityPrefix); tool.addEvent(event); } eventRegistry.add(tool); // Set expired flag on EventRegistry to true setChanged(); notifyObservers(EventRegistryService.NOTIF_EVENT_REGISTRY_EXPIRED); }
public void run(Statisticable provider) { LOG.info("Statisticable capability registered with prefix: " + provider.getEntityPrefix()); processStatisticableProvider(provider); }