Search in sources :

Example 61 with TaxonomyLevel

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

the class TaxonomyCompetenceDAOTest method deleteCompetencesByIdentity.

@Test
public void deleteCompetencesByIdentity() {
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-6");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-6");
    Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-30", "Competence", "", null);
    Taxonomy taxonomy2 = taxonomyDao.createTaxonomy("ID-31", "Competence", "", null);
    TaxonomyLevel levelA = taxonomyLevelDao.createTaxonomyLevel("ID-Level-A", "Competence level", "A competence", null, null, null, null, taxonomy1);
    TaxonomyLevel levelB = taxonomyLevelDao.createTaxonomyLevel("ID-Level-B", "Competence level", "B competence", null, null, null, null, taxonomy1);
    TaxonomyLevel levelC = taxonomyLevelDao.createTaxonomyLevel("ID-Level-C", "Competence level", "C competence", null, null, null, null, taxonomy2);
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, levelA, id1, null);
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, levelB, id1, null);
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, levelC, id1, null);
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, levelA, id2, null);
    dbInstance.commitAndCloseSession();
    int deleteCompetences = taxonomyCompetenceDao.deleteCompetences(id1);
    Assert.assertEquals(3, deleteCompetences);
    List<TaxonomyCompetence> competencesID1 = taxonomyCompetenceDao.getCompetences(id1);
    Assert.assertEquals(0, competencesID1.size());
    List<TaxonomyCompetence> competencesID2 = taxonomyCompetenceDao.getCompetences(id2);
    Assert.assertEquals(1, competencesID2.size());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 62 with TaxonomyLevel

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

the class TaxonomyCompetenceDAOTest method hasCompetenceByTaxonomy_negative.

@Test
public void hasCompetenceByTaxonomy_negative() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-30", "Competence", "", null);
    TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-A", "Competence level", "A competence", null, null, null, null, taxonomy);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(level);
    boolean hasCompetence = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date());
    Assert.assertFalse(hasCompetence);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Identity(org.olat.core.id.Identity) Date(java.util.Date) Test(org.junit.Test)

Example 63 with TaxonomyLevel

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

Example 64 with TaxonomyLevel

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

Example 65 with TaxonomyLevel

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