Search in sources :

Example 21 with AggregatedGroupMapping

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

the class JpaBaseAggregationDaoTest method testModifyingClosedAggregationRangeQuery.

@Test
public final void testModifyingClosedAggregationRangeQuery() throws Exception {
    final IEntityGroup entityGroupA = mock(IEntityGroup.class);
    when(entityGroupA.getServiceName()).thenReturn(new CompositeName("local"));
    when(entityGroupA.getName()).thenReturn("Group A");
    when(compositeGroupService.findGroup("local.0")).thenReturn(entityGroupA);
    final MutableInt aggrs = new MutableInt();
    //Create 10 minutes of aggregations
    final DateTime start = new DateTime(1326734644000l, DateTimeZone.UTC).minuteOfDay().roundFloorCopy();
    final DateTime end = start.plusMinutes(10);
    final AggregationInterval interval = AggregationInterval.FIVE_MINUTE;
    final MutableObject startObj = new MutableObject();
    final MutableObject endObj = new MutableObject();
    this.executeInTransaction(new CallableWithoutResult() {

        @Override
        protected void callWithoutResult() {
            final Random r = new Random(0);
            final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
            populateDateTimeDimensions(start, end, new FunctionWithoutResult<Tuple<DateDimension, TimeDimension>>() {

                @Override
                protected void applyWithoutResult(Tuple<DateDimension, TimeDimension> input) {
                    final TimeDimension td = input.second;
                    final DateDimension dd = input.first;
                    final DateTime instant = td.getTime().toDateTime(dd.getDate());
                    if (startObj.getValue() == null) {
                        startObj.setValue(instant);
                    }
                    endObj.setValue(instant);
                    if (instant.equals(interval.determineStart(instant))) {
                        final AggregationIntervalInfo intervalInfo = aggregationIntervalHelper.getIntervalInfo(interval, instant);
                        final T baseAggregationA = getAggregationDao().createAggregation(createAggregationKey(intervalInfo, groupA));
                        for (int u = 0; u < r.nextInt(50); u++) {
                            updateAggregation(intervalInfo, baseAggregationA, r);
                        }
                        baseAggregationA.intervalComplete(5);
                        getAggregationDao().updateAggregation(baseAggregationA);
                        aggrs.add(1);
                    }
                }
            });
        }
    });
    //Verify all aggrs created
    assertEquals(2, aggrs.intValue());
    //Find unclosed 1 aggr
    this.execute(new CallableWithoutResult() {

        @Override
        protected void callWithoutResult() {
            final Random r = new Random(0);
            final AggregatedGroupMapping groupA = aggregatedGroupLookupDao.getGroupMapping("local.0");
            final K key = createAggregationKey(interval, groupA);
            final List<T> aggregations = getAggregationDao().getAggregations(start.minusDays(1), end.plusDays(1), key);
            assertEquals(2, aggregations.size());
            for (final T baseAggregationImpl : aggregations) {
                final DateTime instant = baseAggregationImpl.getDateTime();
                final AggregationIntervalInfo intervalInfo = aggregationIntervalHelper.getIntervalInfo(interval, instant);
                updateAggregation(intervalInfo, baseAggregationImpl, r);
            //TODO verify unchanged
            }
        }
    });
}
Also used : CompositeName(javax.naming.CompositeName) DateTime(org.joda.time.DateTime) CallableWithoutResult(org.apereo.portal.concurrency.CallableWithoutResult) IEntityGroup(org.apereo.portal.groups.IEntityGroup) FunctionWithoutResult(org.apereo.portal.concurrency.FunctionWithoutResult) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) Random(java.util.Random) MutableInt(org.apache.commons.lang.mutable.MutableInt) LinkedList(java.util.LinkedList) List(java.util.List) Tuple(org.apereo.portal.utils.Tuple) MutableObject(org.apache.commons.lang.mutable.MutableObject) Test(org.junit.Test) BaseAggrEventsJpaDaoTest(org.apereo.portal.test.BaseAggrEventsJpaDaoTest)

Example 22 with AggregatedGroupMapping

use of org.apereo.portal.events.aggr.groups.AggregatedGroupMapping 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 23 with AggregatedGroupMapping

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

the class JpaPortletLayoutAggregationDao method getAggregationsForAllPortlets.

public final List<PortletLayoutAggregationImpl> getAggregationsForAllPortlets(DateTime start, DateTime end, AggregationInterval interval, AggregatedGroupMapping aggregatedGroupMapping, AggregatedGroupMapping... aggregatedGroupMappings) {
    if (!start.isBefore(end)) {
        throw new IllegalArgumentException("Start must be before End: " + start + " - " + end);
    }
    final LocalDate startDate = start.toLocalDate();
    final LocalDate endDate = end.toLocalDate();
    final TypedQuery<PortletLayoutAggregationImpl> query = this.createQuery(this.findAllPortletAggregationsByDateRangeQuery);
    query.setParameter(this.startDate, startDate);
    query.setParameter(this.startTime, start.toLocalTime());
    query.setParameter(this.endDate, endDate);
    query.setParameter(this.endTime, end.toLocalTime());
    query.setParameter(this.endPlusOneDate, endDate.plusDays(1));
    query.setParameter(this.intervalParameter, interval);
    final Set<AggregatedGroupMapping> groups = ImmutableSet.<AggregatedGroupMapping>builder().add(aggregatedGroupMapping).add(aggregatedGroupMappings).build();
    query.setParameter(this.aggregatedGroupsParameter, groups);
    return query.getResultList();
}
Also used : AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) LocalDate(org.joda.time.LocalDate)

Example 24 with AggregatedGroupMapping

use of org.apereo.portal.events.aggr.groups.AggregatedGroupMapping 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 25 with AggregatedGroupMapping

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

the class JpaConcurrentUserAggregationDao method createAggregationInstance.

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

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