Search in sources :

Example 1 with PortletLayoutAggregation

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

the class BasePortletLayoutStatisticsController method createColumnDiscriminatorMap.

protected Map<PortletLayoutAggregationDiscriminator, SortedSet<PortletLayoutAggregation>> createColumnDiscriminatorMap(F form) {
    //Collections used to track the queried groups and the results
    final Map<PortletLayoutAggregationDiscriminator, SortedSet<PortletLayoutAggregation>> groupedAggregations = new TreeMap<PortletLayoutAggregationDiscriminator, SortedSet<PortletLayoutAggregation>>(PortletLayoutAggregationDiscriminatorImpl.Comparator.INSTANCE);
    //Get concrete group mapping objects that are being queried for
    List<Long> groups = form.getGroups();
    Set<String> portletFNames = form.getPortlets();
    for (final Long queryGroupId : groups) {
        AggregatedGroupMapping groupMapping = this.aggregatedGroupLookupDao.getGroupMapping(queryGroupId);
        for (final String portletFName : portletFNames) {
            AggregatedPortletMapping tabMapping = this.aggregatedPortletLookupDao.getMappedPortletForFname(portletFName);
            final PortletLayoutAggregationDiscriminator mapping = new PortletLayoutAggregationDiscriminatorImpl(groupMapping, tabMapping);
            //Create the set the aggregations for this report column will be stored in, sorted chronologically
            final SortedSet<PortletLayoutAggregation> aggregations = new TreeSet<PortletLayoutAggregation>(BaseAggregationDateTimeComparator.INSTANCE);
            //Map the group to the set
            groupedAggregations.put(mapping, aggregations);
        }
    }
    return groupedAggregations;
}
Also used : PortletLayoutAggregationDiscriminator(org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregationDiscriminator) PortletLayoutAggregation(org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregation) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) TreeSet(java.util.TreeSet) PortletLayoutAggregationDiscriminatorImpl(org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregationDiscriminatorImpl)

Example 2 with PortletLayoutAggregation

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

the class PopularPortletsController method buildEventCounts.

private List<PortletUsage> buildEventCounts(Integer days, IPerson user, Locale locale) {
    final DateTime end = new DateTime();
    final DateTime begin = end.minusDays(days);
    final IEntityGroup everyone = GroupService.getRootGroup(IPerson.class);
    final AggregatedGroupMapping group = aggregatedGroupLookupDao.getGroupMapping(everyone.getKey());
    final List<PortletLayoutAggregation> aggregations = portletLayoutDao.getAggregationsForAllPortlets(begin, end, AGGREGATION_INTERVAL, group);
    final EntityIdentifier ei = user.getEntityIdentifier();
    final AuthorizationService authService = AuthorizationService.instance();
    final IAuthorizationPrincipal ap = authService.newPrincipal(ei.getKey(), ei.getType());
    final Map<String, PortletUsage> resultBuilder = new HashMap<String, PortletUsage>();
    for (final PortletLayoutAggregation aggregation : aggregations) {
        final AggregatedPortletMapping portlet = aggregation.getPortletMapping();
        final String fname = portlet.getFname();
        PortletUsage portletUsage = resultBuilder.get(fname);
        if (portletUsage == null) {
            final IPortletDefinition portletDefinition = this.portletDefinitionDao.getPortletDefinitionByFname(fname);
            if (portletDefinition == null || !ap.canSubscribe(portletDefinition.getPortletDefinitionId().getStringId())) {
                //Skip portlets that no longer exist or cannot be subscribed to
                continue;
            }
            portletUsage = new PortletUsage(portletDefinition.getPortletDefinitionId().getLongId(), fname, portletDefinition.getTitle(locale.toString()), portletDefinition.getDescription(locale.toString()));
            resultBuilder.put(fname, portletUsage);
        }
        portletUsage.incrementCount(aggregation.getAddCount());
    }
    final ArrayList<PortletUsage> results = new ArrayList<PortletUsage>(resultBuilder.values());
    Collections.sort(results);
    return results;
}
Also used : HashMap(java.util.HashMap) PortletLayoutAggregation(org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregation) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) ArrayList(java.util.ArrayList) EntityIdentifier(org.apereo.portal.EntityIdentifier) DateTime(org.joda.time.DateTime) IEntityGroup(org.apereo.portal.groups.IEntityGroup) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) AuthorizationService(org.apereo.portal.services.AuthorizationService) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

AggregatedGroupMapping (org.apereo.portal.events.aggr.groups.AggregatedGroupMapping)2 PortletLayoutAggregation (org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregation)2 AggregatedPortletMapping (org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 SortedSet (java.util.SortedSet)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 EntityIdentifier (org.apereo.portal.EntityIdentifier)1 PortletLayoutAggregationDiscriminator (org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregationDiscriminator)1 PortletLayoutAggregationDiscriminatorImpl (org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregationDiscriminatorImpl)1 IEntityGroup (org.apereo.portal.groups.IEntityGroup)1 IPortletDefinition (org.apereo.portal.portlet.om.IPortletDefinition)1 IAuthorizationPrincipal (org.apereo.portal.security.IAuthorizationPrincipal)1 AuthorizationService (org.apereo.portal.services.AuthorizationService)1 DateTime (org.joda.time.DateTime)1