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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations