Search in sources :

Example 46 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

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 47 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

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 48 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class TaxonomyTreeTableController method getSelectedTaxonomyLevels.

private List<TaxonomyLevel> getSelectedTaxonomyLevels(TaxonomyLevelManagedFlag flag) {
    Set<Integer> indexList = tableEl.getMultiSelectedIndex();
    List<TaxonomyLevel> allowedLevels = new ArrayList<>(indexList.size());
    for (Integer index : indexList) {
        TaxonomyLevelRow row = model.getObject(index.intValue());
        if (!TaxonomyLevelManagedFlag.isManaged(row.getManagedFlags(), flag)) {
            TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(row);
            if (taxonomyLevel != null) {
                allowedLevels.add(taxonomyLevel);
            }
        }
    }
    return allowedLevels;
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList)

Example 49 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class TaxonomyTreeTableController method doAssignType.

private void doAssignType(UserRequest ureq) {
    if (typeLevelCtrl != null)
        return;
    List<TaxonomyLevel> levelsToMerge = getSelectedTaxonomyLevels(TaxonomyLevelManagedFlag.type);
    if (levelsToMerge.isEmpty()) {
        showWarning("warning.atleastone.level");
    } else {
        typeLevelCtrl = new TypeTaxonomyLevelController(ureq, getWindowControl(), levelsToMerge, taxonomy);
        listenTo(typeLevelCtrl);
        cmc = new CloseableModalController(getWindowControl(), "close", typeLevelCtrl.getInitialComponent(), true, translate("type.taxonomy.level"));
        listenTo(cmc);
        cmc.activate();
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

Example 50 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class TaxonomyTreeTableController method doConfirmDelete.

private void doConfirmDelete(UserRequest ureq, TaxonomyLevelRow row) {
    if (TaxonomyLevelManagedFlag.isManaged(row.getManagedFlags(), TaxonomyLevelManagedFlag.delete)) {
        showWarning("warning.atleastone.level");
        return;
    }
    TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(row);
    List<TaxonomyLevel> levelToDelete = Collections.singletonList(taxonomyLevel);
    confirmDeleteCtrl = new DeleteTaxonomyLevelController(ureq, getWindowControl(), levelToDelete, taxonomy);
    listenTo(confirmDeleteCtrl);
    String title = translate("confirmation.delete.level.title");
    cmc = new CloseableModalController(getWindowControl(), "close", confirmDeleteCtrl.getInitialComponent(), true, title);
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel)

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