Search in sources :

Example 21 with IdentityRef

use of org.olat.basesecurity.IdentityRef in project OpenOLAT by OpenOLAT.

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 22 with IdentityRef

use of org.olat.basesecurity.IdentityRef in project OpenOLAT by OpenOLAT.

the class LDAPLoginManagerImpl method doSyncGroupByAttribute.

private void doSyncGroupByAttribute(List<LDAPUser> ldapUsers, Map<String, LDAPGroup> cnToGroupMap) {
    for (LDAPUser ldapUser : ldapUsers) {
        List<String> groupIds = ldapUser.getGroupIds();
        List<String> coachedGroupIds = ldapUser.getCoachedGroupIds();
        if ((groupIds != null && groupIds.size() > 0) || (coachedGroupIds != null && coachedGroupIds.size() > 0)) {
            IdentityRef identity = ldapUser.getCachedIdentity();
            if (identity == null) {
                log.error("Identity with dn=" + ldapUser.getDn() + " not found");
            } else {
                if (groupIds != null && groupIds.size() > 0) {
                    for (String groupId : groupIds) {
                        if (!cnToGroupMap.containsKey(groupId)) {
                            cnToGroupMap.put(groupId, new LDAPGroup(groupId));
                        }
                        cnToGroupMap.get(groupId).getParticipants().add(ldapUser);
                    }
                }
                if (coachedGroupIds != null && coachedGroupIds.size() > 0) {
                    for (String coachedGroupId : coachedGroupIds) {
                        if (!cnToGroupMap.containsKey(coachedGroupId)) {
                            cnToGroupMap.put(coachedGroupId, new LDAPGroup(coachedGroupId));
                        }
                        cnToGroupMap.get(coachedGroupId).getCoaches().add(ldapUser);
                    }
                }
            }
        }
    }
}
Also used : IdentityRef(org.olat.basesecurity.IdentityRef) LDAPUser(org.olat.ldap.model.LDAPUser) LDAPGroup(org.olat.ldap.model.LDAPGroup)

Example 23 with IdentityRef

use of org.olat.basesecurity.IdentityRef in project OpenOLAT by OpenOLAT.

the class GTACoachedParticipantListController method updateModel.

protected void updateModel(UserRequest ureq) {
    RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
    List<TaskLight> tasks = gtaManager.getTasksLight(entry, gtaNode);
    Map<Long, TaskLight> identityToTasks = new HashMap<>(tasks.size());
    for (TaskLight task : tasks) {
        if (task.getIdentityKey() != null) {
            identityToTasks.put(task.getIdentityKey(), task);
        }
    }
    List<IdentityMark> marks = gtaManager.getMarks(entry, gtaNode, ureq.getIdentity());
    Map<Long, IdentityMark> identityToMarks = new HashMap<>(marks.size());
    for (IdentityMark mark : marks) {
        if (mark.getParticipant() != null) {
            identityToMarks.put(mark.getParticipant().getKey(), mark);
        }
    }
    List<AssessmentEntry> assessments = assessmentService.loadAssessmentEntriesBySubIdent(entry, gtaNode.getIdent());
    Map<Long, AssessmentEntry> identityToAssessments = new HashMap<>(assessments.size());
    for (AssessmentEntry assessment : assessments) {
        if (assessment.getIdentity() != null) {
            identityToAssessments.put(assessment.getIdentity().getKey(), assessment);
        }
    }
    List<CoachedIdentityRow> rows = new ArrayList<>(assessableIdentities.size());
    for (UserPropertiesRow assessableIdentity : assessableIdentities) {
        IdentityMark mark = identityToMarks.get(assessableIdentity.getIdentityKey());
        if (markedOnly && mark == null)
            continue;
        FormLink markLink = uifactory.addFormLink("mark_" + assessableIdentity.getIdentityKey(), "mark", "", null, null, Link.NONTRANSLATED);
        markLink.setIconLeftCSS(mark != null ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
        markLink.setUserObject(assessableIdentity.getIdentityKey());
        TaskLight task = identityToTasks.get(assessableIdentity.getIdentityKey());
        Date submissionDueDate = null;
        if (task == null || task.getTaskStatus() == null || task.getTaskStatus() == TaskProcess.assignment) {
            IdentityRef identityRef = new IdentityRefImpl(assessableIdentity.getIdentityKey());
            DueDate dueDate = gtaManager.getSubmissionDueDate(task, identityRef, null, gtaNode, entry, true);
            if (dueDate != null) {
                submissionDueDate = dueDate.getDueDate();
            }
        }
        Date syntheticSubmissionDate = null;
        boolean hasSubmittedDocument = false;
        if (task != null && task.getTaskStatus() != null && task.getTaskStatus() != TaskProcess.assignment && task.getTaskStatus() != TaskProcess.submit) {
            syntheticSubmissionDate = getSyntheticSubmissionDate(task);
            if (syntheticSubmissionDate != null) {
                hasSubmittedDocument = hasSubmittedDocument(task);
            }
        }
        int numSubmittedDocs = task != null && task.getSubmissionNumOfDocs() != null ? task.getSubmissionNumOfDocs() : 0;
        AssessmentEntry assessment = identityToAssessments.get(assessableIdentity.getIdentityKey());
        Boolean userVisibility = assessment != null ? assessment.getUserVisibility() : null;
        BigDecimal score = assessment != null ? assessment.getScore() : null;
        Boolean passed = assessment != null ? assessment.getPassed() : null;
        rows.add(new CoachedIdentityRow(assessableIdentity, task, submissionDueDate, syntheticSubmissionDate, hasSubmittedDocument, markLink, userVisibility, score, passed, numSubmittedDocs));
    }
    tableModel.setObjects(rows);
    tableEl.reset();
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) IdentityRefImpl(org.olat.basesecurity.model.IdentityRefImpl) IdentityRef(org.olat.basesecurity.IdentityRef) TaskLight(org.olat.course.nodes.gta.TaskLight) UserPropertiesRow(org.olat.user.UserPropertiesRow) DueDate(org.olat.course.nodes.gta.model.DueDate) IdentityMark(org.olat.course.nodes.gta.IdentityMark) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) AssessmentEntry(org.olat.modules.assessment.AssessmentEntry) Date(java.util.Date) DueDate(org.olat.course.nodes.gta.model.DueDate) BigDecimal(java.math.BigDecimal)

Example 24 with IdentityRef

use of org.olat.basesecurity.IdentityRef in project OpenOLAT by OpenOLAT.

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 25 with IdentityRef

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

Aggregations

IdentityRef (org.olat.basesecurity.IdentityRef)36 ArrayList (java.util.ArrayList)18 IdentityRefImpl (org.olat.basesecurity.model.IdentityRefImpl)18 Identity (org.olat.core.id.Identity)8 BusinessGroupRef (org.olat.group.BusinessGroupRef)8 LDAPUser (org.olat.ldap.model.LDAPUser)8 RepositoryEntryRef (org.olat.repository.RepositoryEntryRef)6 RepositoryEntryRefImpl (org.olat.repository.model.RepositoryEntryRefImpl)6 OLATResource (org.olat.resource.OLATResource)6 HashMap (java.util.HashMap)4 AuthenticationException (javax.naming.AuthenticationException)4 NamingException (javax.naming.NamingException)4 Attributes (javax.naming.directory.Attributes)4 GroupRoles (org.olat.basesecurity.GroupRoles)4 Roles (org.olat.core.id.Roles)4 BusinessGroupRefImpl (org.olat.group.model.BusinessGroupRefImpl)4 ModuleConfiguration (org.olat.modules.ModuleConfiguration)4 RepositoryEntry (org.olat.repository.RepositoryEntry)4 AssessmentEntry (org.olat.modules.assessment.AssessmentEntry)3 File (java.io.File)2