Search in sources :

Example 6 with BusinessGroupRef

use of org.olat.group.BusinessGroupRef in project OpenOLAT by OpenOLAT.

the class BusinessGroupRelationDAO method getMemberKeys.

public List<Long> getMemberKeys(List<? extends BusinessGroupRef> groups, String... roles) {
    if (groups == null || groups.isEmpty())
        return Collections.emptyList();
    StringBuilder sb = new StringBuilder();
    sb.append("select membership.identity.key from businessgroup as bgroup ").append(" inner join bgroup.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" where bgroup.key in (:businessGroupKeys) and membership.role in (:roles)");
    List<String> roleList = GroupRoles.toList(roles);
    List<Long> groupKeys = new ArrayList<>(groups.size());
    for (BusinessGroupRef group : groups) {
        groupKeys.add(group.getKey());
    }
    List<Long> members = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Long.class).setParameter("businessGroupKeys", groupKeys).setParameter("roles", roleList).getResultList();
    return members;
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) ArrayList(java.util.ArrayList)

Example 7 with BusinessGroupRef

use of org.olat.group.BusinessGroupRef in project OpenOLAT by OpenOLAT.

the class BusinessGroupRelationDAO method getDuplicateMemberships.

/**
 * @param groups
 * @return The list of identity key which have multiple memberships in the specified groups
 */
public List<IdentityRef> getDuplicateMemberships(List<? extends BusinessGroupRef> groups) {
    if (groups == null || groups.isEmpty())
        return Collections.emptyList();
    StringBuilder sb = new StringBuilder();
    sb.append("select count(membership.key ), membership.identity.key from businessgroup as bgroup ").append(" inner join bgroup.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" where bgroup.key in (:businessGroupKeys) and membership.role='participant'").append(" group by membership.identity.key");
    List<Long> groupKeys = new ArrayList<>(groups.size());
    for (BusinessGroupRef group : groups) {
        groupKeys.add(group.getKey());
    }
    List<Object[]> groupBy = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("businessGroupKeys", groupKeys).getResultList();
    List<IdentityRef> duplicates = new ArrayList<>();
    for (Object[] id : groupBy) {
        Number numOfMembership = (Number) id[0];
        Long identityKey = (Long) id[1];
        if (numOfMembership.longValue() > 1) {
            duplicates.add(new IdentityRefImpl(identityKey));
        }
    }
    return duplicates;
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) IdentityRef(org.olat.basesecurity.IdentityRef) ArrayList(java.util.ArrayList)

Example 8 with BusinessGroupRef

use of org.olat.group.BusinessGroupRef in project openolat by klemens.

the class GTAManagerImpl method getDuplicatedMemberships.

@Override
public List<IdentityRef> getDuplicatedMemberships(GTACourseNode cNode) {
    List<IdentityRef> duplicates;
    ModuleConfiguration config = cNode.getModuleConfiguration();
    if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
        List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
        List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
        List<Long> consolidatedGroupKeys = new ArrayList<>();
        if (groupKeys != null && groupKeys.size() > 0) {
            consolidatedGroupKeys.addAll(groupKeys);
        }
        consolidatedGroupKeys.addAll(areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys));
        List<BusinessGroupRef> businessGroups = BusinessGroupRefImpl.toRefs(consolidatedGroupKeys);
        duplicates = businessGroupRelationDao.getDuplicateMemberships(businessGroups);
    } else {
        duplicates = Collections.emptyList();
    }
    return duplicates;
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) ModuleConfiguration(org.olat.modules.ModuleConfiguration) IdentityRef(org.olat.basesecurity.IdentityRef) ArrayList(java.util.ArrayList)

Example 9 with BusinessGroupRef

use of org.olat.group.BusinessGroupRef in project openolat by klemens.

the class BusinessGroupMembershipProcessor method processIdentityRemoved.

private void processIdentityRemoved(Long groupKey, Long identityKey) {
    IdentityRef identityRef = new IdentityRefImpl(identityKey);
    BusinessGroupRef groupRef = new BusinessGroupRefImpl(groupKey);
    if (!businessGroupRelationDao.hasAnyRole(identityRef, groupRef)) {
        infoMessageManager.updateInfoMessagesOfIdentity(groupRef, identityRef);
        notificationsManager.unsubscribeAllForIdentityAndResId(identityRef, groupRef.getKey());
        List<BGRepositoryEntryRelation> relations = businessGroupRelationDao.findRelationToRepositoryEntries(Collections.singletonList(groupKey), 0, -1);
        for (BGRepositoryEntryRelation relation : relations) {
            Long repositoryEntryKey = relation.getRepositoryEntryKey();
            RepositoryEntryRef entryRef = new RepositoryEntryRefImpl(repositoryEntryKey);
            List<String> remaingRoles = repositoryEntryRelationDao.getRoles(identityRef, entryRef);
            if (remaingRoles.isEmpty()) {
                OLATResource resource = repositoryManager.lookupRepositoryEntryResource(entryRef.getKey());
                notificationsManager.unsubscribeAllForIdentityAndResId(identityRef, resource.getResourceableId());
            }
        }
    }
}
Also used : IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) BusinessGroupRef(org.olat.group.BusinessGroupRef) IdentityRef(org.olat.basesecurity.IdentityRef) RepositoryEntryRefImpl(org.olat.repository.model.RepositoryEntryRefImpl) OLATResource(org.olat.resource.OLATResource) BusinessGroupRefImpl(org.olat.group.model.BusinessGroupRefImpl) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef) BGRepositoryEntryRelation(org.olat.group.model.BGRepositoryEntryRelation)

Example 10 with BusinessGroupRef

use of org.olat.group.BusinessGroupRef in project openolat by klemens.

the class BusinessGroupRelationDAO method getDuplicateMemberships.

/**
 * @param groups
 * @return The list of identity key which have multiple memberships in the specified groups
 */
public List<IdentityRef> getDuplicateMemberships(List<? extends BusinessGroupRef> groups) {
    if (groups == null || groups.isEmpty())
        return Collections.emptyList();
    StringBuilder sb = new StringBuilder();
    sb.append("select count(membership.key ), membership.identity.key from businessgroup as bgroup ").append(" inner join bgroup.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" where bgroup.key in (:businessGroupKeys) and membership.role='participant'").append(" group by membership.identity.key");
    List<Long> groupKeys = new ArrayList<>(groups.size());
    for (BusinessGroupRef group : groups) {
        groupKeys.add(group.getKey());
    }
    List<Object[]> groupBy = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).setParameter("businessGroupKeys", groupKeys).getResultList();
    List<IdentityRef> duplicates = new ArrayList<>();
    for (Object[] id : groupBy) {
        Number numOfMembership = (Number) id[0];
        Long identityKey = (Long) id[1];
        if (numOfMembership.longValue() > 1) {
            duplicates.add(new IdentityRefImpl(identityKey));
        }
    }
    return duplicates;
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) IdentityRef(org.olat.basesecurity.IdentityRef) ArrayList(java.util.ArrayList)

Aggregations

BusinessGroupRef (org.olat.group.BusinessGroupRef)22 ArrayList (java.util.ArrayList)12 IdentityRef (org.olat.basesecurity.IdentityRef)8 IdentityRefImpl (org.olat.basesecurity.model.IdentityRefImpl)6 BusinessGroupRefImpl (org.olat.group.model.BusinessGroupRefImpl)6 BusinessGroup (org.olat.group.BusinessGroup)4 BGConfigBusinessGroup (org.olat.group.ui.wizard.BGConfigBusinessGroup)4 BGCopyBusinessGroup (org.olat.group.ui.wizard.BGCopyBusinessGroup)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)4 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)4 OLATResource (org.olat.resource.OLATResource)4 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2 SelectionEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent)2 Link (org.olat.core.gui.components.link.Link)2 PopEvent (org.olat.core.gui.components.stack.PopEvent)2 VetoPopEvent (org.olat.core.gui.components.stack.VetoPopEvent)2 Identity (org.olat.core.id.Identity)2 ICourse (org.olat.course.ICourse)2