use of org.apereo.portal.events.aggr.groups.AggregatedGroupMapping in project uPortal by Jasig.
the class PortletExecutionStatisticsController method createColumnDiscriminatorMap.
protected Map<PortletExecutionAggregationDiscriminator, SortedSet<PortletExecutionAggregation>> createColumnDiscriminatorMap(PortletExecutionReportForm form) {
//Collections used to track the queried groups and the results
final Map<PortletExecutionAggregationDiscriminator, SortedSet<PortletExecutionAggregation>> groupedAggregations = new TreeMap<PortletExecutionAggregationDiscriminator, SortedSet<PortletExecutionAggregation>>(PortletExecutionAggregationDiscriminatorImpl.Comparator.INSTANCE);
//Get concrete group mapping objects that are being queried for
List<Long> groups = form.getGroups();
Set<String> portletFNames = form.getPortlets();
Set<String> executionTypes = form.getExecutionTypeNames();
for (final Long queryGroupId : groups) {
AggregatedGroupMapping groupMapping = this.aggregatedGroupLookupDao.getGroupMapping(queryGroupId);
for (final String portletFName : portletFNames) {
AggregatedPortletMapping tabMapping = this.aggregatedPortletLookupDao.getMappedPortletForFname(portletFName);
for (String executionType : executionTypes) {
final PortletExecutionAggregationDiscriminator mapping = new PortletExecutionAggregationDiscriminatorImpl(groupMapping, tabMapping, ExecutionType.valueOf(executionType));
//Create the set the aggregations for this report column will be stored in, sorted chronologically
final SortedSet<PortletExecutionAggregation> aggregations = new TreeSet<PortletExecutionAggregation>(BaseAggregationDateTimeComparator.INSTANCE);
//Map the group to the set
groupedAggregations.put(mapping, aggregations);
}
}
}
return groupedAggregations;
}
use of org.apereo.portal.events.aggr.groups.AggregatedGroupMapping in project uPortal by Jasig.
the class TabRenderStatisticsController method createColumnDiscriminatorMap.
protected Map<TabRenderAggregationDiscriminator, SortedSet<TabRenderAggregation>> createColumnDiscriminatorMap(TabRenderReportForm form) {
//Collections used to track the queried groups and the results
final Map<TabRenderAggregationDiscriminator, SortedSet<TabRenderAggregation>> groupedAggregations = new TreeMap<TabRenderAggregationDiscriminator, SortedSet<TabRenderAggregation>>(TabRenderAggregationDiscriminatorImpl.Comparator.INSTANCE);
//Get concrete group mapping objects that are being queried for
List<Long> groups = form.getGroups();
List<Long> tabs = form.getTabs();
for (final Long queryGroupId : groups) {
AggregatedGroupMapping groupMapping = this.aggregatedGroupDao.getGroupMapping(queryGroupId);
for (final Long tabId : tabs) {
AggregatedTabMapping tabMapping = this.aggregatedTabLookupDao.getTabMapping(tabId);
final TabRenderAggregationDiscriminator mapping = new TabRenderAggregationDiscriminatorImpl(groupMapping, tabMapping);
//Create the set the aggregations for this report column will be stored in, sorted chronologically
final SortedSet<TabRenderAggregation> aggregations = new TreeSet<TabRenderAggregation>(BaseAggregationDateTimeComparator.INSTANCE);
//Map the group to the set
groupedAggregations.put(mapping, aggregations);
}
}
return groupedAggregations;
}
use of org.apereo.portal.events.aggr.groups.AggregatedGroupMapping in project uPortal by Jasig.
the class JpaSearchRequestAggregationDao method getAggregations.
@Override
public final List<SearchRequestAggregationImpl> getAggregations(DateTime start, DateTime end, AggregationInterval interval, AggregatedGroupMapping aggregatedGroupMapping, AggregatedGroupMapping... aggregatedGroupMappings) {
if (!start.isBefore(end)) {
throw new IllegalArgumentException("Start must be before End: " + start + " - " + end);
}
final LocalDate startDate = start.toLocalDate();
final LocalDate endDate = end.toLocalDate();
final TypedQuery<SearchRequestAggregationImpl> query = this.createQuery(this.findAllSearchRequestAggregationsByDateRangeQuery);
query.setParameter(this.startDate, startDate);
query.setParameter(this.startTime, start.toLocalTime());
query.setParameter(this.endDate, endDate);
query.setParameter(this.endTime, end.toLocalTime());
query.setParameter(this.endPlusOneDate, endDate.plusDays(1));
query.setParameter(this.intervalParameter, interval);
final Set<AggregatedGroupMapping> groups = ImmutableSet.<AggregatedGroupMapping>builder().add(aggregatedGroupMapping).add(aggregatedGroupMappings).build();
query.setParameter(this.aggregatedGroupsParameter, groups);
return query.getResultList();
}
use of org.apereo.portal.events.aggr.groups.AggregatedGroupMapping in project uPortal by Jasig.
the class JpaBaseAggregationDao method getAggregations.
@Override
public final List<T> getAggregations(DateTime start, DateTime end, Set<K> keys, AggregatedGroupMapping... aggregatedGroupMappings) {
if (!start.isBefore(end)) {
throw new IllegalArgumentException("Start must be before End: " + start + " - " + end);
}
final LocalDate startDate = start.toLocalDate();
final LocalDate endDate = end.toLocalDate();
final TypedQuery<T> query = this.createQuery(findAggregationsByDateRangeQuery);
query.setParameter(this.startDate, startDate);
query.setParameter(this.startTime, start.toLocalTime());
query.setParameter(this.endDate, endDate);
query.setParameter(this.endTime, end.toLocalTime());
query.setParameter(this.endPlusOneDate, endDate.plusDays(1));
// Get the first key to use for the interval
K key = keys.iterator().next();
query.setParameter(this.intervalParameter, key.getInterval());
this.bindAggregationSpecificKeyParameters(query, keys);
final Set<AggregatedGroupMapping> groups = collectAllGroupsFromParams(keys, aggregatedGroupMappings);
query.setParameter(this.aggregatedGroupsParameter, groups);
return query.getResultList();
}
use of org.apereo.portal.events.aggr.groups.AggregatedGroupMapping in project uPortal by Jasig.
the class BaseIntervalAwarePortalEventAggregator method aggregateEvent.
@AggrEventsTransactional
@Override
public final void aggregateEvent(E e, EventSession eventSession, EventAggregationContext eventAggregationContext, Map<AggregationInterval, AggregationIntervalInfo> currentIntervals) {
final BaseAggregationPrivateDao<T, K> aggregationDao = this.getAggregationDao();
for (Map.Entry<AggregationInterval, AggregationIntervalInfo> intervalInfoEntry : currentIntervals.entrySet()) {
final AggregationIntervalInfo intervalInfo = intervalInfoEntry.getValue();
//Map used to cache aggregations locally after loading
Map<K, T> aggregationsCache = eventAggregationContext.getAttribute(this.aggregationsCacheKey);
if (aggregationsCache == null) {
aggregationsCache = new HashMap<K, T>();
eventAggregationContext.setAttribute(this.aggregationsCacheKey, aggregationsCache);
}
//Groups this event is for
final Set<AggregatedGroupMapping> groupMappings = eventSession.getGroupMappings();
//For each group get/create then update the aggregation
for (final AggregatedGroupMapping groupMapping : groupMappings) {
final K key = this.createAggregationKey(e, eventAggregationContext, intervalInfo, groupMapping);
//Load the aggregation, try from the cache first
T aggregation = aggregationsCache.get(key);
if (aggregation == null) {
//Then try loading from the db
aggregation = aggregationDao.getAggregation(key);
if (aggregation == null) {
//Finally create the aggregation
aggregation = aggregationDao.createAggregation(key);
}
//Store the loaded/created aggregation in the local cache
aggregationsCache.put(key, aggregation);
}
//Update the aggregation with the event
updateAggregation(e, eventAggregationContext, intervalInfo, aggregation);
}
}
}
Aggregations