Search in sources :

Example 6 with BusinessGroupRefImpl

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

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 7 with BusinessGroupRefImpl

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

the class BusinessGroupRoleRuleSPI method evaluate.

@Override
public List<Identity> evaluate(RepositoryEntry entry, ReminderRule rule) {
    List<Identity> identities = null;
    if (rule instanceof ReminderRuleImpl) {
        ReminderRuleImpl r = (ReminderRuleImpl) rule;
        String groupKey = r.getRightOperand();
        if (StringHelper.isLong(groupKey)) {
            Long key = Long.parseLong(groupKey);
            BusinessGroupRef groupRef = new BusinessGroupRefImpl(key);
            identities = businessGroupRelationDao.getMembers(groupRef, GroupRoles.coach.name(), GroupRoles.participant.name());
        }
    }
    return identities == null ? Collections.<Identity>emptyList() : identities;
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) ReminderRuleImpl(org.olat.modules.reminder.model.ReminderRuleImpl) BusinessGroupRefImpl(org.olat.group.model.BusinessGroupRefImpl) Identity(org.olat.core.id.Identity)

Example 8 with BusinessGroupRefImpl

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

Aggregations

BusinessGroupRefImpl (org.olat.group.model.BusinessGroupRefImpl)8 BusinessGroupRef (org.olat.group.BusinessGroupRef)6 IdentityRef (org.olat.basesecurity.IdentityRef)4 IdentityRefImpl (org.olat.basesecurity.model.IdentityRefImpl)4 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)4 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)4 OLATResource (org.olat.resource.OLATResource)4 ArrayList (java.util.ArrayList)2 Identity (org.olat.core.id.Identity)2 BGRepositoryEntryRelation (org.olat.group.model.BGRepositoryEntryRelation)2 ReminderRuleImpl (org.olat.modules.reminder.model.ReminderRuleImpl)2