Search in sources :

Example 1 with TaxonomyInfos

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

the class TaxonomyListAdminController method loadModel.

private void loadModel() {
    List<TaxonomyInfos> taxonomyList = taxonomyService.getTaxonomyInfosList();
    List<TaxonomyRow> rows = new ArrayList<>(taxonomyList.size());
    for (TaxonomyInfos taxonomy : taxonomyList) {
        rows.add(forgeTaxonomyRow(taxonomy));
    }
    model.setObjects(rows);
    tableEl.reset(true, true, true);
}
Also used : ArrayList(java.util.ArrayList) TaxonomyInfos(org.olat.modules.taxonomy.model.TaxonomyInfos)

Example 2 with TaxonomyInfos

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

the class TaxonomyDAOTest method getTaxonomyInfosList.

@Test
public void getTaxonomyInfosList() {
    Taxonomy taxonomy0 = taxonomyDao.createTaxonomy("ID40", "An other taxonomy", "A little taxonomy", "REF-40");
    Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID41", "An other taxonomy", "A little taxonomy", "REF-41");
    dbInstance.commitAndCloseSession();
    List<TaxonomyInfos> infosList = taxonomyDao.getTaxonomyInfosList();
    Assert.assertNotNull(infosList);
    int found = 0;
    for (TaxonomyInfos info : infosList) {
        if (info.getKey().equals(taxonomy0.getKey()) || info.getKey().equals(taxonomy1.getKey())) {
            found++;
        }
    }
    Assert.assertEquals(2, found);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyInfos(org.olat.modules.taxonomy.model.TaxonomyInfos) Test(org.junit.Test)

Example 3 with TaxonomyInfos

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

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)

Example 4 with TaxonomyInfos

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

the class TaxonomyDAOTest method getTaxonomyInfosList.

@Test
public void getTaxonomyInfosList() {
    Taxonomy taxonomy0 = taxonomyDao.createTaxonomy("ID40", "An other taxonomy", "A little taxonomy", "REF-40");
    Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID41", "An other taxonomy", "A little taxonomy", "REF-41");
    dbInstance.commitAndCloseSession();
    List<TaxonomyInfos> infosList = taxonomyDao.getTaxonomyInfosList();
    Assert.assertNotNull(infosList);
    int found = 0;
    for (TaxonomyInfos info : infosList) {
        if (info.getKey().equals(taxonomy0.getKey()) || info.getKey().equals(taxonomy1.getKey())) {
            found++;
        }
    }
    Assert.assertEquals(2, found);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyInfos(org.olat.modules.taxonomy.model.TaxonomyInfos) Test(org.junit.Test)

Example 5 with TaxonomyInfos

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

the class TaxonomyListAdminController method loadModel.

private void loadModel() {
    List<TaxonomyInfos> taxonomyList = taxonomyService.getTaxonomyInfosList();
    List<TaxonomyRow> rows = new ArrayList<>(taxonomyList.size());
    for (TaxonomyInfos taxonomy : taxonomyList) {
        rows.add(forgeTaxonomyRow(taxonomy));
    }
    model.setObjects(rows);
    tableEl.reset(true, true, true);
}
Also used : 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