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);
}
}
}
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());
}
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());
}
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);
}
}
}
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());
}
Aggregations