Search in sources :

Example 1 with MembershipModification

use of org.olat.group.model.MembershipModification in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == deleteDialogBox) {
        if (event == Event.DONE_EVENT) {
            boolean withEmail = deleteDialogBox.isSendMail();
            List<BusinessGroup> groupsToDelete = deleteDialogBox.getGroupsToDelete();
            doDelete(ureq, withEmail, groupsToDelete);
            tableEl.deselectAll();
            reloadModel();
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == leaveDialogBox) {
        if (event != Event.CANCELLED_EVENT && DialogBoxUIFactory.isYesEvent(event)) {
            doLeave((BusinessGroup) leaveDialogBox.getUserObject());
            tableEl.deselectAll();
            reloadModel();
        }
    } else if (source == groupCreateController) {
        BusinessGroup group = null;
        if (event == Event.DONE_EVENT) {
            Set<BusinessGroup> groups = groupCreateController.getCreatedGroups();
            if (groups.size() == 1) {
                group = groups.iterator().next();
            }
            if (groups.size() > 0) {
                tableEl.deselectAll();
                reloadModel();
            }
        }
        cmc.deactivate();
        cleanUpPopups();
        // if new group -> go to the tab
        if (group != null) {
            String businessPath = "[BusinessGroup:" + group.getKey() + "]";
            NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
        }
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (source == businessGroupWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(businessGroupWizard);
            businessGroupWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                reloadModel();
            }
        }
    } else if (source == emailWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(emailWizard);
            emailWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                tableEl.deselectAll();
            }
        }
    } else if (source == userManagementController) {
        cmc.deactivate();
        if (event == Event.DONE_EVENT) {
            // confirm sending emails
            MembershipModification mod = userManagementController.getModifications();
            List<BusinessGroup> groups = userManagementController.getGroups();
            confirmUserManagementEmail(ureq, mod, groups);
        } else {
            cleanUpPopups();
        }
    } else if (source == userManagementSendMailController) {
        if (event == Event.DONE_EVENT) {
            BGUserMailTemplate sendMail = (BGUserMailTemplate) userManagementSendMailController.getTemplate();
            MembershipModification mod = sendMail.getModifications();
            List<BusinessGroup> groups = sendMail.getGroups();
            finishUserManagement(mod, groups, sendMail, userManagementSendMailController.isSendMail());
            reloadModel();
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == searchCtrl) {
        if (event instanceof SearchEvent) {
            doSearch(ureq, (SearchEvent) event);
        }
    } else if (source == contactCtrl) {
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == cmc) {
        cleanUpPopups();
    }
    super.event(ureq, source, event);
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) MembershipModification(org.olat.group.model.MembershipModification) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) BGUserMailTemplate(org.olat.group.ui.wizard.BGUserMailTemplate) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)

Example 2 with MembershipModification

use of org.olat.group.model.MembershipModification in project openolat by klemens.

the class BusinessGroupServiceTest method testUpdateMembership.

@Test
public void testUpdateMembership() {
    // create a group with owner and participant
    Identity ureqIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("Up-mship-u-");
    Identity ownerIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("Up-mship-o-");
    Identity partIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("Up-mship-p-");
    BusinessGroup group = businessGroupService.createBusinessGroup(ureqIdentity, "Up-mship", "updateMembership", 0, 10, false, false, null);
    businessGroupRelationDao.addRole(ownerIdentity, group, GroupRoles.coach.name());
    businessGroupRelationDao.addRole(partIdentity, group, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // update memberships
    MailPackage mailing = new MailPackage(false);
    List<BusinessGroup> groups = Collections.singletonList(group);
    MembershipModification membersMod = new MembershipModification();
    membersMod.getAddOwners().add(partIdentity);
    membersMod.getAddParticipants().add(ownerIdentity);
    businessGroupService.updateMembership(ureqIdentity, membersMod, groups, mailing);
    dbInstance.commitAndCloseSession();
    // check if the participant is owner too and the owner is participant too
    boolean partIsOwner = businessGroupService.hasRoles(partIdentity, group, GroupRoles.coach.name());
    Assert.assertTrue(partIsOwner);
    boolean partIsPart = businessGroupService.hasRoles(partIdentity, group, GroupRoles.participant.name());
    Assert.assertTrue(partIsPart);
    boolean ownerIsOwner = businessGroupService.hasRoles(ownerIdentity, group, GroupRoles.coach.name());
    Assert.assertTrue(ownerIsOwner);
    boolean ownerIsPart = businessGroupService.hasRoles(ownerIdentity, group, GroupRoles.participant.name());
    Assert.assertTrue(ownerIsPart);
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) BusinessGroup(org.olat.group.BusinessGroup) MembershipModification(org.olat.group.model.MembershipModification) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 3 with MembershipModification

use of org.olat.group.model.MembershipModification in project openolat by klemens.

the class AbstractBusinessGroupListController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == deleteDialogBox) {
        if (event == Event.DONE_EVENT) {
            boolean withEmail = deleteDialogBox.isSendMail();
            List<BusinessGroup> groupsToDelete = deleteDialogBox.getGroupsToDelete();
            doDelete(ureq, withEmail, groupsToDelete);
            tableEl.deselectAll();
            reloadModel();
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == leaveDialogBox) {
        if (event != Event.CANCELLED_EVENT && DialogBoxUIFactory.isYesEvent(event)) {
            doLeave((BusinessGroup) leaveDialogBox.getUserObject());
            tableEl.deselectAll();
            reloadModel();
        }
    } else if (source == groupCreateController) {
        BusinessGroup group = null;
        if (event == Event.DONE_EVENT) {
            Set<BusinessGroup> groups = groupCreateController.getCreatedGroups();
            if (groups.size() == 1) {
                group = groups.iterator().next();
            }
            if (groups.size() > 0) {
                tableEl.deselectAll();
                reloadModel();
            }
        }
        cmc.deactivate();
        cleanUpPopups();
        // if new group -> go to the tab
        if (group != null) {
            String businessPath = "[BusinessGroup:" + group.getKey() + "]";
            NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
        }
        fireEvent(ureq, Event.CHANGED_EVENT);
    } else if (source == businessGroupWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(businessGroupWizard);
            businessGroupWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                reloadModel();
            }
        }
    } else if (source == emailWizard) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            getWindowControl().pop();
            removeAsListenerAndDispose(emailWizard);
            emailWizard = null;
            if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
                tableEl.deselectAll();
            }
        }
    } else if (source == userManagementController) {
        cmc.deactivate();
        if (event == Event.DONE_EVENT) {
            // confirm sending emails
            MembershipModification mod = userManagementController.getModifications();
            List<BusinessGroup> groups = userManagementController.getGroups();
            confirmUserManagementEmail(ureq, mod, groups);
        } else {
            cleanUpPopups();
        }
    } else if (source == userManagementSendMailController) {
        if (event == Event.DONE_EVENT) {
            BGUserMailTemplate sendMail = (BGUserMailTemplate) userManagementSendMailController.getTemplate();
            MembershipModification mod = sendMail.getModifications();
            List<BusinessGroup> groups = sendMail.getGroups();
            finishUserManagement(mod, groups, sendMail, userManagementSendMailController.isSendMail());
            reloadModel();
        }
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == searchCtrl) {
        if (event instanceof SearchEvent) {
            doSearch(ureq, (SearchEvent) event);
        }
    } else if (source == contactCtrl) {
        cmc.deactivate();
        cleanUpPopups();
    } else if (source == cmc) {
        cleanUpPopups();
    }
    super.event(ureq, source, event);
}
Also used : BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) MembershipModification(org.olat.group.model.MembershipModification) ContactList(org.olat.core.util.mail.ContactList) List(java.util.List) ArrayList(java.util.ArrayList) BGUserMailTemplate(org.olat.group.ui.wizard.BGUserMailTemplate) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)

Example 4 with MembershipModification

use of org.olat.group.model.MembershipModification in project openolat by klemens.

the class BGUserManagementController method getModifications.

public MembershipModification getModifications() {
    MembershipModification mod = new MembershipModification();
    mod.setAddOwners(userTableModel.getAddOwnerIdentities());
    mod.setAddParticipants(userTableModel.getAddParticipantIdentities());
    mod.setAddToWaitingList(userTableModel.getAddToWaitingList());
    mod.setRemovedIdentities(userTableModel.getRemovedIdentities());
    return mod;
}
Also used : MembershipModification(org.olat.group.model.MembershipModification)

Example 5 with MembershipModification

use of org.olat.group.model.MembershipModification in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceTest method testUpdateMembership.

@Test
public void testUpdateMembership() {
    // create a group with owner and participant
    Identity ureqIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("Up-mship-u-");
    Identity ownerIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("Up-mship-o-");
    Identity partIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("Up-mship-p-");
    BusinessGroup group = businessGroupService.createBusinessGroup(ureqIdentity, "Up-mship", "updateMembership", 0, 10, false, false, null);
    businessGroupRelationDao.addRole(ownerIdentity, group, GroupRoles.coach.name());
    businessGroupRelationDao.addRole(partIdentity, group, GroupRoles.participant.name());
    dbInstance.commitAndCloseSession();
    // update memberships
    MailPackage mailing = new MailPackage(false);
    List<BusinessGroup> groups = Collections.singletonList(group);
    MembershipModification membersMod = new MembershipModification();
    membersMod.getAddOwners().add(partIdentity);
    membersMod.getAddParticipants().add(ownerIdentity);
    businessGroupService.updateMembership(ureqIdentity, membersMod, groups, mailing);
    dbInstance.commitAndCloseSession();
    // check if the participant is owner too and the owner is participant too
    boolean partIsOwner = businessGroupService.hasRoles(partIdentity, group, GroupRoles.coach.name());
    Assert.assertTrue(partIsOwner);
    boolean partIsPart = businessGroupService.hasRoles(partIdentity, group, GroupRoles.participant.name());
    Assert.assertTrue(partIsPart);
    boolean ownerIsOwner = businessGroupService.hasRoles(ownerIdentity, group, GroupRoles.coach.name());
    Assert.assertTrue(ownerIsOwner);
    boolean ownerIsPart = businessGroupService.hasRoles(ownerIdentity, group, GroupRoles.participant.name());
    Assert.assertTrue(ownerIsPart);
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) BusinessGroup(org.olat.group.BusinessGroup) MembershipModification(org.olat.group.model.MembershipModification) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

MembershipModification (org.olat.group.model.MembershipModification)6 BusinessGroup (org.olat.group.BusinessGroup)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Test (org.junit.Test)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2 Identity (org.olat.core.id.Identity)2 ContactList (org.olat.core.util.mail.ContactList)2 MailPackage (org.olat.core.util.mail.MailPackage)2 BGConfigBusinessGroup (org.olat.group.ui.wizard.BGConfigBusinessGroup)2 BGCopyBusinessGroup (org.olat.group.ui.wizard.BGCopyBusinessGroup)2 BGUserMailTemplate (org.olat.group.ui.wizard.BGUserMailTemplate)2