Search in sources :

Example 6 with TaxonomyCompetenceTypes

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

the class EditTaxonomyCompetenceController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    String fullName = userManager.getUserDisplayName(competence.getIdentity());
    uifactory.addStaticTextElement("taxonomy.competence.fullName", fullName, formLayout);
    TaxonomyCompetenceTypes competenceType = competence.getCompetenceType();
    String type = translate(competenceType.name());
    uifactory.addStaticTextElement("taxonomy.competence.type", type, formLayout);
    TaxonomyLevelManagedFlag marker = TaxonomyLevelManagedFlag.getCorrespondingFlag(competenceType);
    expirationEl = uifactory.addDateChooser("taxonomy.competence.expiration", competence.getExpiration(), formLayout);
    expirationEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(taxonomyLevel, marker));
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
    if (expirationEl.isEnabled()) {
        // save only if there is something to update
        uifactory.addFormSubmitButton("save", buttonsCont);
    }
}
Also used : FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) TaxonomyLevelManagedFlag(org.olat.modules.taxonomy.TaxonomyLevelManagedFlag)

Example 7 with TaxonomyCompetenceTypes

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

the class IdentityCompetenceRow method isManaged.

public boolean isManaged() {
    TaxonomyLevel level = competence.getTaxonomyLevel();
    TaxonomyCompetenceTypes competenceType = competence.getCompetenceType();
    TaxonomyLevelManagedFlag marker = TaxonomyLevelManagedFlag.getCorrespondingFlag(competenceType);
    return TaxonomyLevelManagedFlag.isManaged(level, marker);
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) TaxonomyLevelManagedFlag(org.olat.modules.taxonomy.TaxonomyLevelManagedFlag)

Example 8 with TaxonomyCompetenceTypes

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

the class TaxonomyTreeBuilder method computePermissionsRecursive.

private void computePermissionsRecursive(TaxonomyTreeNode node, Map<TaxonomyLevel, List<TaxonomyCompetenceTypes>> levelToCompetences) {
    boolean hasRead = node.isCanRead();
    boolean hasWrite = node.isCanWrite();
    if (node.getType() == TaxonomyTreeNodeType.lostAndFound) {
        hasRead = isTaxonomyAdmin;
        hasWrite = isTaxonomyAdmin;
        node.setCanRead(hasRead);
        node.setCanWrite(hasWrite);
    } else if (node.getTaxonomyLevel() != null) {
        TaxonomyLevel level = node.getTaxonomyLevel();
        TaxonomyLevelType type = level.getType();
        if (type != null) {
            List<TaxonomyCompetenceTypes> competences = levelToCompetences.get(level);
            if (competences != null && competences.size() > 0) {
                for (TaxonomyCompetenceTypes competence : competences) {
                    hasRead |= hasReadAccess(type, competence);
                    hasWrite |= hasWriteAccess(type, competence);
                    if (competence == TaxonomyCompetenceTypes.teach && type.getDocumentsLibraryTeachCompetenceReadParentLevels() > 0) {
                        int parentLevels = type.getDocumentsLibraryTeachCompetenceReadParentLevels();
                        TaxonomyTreeNode parent = (TaxonomyTreeNode) node.getParent();
                        for (int i = parentLevels; i-- > 0 && parent != null; ) {
                            parent.setCanRead(true);
                            parent = (TaxonomyTreeNode) parent.getParent();
                        }
                    }
                }
            } else if (isTaxonomyAdmin) {
                hasRead |= hasReadAccess(type, null);
                hasWrite |= hasWriteAccess(type, null);
            }
        }
        node.setCanRead(hasRead);
        node.setCanWrite(hasWrite);
    } else if (node.getType() == TaxonomyTreeNodeType.templates) {
        hasRead = true;
        hasWrite = isTaxonomyAdmin;
        node.setCanRead(hasRead);
        node.setCanWrite(hasWrite);
    }
    for (int i = node.getChildCount(); i-- > 0; ) {
        TaxonomyTreeNode child = (TaxonomyTreeNode) node.getChildAt(i);
        child.setCanRead(hasRead);
        child.setCanWrite(hasWrite);
        computePermissionsRecursive(child, levelToCompetences);
    }
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) ArrayList(java.util.ArrayList) List(java.util.List) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes)

Example 9 with TaxonomyCompetenceTypes

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

the class TaxonomyWebService method addTaxonomyLevelComptencesByIdentity.

private Response addTaxonomyLevelComptencesByIdentity(Long taxonomyLevelKey, TaxonomyCompetenceVO comptenceVo, Identity executor) {
    if (taxonomyLevelKey != null && comptenceVo.getTaxonomyLevelKey() != null && !taxonomyLevelKey.equals(comptenceVo.getTaxonomyLevelKey())) {
        return Response.serverError().status(Status.CONFLICT).build();
    }
    if (taxonomyLevelKey == null) {
        taxonomyLevelKey = comptenceVo.getTaxonomyLevelKey();
    }
    TaxonomyLevel level = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(new Long(taxonomyLevelKey)));
    if (level == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    Identity identity = securityManager.loadIdentityByKey(comptenceVo.getIdentityKey());
    if (identity == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    }
    TaxonomyCompetence competence = null;
    List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyLevelCompetences(level, identity);
    for (TaxonomyCompetence c : competences) {
        if (c.getCompetenceType().name().equals(comptenceVo.getTaxonomyCompetenceType())) {
            competence = c;
        }
    }
    if (competence == null) {
        TaxonomyCompetenceTypes competenceType = TaxonomyCompetenceTypes.valueOf(comptenceVo.getTaxonomyCompetenceType());
        competence = taxonomyService.addTaxonomyLevelCompetences(level, identity, competenceType, comptenceVo.getExpiration());
    } else {
        competence.setExpiration(comptenceVo.getExpiration());
        competence = taxonomyService.updateTaxonomyLevelCompetence(competence);
    }
    String after = taxonomyService.toAuditXml(competence);
    taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.addCompetence, null, after, null, taxonomy, competence, identity, executor);
    return Response.ok(new TaxonomyCompetenceVO(competence)).build();
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) RestSecurityHelper.getIdentity(org.olat.restapi.security.RestSecurityHelper.getIdentity) Identity(org.olat.core.id.Identity)

Example 10 with TaxonomyCompetenceTypes

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

the class TaxonomyCompetenceTypeRenderer method render.

@Override
public void render(Renderer renderer, StringOutput target, Object cellValue, int row, FlexiTableComponent source, URLBuilder ubu, Translator trans) {
    if (cellValue instanceof TaxonomyCompetenceTypes) {
        TaxonomyCompetenceTypes type = (TaxonomyCompetenceTypes) cellValue;
        target.append(translator.translate(type.name()));
    }
}
Also used : 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