Search in sources :

Example 11 with Taxonomy

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

Example 12 with Taxonomy

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

Example 13 with Taxonomy

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));
}
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 Taxonomy

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

Example 15 with Taxonomy

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);
}
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

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