Search in sources :

Example 16 with TaxonomyLevel

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

the class TaxonomyTreeNodeComparator method compare.

@Override
public int compare(INode i1, INode i2) {
    if (i1 == null || i2 == null) {
        return compareNullObjects(i1, i2);
    }
    Integer s1 = null;
    Integer s2 = null;
    String title1 = null;
    String title2 = null;
    TaxonomyTreeNodeType type1 = null;
    TaxonomyTreeNodeType type2 = null;
    if (i1 instanceof TaxonomyTreeNode) {
        TaxonomyTreeNode t1 = (TaxonomyTreeNode) i1;
        title1 = t1.getTitle();
        type1 = t1.getType();
        if (t1.getTaxonomyLevel() != null) {
            s1 = t1.getTaxonomyLevel().getSortOrder();
        }
    } else if (i1 instanceof GenericTreeNode) {
        GenericTreeNode node = (GenericTreeNode) i1;
        title1 = node.getTitle();
        Object uobject = node.getUserObject();
        if (uobject instanceof TaxonomyLevel) {
            TaxonomyLevel level = (TaxonomyLevel) uobject;
            type1 = TaxonomyTreeNodeType.taxonomyLevel;
            s1 = level.getSortOrder();
        }
    }
    if (i2 instanceof TaxonomyTreeNode) {
        TaxonomyTreeNode t2 = (TaxonomyTreeNode) i2;
        title2 = t2.getTitle();
        type2 = t2.getType();
        if (t2.getTaxonomyLevel() != null) {
            s2 = t2.getTaxonomyLevel().getSortOrder();
        }
    } else if (i1 instanceof GenericTreeNode) {
        GenericTreeNode node = (GenericTreeNode) i2;
        title2 = node.getTitle();
        Object uobject = node.getUserObject();
        if (uobject instanceof TaxonomyLevel) {
            TaxonomyLevel level = (TaxonomyLevel) uobject;
            type2 = TaxonomyTreeNodeType.taxonomyLevel;
            s2 = level.getSortOrder();
        }
    }
    int c = 0;
    if (type1 == TaxonomyTreeNodeType.templates && type2 == TaxonomyTreeNodeType.templates) {
        c = 0;
    } else if (type1 == TaxonomyTreeNodeType.templates) {
        return -1;
    } else if (type2 == TaxonomyTreeNodeType.templates) {
        return 1;
    }
    if (type1 == TaxonomyTreeNodeType.lostAndFound && type2 == TaxonomyTreeNodeType.lostAndFound) {
        c = 0;
    } else if (type1 == TaxonomyTreeNodeType.lostAndFound) {
        return 1;
    } else if (type2 == TaxonomyTreeNodeType.lostAndFound) {
        return -1;
    }
    if (c == 0) {
        if (s1 == null || s2 == null) {
            c = compareNullObjects(s1, s2);
        } else {
            c = s1.compareTo(s2);
        }
    }
    if (c == 0) {
        if (title1 == null || title2 == null) {
            c = compareNullObjects(title1, title2);
        } else {
            c = title1.compareTo(title2);
        }
    }
    return c;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyTreeNode(org.olat.modules.taxonomy.model.TaxonomyTreeNode) TaxonomyTreeNodeType(org.olat.modules.taxonomy.model.TaxonomyTreeNodeType)

Example 17 with TaxonomyLevel

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

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

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

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)

Example 19 with TaxonomyLevel

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

the class EditTaxonomyLevelController method getTypes.

private List<TaxonomyLevelType> getTypes() {
    List<TaxonomyLevelType> types = new ArrayList<>();
    if (level != null) {
        List<TaxonomyLevel> parentLine = taxonomyService.getTaxonomyLevelParentLine(level, taxonomy);
        for (int i = parentLine.size() - 1; i-- > 0; ) {
            TaxonomyLevel parent = parentLine.get(i);
            TaxonomyLevelType parentType = parent.getType();
            if (parentType != null) {
                Set<TaxonomyLevelTypeToType> typeToTypes = parentType.getAllowedTaxonomyLevelSubTypes();
                for (TaxonomyLevelTypeToType typeToType : typeToTypes) {
                    if (typeToType != null) {
                        types.add(typeToType.getAllowedSubTaxonomyLevelType());
                    }
                }
                break;
            }
        }
    }
    if (types.isEmpty()) {
        types.addAll(taxonomyService.getTaxonomyLevelTypes(taxonomy));
    } else if (level != null && level.getType() != null) {
        if (!types.contains(level.getType())) {
            types.add(level.getType());
        }
    }
    return types;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType)

Example 20 with TaxonomyLevel

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

the class EditTaxonomyLevelController method buildPathKeysAndValues.

private void buildPathKeysAndValues(List<String> pathKeyList, List<String> pathValueList) {
    pathKeyList.add("-");
    pathValueList.add("");
    List<TreeNode> nodeList = new TaxonomyAllTreesBuilder().getFlattedModel(taxonomy, false);
    for (TreeNode node : nodeList) {
        TaxonomyLevel taxonomyLevel = (TaxonomyLevel) node.getUserObject();
        pathKeyList.add(taxonomyLevel.getKey().toString());
        pathValueList.add(taxonomyLevel.getMaterializedPathIdentifiers());
    }
}
Also used : TreeNode(org.olat.core.gui.components.tree.TreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyAllTreesBuilder(org.olat.modules.taxonomy.manager.TaxonomyAllTreesBuilder)

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