Search in sources :

Example 1 with IdentityGroupKey

use of org.olat.group.model.IdentityGroupKey in project OpenOLAT by OpenOLAT.

the class BusinessGroupDAO method loadBusinessGroupsMembership.

private void loadBusinessGroupsMembership(Collection<Long> groupKeys, Map<IdentityGroupKey, BusinessGroupMembershipImpl> memberships) {
    if (groupKeys == null || groupKeys.isEmpty()) {
        return;
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select membership.identity.key, membership.creationDate, membership.lastModified, membership.role, grp.key ").append(" from businessgroup as grp ").append(" inner join grp.baseGroup as baseGroup ").append(" inner join baseGroup.members as membership ").append(" where grp.key in (:groupKeys)");
    List<Object[]> members = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("groupKeys", groupKeys).getResultList();
    for (Object[] membership : members) {
        Long identityKey = (Long) membership[0];
        Date creationDate = (Date) membership[1];
        Date lastModified = (Date) membership[2];
        String role = (String) membership[3];
        Long groupKey = (Long) membership[4];
        IdentityGroupKey key = new IdentityGroupKey(identityKey, groupKey);
        if (!memberships.containsKey(key)) {
            memberships.put(key, new BusinessGroupMembershipImpl(identityKey, groupKey));
        }
        BusinessGroupMembershipImpl mb = memberships.get(key);
        mb.setCreationDate(creationDate);
        mb.setLastModified(lastModified);
        if (GroupRoles.coach.name().equals(role)) {
            mb.setOwner(true);
        } else if (GroupRoles.participant.name().equals(role)) {
            mb.setParticipant(true);
        } else if (GroupRoles.waiting.name().equals(role)) {
            mb.setWaiting(true);
        }
    }
}
Also used : IdentityGroupKey(org.olat.group.model.IdentityGroupKey) BusinessGroupMembershipImpl(org.olat.group.model.BusinessGroupMembershipImpl) Date(java.util.Date)

Example 2 with IdentityGroupKey

use of org.olat.group.model.IdentityGroupKey in project OpenOLAT by OpenOLAT.

the class BusinessGroupDAO method getBusinessGroupsMembership.

public List<BusinessGroupMembership> getBusinessGroupsMembership(Collection<BusinessGroup> groups) {
    List<Long> groupKeys = new ArrayList<>();
    for (BusinessGroup group : groups) {
        groupKeys.add(group.getKey());
    }
    Map<IdentityGroupKey, BusinessGroupMembershipImpl> memberships = new HashMap<IdentityGroupKey, BusinessGroupMembershipImpl>();
    loadBusinessGroupsMembership(groupKeys, memberships);
    return new ArrayList<BusinessGroupMembership>(memberships.values());
}
Also used : IdentityGroupKey(org.olat.group.model.IdentityGroupKey) BusinessGroupMembershipImpl(org.olat.group.model.BusinessGroupMembershipImpl) BusinessGroup(org.olat.group.BusinessGroup) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 3 with IdentityGroupKey

use of org.olat.group.model.IdentityGroupKey in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceImpl method getBusinessGroupMembership.

@Override
public List<BusinessGroupMembership> getBusinessGroupMembership(Collection<Long> businessGroups, Identity... identity) {
    List<BusinessGroupMembershipViewImpl> views = businessGroupDAO.getMembershipInfoInBusinessGroups(businessGroups, identity);
    Map<IdentityGroupKey, BusinessGroupMembershipImpl> memberships = new HashMap<IdentityGroupKey, BusinessGroupMembershipImpl>();
    for (BusinessGroupMembershipViewImpl membership : views) {
        if (GroupRoles.coach.name().equals(membership.getRole())) {
            Long groupKey = membership.getGroupKey();
            IdentityGroupKey key = new IdentityGroupKey(membership.getIdentityKey(), groupKey);
            if (!memberships.containsKey(key)) {
                memberships.put(key, new BusinessGroupMembershipImpl(membership.getIdentityKey(), groupKey));
            }
            BusinessGroupMembershipImpl mb = memberships.get(key);
            mb.setOwner(true);
            mb.setCreationDate(membership.getCreationDate());
            mb.setLastModified(membership.getLastModified());
        }
        if (GroupRoles.participant.name().equals(membership.getRole())) {
            Long groupKey = membership.getGroupKey();
            IdentityGroupKey key = new IdentityGroupKey(membership.getIdentityKey(), groupKey);
            if (!memberships.containsKey(key)) {
                memberships.put(key, new BusinessGroupMembershipImpl(membership.getIdentityKey(), groupKey));
            }
            BusinessGroupMembershipImpl mb = memberships.get(key);
            mb.setParticipant(true);
            mb.setCreationDate(membership.getCreationDate());
            mb.setLastModified(membership.getLastModified());
        }
        if (GroupRoles.waiting.name().equals(membership.getRole())) {
            Long groupKey = membership.getGroupKey();
            IdentityGroupKey key = new IdentityGroupKey(membership.getIdentityKey(), groupKey);
            if (!memberships.containsKey(key)) {
                memberships.put(key, new BusinessGroupMembershipImpl(membership.getIdentityKey(), groupKey));
            }
            BusinessGroupMembershipImpl mb = memberships.get(key);
            mb.setWaiting(true);
            mb.setCreationDate(membership.getCreationDate());
            mb.setLastModified(membership.getLastModified());
        }
    }
    return new ArrayList<BusinessGroupMembership>(memberships.values());
}
Also used : IdentityGroupKey(org.olat.group.model.IdentityGroupKey) BusinessGroupMembershipImpl(org.olat.group.model.BusinessGroupMembershipImpl) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BusinessGroupMembershipViewImpl(org.olat.group.model.BusinessGroupMembershipViewImpl)

Example 4 with IdentityGroupKey

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

the class BusinessGroupDAO method loadBusinessGroupsMembership.

private void loadBusinessGroupsMembership(Collection<Long> groupKeys, Map<IdentityGroupKey, BusinessGroupMembershipImpl> memberships) {
    if (groupKeys == null || groupKeys.isEmpty()) {
        return;
    }
    StringBuilder sb = new StringBuilder();
    sb.append("select membership.identity.key, membership.creationDate, membership.lastModified, membership.role, grp.key ").append(" from businessgroup as grp ").append(" inner join grp.baseGroup as baseGroup ").append(" inner join baseGroup.members as membership ").append(" where grp.key in (:groupKeys)");
    List<Object[]> members = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("groupKeys", groupKeys).getResultList();
    for (Object[] membership : members) {
        Long identityKey = (Long) membership[0];
        Date creationDate = (Date) membership[1];
        Date lastModified = (Date) membership[2];
        String role = (String) membership[3];
        Long groupKey = (Long) membership[4];
        IdentityGroupKey key = new IdentityGroupKey(identityKey, groupKey);
        if (!memberships.containsKey(key)) {
            memberships.put(key, new BusinessGroupMembershipImpl(identityKey, groupKey));
        }
        BusinessGroupMembershipImpl mb = memberships.get(key);
        mb.setCreationDate(creationDate);
        mb.setLastModified(lastModified);
        if (GroupRoles.coach.name().equals(role)) {
            mb.setOwner(true);
        } else if (GroupRoles.participant.name().equals(role)) {
            mb.setParticipant(true);
        } else if (GroupRoles.waiting.name().equals(role)) {
            mb.setWaiting(true);
        }
    }
}
Also used : IdentityGroupKey(org.olat.group.model.IdentityGroupKey) BusinessGroupMembershipImpl(org.olat.group.model.BusinessGroupMembershipImpl) Date(java.util.Date)

Example 5 with IdentityGroupKey

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

the class BusinessGroupServiceImpl method getBusinessGroupMembership.

@Override
public List<BusinessGroupMembership> getBusinessGroupMembership(Collection<Long> businessGroups, Identity... identity) {
    List<BusinessGroupMembershipViewImpl> views = businessGroupDAO.getMembershipInfoInBusinessGroups(businessGroups, identity);
    Map<IdentityGroupKey, BusinessGroupMembershipImpl> memberships = new HashMap<IdentityGroupKey, BusinessGroupMembershipImpl>();
    for (BusinessGroupMembershipViewImpl membership : views) {
        if (GroupRoles.coach.name().equals(membership.getRole())) {
            Long groupKey = membership.getGroupKey();
            IdentityGroupKey key = new IdentityGroupKey(membership.getIdentityKey(), groupKey);
            if (!memberships.containsKey(key)) {
                memberships.put(key, new BusinessGroupMembershipImpl(membership.getIdentityKey(), groupKey));
            }
            BusinessGroupMembershipImpl mb = memberships.get(key);
            mb.setOwner(true);
            mb.setCreationDate(membership.getCreationDate());
            mb.setLastModified(membership.getLastModified());
        }
        if (GroupRoles.participant.name().equals(membership.getRole())) {
            Long groupKey = membership.getGroupKey();
            IdentityGroupKey key = new IdentityGroupKey(membership.getIdentityKey(), groupKey);
            if (!memberships.containsKey(key)) {
                memberships.put(key, new BusinessGroupMembershipImpl(membership.getIdentityKey(), groupKey));
            }
            BusinessGroupMembershipImpl mb = memberships.get(key);
            mb.setParticipant(true);
            mb.setCreationDate(membership.getCreationDate());
            mb.setLastModified(membership.getLastModified());
        }
        if (GroupRoles.waiting.name().equals(membership.getRole())) {
            Long groupKey = membership.getGroupKey();
            IdentityGroupKey key = new IdentityGroupKey(membership.getIdentityKey(), groupKey);
            if (!memberships.containsKey(key)) {
                memberships.put(key, new BusinessGroupMembershipImpl(membership.getIdentityKey(), groupKey));
            }
            BusinessGroupMembershipImpl mb = memberships.get(key);
            mb.setWaiting(true);
            mb.setCreationDate(membership.getCreationDate());
            mb.setLastModified(membership.getLastModified());
        }
    }
    return new ArrayList<BusinessGroupMembership>(memberships.values());
}
Also used : IdentityGroupKey(org.olat.group.model.IdentityGroupKey) BusinessGroupMembershipImpl(org.olat.group.model.BusinessGroupMembershipImpl) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BusinessGroupMembershipViewImpl(org.olat.group.model.BusinessGroupMembershipViewImpl)

Aggregations

BusinessGroupMembershipImpl (org.olat.group.model.BusinessGroupMembershipImpl)6 IdentityGroupKey (org.olat.group.model.IdentityGroupKey)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Date (java.util.Date)2 BusinessGroup (org.olat.group.BusinessGroup)2 BusinessGroupMembershipViewImpl (org.olat.group.model.BusinessGroupMembershipViewImpl)2