Search in sources :

Example 16 with TaxonomyCompetenceTypes

use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project openolat by klemens.

the class TaxonomyLevelCompetenceController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (userSearchCtrl == source) {
        if (event instanceof SingleIdentityChosenEvent) {
            SingleIdentityChosenEvent singleEvent = (SingleIdentityChosenEvent) event;
            Identity choosenIdentity = singleEvent.getChosenIdentity();
            if (choosenIdentity != null) {
                List<Identity> toAdd = Collections.singletonList(choosenIdentity);
                doAddCompetence(toAdd, (TaxonomyCompetenceTypes) userSearchCtrl.getUserObject());
                loadModel();
            }
        } else if (event instanceof MultiIdentityChosenEvent) {
            MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
            List<Identity> toAdd = multiEvent.getChosenIdentities();
            if (toAdd.size() > 0) {
                doAddCompetence(toAdd, (TaxonomyCompetenceTypes) userSearchCtrl.getUserObject());
                loadModel();
            }
        }
        cmc.deactivate();
        cleanUp();
    } else if (confirmDeleteDialog == source) {
        if (DialogBoxUIFactory.isOkEvent(event) || DialogBoxUIFactory.isYesEvent(event)) {
            @SuppressWarnings("unchecked") List<TaxonomyLevelCompetenceRow> selectedRows = (List<TaxonomyLevelCompetenceRow>) confirmDeleteDialog.getUserObject();
            doRemoveCompetences(selectedRows);
        }
    } else if (editCompetenceCtrl == source) {
        if (event == Event.DONE_EVENT || event == Event.CHANGED_EVENT) {
            loadModel();
            tableEl.reset(false, false, true);
        }
        cmc.deactivate();
        cleanUp();
    } else if (addCompetencesCallout == source) {
        cleanUp();
    } else if (cmc == source) {
        cleanUp();
    }
    super.event(ureq, source, event);
}
Also used : SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) List(java.util.List) ArrayList(java.util.ArrayList) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Identity(org.olat.core.id.Identity) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent)

Example 17 with TaxonomyCompetenceTypes

use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project openolat by klemens.

the class TaxonomyTreeBuilder method computePermissions.

private void computePermissions(TaxonomyTreeNode root) {
    List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyCompetences(taxonomy, identity, new Date());
    Map<TaxonomyLevel, List<TaxonomyCompetenceTypes>> levelToCompetences = new HashMap<>();
    for (TaxonomyCompetence competence : competences) {
        TaxonomyLevel level = competence.getTaxonomyLevel();
        if (levelToCompetences.containsKey(level)) {
            levelToCompetences.get(level).add(competence.getCompetenceType());
        } else {
            List<TaxonomyCompetenceTypes> types = new ArrayList<>(4);
            types.add(competence.getCompetenceType());
            levelToCompetences.put(level, types);
        }
    }
    computePermissionsRecursive(root, levelToCompetences);
    trimRecursive(root);
}
Also used : HashMap(java.util.HashMap) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Date(java.util.Date)

Example 18 with TaxonomyCompetenceTypes

use of org.olat.modules.taxonomy.TaxonomyCompetenceTypes in project openolat by klemens.

the class TaxonomyCompetenceDAO method hasCompetenceByTaxonomy.

public boolean hasCompetenceByTaxonomy(TaxonomyRef taxonomy, IdentityRef identity, Date date, TaxonomyCompetenceTypes... competences) {
    List<String> competenceList = new ArrayList<>(5);
    if (competences != null && competences.length > 0 && competences[0] != null) {
        for (TaxonomyCompetenceTypes competence : competences) {
            competenceList.add(competence.name());
        }
    }
    StringBuilder sb = new StringBuilder(256);
    sb.append("select competence.key from ctaxonomycompetence competence").append(" inner join competence.taxonomyLevel taxonomyLevel").append(" where taxonomyLevel.taxonomy.key=:taxonomyKey and competence.identity.key=:identityKey").append(" and (competence.expiration is null or competence.expiration>=:date)");
    if (competenceList.size() > 0) {
        sb.append(" and competence.type in (:types)");
    }
    TypedQuery<Long> query = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Long.class).setParameter("taxonomyKey", taxonomy.getKey()).setParameter("identityKey", identity.getKey()).setParameter("date", CalendarUtils.removeTime(date)).setFirstResult(0).setMaxResults(1);
    if (competenceList.size() > 0) {
        query.setParameter("types", competenceList);
    }
    List<Long> keys = query.getResultList();
    return keys != null && keys.size() > 0 && keys.get(0) != null && keys.get(0).intValue() > 0;
}
Also used : ArrayList(java.util.ArrayList) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes)

Aggregations

TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)18 ArrayList (java.util.ArrayList)8 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)8 List (java.util.List)6 Date (java.util.Date)4 Identity (org.olat.core.id.Identity)4 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)4 TaxonomyLevelManagedFlag (org.olat.modules.taxonomy.TaxonomyLevelManagedFlag)4 HashMap (java.util.HashMap)2 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)2 SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)2 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 Roles (org.olat.core.id.Roles)2 UserSession (org.olat.core.util.UserSession)2 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)2 TaxonomyRef (org.olat.modules.taxonomy.TaxonomyRef)2 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)2 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)2 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)2 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)2