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);
}
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());
}
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);
}
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);
}
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;
}
Aggregations