Search in sources :

Example 46 with TaxonomyLevelType

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

the class TaxonomyLibraryIndexer method doIndexTaxonomyLibrary.

protected void doIndexTaxonomyLibrary(SearchResourceContext searchResourceContext, Taxonomy taxonomy, OlatFullIndexer indexerWriter) throws InterruptedException {
    VFSContainer templatesContainer = taxonomyService.getDocumentsLibrary(taxonomy);
    if (templatesContainer != null) {
        try {
            taxonomyTemplatesLibraryIndexer.doIndex(searchResourceContext, taxonomy, indexerWriter);
        } catch (InterruptedException e) {
            throw e;
        } catch (Exception e) {
            logError("", e);
        }
    }
    List<TaxonomyLevel> levels = taxonomyService.getTaxonomyLevels(taxonomy);
    for (TaxonomyLevel level : levels) {
        TaxonomyLevelType type = level.getType();
        if (type != null && hasDocumentLibraryEnabled(type)) {
            try {
                taxonomyLevelLibraryIndexer.doIndex(searchResourceContext, level, indexerWriter);
            } catch (InterruptedException e) {
                throw e;
            } catch (Exception e) {
                logError("", e);
            }
        }
    }
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType)

Example 47 with TaxonomyLevelType

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

the class MoveTaxonomyLevelController method filterByAllowedTypes.

private boolean filterByAllowedTypes(TreeNode node, List<TreeNode> openedNodes) {
    ((GenericTreeNode) node).setIconCssClass(null);
    for (int i = node.getChildCount(); i-- > 0; ) {
        boolean ok = filterByAllowedTypes((TreeNode) node.getChildAt(i), openedNodes);
        if (!ok) {
            node.remove(node.getChildAt(i));
        }
    }
    boolean ok = false;
    Object uobject = node.getUserObject();
    if (uobject instanceof TaxonomyLevel) {
        TaxonomyLevel level = (TaxonomyLevel) uobject;
        TaxonomyLevelType type = level.getType();
        if (type == null || allowedTypes.contains(type)) {
            openedNodes.add(node);
            ((GenericTreeNode) node).setIconCssClass("o_icon_node_under o_icon-rotate-180");
            targetableNodes.add(node);
            ok = true;
        } else if (node.getChildCount() > 0) {
            openedNodes.add(node);
            ok = true;
        }
    } else {
        targetableNodes.add(node);
        openedNodes.add(node);
        ok = true;
    }
    return ok;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType)

Example 48 with TaxonomyLevelType

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

the class TaxonomyTreeTableController method getFilters.

private List<FlexiTableFilter> getFilters() {
    List<TaxonomyLevelType> types = taxonomyService.getTaxonomyLevelTypes(taxonomy);
    List<FlexiTableFilter> resources = new ArrayList<>(types.size() + 1);
    for (TaxonomyLevelType type : types) {
        resources.add(new FlexiTableFilter(type.getDisplayName(), type.getKey().toString()));
    }
    resources.add(new FlexiTableFilter(translate("filter.no.level.type"), "-"));
    resources.add(FlexiTableFilter.SPACER);
    resources.add(new FlexiTableFilter(translate("show.all"), "all", true));
    return resources;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) FlexiTableFilter(org.olat.core.gui.components.form.flexible.elements.FlexiTableFilter) ArrayList(java.util.ArrayList)

Example 49 with TaxonomyLevelType

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

the class TypeTaxonomyLevelController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    String selectedTypeKey = typeEl.getSelectedKey();
    TaxonomyLevelType selectedType = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(Long.valueOf(selectedTypeKey)));
    for (TaxonomyLevel level : levels) {
        level.setType(selectedType);
        level = taxonomyService.updateTaxonomyLevel(level);
    }
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelTypeRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl)

Example 50 with TaxonomyLevelType

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

the class TypeTaxonomyLevelController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (availableTypes.isEmpty()) {
        if (formLayout instanceof FormLayoutContainer) {
            FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
            layoutCont.contextPut("errorMsg", translate("error.found.no.allowed.sub.types"));
        }
        uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    } else {
        String[] theKeys = new String[availableTypes.size()];
        String[] theValues = new String[availableTypes.size()];
        for (int i = availableTypes.size(); i-- > 0; ) {
            TaxonomyLevelType type = availableTypes.get(i);
            theKeys[i] = type.getKey().toString();
            theValues[i] = type.getDisplayName();
        }
        typeEl = uifactory.addDropdownSingleselect("types", "level.types.to.assign", formLayout, theKeys, theValues, null);
        uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
        uifactory.addFormSubmitButton("assign.type", formLayout);
    }
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Aggregations

TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)92 Test (org.junit.Test)40 Taxonomy (org.olat.modules.taxonomy.Taxonomy)32 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)32 ArrayList (java.util.ArrayList)26 Identity (org.olat.core.id.Identity)20 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)16 URI (java.net.URI)14 HttpResponse (org.apache.http.HttpResponse)14 TaxonomyLevelTypeRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl)14 Path (javax.ws.rs.Path)12 List (java.util.List)10 Produces (javax.ws.rs.Produces)10 Collectors (java.util.stream.Collectors)8 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 PUT (javax.ws.rs.PUT)6 HttpGet (org.apache.http.client.methods.HttpGet)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6