Search in sources :

Example 6 with AggregatedGroupMapping

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;
}
Also used : PortletExecutionAggregation(org.apereo.portal.events.aggr.portletexec.PortletExecutionAggregation) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) PortletExecutionAggregationDiscriminator(org.apereo.portal.events.aggr.portletexec.PortletExecutionAggregationDiscriminator) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) TreeSet(java.util.TreeSet) PortletExecutionAggregationDiscriminatorImpl(org.apereo.portal.events.aggr.portletexec.PortletExecutionAggregationDiscriminatorImpl)

Example 7 with AggregatedGroupMapping

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;
}
Also used : TabRenderAggregationDiscriminatorImpl(org.apereo.portal.events.aggr.tabrender.TabRenderAggregationDiscriminatorImpl) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) TabRenderAggregationDiscriminator(org.apereo.portal.events.aggr.tabrender.TabRenderAggregationDiscriminator) TabRenderAggregation(org.apereo.portal.events.aggr.tabrender.TabRenderAggregation) TreeSet(java.util.TreeSet) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) AggregatedTabMapping(org.apereo.portal.events.aggr.tabs.AggregatedTabMapping)

Example 8 with AggregatedGroupMapping

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();
}
Also used : AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) LocalDate(org.joda.time.LocalDate)

Example 9 with AggregatedGroupMapping

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();
}
Also used : AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) LocalDate(org.joda.time.LocalDate)

Example 10 with AggregatedGroupMapping

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);
        }
    }
}
Also used : AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) Map(java.util.Map) HashMap(java.util.HashMap) AggrEventsTransactional(org.apereo.portal.jpa.BaseAggrEventsJpaDao.AggrEventsTransactional)

Aggregations

AggregatedGroupMapping (org.apereo.portal.events.aggr.groups.AggregatedGroupMapping)26 AggregationInterval (org.apereo.portal.events.aggr.AggregationInterval)10 IEntityGroup (org.apereo.portal.groups.IEntityGroup)8 DateTime (org.joda.time.DateTime)8 DateDimension (org.apereo.portal.events.aggr.DateDimension)6 TimeDimension (org.apereo.portal.events.aggr.TimeDimension)6 CompositeName (javax.naming.CompositeName)5 CallableWithoutResult (org.apereo.portal.concurrency.CallableWithoutResult)5 AggregatedPortletMapping (org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping)5 BaseAggrEventsJpaDaoTest (org.apereo.portal.test.BaseAggrEventsJpaDaoTest)5 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 Random (java.util.Random)4 TreeMap (java.util.TreeMap)4 ArrayList (java.util.ArrayList)3 SortedSet (java.util.SortedSet)3 TreeSet (java.util.TreeSet)3 MutableInt (org.apache.commons.lang.mutable.MutableInt)3 MutableObject (org.apache.commons.lang.mutable.MutableObject)3 FunctionWithoutResult (org.apereo.portal.concurrency.FunctionWithoutResult)3