Search in sources :

Example 1 with SecurityGroupMembershipImpl

use of org.olat.basesecurity.SecurityGroupMembershipImpl in project OpenOLAT by OpenOLAT.

the class OLATUpgrade_10_0_0 method processSecurityGroup.

private void processSecurityGroup(Group group, String role, SecurityGroup secGroup) {
    if (secGroup == null)
        return;
    List<SecurityGroupMembershipImpl> oldMemberships = getMembershipsOfSecurityGroup(secGroup);
    for (SecurityGroupMembershipImpl oldMembership : oldMemberships) {
        GroupMembershipImpl membership = new GroupMembershipImpl();
        membership.setCreationDate(oldMembership.getCreationDate());
        membership.setLastModified(oldMembership.getLastModified());
        membership.setGroup(group);
        membership.setIdentity(oldMembership.getIdentity());
        membership.setRole(role);
        dbInstance.getCurrentEntityManager().persist(membership);
        Set<GroupMembership> members = ((GroupImpl) group).getMembers();
        if (members == null) {
            members = new HashSet<>();
            ((GroupImpl) group).setMembers(members);
        }
        members.add(membership);
    }
}
Also used : SecurityGroupMembershipImpl(org.olat.basesecurity.SecurityGroupMembershipImpl) GroupImpl(org.olat.basesecurity.model.GroupImpl) GroupMembership(org.olat.basesecurity.GroupMembership) GroupMembershipImpl(org.olat.basesecurity.model.GroupMembershipImpl) SecurityGroupMembershipImpl(org.olat.basesecurity.SecurityGroupMembershipImpl)

Example 2 with SecurityGroupMembershipImpl

use of org.olat.basesecurity.SecurityGroupMembershipImpl in project openolat by klemens.

the class OLATUpgrade_10_0_0 method processSecurityGroup.

private void processSecurityGroup(Group group, String role, SecurityGroup secGroup) {
    if (secGroup == null)
        return;
    List<SecurityGroupMembershipImpl> oldMemberships = getMembershipsOfSecurityGroup(secGroup);
    for (SecurityGroupMembershipImpl oldMembership : oldMemberships) {
        GroupMembershipImpl membership = new GroupMembershipImpl();
        membership.setCreationDate(oldMembership.getCreationDate());
        membership.setLastModified(oldMembership.getLastModified());
        membership.setGroup(group);
        membership.setIdentity(oldMembership.getIdentity());
        membership.setRole(role);
        dbInstance.getCurrentEntityManager().persist(membership);
        Set<GroupMembership> members = ((GroupImpl) group).getMembers();
        if (members == null) {
            members = new HashSet<>();
            ((GroupImpl) group).setMembers(members);
        }
        members.add(membership);
    }
}
Also used : SecurityGroupMembershipImpl(org.olat.basesecurity.SecurityGroupMembershipImpl) GroupImpl(org.olat.basesecurity.model.GroupImpl) GroupMembership(org.olat.basesecurity.GroupMembership) GroupMembershipImpl(org.olat.basesecurity.model.GroupMembershipImpl) SecurityGroupMembershipImpl(org.olat.basesecurity.SecurityGroupMembershipImpl)

Aggregations

GroupMembership (org.olat.basesecurity.GroupMembership)2 SecurityGroupMembershipImpl (org.olat.basesecurity.SecurityGroupMembershipImpl)2 GroupImpl (org.olat.basesecurity.model.GroupImpl)2 GroupMembershipImpl (org.olat.basesecurity.model.GroupMembershipImpl)2