Search in sources :

Example 1 with GroupMembershipImpl

use of org.olat.basesecurity.model.GroupMembershipImpl in project OpenOLAT by OpenOLAT.

the class GTAReminderRuleTest method addEnrollmentDate.

private void addEnrollmentDate(RepositoryEntry entry, Identity id, GroupRoles role, int amount, int field) {
    RepositoryEntryToGroupRelation rel = entry.getGroups().iterator().next();
    rel.getGroup();
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(field, amount);
    GroupMembershipImpl membership = new GroupMembershipImpl();
    membership.setCreationDate(cal.getTime());
    membership.setLastModified(cal.getTime());
    membership.setGroup(rel.getGroup());
    membership.setIdentity(id);
    membership.setRole(role.name());
    dbInstance.getCurrentEntityManager().persist(membership);
    dbInstance.commit();
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) GroupMembershipImpl(org.olat.basesecurity.model.GroupMembershipImpl) RepositoryEntryToGroupRelation(org.olat.repository.model.RepositoryEntryToGroupRelation)

Example 2 with GroupMembershipImpl

use of org.olat.basesecurity.model.GroupMembershipImpl in project OpenOLAT by OpenOLAT.

the class ReminderRuleEngineTest method addEnrollmentDate.

private void addEnrollmentDate(RepositoryEntry entry, Identity id, GroupRoles role, int amount, int field) {
    RepositoryEntryToGroupRelation rel = entry.getGroups().iterator().next();
    rel.getGroup();
    Calendar cal = Calendar.getInstance();
    cal.setTime(new Date());
    cal.add(field, amount);
    GroupMembershipImpl membership = new GroupMembershipImpl();
    membership.setCreationDate(cal.getTime());
    membership.setLastModified(cal.getTime());
    membership.setGroup(rel.getGroup());
    membership.setIdentity(id);
    membership.setRole(role.name());
    dbInstance.getCurrentEntityManager().persist(membership);
    dbInstance.commit();
}
Also used : Calendar(java.util.Calendar) Date(java.util.Date) GroupMembershipImpl(org.olat.basesecurity.model.GroupMembershipImpl) RepositoryEntryToGroupRelation(org.olat.repository.model.RepositoryEntryToGroupRelation)

Example 3 with GroupMembershipImpl

use of org.olat.basesecurity.model.GroupMembershipImpl 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 4 with GroupMembershipImpl

use of org.olat.basesecurity.model.GroupMembershipImpl in project OpenOLAT by OpenOLAT.

the class BusinessGroupRelationDAO method touchMembership.

public void touchMembership(IdentityRef identity, BusinessGroupRef group) {
    StringBuilder sb = new StringBuilder();
    sb.append("select membership from businessgroup as bgroup ").append(" inner join bgroup.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" where bgroup.key=:businessGroupKey and membership.identity.key=:identityKey");
    List<GroupMembershipImpl> memberships = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), GroupMembershipImpl.class).setParameter("businessGroupKey", group.getKey()).setParameter("identityKey", identity.getKey()).getResultList();
    for (GroupMembershipImpl membership : memberships) {
        membership.setLastModified(new Date());
    }
}
Also used : GroupMembershipImpl(org.olat.basesecurity.model.GroupMembershipImpl) SecurityGroupMembershipImpl(org.olat.basesecurity.SecurityGroupMembershipImpl) Date(java.util.Date)

Example 5 with GroupMembershipImpl

use of org.olat.basesecurity.model.GroupMembershipImpl in project openolat by klemens.

the class GroupDAO method addMembershipOneWay.

/**
 * Create a membership without updating the set in the group.
 */
public void addMembershipOneWay(Group group, Identity identity, String role) {
    GroupMembershipImpl membership = new GroupMembershipImpl();
    membership.setCreationDate(new Date());
    membership.setLastModified(new Date());
    membership.setGroup(group);
    membership.setIdentity(identity);
    membership.setRole(role);
    dbInstance.getCurrentEntityManager().persist(membership);
}
Also used : GroupMembershipImpl(org.olat.basesecurity.model.GroupMembershipImpl) Date(java.util.Date)

Aggregations

GroupMembershipImpl (org.olat.basesecurity.model.GroupMembershipImpl)12 Date (java.util.Date)10 Calendar (java.util.Calendar)4 GroupMembership (org.olat.basesecurity.GroupMembership)4 SecurityGroupMembershipImpl (org.olat.basesecurity.SecurityGroupMembershipImpl)4 GroupImpl (org.olat.basesecurity.model.GroupImpl)4 RepositoryEntryToGroupRelation (org.olat.repository.model.RepositoryEntryToGroupRelation)4