Search in sources :

Example 1 with FlexiTreeNodeComparator

use of org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeNodeComparator in project OpenOLAT by OpenOLAT.

the class TaxonomyTreeTableController method loadModel.

private void loadModel(boolean resetPage, boolean resetInternal) {
    TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
    searchParams.setQuickSearch(tableEl.getQuickSearchString());
    List<TaxonomyLevel> taxonomyLevels = taxonomyService.getTaxonomyLevels(taxonomy, searchParams);
    List<TaxonomyLevelRow> rows = new ArrayList<>(taxonomyLevels.size());
    Map<Long, TaxonomyLevelRow> levelToRows = new HashMap<>();
    for (TaxonomyLevel taxonomyLevel : taxonomyLevels) {
        TaxonomyLevelRow row = forgeRow(taxonomyLevel);
        rows.add(row);
        levelToRows.put(taxonomyLevel.getKey(), row);
    }
    for (TaxonomyLevelRow row : rows) {
        Long parentLevelKey = row.getParentLevelKey();
        TaxonomyLevelRow parentRow = levelToRows.get(parentLevelKey);
        row.setParent(parentRow);
    }
    for (TaxonomyLevelRow row : rows) {
        for (FlexiTreeTableNode parent = row.getParent(); parent != null; parent = parent.getParent()) {
            ((TaxonomyLevelRow) parent).incrementNumberOfChildren();
        }
    }
    Collections.sort(rows, new FlexiTreeNodeComparator());
    model.setObjects(rows);
    tableEl.reset(resetPage, resetInternal, true);
}
Also used : FlexiTreeTableNode(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeTableNode) HashMap(java.util.HashMap) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelSearchParameters(org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters) ArrayList(java.util.ArrayList) FlexiTreeNodeComparator(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeNodeComparator)

Example 2 with FlexiTreeNodeComparator

use of org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeNodeComparator in project openolat by klemens.

the class TaxonomyTreeTableController method loadModel.

private void loadModel(boolean resetPage, boolean resetInternal) {
    TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
    searchParams.setQuickSearch(tableEl.getQuickSearchString());
    List<TaxonomyLevel> taxonomyLevels = taxonomyService.getTaxonomyLevels(taxonomy, searchParams);
    List<TaxonomyLevelRow> rows = new ArrayList<>(taxonomyLevels.size());
    Map<Long, TaxonomyLevelRow> levelToRows = new HashMap<>();
    for (TaxonomyLevel taxonomyLevel : taxonomyLevels) {
        TaxonomyLevelRow row = forgeRow(taxonomyLevel);
        rows.add(row);
        levelToRows.put(taxonomyLevel.getKey(), row);
    }
    for (TaxonomyLevelRow row : rows) {
        Long parentLevelKey = row.getParentLevelKey();
        TaxonomyLevelRow parentRow = levelToRows.get(parentLevelKey);
        row.setParent(parentRow);
    }
    for (TaxonomyLevelRow row : rows) {
        for (FlexiTreeTableNode parent = row.getParent(); parent != null; parent = parent.getParent()) {
            ((TaxonomyLevelRow) parent).incrementNumberOfChildren();
        }
    }
    Collections.sort(rows, new FlexiTreeNodeComparator());
    model.setObjects(rows);
    tableEl.reset(resetPage, resetInternal, true);
}
Also used : FlexiTreeTableNode(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeTableNode) HashMap(java.util.HashMap) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelSearchParameters(org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters) ArrayList(java.util.ArrayList) FlexiTreeNodeComparator(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeNodeComparator)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 FlexiTreeNodeComparator (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeNodeComparator)2 FlexiTreeTableNode (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeTableNode)2 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)2 TaxonomyLevelSearchParameters (org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters)2