Search in sources :

Example 91 with TaxonomyLevel

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

the class MergeTaxonomyLevelController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    if (levels.size() > 1) {
        Collections.sort(levels, new TaxonomyLevelDepthComparator());
    }
    String selectedNodeKey = mergeToEl.getSelectedKey();
    TreeNode selectedNode = treeModel.getNodeById(selectedNodeKey);
    TaxonomyLevel mergeTo = (TaxonomyLevel) selectedNode.getUserObject();
    StringBuilder sb = new StringBuilder();
    for (TaxonomyLevel level : levels) {
        TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(level);
        if (taxonomyService.deleteTaxonomyLevel(taxonomyLevel, mergeTo)) {
            if (sb.length() > 0)
                sb.append(", ");
            sb.append(StringHelper.escapeHtml(taxonomyLevel.getDisplayName()));
        }
    }
    // commit before sending event
    dbInstance.commit();
    fireEvent(ureq, new DeleteTaxonomyLevelEvent());
    showInfo("confirm.merge.level", new String[] { sb.toString() });
}
Also used : TaxonomyLevelDepthComparator(org.olat.modules.taxonomy.ui.component.TaxonomyLevelDepthComparator) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) DeleteTaxonomyLevelEvent(org.olat.modules.taxonomy.ui.events.DeleteTaxonomyLevelEvent)

Example 92 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel 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 93 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel 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 94 with TaxonomyLevel

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

the class TaxonomyLevelLibraryIndexer method checkAccess.

@Override
public boolean checkAccess(ContextEntry contextEntry, BusinessControl businessControl, Identity identity, Roles roles) {
    if (roles.isOLATAdmin())
        return true;
    if ("TaxonomyLevel".equals(contextEntry.getOLATResourceable().getResourceableTypeName())) {
        Long levelKey = contextEntry.getOLATResourceable().getResourceableId();
        TaxonomyLevel level = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(levelKey));
        TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(level.getTaxonomy(), identity, null, false, true, "Templates", null);
        TreeModel model = builder.buildTreeModel();
        List<TreeNode> flat = new ArrayList<>();
        TreeHelper.makeTreeFlat(model.getRootNode(), flat);
        for (TreeNode node : flat) {
            TaxonomyTreeNode taxonomyNode = (TaxonomyTreeNode) node;
            if (taxonomyNode.getType() == TaxonomyTreeNodeType.taxonomyLevel && level.equals(taxonomyNode.getTaxonomyLevel())) {
                if (taxonomyNode.isDocumentsLibraryEnabled() && taxonomyNode.isCanRead()) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyLevelRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl) TaxonomyTreeBuilder(org.olat.modules.taxonomy.manager.TaxonomyTreeBuilder)

Example 95 with TaxonomyLevel

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

the class TaxonomyLevelLibraryIndexer method doIndex.

@Override
public void doIndex(SearchResourceContext parentResourceContext, Object object, OlatFullIndexer indexerWriter) throws IOException, InterruptedException {
    if (object instanceof TaxonomyLevel) {
        TaxonomyLevel level = (TaxonomyLevel) object;
        VFSContainer library = taxonomyService.getDocumentsLibrary(level);
        if (library != null) {
            SearchResourceContext searchResourceContext = new SearchResourceContext(parentResourceContext);
            searchResourceContext.setBusinessControlFor(level);
            searchResourceContext.setTitle(level.getDisplayName());
            searchResourceContext.setDescription(level.getDescription());
            searchResourceContext.setLastModified(level.getLastModified());
            searchResourceContext.setCreatedDate(level.getCreationDate());
            FolderIndexerWorker runnableFolderIndexer = new FolderIndexerWorker();
            runnableFolderIndexer.setAccessRule(FolderIndexerAccess.FULL_ACCESS);
            runnableFolderIndexer.setParentResourceContext(searchResourceContext);
            runnableFolderIndexer.setContainer(library);
            runnableFolderIndexer.setIndexWriter(indexerWriter);
            runnableFolderIndexer.setFilePath("");
            indexerWriter.submit(runnableFolderIndexer);
        }
    }
}
Also used : SearchResourceContext(org.olat.search.service.SearchResourceContext) FolderIndexerWorker(org.olat.search.service.indexer.FolderIndexerWorker) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) VFSContainer(org.olat.core.util.vfs.VFSContainer)

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