use of org.olat.core.util.event.EventBus in project OpenOLAT by OpenOLAT.
the class CertificatesOptionsController method doChangeConfig.
private void doChangeConfig(UserRequest ureq) {
OLATResourceable courseOres = entry.getOlatResource();
if (CourseFactory.isCourseEditSessionOpen(courseOres.getResourceableId())) {
showWarning("error.editoralreadylocked", new String[] { "???" });
return;
}
ICourse course = CourseFactory.openCourseEditSession(courseOres.getResourceableId());
courseConfig = course.getCourseEnvironment().getCourseConfig();
boolean enableEfficiencyStatment = efficencyEl.isSelected(0);
boolean updateStatement = courseConfig.isEfficencyStatementEnabled() != enableEfficiencyStatment;
courseConfig.setEfficencyStatementIsEnabled(enableEfficiencyStatment);
Collection<String> certificationOptions = pdfCertificatesEl.getSelectedKeys();
courseConfig.setAutomaticCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.auto.name()));
courseConfig.setManualCertificationEnabled(certificationOptions.contains(PDFCertificatesOptions.manual.name()));
if (selectedTemplate != null) {
Long templateId = selectedTemplate.getKey();
courseConfig.setCertificateTemplate(templateId);
} else {
courseConfig.setCertificateTemplate(null);
}
boolean recertificationEnabled = reCertificationEl.isEnabled() && reCertificationEl.isAtLeastSelected(1);
courseConfig.setRecertificationEnabled(recertificationEnabled);
if (recertificationEnabled) {
int timelapse = reCertificationTimelapseEl.getIntValue();
courseConfig.setRecertificationTimelapse(timelapse);
if (reCertificationTimelapseUnitEl.isOneSelected()) {
String selectedUnit = reCertificationTimelapseUnitEl.getSelectedKey();
RecertificationTimeUnit timeUnit = RecertificationTimeUnit.valueOf(selectedUnit);
courseConfig.setRecertificationTimelapseUnit(timeUnit);
} else {
courseConfig.setRecertificationTimelapseUnit(RecertificationTimeUnit.month);
}
} else {
courseConfig.setRecertificationTimelapse(0);
courseConfig.setRecertificationTimelapseUnit(null);
}
CourseFactory.setCourseConfig(course.getResourceableId(), courseConfig);
CourseFactory.closeCourseEditSession(course.getResourceableId(), true);
if (updateStatement) {
if (enableEfficiencyStatment) {
// first create the efficiencies, send event to agency (all courses add link)
RepositoryEntry courseRe = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
List<Identity> identitiesWithData = course.getCourseEnvironment().getCoursePropertyManager().getAllIdentitiesWithCourseAssessmentData(null);
efficiencyStatementManager.updateEfficiencyStatements(courseRe, identitiesWithData);
} else {
// delete really the efficiencies of the users.
RepositoryEntry courseRepoEntry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
efficiencyStatementManager.deleteEfficiencyStatementsFromCourse(courseRepoEntry.getKey());
}
// inform everybody else
EventBus eventBus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
CourseConfigEvent courseConfigEvent = new CourseConfigEvent(CourseConfigType.efficiencyStatement, course.getResourceableId());
eventBus.fireEventToListenersOf(courseConfigEvent, course);
ILoggingAction loggingAction = enableEfficiencyStatment ? LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_ENABLED : LearningResourceLoggingAction.REPOSITORY_ENTRY_PROPERTIES_EFFICIENCY_STATEMENT_DISABLED;
ThreadLocalUserActivityLogger.log(loggingAction, getClass());
}
fireEvent(ureq, Event.CHANGED_EVENT);
}
use of org.olat.core.util.event.EventBus in project OpenOLAT by OpenOLAT.
the class BusinessGroupModifiedEvent method fireModifiedGroupEvents.
/**
* Fires event to all listeners of this business group and the listeners of
* the ressources associated with the group context of this group
*
* @param command The event identifyer, one of CONFIGURATION_MODIFIED_EVENT,
* IDENTITY_ADDED_EVENT or IDENTITY_REMOVED_EVENT
* @param group The group affected by the modification
* @param identity The identity affected by the modification
*/
public static void fireModifiedGroupEvents(String command, BusinessGroup group, Identity identity) {
BusinessGroupModifiedEvent modifiedEvent = new BusinessGroupModifiedEvent(command, group, identity);
EventBus eventBus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
// 1) notify listeners of group events
eventBus.fireEventToListenersOf(modifiedEvent, group);
eventBus.fireEventToListenersOf(modifiedEvent, OresHelper.lookupType(BusinessGroup.class));
// 2) notify listeners of learning resources of this group
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
List<RepositoryEntry> repoEntries = bgs.findRepositoryEntries(Collections.singletonList(group), 0, -1);
for (RepositoryEntry entry : repoEntries) {
eventBus.fireEventToListenersOf(modifiedEvent, entry);
}
}
use of org.olat.core.util.event.EventBus in project OpenOLAT by OpenOLAT.
the class JMSTest method testSendReceive.
@Test
public void testSendReceive() {
// enable test only if we have the cluster configuration enabled.
// this test requires that an JMS Provider is running
// (see file serviceconfig/org/olat/core/_spring/coreextconfig.xml)
EventBus bus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
if (bus instanceof ClusterEventBus) {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("jms");
// send and wait some time until a message should arrive at the latest.
final OLATResourceable ores = OresHelper.createOLATResourceableInstance("hellojms", new Long(123));
final CountDownLatch doneSignal = new CountDownLatch(1);
bus.registerFor(new GenericEventListener() {
@Override
public void event(Event event) {
log.audit("Event received: " + event);
doneSignal.countDown();
}
}, id, ores);
MultiUserEvent mue = new MultiUserEvent("amuecommand");
bus.fireEventToListenersOf(mue, ores);
try {
boolean interrupt = doneSignal.await(5, TimeUnit.SECONDS);
assertTrue("Test takes too long (more than 5s)", interrupt);
} catch (InterruptedException e) {
fail("" + e.getMessage());
}
}
}
use of org.olat.core.util.event.EventBus in project openolat by klemens.
the class RepositoryManager method sendDeferredEvents.
private void sendDeferredEvents(List<? extends MultiUserEvent> events, OLATResourceable ores) {
EventBus eventBus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
for (MultiUserEvent event : events) {
eventBus.fireEventToListenersOf(event, ores);
eventBus.fireEventToListenersOf(event, OresHelper.lookupType(RepositoryEntry.class));
}
}
use of org.olat.core.util.event.EventBus in project openolat by klemens.
the class BusinessGroupModifiedEvent method fireModifiedGroupEvents.
/**
* Fires event to all listeners of this business group and the listeners of
* the ressources associated with the group context of this group
*
* @param command The event identifyer, one of CONFIGURATION_MODIFIED_EVENT,
* IDENTITY_ADDED_EVENT or IDENTITY_REMOVED_EVENT
* @param group The group affected by the modification
* @param identity The identity affected by the modification
*/
public static void fireModifiedGroupEvents(String command, BusinessGroup group, Identity identity) {
BusinessGroupModifiedEvent modifiedEvent = new BusinessGroupModifiedEvent(command, group, identity);
EventBus eventBus = CoordinatorManager.getInstance().getCoordinator().getEventBus();
// 1) notify listeners of group events
eventBus.fireEventToListenersOf(modifiedEvent, group);
eventBus.fireEventToListenersOf(modifiedEvent, OresHelper.lookupType(BusinessGroup.class));
// 2) notify listeners of learning resources of this group
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
List<RepositoryEntry> repoEntries = bgs.findRepositoryEntries(Collections.singletonList(group), 0, -1);
for (RepositoryEntry entry : repoEntries) {
eventBus.fireEventToListenersOf(modifiedEvent, entry);
}
}
Aggregations