Search in sources :

Example 11 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel 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());
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Example 12 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel 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);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Example 13 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel 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));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelSearchParameters(org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters) Test(org.junit.Test)

Example 14 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel 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));
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Test(org.junit.Test)

Example 15 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel 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);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) VFSContainer(org.olat.core.util.vfs.VFSContainer) VFSItem(org.olat.core.util.vfs.VFSItem)

Aggregations

TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)238 Taxonomy (org.olat.modules.taxonomy.Taxonomy)122 Test (org.junit.Test)106 Identity (org.olat.core.id.Identity)58 ArrayList (java.util.ArrayList)40 TaxonomyCompetence (org.olat.modules.taxonomy.TaxonomyCompetence)40 TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)34 Date (java.util.Date)24 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)24 URI (java.net.URI)22 HttpResponse (org.apache.http.HttpResponse)22 TreeNode (org.olat.core.gui.components.tree.TreeNode)22 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)18 QuestionItemImpl (org.olat.modules.qpool.model.QuestionItemImpl)16 HashMap (java.util.HashMap)14 List (java.util.List)14 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)12 TaxonomyCompetenceTypes (org.olat.modules.taxonomy.TaxonomyCompetenceTypes)12 TaxonomyTreeNode (org.olat.modules.taxonomy.model.TaxonomyTreeNode)12 Path (javax.ws.rs.Path)10