Search in sources :

Example 6 with IdentityRefImpl

use of org.olat.basesecurity.model.IdentityRefImpl in project openolat by klemens.

the class RepositoryEntryMembershipProcessor method processIdentityRemoved.

private void processIdentityRemoved(Long repoKey, Long identityKey) {
    IdentityRef identity = new IdentityRefImpl(identityKey);
    RepositoryEntryRef re = new RepositoryEntryRefImpl(repoKey);
    List<String> remainingRoles = repositoryEntryRelationDao.getRoles(identity, re);
    if (remainingRoles.isEmpty()) {
        OLATResource resource = repositoryManager.lookupRepositoryEntryResource(repoKey);
        notificationsManager.unsubscribeAllForIdentityAndResId(identity, resource.getResourceableId());
    }
}
Also used : IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) IdentityRef(org.olat.basesecurity.IdentityRef) RepositoryEntryRefImpl(org.olat.repository.model.RepositoryEntryRefImpl) OLATResource(org.olat.resource.OLATResource) RepositoryEntryRef(org.olat.repository.RepositoryEntryRef)

Example 7 with IdentityRefImpl

use of org.olat.basesecurity.model.IdentityRefImpl 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 8 with IdentityRefImpl

use of org.olat.basesecurity.model.IdentityRefImpl 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)

Example 9 with IdentityRefImpl

use of org.olat.basesecurity.model.IdentityRefImpl in project openolat by klemens.

the class IdentityListCourseNodeController method getSelectedIdentities.

@Override
public List<IdentityRef> getSelectedIdentities() {
    Set<Integer> selections = tableEl.getMultiSelectedIndex();
    List<AssessedIdentityElementRow> rows = new ArrayList<>(selections.size());
    for (Integer i : selections) {
        AssessedIdentityElementRow row = usersTableModel.getObject(i.intValue());
        if (row != null && row.getAssessmentStatus() != AssessmentEntryStatus.done) {
            rows.add(row);
        }
    }
    if (rows == null || rows.isEmpty()) {
        return Collections.emptyList();
    }
    List<IdentityRef> selectedIdentities = new ArrayList<>();
    for (AssessedIdentityElementRow row : rows) {
        selectedIdentities.add(new IdentityRefImpl(row.getIdentityKey()));
    }
    return selectedIdentities;
}
Also used : IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) AssessedIdentityElementRow(org.olat.modules.assessment.ui.AssessedIdentityElementRow) IdentityRef(org.olat.basesecurity.IdentityRef) ArrayList(java.util.ArrayList)

Example 10 with IdentityRefImpl

use of org.olat.basesecurity.model.IdentityRefImpl in project openolat by klemens.

the class IdentityListCourseNodeController method doUpdateCompletion.

private void doUpdateCompletion(Double completion, AssessmentRunStatus status, AssessedIdentityElementRow row) {
    row.getCurrentCompletion().setCompletion(completion);
    boolean endedRow = row.getCurrentCompletion().isEnded();
    boolean endedEvent = status != null && AssessmentRunStatus.done.equals(status);
    row.getCurrentCompletion().setEnded(endedEvent);
    if (endedEvent && !endedRow) {
        IdentityRef assessedIdentity = new IdentityRefImpl(row.getIdentityKey());
        AssessmentEntry assessmentEntry = assessmentToolManager.getAssessmentEntries(assessedIdentity, courseEntry, courseNode.getIdent());
        row.setAssessmentEntry(assessmentEntry);
        tableEl.getComponent().setDirty(true);
    }
}
Also used : IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) IdentityRef(org.olat.basesecurity.IdentityRef) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry)

Aggregations

IdentityRef (org.olat.basesecurity.IdentityRef)18 IdentityRefImpl (org.olat.basesecurity.model.IdentityRefImpl)18 ArrayList (java.util.ArrayList)8 BusinessGroupRef (org.olat.group.BusinessGroupRef)6 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)6 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)6 OLATResource (org.olat.resource.OLATResource)6 HashMap (java.util.HashMap)4 BusinessGroupRefImpl (org.olat.group.model.BusinessGroupRefImpl)4 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)4 BigDecimal (java.math.BigDecimal)2 Date (java.util.Date)2 Map (java.util.Map)2 AuthenticationException (javax.naming.AuthenticationException)2 NamingException (javax.naming.NamingException)2 Attributes (javax.naming.directory.Attributes)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 Identity (org.olat.core.id.Identity)2 CertificateLight (org.olat.course.certificate.CertificateLight)2 CertificateLightPack (org.olat.course.certificate.model.CertificateLightPack)2