Search in sources :

Example 6 with TaxonomyInfos

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

the class TaxonomyDAO method getTaxonomyInfosList.

public List<TaxonomyInfos> getTaxonomyInfosList() {
    StringBuilder sb = new StringBuilder(256);
    sb.append("select tax, ").append(" (select count(level.key) from ctaxonomylevel level").append("  where level.taxonomy.key=tax.key").append(" ) as numOfLevels").append(" from ctaxonomy tax");
    List<Object[]> objectsList = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Object[].class).getResultList();
    List<TaxonomyInfos> infos = new ArrayList<>(objectsList.size());
    for (Object[] objects : objectsList) {
        Taxonomy taxonomy = (Taxonomy) objects[0];
        Number numOfLevels = (Number) objects[1];
        infos.add(new TaxonomyInfos(taxonomy, numOfLevels == null ? 0 : numOfLevels.intValue()));
    }
    return infos;
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) ArrayList(java.util.ArrayList) TaxonomyInfos(org.olat.modules.taxonomy.model.TaxonomyInfos)

Aggregations

TaxonomyInfos (org.olat.modules.taxonomy.model.TaxonomyInfos)6 ArrayList (java.util.ArrayList)4 Taxonomy (org.olat.modules.taxonomy.Taxonomy)4 Test (org.junit.Test)2