Search in sources :

Example 96 with TaxonomyLevel

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

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

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

the class DeleteTaxonomyLevelController method initForm.

private void initForm(FormItemContainer formLayout, UserRequest ureq) {
    StringBuilder sb = new StringBuilder();
    for (TaxonomyLevel level : levels) {
        if (sb.length() > 0)
            sb.append(", ");
        sb.append(StringHelper.escapeHtml(level.getDisplayName()));
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        String text = translate("confirmation.delete.level", new String[] { sb.toString() });
        layoutCont.contextPut("msg", text);
        layoutCont.contextPut("msgForList", translate("error.delete.num"));
        buildDangerMessage(layoutCont);
    }
    List<String> keyList = new ArrayList<>();
    List<String> valueList = new ArrayList<>();
    keyList.add("-");
    valueList.add("-");
    buildMergeToSelection(treeModel.getRootNode(), "", keyList, valueList);
    mergeToEl = uifactory.addDropdownSingleselect("mergeto", "merge.to", formLayout, keyList.toArray(new String[keyList.size()]), valueList.toArray(new String[valueList.size()]), null);
    mergeToEl.setEscapeHtml(false);
    uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    uifactory.addFormSubmitButton("delete", formLayout);
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 98 with TaxonomyLevel

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

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

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

the class IdentityCompetenceRow method isManaged.

public boolean isManaged() {
    TaxonomyLevel level = competence.getTaxonomyLevel();
    TaxonomyCompetenceTypes competenceType = competence.getCompetenceType();
    TaxonomyLevelManagedFlag marker = TaxonomyLevelManagedFlag.getCorrespondingFlag(competenceType);
    return TaxonomyLevelManagedFlag.isManaged(level, marker);
}
Also used : TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) TaxonomyLevelManagedFlag(org.olat.modules.taxonomy.TaxonomyLevelManagedFlag)

Example 100 with TaxonomyLevel

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

the class TaxonomyLevelDAO method updateTaxonomyLevel.

public TaxonomyLevel updateTaxonomyLevel(TaxonomyLevel level) {
    TaxonomyLevel parentLevel = getParent(level);
    String path = level.getMaterializedPathIdentifiers();
    String newPath = getMaterializedPathIdentifiers(parentLevel, level);
    boolean updatePath = !newPath.equals(path);
    if (updatePath) {
        ((TaxonomyLevelImpl) level).setMaterializedPathIdentifiers(newPath);
    }
    ((TaxonomyLevelImpl) level).setLastModified(new Date());
    TaxonomyLevel mergedLevel = dbInstance.getCurrentEntityManager().merge(level);
    if (updatePath) {
        List<TaxonomyLevel> descendants = getDescendants(mergedLevel, mergedLevel.getTaxonomy());
        for (TaxonomyLevel descendant : descendants) {
            String descendantPath = descendant.getMaterializedPathIdentifiers();
            if (descendantPath.indexOf(path) == 0) {
                String end = descendantPath.substring(path.length(), descendantPath.length());
                String updatedPath = newPath + end;
                ((TaxonomyLevelImpl) descendant).setMaterializedPathIdentifiers(updatedPath);
            }
            dbInstance.getCurrentEntityManager().merge(descendant);
        }
    }
    return mergedLevel;
}
Also used : TaxonomyLevelImpl(org.olat.modules.taxonomy.model.TaxonomyLevelImpl) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Date(java.util.Date)

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