Search in sources :

Example 31 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy 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);
}
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 32 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class TaxonomyDAOTest method getTaxonomyList.

@Test
public void getTaxonomyList() {
    Taxonomy taxonomy0 = taxonomyDao.createTaxonomy("ID40", "An other taxonomy", "A little taxonomy", "REF-40");
    Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID41", "An other taxonomy", "A little taxonomy", "REF-41");
    dbInstance.commitAndCloseSession();
    List<Taxonomy> taxonomyList = taxonomyDao.getTaxonomyList();
    Assert.assertTrue(taxonomyList.contains(taxonomy0));
    Assert.assertTrue(taxonomyList.contains(taxonomy1));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) Test(org.junit.Test)

Example 33 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class TaxonomyLevelTypeDAOTest method allowSubTypes.

@Test
public void allowSubTypes() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("Tax-type", "Typed taxonomy", "A typed taxonomy", "");
    TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-parent", "A type", null, null, taxonomy);
    TaxonomyLevelType subType1 = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-sub-1", "A type", null, null, taxonomy);
    TaxonomyLevelType subType2 = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-sub-2", "A type", null, null, taxonomy);
    dbInstance.commitAndCloseSession();
    taxonomyLevelTypeToTypeDao.addAllowedSubType(type, subType1);
    taxonomyLevelTypeToTypeDao.addAllowedSubType(type, subType2);
    dbInstance.commitAndCloseSession();
    TaxonomyLevelTypeImpl reloadedType = (TaxonomyLevelTypeImpl) taxonomyLevelTypeDao.loadTaxonomyLevelTypeByKey(type.getKey());
    Assert.assertNotNull(reloadedType.getAllowedTaxonomyLevelSubTypes());
    Assert.assertEquals(2, reloadedType.getAllowedTaxonomyLevelSubTypes().size());
    Set<TaxonomyLevelTypeToType> allowedTypeSet = reloadedType.getAllowedTaxonomyLevelSubTypes();
    List<TaxonomyLevelType> allowedSubTypes = allowedTypeSet.stream().map(t -> t.getAllowedSubTaxonomyLevelType()).collect(Collectors.toList());
    Assert.assertTrue(allowedSubTypes.contains(subType1));
    Assert.assertTrue(allowedSubTypes.contains(subType2));
}
Also used : TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) List(java.util.List) DB(org.olat.core.commons.persistence.DB) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Set(java.util.Set) OlatTestCase(org.olat.test.OlatTestCase) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) Assert(org.junit.Assert) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Collectors(java.util.stream.Collectors) Taxonomy(org.olat.modules.taxonomy.Taxonomy) Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Test(org.junit.Test)

Example 34 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class TaxonomyLevelTypeDAOTest method loadTaxonomyLevelTypeByTaxonomy.

@Test
public void loadTaxonomyLevelTypeByTaxonomy() {
    Taxonomy taxonomy = taxonomyDao.createTaxonomy("Tax-type", "Typed taxonomy", "A typed taxonomy", "");
    Taxonomy taxonomyMarker = taxonomyDao.createTaxonomy("Tax-marker", "Marker taxonomy", "An unused taxonomy", "");
    TaxonomyLevelType type = taxonomyLevelTypeDao.createTaxonomyLevelType("Type-reload", "A first reloaded type", "Typed", "TYP-1", taxonomy);
    dbInstance.commitAndCloseSession();
    // check the taxonomy with types
    List<TaxonomyLevelType> taxonomyTypes = taxonomyLevelTypeDao.loadTaxonomyLevelTypeByTaxonomy(taxonomy);
    Assert.assertNotNull(taxonomyTypes);
    Assert.assertEquals(1, taxonomyTypes.size());
    Assert.assertEquals(type, taxonomyTypes.get(0));
    // check the marker without
    List<TaxonomyLevelType> taxonomyWithoutTypes = taxonomyLevelTypeDao.loadTaxonomyLevelTypeByTaxonomy(taxonomyMarker);
    Assert.assertNotNull(taxonomyWithoutTypes);
    Assert.assertEquals(0, taxonomyWithoutTypes.size());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Test(org.junit.Test)

Example 35 with Taxonomy

use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.

the class IdentityCompetencesController method doRemoveCompetence.

private void doRemoveCompetence(IdentityCompetenceRow row) {
    Taxonomy taxonomy = row.getTaxonomy();
    TaxonomyCompetence competence = row.getCompetence();
    String before = taxonomyService.toAuditXml(competence);
    taxonomyService.removeTaxonomyLevelCompetence(competence);
    taxonomyService.auditLog(TaxonomyCompetenceAuditLog.Action.removeCompetence, before, null, null, taxonomy, competence, assessedIdentity, getIdentity());
    loadModel();
    tableEl.reset(true, true, true);
    String competenceTypeName = translate(row.getCompetenceType().name());
    String levelDisplayName = StringHelper.escapeHtml(row.getTaxonomyLevel().getDisplayName());
    showInfo("confirm.removed.competence", new String[] { competenceTypeName, levelDisplayName });
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyCompetence(org.olat.modules.taxonomy.TaxonomyCompetence)

Aggregations

Taxonomy (org.olat.modules.taxonomy.Taxonomy)194 Test (org.junit.Test)132 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)122 Identity (org.olat.core.id.Identity)56 URI (java.net.URI)36 HttpResponse (org.apache.http.HttpResponse)36 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)36 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)22 HttpGet (org.apache.http.client.methods.HttpGet)16 ArrayList (java.util.ArrayList)14 TaxonomyService (org.olat.modules.taxonomy.TaxonomyService)14 TaxonomyRefImpl (org.olat.modules.taxonomy.model.TaxonomyRefImpl)14 HttpPut (org.apache.http.client.methods.HttpPut)12 HashMap (java.util.HashMap)10 List (java.util.List)10 VFSContainer (org.olat.core.util.vfs.VFSContainer)10 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)10 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)10 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)10