use of org.olat.group.model.BusinessGroupMembershipChange in project openolat by klemens.
the class UserImportController method processGroupAdditionForAllIdents.
private void processGroupAdditionForAllIdents(List<Identity> allIdents, List<Long> tutorGroups, List<Long> partGroups, boolean sendmail) {
Collection<Identity> identities = getIdentities(allIdents);
List<BusinessGroupMembershipChange> changes = new ArrayList<BusinessGroupMembershipChange>();
for (Identity identity : identities) {
if (tutorGroups != null && !tutorGroups.isEmpty()) {
for (Long tutorGroupKey : tutorGroups) {
BusinessGroupMembershipChange change = new BusinessGroupMembershipChange(identity, tutorGroupKey);
change.setTutor(Boolean.TRUE);
changes.add(change);
}
}
if (partGroups != null && !partGroups.isEmpty()) {
for (Long partGroupKey : partGroups) {
BusinessGroupMembershipChange change = new BusinessGroupMembershipChange(identity, partGroupKey);
change.setParticipant(Boolean.TRUE);
changes.add(change);
}
}
}
MailPackage mailing = new MailPackage(sendmail);
businessGroupService.updateMemberships(getIdentity(), changes, mailing);
DBFactory.getInstance().commit();
}
use of org.olat.group.model.BusinessGroupMembershipChange in project openolat by klemens.
the class MembersOverviewController method addMembers.
protected void addMembers(UserRequest ureq, StepsRunContext runContext) {
@SuppressWarnings("unchecked") List<Identity> members = (List<Identity>) runContext.get("members");
MemberPermissionChangeEvent changes = (MemberPermissionChangeEvent) runContext.get("permissions");
MailTemplate template = (MailTemplate) runContext.get("mailTemplate");
// commit changes to the repository entry
MailerResult result = new MailerResult();
MailPackage reMailing = new MailPackage(template, result, getWindowControl().getBusinessControl().getAsString(), template != null);
Roles roles = ureq.getUserSession().getRoles();
List<RepositoryEntryPermissionChangeEvent> repoChanges = changes.generateRepositoryChanges(members);
repositoryManager.updateRepositoryEntryMemberships(getIdentity(), roles, repoEntry, repoChanges, reMailing);
// commit all changes to the group memberships
List<BusinessGroupMembershipChange> allModifications = changes.generateBusinessGroupMembershipChange(members);
MailPackage mailing = new MailPackage(template, result, getWindowControl().getBusinessControl().getAsString(), template != null);
businessGroupService.updateMemberships(getIdentity(), allModifications, mailing);
MailHelper.printErrorsAndWarnings(result, getWindowControl(), roles.isOLATAdmin(), getLocale());
switchToAllMembers(ureq);
}
use of org.olat.group.model.BusinessGroupMembershipChange in project openolat by klemens.
the class BusinessGroupServiceImpl method updateMemberships.
@Override
public void updateMemberships(final Identity ureqIdentity, final List<BusinessGroupMembershipChange> changes, MailPackage mailing) {
Roles ureqRoles = securityManager.getRoles(ureqIdentity);
Map<Long, BusinessGroupMembershipsChanges> changesMap = new HashMap<Long, BusinessGroupMembershipsChanges>();
for (BusinessGroupMembershipChange change : changes) {
BusinessGroupMembershipsChanges changesWrapper;
if (changesMap.containsKey(change.getGroupKey())) {
changesWrapper = changesMap.get(change.getGroupKey());
} else {
changesWrapper = new BusinessGroupMembershipsChanges();
changesMap.put(change.getGroupKey(), changesWrapper);
}
Identity id = change.getMember();
if (change.getTutor() != null) {
if (change.getTutor().booleanValue()) {
changesWrapper.addTutors.add(id);
} else {
changesWrapper.removeTutors.add(id);
}
}
if (change.getParticipant() != null) {
if (change.getParticipant().booleanValue()) {
changesWrapper.addParticipants.add(id);
} else {
changesWrapper.removeParticipants.add(id);
}
}
if (change.getWaitingList() != null) {
if (change.getWaitingList().booleanValue()) {
changesWrapper.addToWaitingList.add(id);
} else {
changesWrapper.removeFromWaitingList.add(id);
}
}
}
List<BusinessGroupModifiedEvent.Deferred> events = new ArrayList<BusinessGroupModifiedEvent.Deferred>();
List<BusinessGroup> groups = loadBusinessGroups(changesMap.keySet());
for (BusinessGroup group : groups) {
BusinessGroupMembershipsChanges changesWrapper = changesMap.get(group.getKey());
group = businessGroupDAO.loadForUpdate(group);
for (Identity id : changesWrapper.addToWaitingList) {
addToWaitingList(ureqIdentity, id, group, mailing, events);
}
for (Identity id : changesWrapper.removeFromWaitingList) {
removeFromWaitingList(ureqIdentity, id, group, mailing, events);
}
for (Identity id : changesWrapper.addTutors) {
addOwner(ureqIdentity, ureqRoles, id, group, mailing, events);
}
for (Identity id : changesWrapper.removeTutors) {
removeOwner(ureqIdentity, id, group, events);
}
for (Identity id : changesWrapper.addParticipants) {
addParticipant(ureqIdentity, ureqRoles, id, group, mailing, events);
}
for (Identity id : changesWrapper.removeParticipants) {
removeParticipant(ureqIdentity, id, group, mailing, events);
}
// release lock
dbInstance.commit();
}
BusinessGroupModifiedEvent.fireDeferredEvents(events);
}
use of org.olat.group.model.BusinessGroupMembershipChange in project openolat by klemens.
the class AbstractMemberListController method doChangePermission.
protected void doChangePermission(UserRequest ureq, MemberPermissionChangeEvent changes, List<Identity> members, boolean sendMail) {
MailPackage mailing = new MailPackage(sendMail);
if (repoEntry != null) {
List<RepositoryEntryPermissionChangeEvent> repoChanges = changes.generateRepositoryChanges(members);
repositoryManager.updateRepositoryEntryMemberships(getIdentity(), ureq.getUserSession().getRoles(), repoEntry, repoChanges, mailing);
}
// commit all changes to the group memberships
List<BusinessGroupMembershipChange> allModifications = changes.generateBusinessGroupMembershipChange(members);
businessGroupService.updateMemberships(getIdentity(), allModifications, mailing);
reloadModel();
}
use of org.olat.group.model.BusinessGroupMembershipChange in project openolat by klemens.
the class EditMembershipController method collectGroupChanges.
public void collectGroupChanges(MemberPermissionChangeEvent e) {
List<BusinessGroupMembershipChange> changes = new ArrayList<BusinessGroupMembershipChange>();
for (MemberOption option : tableDataModel.getObjects()) {
BGPermission bgPermission = PermissionHelper.getPermission(option.getGroupKey(), member, groupMemberships);
BusinessGroupMembershipChange change = new BusinessGroupMembershipChange(member, option.getGroup());
boolean bgTutor = option.getTutor().isAtLeastSelected(1);
change.setTutor(bgPermission.isTutor() == bgTutor ? null : new Boolean(bgTutor));
boolean bgParticipant = option.getParticipant().isAtLeastSelected(1);
change.setParticipant(bgPermission.isParticipant() == bgParticipant ? null : new Boolean(bgParticipant));
boolean bgWaitingList = option.getWaiting().isEnabled() && option.getWaiting().isAtLeastSelected(1);
change.setWaitingList(bgPermission.isWaitingList() == bgWaitingList ? null : new Boolean(bgWaitingList));
if (change.getTutor() != null || change.getParticipant() != null || change.getWaitingList() != null) {
changes.add(change);
}
}
e.setGroupChanges(changes);
}
Aggregations