Search in sources :

Example 76 with Taxonomy

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

the class IdentityCompetencesController method doAddTaxonomyLevelsAsCompetence.

private void doAddTaxonomyLevelsAsCompetence(TaxonomyLevel selectedLevel, TaxonomyCompetenceTypes competenceType) {
    if (selectedLevel == null) {
        showWarning("warning.atleastone.level.competence");
    } else {
        boolean found = false;
        List<TaxonomyCompetence> currentCompetences = taxonomyService.getTaxonomyCompetences(assessedIdentity, competenceType);
        for (TaxonomyCompetence currentCompetence : currentCompetences) {
            if (selectedLevel.equals(currentCompetence.getTaxonomyLevel())) {
                found = true;
            }
        }
        if (!found) {
            TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(selectedLevel);
            Taxonomy taxonomy = taxonomyLevel.getTaxonomy();
            TaxonomyCompetence competence = taxonomyService.addTaxonomyLevelCompetences(taxonomyLevel, assessedIdentity, competenceType, null);
            String after = taxonomyService.toAuditXml(competence);
            taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.addCompetence, null, after, null, taxonomy, competence, assessedIdentity, getIdentity());
        }
        loadModel();
        tableEl.reset(true, true, true);
    }
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence)

Example 77 with Taxonomy

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

the class MoveTaxonomyLevelController method loadModel.

private void loadModel() {
    new TaxonomyAllTreesBuilder().loadTreeModel(taxonomyModel, taxonomy);
    // remove children of the level to move
    for (TaxonomyLevel levelToMove : levelsToMove) {
        TreeNode nodeToMove = taxonomyModel.getNodeById(TaxonomyAllTreesBuilder.nodeKey(levelToMove));
        nodeToMove.removeAllChildren();
    }
    // remove the level with
    List<TreeNode> openedNodes = new ArrayList<>();
    filterByAllowedTypes(taxonomyModel.getRootNode(), openedNodes);
    taxonomyModel.sort(taxonomyModel.getRootNode());
    List<String> nodeIds = openedNodes.stream().map(node -> node.getIdent()).collect(Collectors.toList());
    taxonomyEl.setOpenNodeIds(nodeIds);
}
Also used : INode(org.olat.core.util.nodes.INode) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) TaxonomyModel(org.olat.modules.taxonomy.model.TaxonomyModel) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) Map(java.util.Map) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Taxonomy(org.olat.modules.taxonomy.Taxonomy) MenuTreeItem(org.olat.core.gui.components.tree.MenuTreeItem) WindowControl(org.olat.core.gui.control.WindowControl) Set(java.util.Set) Collectors(java.util.stream.Collectors) Controller(org.olat.core.gui.control.Controller) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) List(java.util.List) TaxonomyAllTreesBuilder(org.olat.modules.taxonomy.manager.TaxonomyAllTreesBuilder) TreeNode(org.olat.core.gui.components.tree.TreeNode) UserRequest(org.olat.core.gui.UserRequest) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) TaxonomyAllTreesBuilder(org.olat.modules.taxonomy.manager.TaxonomyAllTreesBuilder)

Example 78 with Taxonomy

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

the class MoveTaxonomyLevelController method getAllowedTypes.

private Set<TaxonomyLevelType> getAllowedTypes() {
    List<TaxonomyLevelType> allTypes = new ArrayList<>(taxonomyService.getTaxonomyLevelTypes(taxonomy));
    Map<TaxonomyLevelType, Set<TaxonomyLevelType>> subToParentTypes = new HashMap<>();
    for (TaxonomyLevelType type : allTypes) {
        Set<TaxonomyLevelTypeToType> typesToTypes = type.getAllowedTaxonomyLevelSubTypes();
        for (TaxonomyLevelTypeToType typeToType : typesToTypes) {
            TaxonomyLevelType subTyp = typeToType.getAllowedSubTaxonomyLevelType();
            subToParentTypes.computeIfAbsent(subTyp, t -> new HashSet<>()).add(type);
        }
    }
    Set<TaxonomyLevelType> analyzedTypes = new HashSet<>();
    for (TaxonomyLevel level : levelsToMove) {
        TaxonomyLevelType levelType = level.getType();
        if (levelType != null && !analyzedTypes.contains(levelType)) {
            analyzedTypes.add(levelType);
            Set<TaxonomyLevelType> allowed = subToParentTypes.get(levelType);
            if (allowed != null) {
                allTypes.retainAll(allowed);
            }
        }
    }
    return new HashSet<>(allTypes);
}
Also used : INode(org.olat.core.util.nodes.INode) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) TaxonomyModel(org.olat.modules.taxonomy.model.TaxonomyModel) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Event(org.olat.core.gui.control.Event) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) FormItemContainer(org.olat.core.gui.components.form.flexible.FormItemContainer) TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) Map(java.util.Map) GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Taxonomy(org.olat.modules.taxonomy.Taxonomy) MenuTreeItem(org.olat.core.gui.components.tree.MenuTreeItem) WindowControl(org.olat.core.gui.control.WindowControl) Set(java.util.Set) Collectors(java.util.stream.Collectors) Controller(org.olat.core.gui.control.Controller) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) List(java.util.List) TaxonomyAllTreesBuilder(org.olat.modules.taxonomy.manager.TaxonomyAllTreesBuilder) TreeNode(org.olat.core.gui.components.tree.TreeNode) UserRequest(org.olat.core.gui.UserRequest) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) HashSet(java.util.HashSet)

Example 79 with Taxonomy

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

the class TaxonomyTemplatesLibraryIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext parentResourceContext, Object parentObject, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    Taxonomy taxonomy = (Taxonomy) parentObject;
    VFSContainer templatesContainer = taxonomyService.getDocumentsLibrary(taxonomy);
    if (templatesContainer != null) {
        SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
        OLATResourceable templateOres = OresHelper.createOLATResourceableInstance(getSupportedTypeName(), 0l);
        searchResourceContext.setBusinessControlFor(templateOres);
        FolderIndexerWorker runnableFolderIndexer = new FolderIndexerWorker();
        runnableFolderIndexer.setAccessRule(FolderIndexerAccess.FULL_ACCESS);
        runnableFolderIndexer.setParentResourceContext(searchResourceContext);
        runnableFolderIndexer.setContainer(templatesContainer);
        runnableFolderIndexer.setIndexWriter(indexerWriter);
        runnableFolderIndexer.setFilePath("");
        indexerWriter.submit(runnableFolderIndexer);
    }
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) SearchResourceContext(org.olat.search.service.SearchResourceContext) OLATResourceable(org.olat.core.id.OLATResourceable) FolderIndexerWorker(org.olat.search.service.indexer.FolderIndexerWorker) VFSContainer(org.olat.core.util.vfs.VFSContainer)

Example 80 with Taxonomy

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

the class TaxonomyTreeBuilder method buildTreeModel.

public TreeModel buildTreeModel() {
    GenericTreeModel gtm = new GenericTreeModel();
    TaxonomyTreeNode root = new TaxonomyTreeNode(taxonomy);
    root.setTitle("ROOT competence");
    gtm.setRootNode(root);
    if (taxonomy != null) {
        taxonomy = taxonomyService.getTaxonomy(taxonomy);
        if (StringHelper.containsNonWhitespace(rootTitle)) {
            root.setTitle(rootTitle);
        } else {
            root.setTitle(taxonomy.getDisplayName());
        }
        root.setUserObject(taxonomy);
        // taxonomy directory
        if (enableTemplates) {
            VFSContainer taxonomyDirectory = taxonomyService.getDocumentsLibrary(taxonomy);
            TaxonomyTreeNode taxonomyDirectorNode = new TaxonomyTreeNode(taxonomy, taxonomyDirectory, TaxonomyTreeNodeType.templates);
            if (locale == null) {
                locale = CoreSpringFactory.getImpl(I18nManager.class).getCurrentThreadLocale();
            }
            taxonomyDirectorNode.setTitle(templateDirectory);
            taxonomyDirectorNode.setUserObject(taxonomyDirectory);
            root.addChild(taxonomyDirectorNode);
        }
        // taxonomy levels
        List<TaxonomyLevel> levels = taxonomyService.getTaxonomyLevels(taxonomy);
        Map<Long, TaxonomyLevel> keytoLevels = levels.stream().collect(Collectors.toMap(l -> l.getKey(), l -> l));
        Map<Long, TaxonomyTreeNode> fieldKeyToNode = new HashMap<>();
        for (TaxonomyLevel taxonomyLevel : levels) {
            Long key = taxonomyLevel.getKey();
            TaxonomyTreeNode node = fieldKeyToNode.get(key);
            if (node == null) {
                node = new TaxonomyTreeNode(taxonomy, taxonomyLevel, getType(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();
                TaxonomyTreeNode parentNode = fieldKeyToNode.get(parentKey);
                if (parentNode == null) {
                    // to use the fetched type
                    parentLevel = keytoLevels.get(parentKey);
                    parentNode = new TaxonomyTreeNode(taxonomy, parentLevel, getType(parentLevel));
                    TaxonomyLevelType type = parentLevel.getType();
                    if (type != null && StringHelper.containsNonWhitespace(type.getCssClass())) {
                        parentNode.setIconCssClass(type.getCssClass());
                    }
                    fieldKeyToNode.put(parentKey, parentNode);
                }
                parentNode.addChild(node);
            }
        }
        computePermissions(root);
        trimVisiblity(root);
        sort(root);
    }
    return gtm;
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) Date(java.util.Date) I18nManager(org.olat.core.util.i18n.I18nManager) CoreSpringFactory(org.olat.core.CoreSpringFactory) HashMap(java.util.HashMap) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) Collectors(java.util.stream.Collectors) VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) TaxonomyTreeNodeType(org.olat.modules.taxonomy.model.TaxonomyTreeNodeType) List(java.util.List) Locale(java.util.Locale) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) Identity(org.olat.core.id.Identity) TaxonomyModule(org.olat.modules.taxonomy.TaxonomyModule) TaxonomyService(org.olat.modules.taxonomy.TaxonomyService) Map(java.util.Map) StringHelper(org.olat.core.util.StringHelper) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) HashMap(java.util.HashMap) VFSContainer(org.olat.core.util.vfs.VFSContainer) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel)

Aggregations

Taxonomy (org.olat.modules.taxonomy.Taxonomy)194 Test (org.junit.Test)132 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)122 Identity (org.olat.core.id.Identity)56 URI (java.net.URI)36 HttpResponse (org.apache.http.HttpResponse)36 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)36 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)22 HttpGet (org.apache.http.client.methods.HttpGet)16 ArrayList (java.util.ArrayList)14 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)14 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)14 HttpPut (org.apache.http.client.methods.HttpPut)12 HashMap (java.util.HashMap)10 List (java.util.List)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)10 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)10