Search in sources :

Example 6 with AggregatedPortletMapping

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

the class PortletExecutionAggregator method createAggregationKey.

@Override
protected PortletExecutionAggregationKey createAggregationKey(PortletExecutionEvent e, EventAggregationContext eventAggregationContext, AggregationIntervalInfo intervalInfo, AggregatedGroupMapping aggregatedGroup) {
    final TimeDimension timeDimension = intervalInfo.getTimeDimension();
    final DateDimension dateDimension = intervalInfo.getDateDimension();
    final AggregationInterval aggregationInterval = intervalInfo.getAggregationInterval();
    Map<String, AggregatedPortletMapping> mappedPortlets = eventAggregationContext.getAttribute(MAPPED_PORTLETS_CACHE_KEY);
    if (mappedPortlets == null) {
        mappedPortlets = new HashMap<String, AggregatedPortletMapping>();
        eventAggregationContext.setAttribute(MAPPED_PORTLETS_CACHE_KEY, mappedPortlets);
    }
    final String fname = e.getFname();
    AggregatedPortletMapping mappedPortlet = mappedPortlets.get(fname);
    if (mappedPortlet == null) {
        mappedPortlet = this.aggregatedPortletLookupDao.getMappedPortletForFname(fname);
        mappedPortlets.put(fname, mappedPortlet);
    }
    return new PortletExecutionAggregationKeyImpl(dateDimension, timeDimension, aggregationInterval, aggregatedGroup, mappedPortlet, executionType);
}
Also used : AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) TimeDimension(org.apereo.portal.events.aggr.TimeDimension) DateDimension(org.apereo.portal.events.aggr.DateDimension) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval)

Example 7 with AggregatedPortletMapping

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

the class PortletExecutionEventConverter method getLrsObject.

@Override
protected LrsObject getLrsObject(PortalEvent event) {
    final String fname = ((PortletExecutionEvent) event).getFname();
    final AggregatedPortletMapping mappedPortletForFname = this.aggregatedPortletLookupDao.getMappedPortletForFname(fname);
    final Builder<String, LocalizedString> definitionBuilder = ImmutableMap.builder();
    definitionBuilder.put("name", new LocalizedString(Locale.US, mappedPortletForFname.getName()));
    return new LrsObject(buildUrn("portlet", fname), getDefaultObjectType(), definitionBuilder.build());
}
Also used : PortletExecutionEvent(org.apereo.portal.events.PortletExecutionEvent) LrsObject(org.apereo.portal.events.tincan.om.LrsObject) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString) LocalizedString(org.apereo.portal.events.tincan.om.LocalizedString)

Example 8 with AggregatedPortletMapping

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

the class JpaPortletLayoutAggregationDao method createAggregationInstance.

@Override
protected PortletLayoutAggregationImpl createAggregationInstance(PortletLayoutAggregationKey key) {
    final TimeDimension timeDimension = key.getTimeDimension();
    final DateDimension dateDimension = key.getDateDimension();
    final AggregationInterval interval = key.getInterval();
    final AggregatedGroupMapping aggregatedGroup = key.getAggregatedGroup();
    final AggregatedPortletMapping portletMapping = key.getPortletMapping();
    return new PortletLayoutAggregationImpl(timeDimension, dateDimension, interval, aggregatedGroup, portletMapping);
}
Also used : AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) TimeDimension(org.apereo.portal.events.aggr.TimeDimension) DateDimension(org.apereo.portal.events.aggr.DateDimension) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval)

Example 9 with AggregatedPortletMapping

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

the class PortletLayoutAggregator method createAggregationKey.

@Override
protected PortletLayoutAggregationKey createAggregationKey(PortletLayoutPortalEvent e, EventAggregationContext eventAggregationContext, AggregationIntervalInfo intervalInfo, AggregatedGroupMapping aggregatedGroup) {
    final TimeDimension timeDimension = intervalInfo.getTimeDimension();
    final DateDimension dateDimension = intervalInfo.getDateDimension();
    final AggregationInterval aggregationInterval = intervalInfo.getAggregationInterval();
    Map<String, AggregatedPortletMapping> mappedPortlets = eventAggregationContext.getAttribute(MAPPED_PORTLETS_CACHE_KEY);
    if (mappedPortlets == null) {
        mappedPortlets = new HashMap<String, AggregatedPortletMapping>();
        eventAggregationContext.setAttribute(MAPPED_PORTLETS_CACHE_KEY, mappedPortlets);
    }
    final String fname = e.getFname();
    AggregatedPortletMapping mappedPortlet = mappedPortlets.get(fname);
    if (mappedPortlet == null) {
        mappedPortlet = this.aggregatedPortletLookupDao.getMappedPortletForFname(fname);
        mappedPortlets.put(fname, mappedPortlet);
    }
    return new PortletLayoutAggregationKeyImpl(dateDimension, timeDimension, aggregationInterval, aggregatedGroup, mappedPortlet);
}
Also used : AggregatedPortletMapping(org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping) TimeDimension(org.apereo.portal.events.aggr.TimeDimension) DateDimension(org.apereo.portal.events.aggr.DateDimension) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval)

Example 10 with AggregatedPortletMapping

use of org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping 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 AuthorizationServiceFacade authService = AuthorizationServiceFacade.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) AuthorizationServiceFacade(org.apereo.portal.services.AuthorizationServiceFacade) IAuthorizationPrincipal(org.apereo.portal.security.IAuthorizationPrincipal) IPortletDefinition(org.apereo.portal.portlet.om.IPortletDefinition)

Aggregations

AggregatedPortletMapping (org.apereo.portal.events.aggr.portlets.AggregatedPortletMapping)10 AggregationInterval (org.apereo.portal.events.aggr.AggregationInterval)6 DateDimension (org.apereo.portal.events.aggr.DateDimension)6 TimeDimension (org.apereo.portal.events.aggr.TimeDimension)6 AggregatedGroupMapping (org.apereo.portal.events.aggr.groups.AggregatedGroupMapping)5 SortedSet (java.util.SortedSet)2 TreeMap (java.util.TreeMap)2 TreeSet (java.util.TreeSet)2 PortletLayoutAggregation (org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregation)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 EntityIdentifier (org.apereo.portal.EntityIdentifier)1 PortletExecutionEvent (org.apereo.portal.events.PortletExecutionEvent)1 PortletExecutionAggregation (org.apereo.portal.events.aggr.portletexec.PortletExecutionAggregation)1 PortletExecutionAggregationDiscriminator (org.apereo.portal.events.aggr.portletexec.PortletExecutionAggregationDiscriminator)1 PortletExecutionAggregationDiscriminatorImpl (org.apereo.portal.events.aggr.portletexec.PortletExecutionAggregationDiscriminatorImpl)1 ExecutionType (org.apereo.portal.events.aggr.portletexec.PortletExecutionAggregationKey.ExecutionType)1 PortletLayoutAggregationDiscriminator (org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregationDiscriminator)1 PortletLayoutAggregationDiscriminatorImpl (org.apereo.portal.events.aggr.portletlayout.PortletLayoutAggregationDiscriminatorImpl)1 LocalizedString (org.apereo.portal.events.tincan.om.LocalizedString)1