use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelDAOTest method createTaxonomyLevel.
@Test
public void createTaxonomyLevel() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-98", "Leveled taxonomy", null, null);
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-0", "My first taxonomy level", "A basic level", null, null, null, null, taxonomy);
dbInstance.commit();
Assert.assertNotNull(level);
Assert.assertNotNull(level.getKey());
Assert.assertNotNull(level.getCreationDate());
Assert.assertNotNull(level.getTaxonomy());
Assert.assertEquals(taxonomy, level.getTaxonomy());
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelDAOTest method moveTaxonomyLevel_simple.
@Test
public void moveTaxonomyLevel_simple() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-106", "Moving taxonomy", null, null);
String displayName = UUID.randomUUID().toString();
TaxonomyLevel parentLevel = taxonomyLevelDao.createTaxonomyLevel("U-1", displayName, "A root level", null, null, null, null, taxonomy);
TaxonomyLevel targetLevel = taxonomyLevelDao.createTaxonomyLevel("T-1", displayName, "A root level", null, null, null, null, taxonomy);
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("U-2", displayName, "A basic level", null, null, parentLevel, null, taxonomy);
dbInstance.commitAndCloseSession();
// move the level
TaxonomyLevel reloadedLevel = taxonomyLevelDao.loadByKey(level.getKey());
TaxonomyLevel movedLevel = taxonomyLevelDao.moveTaxonomyLevel(reloadedLevel, targetLevel);
dbInstance.commitAndCloseSession();
TaxonomyLevel reloadedMovedLevel = taxonomyLevelDao.loadByKey(movedLevel.getKey());
String identifiersPath = reloadedMovedLevel.getMaterializedPathIdentifiers();
Assert.assertEquals("/T-1/U-2/", identifiersPath);
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
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));
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelDAOTest method getTaxonomyLevels_all.
@Test
public void getTaxonomyLevels_all() {
Taxonomy taxonomy = taxonomyDao.createTaxonomy("ID-103", "Leveled taxonomy", null, null);
TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel("ID-Level-4", "A level", "A basic level", null, null, null, null, taxonomy);
dbInstance.commit();
List<TaxonomyLevel> levels = taxonomyLevelDao.getLevels(null);
Assert.assertNotNull(levels);
Assert.assertTrue(levels.contains(level));
}
use of org.olat.modules.taxonomy.Taxonomy in project OpenOLAT by OpenOLAT.
the class TaxonomyServiceImpl method deleteTaxonomyLevel.
@Override
public boolean deleteTaxonomyLevel(TaxonomyLevelRef taxonomyLevel, TaxonomyLevelRef mergeTo) {
// save the documents
TaxonomyLevel reloadedTaxonomyLevel = taxonomyLevelDao.loadByKey(taxonomyLevel.getKey());
if (mergeTo != null) {
TaxonomyLevel reloadedMergeTo = taxonomyLevelDao.loadByKey(mergeTo.getKey());
merge(reloadedTaxonomyLevel, reloadedMergeTo);
} else {
VFSContainer library = taxonomyLevelDao.getDocumentsLibrary(reloadedTaxonomyLevel);
if (library != null) {
Taxonomy taxonomy = reloadedTaxonomyLevel.getTaxonomy();
VFSContainer lostAndFound = taxonomyDao.getLostAndFoundDirectoryLibrary(taxonomy);
String dir = StringHelper.transformDisplayNameToFileSystemName(reloadedTaxonomyLevel.getIdentifier());
dir += "_" + taxonomyLevel.getKey();
VFSContainer lastStorage = lostAndFound.createChildContainer(dir);
if (lastStorage == null) {
VFSItem storageItem = lostAndFound.resolve(dir);
if (storageItem instanceof VFSContainer) {
lastStorage = (VFSContainer) storageItem;
} else {
lastStorage = lostAndFound.createChildContainer(UUID.randomUUID().toString());
}
}
VFSManager.copyContent(library, lastStorage);
}
// delete the competences
taxonomyCompetenceDao.deleteCompetences(taxonomyLevel);
// questions
taxonomyRelationsDao.removeFromQuestionItems(taxonomyLevel);
}
return taxonomyLevelDao.delete(reloadedTaxonomyLevel);
}
Aggregations