Search in sources :

Example 21 with AggregationInterval

use of org.apereo.portal.events.aggr.AggregationInterval in project uPortal by Jasig.

the class ConcurrentUsersStatisticsController method createAggregationsQueryKeyset.

@Override
protected Set<ConcurrentUserAggregationKey> createAggregationsQueryKeyset(Set<ConcurrentUserAggregationDiscriminator> groups, ConcurrentUserReportForm form) {
    final AggregationInterval interval = form.getInterval();
    HashSet<ConcurrentUserAggregationKey> keys = new HashSet<ConcurrentUserAggregationKey>();
    keys.add(new ConcurrentUserAggregationKeyImpl(interval, groups.iterator().next().getAggregatedGroup()));
    return keys;
}
Also used : ConcurrentUserAggregationKeyImpl(org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregationKeyImpl) ConcurrentUserAggregationKey(org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregationKey) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval) HashSet(java.util.HashSet)

Example 22 with AggregationInterval

use of org.apereo.portal.events.aggr.AggregationInterval in project uPortal by Jasig.

the class TabRenderStatisticsController method createAggregationsQueryKeyset.

@Override
protected Set<TabRenderAggregationKey> createAggregationsQueryKeyset(Set<TabRenderAggregationDiscriminator> columnDiscriminators, TabRenderReportForm form) {
    // Create keys (that exclude the temporal date/time information) from the interval
    // and the data in the column discriminators.
    final AggregationInterval interval = form.getInterval();
    final HashSet<TabRenderAggregationKey> keys = new HashSet<TabRenderAggregationKey>();
    for (TabRenderAggregationDiscriminator discriminator : columnDiscriminators) {
        keys.add(new TabRenderAggregationKeyImpl(interval, discriminator.getAggregatedGroup(), discriminator.getTabMapping()));
    }
    return keys;
}
Also used : TabRenderAggregationDiscriminator(org.apereo.portal.events.aggr.tabrender.TabRenderAggregationDiscriminator) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval) TabRenderAggregationKeyImpl(org.apereo.portal.events.aggr.tabrender.TabRenderAggregationKeyImpl) HashSet(java.util.HashSet) TabRenderAggregationKey(org.apereo.portal.events.aggr.tabrender.TabRenderAggregationKey)

Example 23 with AggregationInterval

use of org.apereo.portal.events.aggr.AggregationInterval in project uPortal by Jasig.

the class ActivityController method buildPortalActivity.

private PortalActivity buildPortalActivity(PortletRequest request, int timeframe) {
    PortletPreferences prefs = request.getPreferences();
    DateTime begin, end;
    final AggregationInterval interval;
    final List<PortalGroupActivity> groupActivities = new ArrayList<PortalGroupActivity>();
    switch(timeframe) {
        case NOW:
            {
                end = new DateTime();
                begin = end.minusHours(1);
                interval = AggregationInterval.FIVE_MINUTE;
                break;
            }
        case TODAY:
            {
                begin = new DateMidnight().toDateTime();
                end = begin.plusDays(1);
                interval = AggregationInterval.DAY;
                break;
            }
        case YESTERDAY:
            {
                end = new DateMidnight().toDateTime().minusSeconds(1);
                begin = end.minusDays(1);
                interval = AggregationInterval.DAY;
                break;
            }
        default:
            {
                end = new DateTime();
                begin = end.minusHours(1);
                interval = AggregationInterval.HOUR;
                break;
            }
    }
    String masterGroup = prefs.getValue(PREFERENCE_MASTER_GROUP, DEFAULT_PREFERENCE_MASTER_GROUP);
    List<String> displayGroups = Arrays.asList(prefs.getValues(PREFERENCE_DISPLAY_GROUPS, DEFAULT_PREFERENCE_DISPLAY_GROUPS));
    boolean displayOther = Boolean.valueOf(prefs.getValue(PREFERENCE_DISPLAY_OTHER, DEFAULT_PREFERENCE_DISPLAY_OTHER));
    int masterTotal = 0;
    int absTotal = 0;
    int subTotal = 0;
    switch(timeframe) {
        case NOW:
            for (AggregatedGroupMapping group : concurrentUserAggregationDao.getAggregatedGroupMappings()) {
                ConcurrentUserAggregationKey key = new ConcurrentUserAggregationKeyImpl(interval, group);
                final List<ConcurrentUserAggregation> aggregations = concurrentUserAggregationDao.getAggregations(begin, end, key);
                // NB:  We only care about the most recent entry (??)
                if (aggregations.size() != 0) {
                    final ConcurrentUserAggregation aggregation = aggregations.get(0);
                    int groupTotal = aggregation.getConcurrentUsers();
                    absTotal += aggregation.getConcurrentUsers();
                    if (group.getGroupName().equalsIgnoreCase(masterGroup)) {
                        masterTotal = groupTotal;
                    } else {
                        subTotal += groupTotal;
                    }
                    if (!group.getGroupName().equals(masterGroup)) {
                        if (displayGroups.isEmpty() || displayGroups.contains(group.getGroupName())) {
                            final PortalGroupActivity groupActivity = new PortalGroupActivity(group.getGroupName(), groupTotal);
                            groupActivities.add(groupActivity);
                        }
                    }
                }
            }
            break;
        default:
            String uniqueLoginsPref = prefs.getValue(PREFERENCE_UNIQUE_LOGINS, DEFAULT_PREFERENCE_UNIQUE_LOGINS);
            Boolean uniqueLogins = Boolean.valueOf(uniqueLoginsPref);
            for (AggregatedGroupMapping group : loginAggregationDao.getAggregatedGroupMappings()) {
                final LoginAggregationKey key = new LoginAggregationKeyImpl(interval, group);
                final List<LoginAggregation> aggregations = loginAggregationDao.getAggregations(begin, end, key);
                // NB:  We only care about the most recent entry (??)
                if (aggregations.size() != 0) {
                    final LoginAggregation aggregation = aggregations.get(0);
                    int groupTotal = getAggregationLoginCount(aggregation, uniqueLogins);
                    absTotal += groupTotal;
                    if (group.getGroupName().equalsIgnoreCase(masterGroup)) {
                        masterTotal = groupTotal;
                    } else {
                        subTotal += groupTotal;
                    }
                    if (!group.getGroupName().equals(masterGroup)) {
                        if (displayGroups.isEmpty() || displayGroups.contains(group.getGroupName())) {
                            PortalGroupActivity groupActivity = new PortalGroupActivity(group.getGroupName(), groupTotal);
                            groupActivities.add(groupActivity);
                        }
                    }
                }
            }
            break;
    }
    if (displayOther) {
        int otherTotal = masterTotal - subTotal;
        if (otherTotal > 0) {
            PortalGroupActivity otherGroup = new PortalGroupActivity("Other", otherTotal);
            groupActivities.add(otherGroup);
        }
    }
    Collections.sort(groupActivities);
    Collections.reverse(groupActivities);
    int total = masterTotal > 0 ? masterTotal : absTotal;
    final PortalActivity activity = new PortalActivity(total, groupActivities);
    return activity;
}
Also used : LoginAggregationKey(org.apereo.portal.events.aggr.login.LoginAggregationKey) ConcurrentUserAggregationKey(org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregationKey) ArrayList(java.util.ArrayList) LoginAggregationKeyImpl(org.apereo.portal.events.aggr.login.LoginAggregationKeyImpl) LoginAggregation(org.apereo.portal.events.aggr.login.LoginAggregation) DateTime(org.joda.time.DateTime) ConcurrentUserAggregationKeyImpl(org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregationKeyImpl) ConcurrentUserAggregation(org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregation) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) DateMidnight(org.joda.time.DateMidnight) PortletPreferences(javax.portlet.PortletPreferences) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval)

Example 24 with AggregationInterval

use of org.apereo.portal.events.aggr.AggregationInterval in project uPortal by Jasig.

the class JpaSearchRequestAggregationDao method createAggregationInstance.

@Override
protected SearchRequestAggregationImpl createAggregationInstance(SearchRequestAggregationKey key) {
    final TimeDimension timeDimension = key.getTimeDimension();
    final DateDimension dateDimension = key.getDateDimension();
    final AggregationInterval interval = key.getInterval();
    final AggregatedGroupMapping aggregatedGroup = key.getAggregatedGroup();
    final String searchTerm = key.getSearchTerm();
    return new SearchRequestAggregationImpl(timeDimension, dateDimension, interval, aggregatedGroup, searchTerm);
}
Also used : AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) TimeDimension(org.apereo.portal.events.aggr.TimeDimension) DateDimension(org.apereo.portal.events.aggr.DateDimension) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval)

Example 25 with AggregationInterval

use of org.apereo.portal.events.aggr.AggregationInterval in project uPortal by Jasig.

the class SearchRequestAggregator method createAggregationKey.

@Override
protected SearchRequestAggregationKey createAggregationKey(PortletActionExecutionEvent e, EventAggregationContext eventAggregationContext, AggregationIntervalInfo intervalInfo, AggregatedGroupMapping aggregatedGroup) {
    final TimeDimension timeDimension = intervalInfo.getTimeDimension();
    final DateDimension dateDimension = intervalInfo.getDateDimension();
    final AggregationInterval aggregationInterval = intervalInfo.getAggregationInterval();
    String query = e.getParameters().get(TARGET_PARAM).get(0);
    SearchRequestAggregationKey key = new SearchRequestAggregationKeyImpl(dateDimension, timeDimension, aggregationInterval, aggregatedGroup, query);
    return key;
}
Also used : TimeDimension(org.apereo.portal.events.aggr.TimeDimension) DateDimension(org.apereo.portal.events.aggr.DateDimension) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval)

Aggregations

AggregationInterval (org.apereo.portal.events.aggr.AggregationInterval)30 DateDimension (org.apereo.portal.events.aggr.DateDimension)20 TimeDimension (org.apereo.portal.events.aggr.TimeDimension)20 AggregatedGroupMapping (org.apereo.portal.events.aggr.groups.AggregatedGroupMapping)10 HashSet (java.util.HashSet)6 AggregatedPortletMapping (org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping)6 AggregatedTabMapping (org.apereo.portal.events.aggr.tabs.AggregatedTabMapping)4 DateMidnight (org.joda.time.DateMidnight)4 AcademicTermDetail (org.apereo.portal.events.aggr.AcademicTermDetail)2 AggregatedGroupConfig (org.apereo.portal.events.aggr.AggregatedGroupConfig)2 AggregatedIntervalConfig (org.apereo.portal.events.aggr.AggregatedIntervalConfig)2 QuarterDetail (org.apereo.portal.events.aggr.QuarterDetail)2 ConcurrentUserAggregationKey (org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregationKey)2 ConcurrentUserAggregationKeyImpl (org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregationKeyImpl)2 LoginAggregationKey (org.apereo.portal.events.aggr.login.LoginAggregationKey)2 LoginAggregationKeyImpl (org.apereo.portal.events.aggr.login.LoginAggregationKeyImpl)2 DateTime (org.joda.time.DateTime)2 PeekingIterator (com.google.common.collect.PeekingIterator)1 ColumnDescription (com.google.visualization.datasource.datatable.ColumnDescription)1 DataTable (com.google.visualization.datasource.datatable.DataTable)1