Search in sources :

Example 81 with TaxonomyLevel

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

the class MetadataBulkChangeController method formOKGeneral.

private void formOKGeneral(QuestionItemImpl itemImpl) {
    if (isEnabled(topicEl))
        itemImpl.setTopic(topicEl.getValue());
    if (isEnabled(keywordsEl))
        itemImpl.setKeywords(keywordsEl.getValue());
    if (isEnabled(coverageEl))
        itemImpl.setCoverage(coverageEl.getValue());
    if (isEnabled(addInfosEl))
        itemImpl.setAdditionalInformations(addInfosEl.getValue());
    if (isEnabled(languageEl))
        itemImpl.setLanguage(languageEl.getValue());
    if (isEnabled(taxonomyLevelEl)) {
        String selectedKey = taxonomyLevelEl.getSelectedKey();
        TaxonomyLevel taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
        itemImpl.setTaxonomyLevel(taxonomyLevel);
    }
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 82 with TaxonomyLevel

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

the class QPoolTaxonomyTreeBuilder method computeIntendention.

private StringBuilder computeIntendention(TaxonomyLevel level, StringBuilder intendation) {
    TaxonomyLevel parent = level.getParent();
    if (parent != null && selectableTaxonomyLevels.contains(parent)) {
        intendation = intendation.append(INTENDING).append(INTENDING).append(INTENDING).append(INTENDING);
        computeIntendention(parent, intendation);
    }
    return intendation;
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 83 with TaxonomyLevel

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

the class QPoolTaxonomyTreeBuilder method prefillSelectableTaxonomyLevelsArrays.

private void prefillSelectableTaxonomyLevelsArrays() {
    selectableKeys = new String[selectableTaxonomyLevels.size()];
    selectableValues = new String[selectableTaxonomyLevels.size()];
    taxonomicPaths = new String[selectableTaxonomyLevels.size()];
    for (int i = selectableTaxonomyLevels.size(); i-- > 0; ) {
        TaxonomyLevel level = selectableTaxonomyLevels.get(i);
        selectableKeys[i] = Long.toString(level.getKey());
        selectableValues[i] = computeIntendention(level, new StringBuilder()).append(level.getDisplayName()).toString();
        taxonomicPaths[i] = level.getMaterializedPathIdentifiers();
    }
    addEmptyEntry();
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 84 with TaxonomyLevel

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

the class QPoolTaxonomyTreeBuilder method prefillTaxonomyLevels.

private void prefillTaxonomyLevels(INode node) {
    if (node instanceof TaxonomyLevelNode) {
        TaxonomyLevelNode taxonomyLevelNode = (TaxonomyLevelNode) node;
        TaxonomyLevel level = taxonomyLevelNode.getTaxonomyLevel();
        if (level != null) {
            if (acceptSelectableNode(level)) {
                selectableTaxonomyLevels.add(taxonomyLevelNode.getTaxonomyLevel());
            }
            if (acceptTreeNode(level)) {
                treeTaxonomyLevels.add(taxonomyLevelNode.getTaxonomyLevel());
            }
        }
        for (int i = 0; i < node.getChildCount(); i++) {
            prefillTaxonomyLevels(taxonomyLevelNode.getChildAt(i));
        }
    }
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 85 with TaxonomyLevel

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

the class QPoolTaxonomyTreeBuilder method buildTreeModel.

public TreeModel buildTreeModel() {
    GenericTreeModel gtm = new GenericTreeModel();
    TaxonomyLevelNode root = new TaxonomyLevelNode();
    gtm.setRootNode(root);
    List<TaxonomyLevel> taxonomyLevels = qpoolService.getTaxonomyLevels();
    Map<Long, TaxonomyLevel> keytoLevels = taxonomyLevels.stream().collect(Collectors.toMap(l -> l.getKey(), l -> l));
    Map<Long, TaxonomyLevelNode> fieldKeyToNode = new HashMap<>();
    for (TaxonomyLevel taxonomyLevel : taxonomyLevels) {
        Long key = taxonomyLevel.getKey();
        TaxonomyLevelNode node = fieldKeyToNode.get(key);
        if (node == null) {
            node = new TaxonomyLevelNode(taxonomyLevel);
            TaxonomyLevelType type = taxonomyLevel.getType();
            if (type != null && StringHelper.containsNonWhitespace(type.getCssClass())) {
                node.setIconCssClass(type.getCssClass());
            }
            fieldKeyToNode.put(key, node);
        }
        TaxonomyLevel parentLevel = taxonomyLevel.getParent();
        if (parentLevel == null) {
            // this is a root
            root.addChild(node);
        } else {
            Long parentKey = parentLevel.getKey();
            TaxonomyLevelNode parentNode = fieldKeyToNode.get(parentKey);
            if (parentNode == null) {
                // to use the fetched type
                parentLevel = keytoLevels.get(parentKey);
                parentNode = new TaxonomyLevelNode(parentLevel);
                TaxonomyLevelType type = parentLevel.getType();
                if (type != null && StringHelper.containsNonWhitespace(type.getCssClass())) {
                    parentNode.setIconCssClass(type.getCssClass());
                }
                fieldKeyToNode.put(parentKey, parentNode);
            }
            parentNode.addChild(node);
        }
    }
    sort(root);
    return gtm;
}
Also used : INode(org.olat.core.util.nodes.INode) TreeModel(org.olat.core.gui.components.tree.TreeModel) QPoolService(org.olat.modules.qpool.QPoolService) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) QuestionPoolModule(org.olat.modules.qpool.QuestionPoolModule) Collectors(java.util.stream.Collectors) Scope(org.springframework.context.annotation.Scope) ArrayList(java.util.ArrayList) List(java.util.List) Component(org.springframework.stereotype.Component) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) Identity(org.olat.core.id.Identity) Map(java.util.Map) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) StringHelper(org.olat.core.util.StringHelper) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Comparator(java.util.Comparator) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) HashMap(java.util.HashMap) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Aggregations

TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)238 Taxonomy (org.olat.modules.taxonomy.Taxonomy)122 Test (org.junit.Test)106 Identity (org.olat.core.id.Identity)58 ArrayList (java.util.ArrayList)40 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)40 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)24 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)24 URI (java.net.URI)22 HttpResponse (org.apache.http.HttpResponse)22 TreeNode (org.olat.core.gui.components.tree.TreeNode)22 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)18 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)16 HashMap (java.util.HashMap)14 List (java.util.List)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)12 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)12 Path (javax.ws.rs.Path)10