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