Search in sources :

Example 21 with BusinessGroupMembershipChange

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

the class BusinessGroupMembersController method addMembers.

private void addMembers(StepsRunContext runContext) {
    @SuppressWarnings("unchecked") List<Identity> members = (List<Identity>) runContext.get("members");
    MemberPermissionChangeEvent changes = (MemberPermissionChangeEvent) runContext.get("permissions");
    // commit all changes to the group memberships
    List<BusinessGroupMembershipChange> allModifications = changes.generateBusinessGroupMembershipChange(members);
    MailTemplate template = (MailTemplate) runContext.get("mailTemplate");
    MailPackage mailing = new MailPackage(template, getWindowControl().getBusinessControl().getAsString(), template != null);
    businessGroupService.updateMemberships(getIdentity(), allModifications, mailing);
    MailHelper.printErrorsAndWarnings(mailing.getResult(), getWindowControl(), false, getLocale());
}
Also used : BusinessGroupMembershipChange(org.olat.group.model.BusinessGroupMembershipChange) MailPackage(org.olat.core.util.mail.MailPackage) MemberPermissionChangeEvent(org.olat.group.ui.main.MemberPermissionChangeEvent) MailTemplate(org.olat.core.util.mail.MailTemplate) List(java.util.List) Identity(org.olat.core.id.Identity)

Example 22 with BusinessGroupMembershipChange

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

the class MemberPermissionChangeEvent method generateBusinessGroupMembershipChange.

public List<BusinessGroupMembershipChange> generateBusinessGroupMembershipChange(List<Identity> members) {
    if (members == null || members.isEmpty()) {
        return Collections.emptyList();
    }
    List<BusinessGroupMembershipChange> grChanges = getGroupChanges();
    if (grChanges == null || grChanges.isEmpty()) {
        return Collections.emptyList();
    }
    List<BusinessGroupMembershipChange> allModifications = new ArrayList<BusinessGroupMembershipChange>();
    for (BusinessGroupMembershipChange grChange : grChanges) {
        for (Identity member : members) {
            allModifications.add(new BusinessGroupMembershipChange(member, grChange));
        }
    }
    return allModifications;
}
Also used : BusinessGroupMembershipChange(org.olat.group.model.BusinessGroupMembershipChange) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Aggregations

BusinessGroupMembershipChange (org.olat.group.model.BusinessGroupMembershipChange)22 Identity (org.olat.core.id.Identity)16 MailPackage (org.olat.core.util.mail.MailPackage)16 ArrayList (java.util.ArrayList)14 List (java.util.List)6 MailTemplate (org.olat.core.util.mail.MailTemplate)6 MemberPermissionChangeEvent (org.olat.group.ui.main.MemberPermissionChangeEvent)6 RepositoryEntryPermissionChangeEvent (org.olat.repository.model.RepositoryEntryPermissionChangeEvent)6 Roles (org.olat.core.id.Roles)4 MailerResult (org.olat.core.util.mail.MailerResult)4 BusinessGroup (org.olat.group.BusinessGroup)4 HashMap (java.util.HashMap)2 Locale (java.util.Locale)2 VelocityContext (org.apache.velocity.VelocityContext)2 Context (org.apache.velocity.context.Context)2 Test (org.junit.Test)2 GroupRoles (org.olat.basesecurity.GroupRoles)2 SecurityGroup (org.olat.basesecurity.SecurityGroup)2 ValidationError (org.olat.core.gui.components.form.ValidationError)2 Translator (org.olat.core.gui.translator.Translator)2