Search in sources :

Example 6 with BusinessGroupModifiedEvent

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) PublisherData(org.olat.core.commons.services.notifications.PublisherData) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent) Test(org.junit.Test)

Example 7 with BusinessGroupModifiedEvent

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());
            }
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) List(java.util.List) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 8 with BusinessGroupModifiedEvent

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) Identity(org.olat.core.id.Identity) PublisherData(org.olat.core.commons.services.notifications.PublisherData) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent) Test(org.junit.Test)

Example 9 with BusinessGroupModifiedEvent

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);
        }
    }
}
Also used : OlatCmdEvent(org.olat.core.gui.components.htmlsite.OlatCmdEvent) TreeNode(org.olat.core.gui.components.tree.TreeNode) CourseNode(org.olat.course.nodes.CourseNode) TreeNodeEvent(org.olat.modules.cp.TreeNodeEvent) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 10 with BusinessGroupModifiedEvent

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);
}
Also used : ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) MultiUserEvent(org.olat.core.util.event.MultiUserEvent) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Aggregations

BusinessGroupModifiedEvent (org.olat.group.ui.edit.BusinessGroupModifiedEvent)14 BusinessGroup (org.olat.group.BusinessGroup)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 PublisherData (org.olat.core.commons.services.notifications.PublisherData)2 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)2 OlatCmdEvent (org.olat.core.gui.components.htmlsite.OlatCmdEvent)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)2 TreeModel (org.olat.core.gui.components.tree.TreeModel)2 TreeNode (org.olat.core.gui.components.tree.TreeNode)2 Identity (org.olat.core.id.Identity)2 AssertException (org.olat.core.logging.AssertException)2 MultiUserEvent (org.olat.core.util.event.MultiUserEvent)2 OLATResourceableJustBeforeDeletedEvent (org.olat.core.util.resource.OLATResourceableJustBeforeDeletedEvent)2 ICourse (org.olat.course.ICourse)2 CourseNode (org.olat.course.nodes.CourseNode)2 AssessmentEvent (org.olat.course.nodes.iq.AssessmentEvent)2 TreeNodeEvent (org.olat.modules.cp.TreeNodeEvent)2