Search in sources :

Example 46 with Taxonomy

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

the class TaxonomyCompetenceDAOTest method getCompetenceByTaxonomy.

@Test
public void getCompetenceByTaxonomy() {
    // make 2 taxonomy trees
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
    Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-27", "Competence", "", null);
    TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level taxonomy 1", "A competence", null, null, null, null, taxonomy1);
    TaxonomyCompetence competence1 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level1, id, null);
    Taxonomy taxonomy2 = taxonomyDao.createTaxonomy("ID-28", "Competence", "", null);
    TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-2", "Competence level taxonomy 2", "A competence", null, null, null, null, taxonomy2);
    TaxonomyCompetence competence2 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, id, null);
    dbInstance.commitAndCloseSession();
    // check the competences of the 2 taxonomy trees
    List<TaxonomyCompetence> loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date());
    Assert.assertNotNull(loadedCompetences1);
    Assert.assertEquals(1, loadedCompetences1.size());
    Assert.assertEquals(competence1, loadedCompetences1.get(0));
    List<TaxonomyCompetence> loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date());
    Assert.assertNotNull(loadedCompetences2);
    Assert.assertEquals(1, loadedCompetences2.size());
    Assert.assertEquals(competence2, loadedCompetences2.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) Date(java.util.Date) Test(org.junit.Test)

Example 47 with Taxonomy

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

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 48 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy 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 49 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy 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 50 with Taxonomy

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

the class TaxonomyDAOTest method createTaxonomy.

@Test
public void createTaxonomy() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID21", "My first taxonomy", "A very little taxonomy", "EXT_REF");
    dbInstance.commit();
    Assert.assertNotNull(taxonomy);
    Assert.assertNotNull(taxonomy.getKey());
    Assert.assertNotNull(((TaxonomyImpl) taxonomy).getGroup());
    Assert.assertEquals("ID21", taxonomy.getIdentifier());
    Assert.assertEquals("My first taxonomy", taxonomy.getDisplayName());
    Assert.assertEquals("A very little taxonomy", taxonomy.getDescription());
    Assert.assertEquals("EXT_REF", taxonomy.getExternalId());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) Test(org.junit.Test)

Aggregations

Taxonomy (org.olat.modules.taxonomy.Taxonomy)194 Test (org.junit.Test)132 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)122 Identity (org.olat.core.id.Identity)56 URI (java.net.URI)36 HttpResponse (org.apache.http.HttpResponse)36 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)36 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)22 HttpGet (org.apache.http.client.methods.HttpGet)16 ArrayList (java.util.ArrayList)14 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)14 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)14 HttpPut (org.apache.http.client.methods.HttpPut)12 HashMap (java.util.HashMap)10 List (java.util.List)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)10 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)10