Search in sources :

Example 21 with BusinessGroupRef

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

the class BusinessGroupMembershipProcessor method processResourceRemoved.

private void processResourceRemoved(Long groupKey, Long repoKey) {
    BusinessGroupRef groupRef = new BusinessGroupRefImpl(groupKey);
    RepositoryEntryRef entryRef = new RepositoryEntryRefImpl(repoKey);
    OLATResource resource = repositoryManager.lookupRepositoryEntryResource(entryRef.getKey());
    List<Long> memberKeys = businessGroupRelationDao.getMemberKeys(Collections.singletonList(groupRef), GroupRoles.coach.name(), GroupRoles.participant.name());
    for (Long memberKey : memberKeys) {
        IdentityRef member = new IdentityRefImpl(memberKey);
        List<String> remaingRoles = repositoryEntryRelationDao.getRoles(member, entryRef);
        if (remaingRoles.isEmpty()) {
            notificationsManager.unsubscribeAllForIdentityAndResId(member, resource.getResourceableId());
        }
    }
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) RepositoryEntryRefImpl(org.olat.repository.model.RepositoryEntryRefImpl) IdentityRef(org.olat.basesecurity.IdentityRef) OLATResource(org.olat.resource.OLATResource) BusinessGroupRefImpl(org.olat.group.model.BusinessGroupRefImpl) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef)

Example 22 with BusinessGroupRef

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

the class BusinessGroupRelationDAO method getRoles.

public List<String> getRoles(IdentityRef identity, List<? extends BusinessGroupRef> groups) {
    if (groups == null || groups.isEmpty())
        return Collections.emptyList();
    StringBuilder sb = new StringBuilder();
    sb.append("select membership.role 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.identity.key=:identityKey");
    List<Long> groupKeys = new ArrayList<>(groups.size());
    for (BusinessGroupRef group : groups) {
        groupKeys.add(group.getKey());
    }
    return dbInstance.getCurrentEntityManager().createQuery(sb.toString(), String.class).setParameter("businessGroupKeys", groupKeys).setParameter("identityKey", identity.getKey()).getResultList();
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) 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