use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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());
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
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());
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project OpenOLAT by OpenOLAT.
the class TaxonomyWebServiceTest method putTaxonomyLevelComptence.
@Test
public void putTaxonomyLevelComptence() 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);
dbInstance.commitAndCloseSession();
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
TaxonomyCompetenceVO competenceVo = new TaxonomyCompetenceVO();
competenceVo.setIdentityKey(id.getKey());
competenceVo.setTaxonomyCompetenceType(TaxonomyCompetenceTypes.target.name());
competenceVo.setTaxonomyLevelKey(level.getKey());
URI request = UriBuilder.fromUri(getContextURI()).path("taxonomy").path(taxonomy.getKey().toString()).path("levels").path(level.getKey().toString()).path("competences").build();
HttpPut method = conn.createPut(request, MediaType.APPLICATION_JSON, true);
conn.addJsonEntity(method, competenceVo);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
// check the returned value
TaxonomyCompetenceVO newTaxonomyCompetenceVo = conn.parse(response, TaxonomyCompetenceVO.class);
Assert.assertNotNull(newTaxonomyCompetenceVo);
Assert.assertNotNull(newTaxonomyCompetenceVo.getKey());
Assert.assertEquals(id.getKey(), newTaxonomyCompetenceVo.getIdentityKey());
Assert.assertEquals(TaxonomyCompetenceTypes.target.name(), newTaxonomyCompetenceVo.getTaxonomyCompetenceType());
Assert.assertEquals(level.getKey(), newTaxonomyCompetenceVo.getTaxonomyLevelKey());
// check the database
List<TaxonomyCompetence> competences = taxonomyService.getTaxonomyCompetences(id, TaxonomyCompetenceTypes.target);
Assert.assertNotNull(competences);
Assert.assertEquals(1, competences.size());
TaxonomyCompetence competence = competences.get(0);
Assert.assertEquals(id, competence.getIdentity());
Assert.assertEquals(level, competence.getTaxonomyLevel());
Assert.assertEquals(TaxonomyCompetenceTypes.target, competence.getCompetenceType());
}
use of org.olat.modules.taxonomy.TaxonomyCompetence in project openolat by klemens.
the class DocumentPoolManagerTest method createTypeLevelCompetence.
private TaxonomyLevelType createTypeLevelCompetence(Identity id, TaxonomyLevel parent, TaxonomyCompetenceTypes competenceType) {
String levelId = "DP-Lev. " + UUID.randomUUID();
Taxonomy taxonomy = getDocumentPoolTaxonomy();
TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-docpool", "A type for document pool", "Typed", "TYP-0", taxonomy);
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel(levelId, "Competence level", "A competence", null, null, parent, type, taxonomy);
TaxonomyCompetence competenceTarget = taxonomyCompetenceDao.createTaxonomyCompetence(competenceType, level, id, null);
dbInstance.commit();
type.setDocumentsLibraryManageCompetenceEnabled(false);
type.setDocumentsLibraryTeachCompetenceWriteEnabled(false);
type.setDocumentsLibraryTeachCompetenceReadEnabled(false);
type.setDocumentsLibraryHaveCompetenceReadEnabled(false);
type.setDocumentsLibraryTargetCompetenceReadEnabled(false);
type = taxonomyLevelTypeDao.updateTaxonomyLevelType(type);
dbInstance.commit();
Assert.assertNotNull(competenceTarget);
return type;
}
Aggregations