use of org.olat.modules.taxonomy.Taxonomy 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);
}
use of org.olat.modules.taxonomy.Taxonomy in project openolat by klemens.
the class TaxonomyLevelDAOTest method moveTaxonomyLevel_toRoot.
@Test
public void moveTaxonomyLevel_toRoot() {
// prepare some levels
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-107", "Large moving taxonomy", null, null);
String displayName = UUID.randomUUID().toString();
TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("U-1", displayName, "A basic level", null, null, null, null, taxonomy);
TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("U-2", displayName, "A basic level", null, null, level1, null, taxonomy);
TaxonomyLevel level3 = taxonomyLevelDao.createTaxonomyLevel("U-3", displayName, "A basic level", null, null, level2, null, taxonomy);
TaxonomyLevel level4_1 = taxonomyLevelDao.createTaxonomyLevel("U-4-1", displayName, "A basic level", null, null, level3, null, taxonomy);
TaxonomyLevel level4_2 = taxonomyLevelDao.createTaxonomyLevel("U-4-2", displayName, "A basic level", null, null, level3, null, taxonomy);
dbInstance.commitAndCloseSession();
// move the level 2
TaxonomyLevel reloadedLevel3 = taxonomyLevelDao.loadByKey(level3.getKey());
TaxonomyLevel movedLevel3 = taxonomyLevelDao.moveTaxonomyLevel(reloadedLevel3, null);
dbInstance.commitAndCloseSession();
// check the different levels paths
TaxonomyLevel reloadedMovedLevel3 = taxonomyLevelDao.loadByKey(movedLevel3.getKey());
String identifiersPath3 = reloadedMovedLevel3.getMaterializedPathIdentifiers();
Assert.assertEquals("/U-3/", identifiersPath3);
TaxonomyLevel movedLevel4_1 = taxonomyLevelDao.loadByKey(level4_1.getKey());
String identifiersPath4_1 = movedLevel4_1.getMaterializedPathIdentifiers();
Assert.assertEquals("/U-3/U-4-1/", identifiersPath4_1);
TaxonomyLevel movedLevel4_2 = taxonomyLevelDao.loadByKey(level4_2.getKey());
String identifiersPath4_2 = movedLevel4_2.getMaterializedPathIdentifiers();
Assert.assertEquals("/U-3/U-4-2/", identifiersPath4_2);
}
use of org.olat.modules.taxonomy.Taxonomy 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.Taxonomy 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.Taxonomy in project openolat by klemens.
the class TaxonomyLevelDAOTest method getLevelsByExternalId.
@Test
public void getLevelsByExternalId() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-103", "Externalized taxonomy", null, null);
String externalId = UUID.randomUUID().toString();
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("L-1", "A level", "A basic level", externalId, null, null, null, taxonomy);
dbInstance.commitAndCloseSession();
List<TaxonomyLevel> levels = taxonomyLevelDao.getLevelsByExternalId(taxonomy, externalId);
Assert.assertNotNull(levels);
Assert.assertEquals(1, levels.size());
Assert.assertEquals(level, levels.get(0));
}
Aggregations