Search in sources :

Example 41 with Taxonomy

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

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

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

the class TaxonomyCompetenceDAOTest method getCompetenceByTaxonomyAndCompetenceTypes.

@Test
public void getCompetenceByTaxonomyAndCompetenceTypes() {
    // make 2 taxonomy trees
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
    Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-31", "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-32", "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);
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, level2, id, null);
    Identity otherId = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, otherId, null);
    dbInstance.commitAndCloseSession();
    // check the competences of the 2 taxonomy trees
    List<TaxonomyCompetence> loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date(), TaxonomyCompetenceTypes.target);
    Assert.assertNotNull(loadedCompetences1);
    Assert.assertEquals(1, loadedCompetences1.size());
    Assert.assertEquals(competence1, loadedCompetences1.get(0));
    loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date(), TaxonomyCompetenceTypes.have);
    Assert.assertEquals(0, loadedCompetences1.size());
    List<TaxonomyCompetence> loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date(), TaxonomyCompetenceTypes.target);
    Assert.assertNotNull(loadedCompetences2);
    Assert.assertEquals(1, loadedCompetences2.size());
    Assert.assertEquals(competence2, loadedCompetences2.get(0));
    loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date(), TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach);
    Assert.assertEquals(0, loadedCompetences2.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) Date(java.util.Date) Test(org.junit.Test)

Example 43 with Taxonomy

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

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

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

the class TaxonomyCompetenceDAOTest method getCompetenceByLevel.

@Test
public void getCompetenceByLevel() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-2");
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-25", "Competence", "", null);
    TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level", "A competence", null, null, null, null, taxonomy);
    TaxonomyCompetence competence = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level, id, null);
    dbInstance.commitAndCloseSession();
    List<TaxonomyCompetence> loadedCompetences = taxonomyCompetenceDao.getCompetenceByLevel(level);
    Assert.assertNotNull(loadedCompetences);
    Assert.assertEquals(1, loadedCompetences.size());
    TaxonomyCompetence loadedCompetence = loadedCompetences.get(0);
    Assert.assertNotNull(loadedCompetence);
    Assert.assertEquals(competence, loadedCompetence);
    Assert.assertEquals(level, competence.getTaxonomyLevel());
    Assert.assertEquals(id, competence.getIdentity());
    Assert.assertEquals(TaxonomyCompetenceTypes.target, competence.getCompetenceType());
}
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 45 with Taxonomy

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

the class TaxonomyCompetenceDAOTest method hasCompetenceByLevel_hasOnlyOtherCompetence.

@Test
public void hasCompetenceByLevel_hasOnlyOtherCompetence() {
    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);
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level, id, null);
    dbInstance.commitAndCloseSession();
    boolean hasCompetence = taxonomyCompetenceDao.hasCompetenceByLevel(level, id, new Date(), TaxonomyCompetenceTypes.teach);
    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)

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