Search in sources :

Example 36 with TaxonomyCompetence

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);
}
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 37 with TaxonomyCompetence

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());
}
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 38 with TaxonomyCompetence

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());
}
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 39 with TaxonomyCompetence

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());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) HttpResponse(org.apache.http.HttpResponse) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence) Identity(org.olat.core.id.Identity) URI(java.net.URI) TaxonomyCompetenceVO(org.olat.modules.taxonomy.restapi.TaxonomyCompetenceVO) HttpPut(org.apache.http.client.methods.HttpPut) Test(org.junit.Test)

Example 40 with TaxonomyCompetence

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;
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence)

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