Search in sources :

Example 1 with TaxonomyLevelSearchParameters

use of org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters in project OpenOLAT by OpenOLAT.

the class TaxonomyLevelDAOTest method searchLevelsByDisplayName.

@Test
public void searchLevelsByDisplayName() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-105A", "Named taxonomy", null, null);
    TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("L-1A", "A basic level", "", null, null, null, null, taxonomy);
    TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("L-1G", "A complex level", "", null, null, null, null, taxonomy);
    dbInstance.commitAndCloseSession();
    TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
    searchParams.setQuickSearch("basic");
    List<TaxonomyLevel> levels = taxonomyLevelDao.searchLevels(taxonomy, searchParams);
    Assert.assertNotNull(levels);
    Assert.assertEquals(1, levels.size());
    Assert.assertEquals(level1, levels.get(0));
    Assert.assertNotEquals(level2, levels.get(0));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelSearchParameters(org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters) Test(org.junit.Test)

Example 2 with TaxonomyLevelSearchParameters

use of org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters 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 3 with TaxonomyLevelSearchParameters

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

the class TaxonomyLevelDAOTest method searchLevelsByKey.

@Test
public void searchLevelsByKey() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-105B", "Named taxonomy", null, null);
    TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("L-1E", "A numerated level", "", null, null, null, null, taxonomy);
    TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("L-1F", "A numerated level", "", null, null, null, null, taxonomy);
    dbInstance.commitAndCloseSession();
    // key
    TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
    searchParams.setQuickSearch(level1.getKey().toString());
    List<TaxonomyLevel> levels = taxonomyLevelDao.searchLevels(taxonomy, searchParams);
    Assert.assertNotNull(levels);
    Assert.assertEquals(1, levels.size());
    Assert.assertEquals(level1, levels.get(0));
    Assert.assertNotEquals(level2, levels.get(0));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelSearchParameters(org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters) Test(org.junit.Test)

Example 4 with TaxonomyLevelSearchParameters

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

the class TaxonomyLevelDAOTest method searchLevelsByDisplayName.

@Test
public void searchLevelsByDisplayName() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-105A", "Named taxonomy", null, null);
    TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("L-1A", "A basic level", "", null, null, null, null, taxonomy);
    TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("L-1G", "A complex level", "", null, null, null, null, taxonomy);
    dbInstance.commitAndCloseSession();
    TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
    searchParams.setQuickSearch("basic");
    List<TaxonomyLevel> levels = taxonomyLevelDao.searchLevels(taxonomy, searchParams);
    Assert.assertNotNull(levels);
    Assert.assertEquals(1, levels.size());
    Assert.assertEquals(level1, levels.get(0));
    Assert.assertNotEquals(level2, levels.get(0));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelSearchParameters(org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters) Test(org.junit.Test)

Example 5 with TaxonomyLevelSearchParameters

use of org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters 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

TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)8 TaxonomyLevelSearchParameters (org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters)8 Test (org.junit.Test)6 Taxonomy (org.olat.modules.taxonomy.Taxonomy)6 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