Search in sources :

Example 11 with GroupMembershipImpl

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

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 12 with GroupMembershipImpl

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

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)

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