Search in sources :

Example 6 with BusinessGroupMembershipImpl

use of org.olat.group.model.BusinessGroupMembershipImpl 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)

Example 7 with BusinessGroupMembershipImpl

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

the class BusinessGroupDAO method addMembershipToRow.

private void addMembershipToRow(BusinessGroupRow row, GroupMembershipImpl member) {
    if (row != null && member != null) {
        if (row.getMember() == null) {
            row.setMember(new BusinessGroupMembershipImpl());
        }
        String role = member.getRole();
        BusinessGroupMembershipImpl mb = row.getMember();
        mb.setCreationDate(member.getCreationDate());
        mb.setLastModified(member.getLastModified());
        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 : BusinessGroupMembershipImpl(org.olat.group.model.BusinessGroupMembershipImpl)

Example 8 with BusinessGroupMembershipImpl

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

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)

Aggregations

BusinessGroupMembershipImpl (org.olat.group.model.BusinessGroupMembershipImpl)8 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