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));
}
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);
}
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));
}
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));
}
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);
}
Aggregations