use of org.olat.group.ui.edit.BusinessGroupModifiedEvent in project OpenOLAT by OpenOLAT.
the class BusinessGroupMembershipProcessorTest method testUnlinkMemberOfBusinessGroup_with2Roles.
@Test
public void testUnlinkMemberOfBusinessGroup_with2Roles() {
// create a group with members
Identity member = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-4");
BusinessGroup businessGroup = businessGroupDao.createAndPersist(member, "mbr-proc-2", "mbr-proc-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(member, businessGroup, GroupRoles.participant.name());
// create a publisher
SubscriptionContext context = new SubscriptionContext(businessGroup, "");
PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
notificationManager.getOrCreatePublisher(context, publisherData);
notificationManager.subscribe(member, context, publisherData);
dbInstance.commitAndCloseSession();
// remove id1 as participant and check subscription
businessGroupRelationDao.removeRole(member, businessGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// manually trigger the event
businessGroupMembershipProcessor.event(new BusinessGroupModifiedEvent(BusinessGroupModifiedEvent.IDENTITY_REMOVED_EVENT, businessGroup, member));
dbInstance.commitAndCloseSession();
// check that subscription of member was not deleted because it's still coach
boolean subscribed = notificationManager.isSubscribed(member, context);
Assert.assertTrue(subscribed);
}
use of org.olat.group.ui.edit.BusinessGroupModifiedEvent in project openolat by klemens.
the class ENRunController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
String cmd = event.getCommand();
if (source == tableCtr) {
if (cmd.equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
int rowid = te.getRowId();
EnrollmentRow row = groupListModel.getObject(rowid);
Long choosenGroupKey = row.getKey();
if (actionid.equals(CMD_ENROLL_IN_GROUP)) {
BusinessGroup choosenGroup = businessGroupService.loadBusinessGroup(choosenGroupKey);
addLoggingResourceable(LoggingResourceable.wrap(choosenGroup));
if (log.isDebug()) {
log.debug("CMD_ENROLL_IN_GROUP ureq.getComponentID()=" + ureq.getComponentID() + " ureq.getComponentTimestamp()=" + ureq.getComponentTimestamp());
}
EnrollStatus enrollStatus = enrollmentManager.doEnroll(ureq.getIdentity(), ureq.getUserSession().getRoles(), choosenGroup, enNode, coursePropertyManager, getWindowControl(), getTranslator(), enrollableGroupKeys, enrollableAreaKeys, courseGroupManager);
if (enrollStatus.isEnrolled() || enrollStatus.isInWaitingList()) {
// OK
} else {
getWindowControl().setError(enrollStatus.getErrorMessage());
}
// events are already fired BusinessGroupManager level :: BusinessGroupModifiedEvent.fireModifiedGroupEvents(BusinessGroupModifiedEvent.IDENTITY_ADDED_EVENT, choosenGroup, ureq.getIdentity());
// but async
// fire event to indicate runmaincontroller that the menuview is to update
doEnrollView(updateModel());
if (enrollStatus.isEnrolled()) {
fireEvent(ureq, new BusinessGroupModifiedEvent(BusinessGroupModifiedEvent.IDENTITY_ADDED_EVENT, choosenGroup, getIdentity()));
} else {
fireEvent(ureq, Event.DONE_EVENT);
}
} else if (actionid.equals(CMD_ENROLLED_CANCEL)) {
BusinessGroup choosenGroup = businessGroupService.loadBusinessGroup(choosenGroupKey);
addLoggingResourceable(LoggingResourceable.wrap(choosenGroup));
List<String> roles = businessGroupService.getIdentityRolesInBusinessGroup(getIdentity(), choosenGroup);
if (roles.contains(GroupRoles.waiting.name())) {
enrollmentManager.doCancelEnrollmentInWaitingList(ureq.getIdentity(), choosenGroup, enNode, coursePropertyManager, getWindowControl(), getTranslator());
} else if (roles.contains(GroupRoles.participant.name())) {
enrollmentManager.doCancelEnrollment(ureq.getIdentity(), choosenGroup, enNode, coursePropertyManager, getWindowControl(), getTranslator());
}
// fire event to indicate runmaincontroller that the menuview is to update
fireEvent(ureq, new BusinessGroupModifiedEvent(BusinessGroupModifiedEvent.IDENTITY_REMOVED_EVENT, choosenGroup, getIdentity()));
// events are already fired BusinessGroupManager level :: BusinessGroupModifiedEvent.fireModifiedGroupEvents(BusinessGroupModifiedEvent.IDENTITY_REMOVED_EVENT, group, ureq.getIdentity());
// but async
doEnrollView(updateModel());
} else if (CMD_VISIT_CARD.equals(actionid)) {
List<String> roles = businessGroupService.getIdentityRolesInBusinessGroup(getIdentity(), row);
String businessPath;
if (roles.contains(GroupRoles.coach.name()) || roles.contains(GroupRoles.participant.name())) {
businessPath = "[BusinessGroup:" + choosenGroupKey + "]";
} else {
businessPath = "[GroupCard:" + choosenGroupKey + "]";
}
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
}
}
}
}
use of org.olat.group.ui.edit.BusinessGroupModifiedEvent in project openolat by klemens.
the class BusinessGroupMembershipProcessorTest method testUnlinkMemberOfBusinessGroup_with2Roles.
@Test
public void testUnlinkMemberOfBusinessGroup_with2Roles() {
// create a group with members
Identity member = JunitTestHelper.createAndPersistIdentityAsRndUser("mbr-proc-4");
BusinessGroup businessGroup = businessGroupDao.createAndPersist(member, "mbr-proc-2", "mbr-proc-desc", -1, -1, false, false, false, false, false);
businessGroupRelationDao.addRole(member, businessGroup, GroupRoles.participant.name());
// create a publisher
SubscriptionContext context = new SubscriptionContext(businessGroup, "");
PublisherData publisherData = new PublisherData("testGroupPublishers", "e.g. something", null);
notificationManager.getOrCreatePublisher(context, publisherData);
notificationManager.subscribe(member, context, publisherData);
dbInstance.commitAndCloseSession();
// remove id1 as participant and check subscription
businessGroupRelationDao.removeRole(member, businessGroup, GroupRoles.participant.name());
dbInstance.commitAndCloseSession();
// manually trigger the event
businessGroupMembershipProcessor.event(new BusinessGroupModifiedEvent(BusinessGroupModifiedEvent.IDENTITY_REMOVED_EVENT, businessGroup, member));
dbInstance.commitAndCloseSession();
// check that subscription of member was not deleted because it's still coach
boolean subscribed = notificationManager.isSubscribed(member, context);
Assert.assertTrue(subscribed);
}
use of org.olat.group.ui.edit.BusinessGroupModifiedEvent in project openolat by klemens.
the class RunMainController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (needsRebuildAfter) {
currentCourseNode = updateAfterChanges(currentCourseNode);
needsRebuildAfter = false;
}
if (source == currentNodeController) {
if (event instanceof OlatCmdEvent) {
OlatCmdEvent oe = (OlatCmdEvent) event;
String cmd = oe.getCommand();
if (OlatCmdEvent.GOTONODE_CMD.equals(cmd)) {
// "69680861018558/node-specific-data";
String subcmd = oe.getSubcommand();
CourseNode identNode;
String nodecmd = null;
int slPos = subcmd.indexOf('/');
if (slPos != -1) {
nodecmd = subcmd.substring(slPos + 1);
identNode = course.getRunStructure().getNode(subcmd.substring(0, slPos));
} else {
identNode = course.getRunStructure().getNode(subcmd);
}
if (identNode == null) {
showWarning("msg.nodenotavailableanymore");
} else {
addLoggingResourceable(LoggingResourceable.wrap(identNode));
currentCourseNode = identNode;
updateTreeAndContent(ureq, identNode, nodecmd);
oe.accept();
}
}
} else if (event == Event.DONE_EVENT) {
// preconditions may have changed
if (needsRebuildAfterRunDone) {
needsRebuildAfterRunDone = false;
updateTreeAndContent(ureq, currentCourseNode, null);
}
} else if (REBUILD.equals(event.getCommand())) {
needsRebuildAfterRunDone = false;
updateTreeAndContent(ureq, currentCourseNode, null);
} else if (event instanceof TreeNodeEvent) {
TreeNodeEvent tne = (TreeNodeEvent) event;
TreeNode newCpTreeNode = tne.getChosenTreeNode();
luTree.setSelectedNodeId(newCpTreeNode.getIdent());
} else if (event == Event.CHANGED_EVENT) {
updateTreeAndContent(ureq, currentCourseNode, null);
} else if (event instanceof BusinessGroupModifiedEvent) {
fireEvent(ureq, event);
updateTreeAndContent(ureq, currentCourseNode, null);
}
}
}
use of org.olat.group.ui.edit.BusinessGroupModifiedEvent in project OpenOLAT by OpenOLAT.
the class ProjectGroupManagerImpl method sendGroupChangeEvent.
@Override
public void sendGroupChangeEvent(Project project, Long courseResourceableId, Identity identity) {
ICourse course = CourseFactory.loadCourse(courseResourceableId);
RepositoryEntry ores = course.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
MultiUserEvent modifiedEvent = new BusinessGroupModifiedEvent(BusinessGroupModifiedEvent.IDENTITY_ADDED_EVENT, project.getProjectGroup(), identity);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(modifiedEvent, ores);
}
Aggregations