use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class TaxonomyCompetenceDAOTest method deleteCompetencesByIdentity.
@Test
public void deleteCompetencesByIdentity() {
Identity id1 = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-6");
Identity id2 = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-6");
Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-30", "Competence", "", null);
Taxonomy taxonomy2 = taxonomyDao.createTaxonomy("ID-31", "Competence", "", null);
TaxonomyLevel levelA = taxonomyLevelDao.createTaxonomyLevel("ID-Level-A", "Competence level", "A competence", null, null, null, null, taxonomy1);
TaxonomyLevel levelB = taxonomyLevelDao.createTaxonomyLevel("ID-Level-B", "Competence level", "B competence", null, null, null, null, taxonomy1);
TaxonomyLevel levelC = taxonomyLevelDao.createTaxonomyLevel("ID-Level-C", "Competence level", "C competence", null, null, null, null, taxonomy2);
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, levelA, id1, null);
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, levelB, id1, null);
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, levelC, id1, null);
taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, levelA, id2, null);
dbInstance.commitAndCloseSession();
int deleteCompetences = taxonomyCompetenceDao.deleteCompetences(id1);
Assert.assertEquals(3, deleteCompetences);
List<TaxonomyCompetence> competencesID1 = taxonomyCompetenceDao.getCompetences(id1);
Assert.assertEquals(0, competencesID1.size());
List<TaxonomyCompetence> competencesID2 = taxonomyCompetenceDao.getCompetences(id2);
Assert.assertEquals(1, competencesID2.size());
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class TaxonomyCompetenceDAOTest method hasCompetenceByTaxonomy_negative.
@Test
public void hasCompetenceByTaxonomy_negative() {
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);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(level);
boolean hasCompetence = taxonomyCompetenceDao.hasCompetenceByTaxonomy(taxonomy, id, new Date());
Assert.assertFalse(hasCompetence);
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class TaxonomyLevelDAOTest method moveTaxonomyLevel_toRoot.
@Test
public void moveTaxonomyLevel_toRoot() {
// prepare some levels
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-107", "Large moving taxonomy", null, null);
String displayName = UUID.randomUUID().toString();
TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("U-1", displayName, "A basic level", null, null, null, null, taxonomy);
TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("U-2", displayName, "A basic level", null, null, level1, null, taxonomy);
TaxonomyLevel level3 = taxonomyLevelDao.createTaxonomyLevel("U-3", displayName, "A basic level", null, null, level2, null, taxonomy);
TaxonomyLevel level4_1 = taxonomyLevelDao.createTaxonomyLevel("U-4-1", displayName, "A basic level", null, null, level3, null, taxonomy);
TaxonomyLevel level4_2 = taxonomyLevelDao.createTaxonomyLevel("U-4-2", displayName, "A basic level", null, null, level3, null, taxonomy);
dbInstance.commitAndCloseSession();
// move the level 2
TaxonomyLevel reloadedLevel3 = taxonomyLevelDao.loadByKey(level3.getKey());
TaxonomyLevel movedLevel3 = taxonomyLevelDao.moveTaxonomyLevel(reloadedLevel3, null);
dbInstance.commitAndCloseSession();
// check the different levels paths
TaxonomyLevel reloadedMovedLevel3 = taxonomyLevelDao.loadByKey(movedLevel3.getKey());
String identifiersPath3 = reloadedMovedLevel3.getMaterializedPathIdentifiers();
Assert.assertEquals("/U-3/", identifiersPath3);
TaxonomyLevel movedLevel4_1 = taxonomyLevelDao.loadByKey(level4_1.getKey());
String identifiersPath4_1 = movedLevel4_1.getMaterializedPathIdentifiers();
Assert.assertEquals("/U-3/U-4-1/", identifiersPath4_1);
TaxonomyLevel movedLevel4_2 = taxonomyLevelDao.loadByKey(level4_2.getKey());
String identifiersPath4_2 = movedLevel4_2.getMaterializedPathIdentifiers();
Assert.assertEquals("/U-3/U-4-2/", identifiersPath4_2);
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class TaxonomyLevelDAOTest method searchLevelsByKey.
@Test
public void searchLevelsByKey() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-105B", "Named taxonomy", null, null);
TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("L-1E", "A numerated level", "", null, null, null, null, taxonomy);
TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("L-1F", "A numerated level", "", null, null, null, null, taxonomy);
dbInstance.commitAndCloseSession();
// key
TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
searchParams.setQuickSearch(level1.getKey().toString());
List<TaxonomyLevel> levels = taxonomyLevelDao.searchLevels(taxonomy, searchParams);
Assert.assertNotNull(levels);
Assert.assertEquals(1, levels.size());
Assert.assertEquals(level1, levels.get(0));
Assert.assertNotEquals(level2, levels.get(0));
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class TaxonomyLevelDAOTest method searchLevelsByDisplayName.
@Test
public void searchLevelsByDisplayName() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-105A", "Named taxonomy", null, null);
TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("L-1A", "A basic level", "", null, null, null, null, taxonomy);
TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("L-1G", "A complex level", "", null, null, null, null, taxonomy);
dbInstance.commitAndCloseSession();
TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
searchParams.setQuickSearch("basic");
List<TaxonomyLevel> levels = taxonomyLevelDao.searchLevels(taxonomy, searchParams);
Assert.assertNotNull(levels);
Assert.assertEquals(1, levels.size());
Assert.assertEquals(level1, levels.get(0));
Assert.assertNotEquals(level2, levels.get(0));
}
Aggregations