Search in sources :

Example 66 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel 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));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Example 67 with TaxonomyLevel

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

the class TaxonomyLevelDAOTest method getLevelsByDisplayName.

@Test
public void getLevelsByDisplayName() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-104", "Named taxonomy", null, null);
    String displayName = UUID.randomUUID().toString();
    TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("L-1", displayName, "A basic level", null, null, null, null, taxonomy);
    dbInstance.commitAndCloseSession();
    List<TaxonomyLevel> levels = taxonomyLevelDao.getLevelsByDisplayName(taxonomy, displayName);
    Assert.assertNotNull(levels);
    Assert.assertEquals(1, levels.size());
    Assert.assertEquals(level, levels.get(0));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Example 68 with TaxonomyLevel

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

the class TaxonomyLevelDAOTest method createTaxonomyCompetence_2Level.

@Test
public void createTaxonomyCompetence_2Level() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-99", "Leveled taxonomy", null, null);
    TaxonomyLevel rootLevel = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "My root level", "A basic level", null, null, null, null, taxonomy);
    dbInstance.commit();
    TaxonomyLevel secondLevel = taxonomyLevelDao.createTaxonomyLevel("ID-Level-2", "My second level", "A basic level", null, null, rootLevel, null, taxonomy);
    dbInstance.commit();
    TaxonomyLevel reloadedSecondLevel = taxonomyLevelDao.loadByKey(secondLevel.getKey());
    Assert.assertNotNull(reloadedSecondLevel);
    Assert.assertNotNull(reloadedSecondLevel.getKey());
    Assert.assertNotNull(reloadedSecondLevel.getCreationDate());
    Assert.assertEquals(taxonomy, reloadedSecondLevel.getTaxonomy());
    Assert.assertEquals(rootLevel, reloadedSecondLevel.getParent());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Example 69 with TaxonomyLevel

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

the class TaxonomyLevelDAOTest method getParentLine.

@Test
public void getParentLine() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-103", "Deeply leveled taxonomy", null, null);
    TaxonomyLevel level_1 = taxonomyLevelDao.createTaxonomyLevel("L-1", "A level", "A basic level", null, null, null, null, taxonomy);
    TaxonomyLevel level_2 = taxonomyLevelDao.createTaxonomyLevel("L-2", "A level", "A basic level", null, null, level_1, null, taxonomy);
    TaxonomyLevel level_3 = taxonomyLevelDao.createTaxonomyLevel("L-3", "A level", "A basic level", null, null, level_2, null, taxonomy);
    TaxonomyLevel level_4 = taxonomyLevelDao.createTaxonomyLevel("L-4", "A level", "A basic level", null, null, level_3, null, taxonomy);
    TaxonomyLevel level_5 = taxonomyLevelDao.createTaxonomyLevel("L-5", "A level", "A basic level", null, null, level_4, null, taxonomy);
    dbInstance.commit();
    List<TaxonomyLevel> levels = taxonomyLevelDao.getParentLine(level_5, taxonomy);
    Assert.assertNotNull(levels);
    Assert.assertEquals(5, levels.size());
    Assert.assertEquals(level_1, levels.get(0));
    Assert.assertEquals(level_2, levels.get(1));
    Assert.assertEquals(level_3, levels.get(2));
    Assert.assertEquals(level_4, levels.get(3));
    Assert.assertEquals(level_5, levels.get(4));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Example 70 with TaxonomyLevel

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

the class TaxonomyLevelDAOTest method createAndLoadTaxonomyLevel.

@Test
public void createAndLoadTaxonomyLevel() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-100", "Leveled taxonomy", null, null);
    TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-0", "A taxonomy level", "A basic level", null, null, null, null, taxonomy);
    dbInstance.commitAndCloseSession();
    TaxonomyLevel reloadedLevel = taxonomyLevelDao.loadByKey(level.getKey());
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(reloadedLevel);
    Assert.assertNotNull(reloadedLevel.getKey());
    Assert.assertEquals(level, reloadedLevel);
    Assert.assertEquals(taxonomy, reloadedLevel.getTaxonomy());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Aggregations

TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)238 Taxonomy (org.olat.modules.taxonomy.Taxonomy)122 Test (org.junit.Test)106 Identity (org.olat.core.id.Identity)58 ArrayList (java.util.ArrayList)40 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)40 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)24 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)24 URI (java.net.URI)22 HttpResponse (org.apache.http.HttpResponse)22 TreeNode (org.olat.core.gui.components.tree.TreeNode)22 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)18 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)16 HashMap (java.util.HashMap)14 List (java.util.List)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)12 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)12 Path (javax.ws.rs.Path)10