use of org.apereo.portal.events.aggr.AggregatedGroupConfig in project uPortal by Jasig.
the class EventAggregationConfigurationImporterExporter method deleteData.
/*
* (non-Javadoc)
* @see org.apereo.portal.io.xml.IDataImporterExporter#deleteData(java.lang.String)
*/
@Transactional("aggrEventsTransactionManager")
@Override
public ExternalEventAggregationConfiguration deleteData(String id) {
final ExternalEventAggregationConfiguration data = this.exportData(id);
for (final AggregatedIntervalConfig aggregatedIntervalConfig : this.aggregationManagementDao.getAggregatedIntervalConfigs()) {
this.aggregationManagementDao.deleteAggregatedIntervalConfig(aggregatedIntervalConfig);
}
for (final AggregatedGroupConfig aggregatedGroupConfig : this.aggregationManagementDao.getAggregatedGroupConfigs()) {
this.aggregationManagementDao.deleteAggregatedGroupConfig(aggregatedGroupConfig);
}
this.aggregationManagementDao.setAcademicTermDetails(Collections.<AcademicTermDetail>emptyList());
this.aggregationManagementDao.setQuarterDetails(EventDateTimeUtils.createStandardQuarters());
return data;
}
use of org.apereo.portal.events.aggr.AggregatedGroupConfig in project uPortal by Jasig.
the class EventAggregationConfigurationImporterExporter method importData.
@Transactional("aggrEventsTransactionManager")
@Override
public void importData(ExternalEventAggregationConfiguration data) {
//Import interval configs
final Set<AggregatedIntervalConfig> oldAggregatedIntervalConfigs = new HashSet<AggregatedIntervalConfig>(this.aggregationManagementDao.getAggregatedIntervalConfigs());
for (final ExternalAggregatedIntervalConfig extAggregatedIntervalConfig : data.getAggregatedIntervalConfigs()) {
final String aggregatorTypeName = extAggregatedIntervalConfig.getAggregatorType();
final Class<? extends IPortalEventAggregator> aggregatorType = getAggregatorType(aggregatorTypeName);
AggregatedIntervalConfig aggregatedIntervalConfig = this.aggregationManagementDao.getAggregatedIntervalConfig(aggregatorType);
if (aggregatedIntervalConfig == null) {
aggregatedIntervalConfig = this.aggregationManagementDao.createAggregatedIntervalConfig(aggregatorType);
}
//Remove the config from the old configs set, marking it as updated
oldAggregatedIntervalConfigs.remove(aggregatedIntervalConfig);
//Copy over excludes
final Set<AggregationInterval> excluded = aggregatedIntervalConfig.getExcluded();
excluded.clear();
for (final ExternalAggregationInterval extInterval : extAggregatedIntervalConfig.getExcludes()) {
excluded.add(convert(extInterval));
}
//Copy over includes
final Set<AggregationInterval> included = aggregatedIntervalConfig.getIncluded();
included.clear();
for (final ExternalAggregationInterval extInterval : extAggregatedIntervalConfig.getIncludes()) {
included.add(convert(extInterval));
}
this.aggregationManagementDao.updateAggregatedIntervalConfig(aggregatedIntervalConfig);
}
//Delete interval configs that were not updated
for (final AggregatedIntervalConfig aggregatedIntervalConfig : oldAggregatedIntervalConfigs) {
this.aggregationManagementDao.deleteAggregatedIntervalConfig(aggregatedIntervalConfig);
}
//Import Group configs
final Set<AggregatedGroupConfig> oldAggregatedGroupConfigs = new HashSet<AggregatedGroupConfig>(this.aggregationManagementDao.getAggregatedGroupConfigs());
for (final ExternalAggregatedGroupConfig extAggregatedGroupConfig : data.getAggregatedGroupConfigs()) {
final String aggregatorTypeName = extAggregatedGroupConfig.getAggregatorType();
final Class<? extends IPortalEventAggregator> aggregatorType = getAggregatorType(aggregatorTypeName);
AggregatedGroupConfig aggregatedGroupConfig = this.aggregationManagementDao.getAggregatedGroupConfig(aggregatorType);
if (aggregatedGroupConfig == null) {
aggregatedGroupConfig = this.aggregationManagementDao.createAggregatedGroupConfig(aggregatorType);
}
//Remove the config from the old configs set, marking it as updated
oldAggregatedGroupConfigs.remove(aggregatedGroupConfig);
//Copy over excludes
final Set<AggregatedGroupMapping> excluded = aggregatedGroupConfig.getExcluded();
excluded.clear();
for (final ExternalAggregatedGroupMapping extGroup : extAggregatedGroupConfig.getExcludes()) {
excluded.add(convert(extGroup));
}
//Copy over includes
final Set<AggregatedGroupMapping> included = aggregatedGroupConfig.getIncluded();
included.clear();
for (final ExternalAggregatedGroupMapping extGroup : extAggregatedGroupConfig.getIncludes()) {
included.add(convert(extGroup));
}
this.aggregationManagementDao.updateAggregatedGroupConfig(aggregatedGroupConfig);
}
//Delete interval configs that were not updated
for (final AggregatedGroupConfig aggregatedGroupConfig : oldAggregatedGroupConfigs) {
this.aggregationManagementDao.deleteAggregatedGroupConfig(aggregatedGroupConfig);
}
//Set quarter details if configured or set default quarters
final List<ExternalQuarterDetail> extQuarterDetails = data.getQuarterDetails();
final List<QuarterDetail> quarterDetails;
if (!extQuarterDetails.isEmpty()) {
quarterDetails = convertQuarterDetail(extQuarterDetails);
} else {
quarterDetails = EventDateTimeUtils.createStandardQuarters();
}
this.aggregationManagementDao.setQuarterDetails(quarterDetails);
//Set academic term if configured
final List<AcademicTermDetail> academicTerms = Lists.transform(data.getTermDetails(), new Function<ExternalTermDetail, AcademicTermDetail>() {
public AcademicTermDetail apply(ExternalTermDetail externalTermDetail) {
return new AcademicTermDetailImpl(new DateMidnight(externalTermDetail.getStart()), new DateMidnight(externalTermDetail.getEnd()), externalTermDetail.getName());
}
});
this.aggregationManagementDao.setAcademicTermDetails(academicTerms);
}
use of org.apereo.portal.events.aggr.AggregatedGroupConfig in project uPortal by Jasig.
the class EventAggregationConfigurationImporterExporter method exportData.
/*
* (non-Javadoc)
* @see org.apereo.portal.io.xml.IDataImporterExporter#exportData(java.lang.String)
*/
@Override
public ExternalEventAggregationConfiguration exportData(String id) {
final ExternalEventAggregationConfiguration externalData = new ExternalEventAggregationConfiguration();
//Copy interval configs
final List<ExternalAggregatedIntervalConfig> aggregatedIntervalConfigs = externalData.getAggregatedIntervalConfigs();
for (final AggregatedIntervalConfig aggregatedIntervalConfig : this.aggregationManagementDao.getAggregatedIntervalConfigs()) {
final ExternalAggregatedIntervalConfig externalIntervalConfig = new ExternalAggregatedIntervalConfig();
externalIntervalConfig.setAggregatorType(aggregatedIntervalConfig.getAggregatorType().getName());
final List<ExternalAggregationInterval> extIncludes = externalIntervalConfig.getIncludes();
for (final AggregationInterval interval : aggregatedIntervalConfig.getIncluded()) {
extIncludes.add(convert(interval));
}
Collections.sort(extIncludes, EnumNameComparator.INSTANCE);
final List<ExternalAggregationInterval> extExcludes = externalIntervalConfig.getExcludes();
for (final AggregationInterval interval : aggregatedIntervalConfig.getExcluded()) {
extExcludes.add(convert(interval));
}
Collections.sort(extExcludes, EnumNameComparator.INSTANCE);
aggregatedIntervalConfigs.add(externalIntervalConfig);
}
Collections.sort(aggregatedIntervalConfigs, ExternalAggregatedDimensionConfigComparator.INSTANCE);
//Copy group configs
final List<ExternalAggregatedGroupConfig> aggregatedGroupConfigs = externalData.getAggregatedGroupConfigs();
for (final AggregatedGroupConfig aggregatedGroupConfig : this.aggregationManagementDao.getAggregatedGroupConfigs()) {
final ExternalAggregatedGroupConfig externalGroupConfig = new ExternalAggregatedGroupConfig();
externalGroupConfig.setAggregatorType(aggregatedGroupConfig.getAggregatorType().getName());
final List<ExternalAggregatedGroupMapping> extIncludes = externalGroupConfig.getIncludes();
for (final AggregatedGroupMapping Group : aggregatedGroupConfig.getIncluded()) {
extIncludes.add(convert(Group));
}
Collections.sort(extIncludes, ExternalAggregatedGroupMappingComparator.INSTANCE);
final List<ExternalAggregatedGroupMapping> extExcludes = externalGroupConfig.getExcludes();
for (final AggregatedGroupMapping Group : aggregatedGroupConfig.getExcluded()) {
extExcludes.add(convert(Group));
}
Collections.sort(extExcludes, ExternalAggregatedGroupMappingComparator.INSTANCE);
aggregatedGroupConfigs.add(externalGroupConfig);
}
Collections.sort(aggregatedGroupConfigs, ExternalAggregatedDimensionConfigComparator.INSTANCE);
//Copy term details
final List<ExternalTermDetail> externalTermDetails = externalData.getTermDetails();
for (final AcademicTermDetail academicTermDetail : this.aggregationManagementDao.getAcademicTermDetails()) {
final ExternalTermDetail externalTermDetail = new ExternalTermDetail();
externalTermDetail.setName(academicTermDetail.getTermName());
externalTermDetail.setStart(academicTermDetail.getStart().toGregorianCalendar());
externalTermDetail.setEnd(academicTermDetail.getEnd().toGregorianCalendar());
externalTermDetails.add(externalTermDetail);
}
Collections.sort(externalTermDetails, ExternalTermDetailComparator.INSTANCE);
//Copy quarter details
final List<ExternalQuarterDetail> quarterDetails = externalData.getQuarterDetails();
for (final QuarterDetail quarterDetail : this.aggregationManagementDao.getQuartersDetails()) {
final ExternalQuarterDetail externalQuarterDetail = new ExternalQuarterDetail();
externalQuarterDetail.setId(quarterDetail.getQuarterId());
externalQuarterDetail.setStart(quarterDetail.getStart().toString());
externalQuarterDetail.setEnd(quarterDetail.getEnd().toString());
quarterDetails.add(externalQuarterDetail);
}
Collections.sort(quarterDetails, ExternalQuarterDetailComparator.INSTANCE);
return externalData;
}
use of org.apereo.portal.events.aggr.AggregatedGroupConfig in project uPortal by Jasig.
the class JpaEventAggregationManagementDaoTest method testAggregatedGroupConfig.
@Test
public void testAggregatedGroupConfig() throws Exception {
final IEntityGroup everyoneGroup = mock(IEntityGroup.class);
when(everyoneGroup.getServiceName()).thenReturn(new CompositeName("local"));
when(everyoneGroup.getName()).thenReturn("Everyone");
when(compositeGroupService.findGroup("local.0")).thenReturn(everyoneGroup);
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(0, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNull(loginAggregatedGroupConfig);
loginAggregatedGroupConfig = eventAggregationManagementDao.createAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNotNull(loginAggregatedGroupConfig);
assertEquals(0, loginAggregatedGroupConfig.getExcluded().size());
assertEquals(0, loginAggregatedGroupConfig.getIncluded().size());
final AggregatedGroupMapping group = aggregatedGroupLookupDao.getGroupMapping("local.0");
defaultAggregatedGroupConfig.getIncluded().add(group);
loginAggregatedGroupConfig.getExcluded().add(group);
eventAggregationManagementDao.updateAggregatedGroupConfig(defaultAggregatedGroupConfig);
eventAggregationManagementDao.updateAggregatedGroupConfig(loginAggregatedGroupConfig);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(1, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNotNull(loginAggregatedGroupConfig);
assertEquals(1, loginAggregatedGroupConfig.getExcluded().size());
assertEquals(0, loginAggregatedGroupConfig.getIncluded().size());
eventAggregationManagementDao.deleteAggregatedGroupConfig(defaultAggregatedGroupConfig);
eventAggregationManagementDao.deleteAggregatedGroupConfig(loginAggregatedGroupConfig);
}
});
this.execute(new CallableWithoutResult() {
@Override
protected void callWithoutResult() {
final AggregatedGroupConfig defaultAggregatedGroupConfig = eventAggregationManagementDao.getDefaultAggregatedGroupConfig();
assertNotNull(defaultAggregatedGroupConfig);
assertEquals(0, defaultAggregatedGroupConfig.getExcluded().size());
assertEquals(0, defaultAggregatedGroupConfig.getIncluded().size());
AggregatedGroupConfig loginAggregatedGroupConfig = eventAggregationManagementDao.getAggregatedGroupConfig(LoginPortalEventAggregator.class);
assertNull(loginAggregatedGroupConfig);
}
});
}
use of org.apereo.portal.events.aggr.AggregatedGroupConfig in project uPortal by Jasig.
the class JpaEventAggregationManagementDao method createAggregatedGroupConfig.
@Override
@AggrEventsTransactional
public AggregatedGroupConfig createAggregatedGroupConfig(Class<? extends IPortalEventAggregator> aggregatorType) {
final AggregatedGroupConfig aggregatedGroupConfig = new AggregatedGroupConfigImpl(aggregatorType);
this.getEntityManager().persist(aggregatedGroupConfig);
return aggregatedGroupConfig;
}
Aggregations