Search in sources :

Example 11 with AggregatedGroupMapping

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

the class JpaEventSessionDao method getGroupsForEvent.

/** Get groups for the event */
protected Set<AggregatedGroupMapping> getGroupsForEvent(PortalEvent event) {
    final Set<AggregatedGroupMapping> groupMappings = new LinkedHashSet<AggregatedGroupMapping>();
    if (event instanceof LoginEvent) {
        for (final String groupKey : ((LoginEvent) event).getGroups()) {
            final AggregatedGroupMapping groupMapping = this.aggregatedGroupLookupDao.getGroupMapping(groupKey);
            if (groupMapping != null) {
                groupMappings.add(groupMapping);
            }
        }
    } else {
        final String userName = event.getUserName();
        final IGroupMember groupMember = this.compositeGroupService.getGroupMember(userName, IPerson.class);
        for (@SuppressWarnings("unchecked") final Iterator<IEntityGroup> containingGroups = this.compositeGroupService.findParentGroups(groupMember); containingGroups.hasNext(); ) {
            final IEntityGroup group = containingGroups.next();
            final AggregatedGroupMapping groupMapping = this.aggregatedGroupLookupDao.getGroupMapping(group.getServiceName().toString(), group.getName());
            groupMappings.add(groupMapping);
        }
    }
    return groupMappings;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IEntityGroup(org.apereo.portal.groups.IEntityGroup) IGroupMember(org.apereo.portal.groups.IGroupMember) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) LoginEvent(org.apereo.portal.events.LoginEvent)

Example 12 with AggregatedGroupMapping

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

the class JpaEventSessionDao method getEventSession.

@AggrEventsTransactional
@Override
public EventSession getEventSession(PortalEvent event) {
    final String eventSessionId = event.getEventSessionId();
    final CacheKey key = CacheKey.build(EVENT_SESSION_CACHE_SOURCE, eventSessionId);
    EventSessionImpl eventSession = this.entityManagerCache.get(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key);
    if (eventSession != null) {
        return eventSession;
    }
    final NaturalIdQuery<EventSessionImpl> naturalIdQuery = this.createNaturalIdQuery(EventSessionImpl.class);
    naturalIdQuery.using(EventSessionImpl_.eventSessionId, eventSessionId);
    eventSession = naturalIdQuery.load();
    if (eventSession == null) {
        //No event session, somehow we missed the login event. Look at the groups the user is currently a member of
        final Set<AggregatedGroupMapping> groupMappings = this.getGroupsForEvent(event);
        final DateTime eventDate = event.getTimestampAsDate();
        eventSession = new EventSessionImpl(eventSessionId, eventDate, groupMappings);
        this.getEntityManager().persist(eventSession);
        this.entityManagerCache.put(BaseAggrEventsJpaDao.PERSISTENCE_UNIT_NAME, key, eventSession);
    }
    return eventSession;
}
Also used : AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) CacheKey(org.apereo.portal.utils.cache.CacheKey) DateTime(org.joda.time.DateTime)

Example 13 with AggregatedGroupMapping

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

the class JpaLoginAggregationDao method createAggregationInstance.

@Override
protected LoginAggregationImpl createAggregationInstance(LoginAggregationKey key) {
    final TimeDimension timeDimension = key.getTimeDimension();
    final DateDimension dateDimension = key.getDateDimension();
    final AggregationInterval interval = key.getInterval();
    final AggregatedGroupMapping aggregatedGroup = key.getAggregatedGroup();
    return new LoginAggregationImpl(timeDimension, dateDimension, interval, aggregatedGroup);
}
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 14 with AggregatedGroupMapping

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

the class JpaPortletExecutionAggregationDao method createAggregationInstance.

@Override
protected PortletExecutionAggregationImpl createAggregationInstance(PortletExecutionAggregationKey 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();
    final ExecutionType executionType = key.getExecutionType();
    return new PortletExecutionAggregationImpl(timeDimension, dateDimension, interval, aggregatedGroup, portletMapping, executionType);
}
Also used : AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) ExecutionType(org.apereo.portal.events.aggr.portletexec.PortletExecutionAggregationKey.ExecutionType) 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 15 with AggregatedGroupMapping

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

the class JpaTabRenderAggregationDao method createAggregationInstance.

@Override
protected TabRenderAggregationImpl createAggregationInstance(TabRenderAggregationKey key) {
    final TimeDimension timeDimension = key.getTimeDimension();
    final DateDimension dateDimension = key.getDateDimension();
    final AggregationInterval interval = key.getInterval();
    final AggregatedGroupMapping aggregatedGroup = key.getAggregatedGroup();
    final AggregatedTabMapping tabMapping = key.getTabMapping();
    return new TabRenderAggregationImpl(timeDimension, dateDimension, interval, aggregatedGroup, tabMapping);
}
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) AggregatedTabMapping(org.apereo.portal.events.aggr.tabs.AggregatedTabMapping)

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