Search in sources :

Example 6 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

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 7 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class TaxonomyCompetenceDAOTest method getCompetenceByLevel_withIdentity.

@Test
public void getCompetenceByLevel_withIdentity() {
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-3");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-4");
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-25", "Competence", "", null);
    TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level", "A competence", null, null, null, null, taxonomy);
    TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level", "A competence", null, null, null, null, taxonomy);
    TaxonomyCompetence competence1_1 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level1, id1, null);
    TaxonomyCompetence competence1_2 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level1, id2, null);
    TaxonomyCompetence competence2_1 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, id1, null);
    TaxonomyCompetence competence2_2 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, id2, null);
    dbInstance.commitAndCloseSession();
    // check the different possiblities
    List<TaxonomyCompetence> loadedCompetences1_1 = taxonomyCompetenceDao.getCompetenceByLevel(level1, id1);
    Assert.assertNotNull(loadedCompetences1_1);
    Assert.assertEquals(1, loadedCompetences1_1.size());
    Assert.assertEquals(competence1_1, loadedCompetences1_1.get(0));
    List<TaxonomyCompetence> loadedCompetences1_2 = taxonomyCompetenceDao.getCompetenceByLevel(level1, id2);
    Assert.assertNotNull(loadedCompetences1_2);
    Assert.assertEquals(1, loadedCompetences1_2.size());
    Assert.assertEquals(competence1_2, loadedCompetences1_2.get(0));
    List<TaxonomyCompetence> loadedCompetences2_1 = taxonomyCompetenceDao.getCompetenceByLevel(level2, id1);
    Assert.assertNotNull(loadedCompetences2_1);
    Assert.assertEquals(1, loadedCompetences2_1.size());
    Assert.assertEquals(competence2_1, loadedCompetences2_1.get(0));
    List<TaxonomyCompetence> loadedCompetences2_2 = taxonomyCompetenceDao.getCompetenceByLevel(level2, id2);
    Assert.assertNotNull(loadedCompetences2_2);
    Assert.assertEquals(1, loadedCompetences2_2.size());
    Assert.assertEquals(competence2_2, loadedCompetences2_2.get(0));
}
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 8 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class TaxonomyCompetenceDAOTest method getCompetences_identityAndTypes.

@Test
public void getCompetences_identityAndTypes() {
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-6");
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-6");
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-30", "Competence", "", null);
    TaxonomyLevel levelA = taxonomyLevelDao.createTaxonomyLevel("ID-Level-A", "Competence level", "A competence", null, null, null, null, taxonomy);
    TaxonomyLevel levelB = taxonomyLevelDao.createTaxonomyLevel("ID-Level-B", "Competence level", "B competence", null, null, null, null, taxonomy);
    TaxonomyCompetence competenceTarget = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, levelA, id1, null);
    TaxonomyCompetence competenceHave = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, levelB, id1, null);
    TaxonomyCompetence competenceTeach = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, levelB, id2, null);
    dbInstance.commitAndCloseSession();
    // check the competences
    List<TaxonomyCompetence> loadedTargetCompetences1 = taxonomyCompetenceDao.getCompetences(id1, TaxonomyCompetenceTypes.target);
    Assert.assertNotNull(loadedTargetCompetences1);
    Assert.assertEquals(1, loadedTargetCompetences1.size());
    Assert.assertEquals(competenceTarget, loadedTargetCompetences1.get(0));
    // have
    List<TaxonomyCompetence> loadedTargetHaveCompetences1 = taxonomyCompetenceDao.getCompetences(id1, TaxonomyCompetenceTypes.target, TaxonomyCompetenceTypes.have, TaxonomyCompetenceTypes.teach);
    Assert.assertNotNull(loadedTargetHaveCompetences1);
    Assert.assertEquals(2, loadedTargetHaveCompetences1.size());
    Assert.assertTrue(loadedTargetHaveCompetences1.contains(competenceTarget));
    Assert.assertTrue(loadedTargetHaveCompetences1.contains(competenceHave));
    // all
    List<TaxonomyCompetence> loadedAllCompetences2 = taxonomyCompetenceDao.getCompetences(id2);
    Assert.assertNotNull(loadedAllCompetences2);
    Assert.assertEquals(1, loadedAllCompetences2.size());
    Assert.assertEquals(competenceTeach, loadedAllCompetences2.get(0));
}
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 9 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

the class TaxonomyCompetenceDAOTest method createTaxonomyCompetence.

@Test
public void createTaxonomyCompetence() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-1");
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-24", "Competence", "", null);
    TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level", "A very difficult competence", null, null, null, null, taxonomy);
    TaxonomyCompetence competence = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, level, id, null);
    dbInstance.commit();
    Assert.assertNotNull(competence);
    Assert.assertNotNull(competence.getCreationDate());
}
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 10 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.

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)

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