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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations