use of org.olat.modules.taxonomy.TaxonomyCompetence 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());
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class TaxonomyCompetenceDAO method deleteCompetence.
public void deleteCompetence(TaxonomyCompetence competence) {
TaxonomyCompetence reloadedCompetence = dbInstance.getCurrentEntityManager().getReference(TaxonomyCompetenceImpl.class, competence.getKey());
dbInstance.getCurrentEntityManager().remove(reloadedCompetence);
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class TaxonomyWebServiceTest method removeTaxonomyLevelCompetence.
@Test
public void removeTaxonomyLevelCompetence() throws IOException, URISyntaxException {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competence-4");
Taxonomy taxonomy = taxonomyService.createTaxonomy("REST-Tax-8", "Taxonomy on rest", "PUT is cool, yes!", "PUT-tax-2");
TaxonomyLevel level = taxonomyService.createTaxonomyLevel("REST-Tax-r-8", "Root level on rest", "Level", "Ext-23", null, null, taxonomy);
TaxonomyCompetence competence = taxonomyService.addTaxonomyLevelCompetences(level, id, TaxonomyCompetenceTypes.target, null);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(competence);
// make sure we have something to delete
TaxonomyCompetence reloadedCompetence = taxonomyService.getTaxonomyCompetence(competence);
Assert.assertNotNull(reloadedCompetence);
dbInstance.commitAndCloseSession();
// remove the competence
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").path(level.getKey().toString()).path("competences").path(competence.getKey().toString()).build();
HttpDelete method = conn.createDelete(request, MediaType.APPLICATION_JSON);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check the database
List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyCompetences(id, TaxonomyCompetenceTypes.target);
Assert.assertNotNull(competences);
Assert.assertEquals(0, competences.size());
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
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);
}
Aggregations