Search in sources :

Example 46 with TaxonomyCompetence

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

the class TaxonomyTreeBuilder method computePermissions.

private void computePermissions(TaxonomyTreeNode root) {
    List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyCompetences(taxonomy, identity, new Date());
    Map<TaxonomyLevel, List<TaxonomyCompetenceTypes>> levelToCompetences = new HashMap<>();
    for (TaxonomyCompetence competence : competences) {
        TaxonomyLevel level = competence.getTaxonomyLevel();
        if (levelToCompetences.containsKey(level)) {
            levelToCompetences.get(level).add(competence.getCompetenceType());
        } else {
            List<TaxonomyCompetenceTypes> types = new ArrayList<>(4);
            types.add(competence.getCompetenceType());
            levelToCompetences.put(level, types);
        }
    }
    computePermissionsRecursive(root, levelToCompetences);
    trimRecursive(root);
}
Also used : HashMap(java.util.HashMap) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) TaxonomyCompetenceTypes(org.olat.modules.taxonomy.TaxonomyCompetenceTypes) Date(java.util.Date)

Example 47 with TaxonomyCompetence

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

the class TaxonomyCompetenceAuditLogDAOTest method auditLog.

@Test
public void auditLog() {
    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();
    String after = taxonomyCompetenceAuditLogDao.toXml(competence);
    taxonomyCompetenceAuditLogDao.auditLog(TaxonomyCompetenceAuditLog.Action.addCompetence, "Before", "After", "Message", taxonomy, competence, id, null);
    dbInstance.commit();
    Assert.assertNotNull(after);
}
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 TaxonomyCompetence

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

the class TaxonomyCompetenceDAOTest method hasCompetenceByTaxonomy.

@Test
public void hasCompetenceByTaxonomy() {
    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);
    TaxonomyCompetence competenceTarget = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level, id, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(competenceTarget);
    boolean hasCompetence = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date());
    Assert.assertTrue(hasCompetence);
}
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 49 with TaxonomyCompetence

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

the class TaxonomyCompetenceDAOTest method hasCompetenceByTaxonomy_competence.

@Test
public void hasCompetenceByTaxonomy_competence() {
    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);
    TaxonomyCompetence competenceTarget = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level, id, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(competenceTarget);
    boolean hasTarget = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date(), TaxonomyCompetenceTypes.target);
    Assert.assertTrue(hasTarget);
    boolean hasTeach = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date(), TaxonomyCompetenceTypes.teach);
    Assert.assertFalse(hasTeach);
}
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 50 with TaxonomyCompetence

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

the class TaxonomyCompetenceDAOTest method createAndReloadTaxonomyCompetence.

@Test
public void createAndReloadTaxonomyCompetence() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-1");
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-24b", "Competence", "", null);
    TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1b", "Competence level", "An important competence to have", null, null, null, null, taxonomy);
    TaxonomyCompetence competence = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, level, id, null);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(competence);
    TaxonomyCompetence reloadedCompetence = taxonomyCompetenceDao.loadCompetenceByKey(competence.getKey());
    Assert.assertNotNull(reloadedCompetence);
    Assert.assertEquals(competence, reloadedCompetence);
    Assert.assertEquals(competence.getKey(), reloadedCompetence.getKey());
    Assert.assertEquals(id, reloadedCompetence.getIdentity());
    Assert.assertEquals(level, reloadedCompetence.getTaxonomyLevel());
    Assert.assertEquals(TaxonomyCompetenceTypes.have, reloadedCompetence.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)

Aggregations

TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)50 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)38 Identity (org.olat.core.id.Identity)36 Taxonomy (org.olat.modules.taxonomy.Taxonomy)34 Test (org.junit.Test)26 Date (java.util.Date)10 ArrayList (java.util.ArrayList)8 Consumes (javax.ws.rs.Consumes)8 Path (javax.ws.rs.Path)8 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)8 GET (javax.ws.rs.GET)6 Produces (javax.ws.rs.Produces)6 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)6 URI (java.net.URI)4 HttpResponse (org.apache.http.HttpResponse)4 TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)4 HashMap (java.util.HashMap)2 List (java.util.List)2 DELETE (javax.ws.rs.DELETE)2 HttpDelete (org.apache.http.client.methods.HttpDelete)2