Search in sources :

Example 51 with TaxonomyLevel

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

the class TaxonomyTreeTableController method loadModel.

private void loadModel(boolean resetPage, boolean resetInternal) {
    TaxonomyLevelSearchParameters searchParams = new TaxonomyLevelSearchParameters();
    searchParams.setQuickSearch(tableEl.getQuickSearchString());
    List<TaxonomyLevel> taxonomyLevels = taxonomyService.getTaxonomyLevels(taxonomy, searchParams);
    List<TaxonomyLevelRow> rows = new ArrayList<>(taxonomyLevels.size());
    Map<Long, TaxonomyLevelRow> levelToRows = new HashMap<>();
    for (TaxonomyLevel taxonomyLevel : taxonomyLevels) {
        TaxonomyLevelRow row = forgeRow(taxonomyLevel);
        rows.add(row);
        levelToRows.put(taxonomyLevel.getKey(), row);
    }
    for (TaxonomyLevelRow row : rows) {
        Long parentLevelKey = row.getParentLevelKey();
        TaxonomyLevelRow parentRow = levelToRows.get(parentLevelKey);
        row.setParent(parentRow);
    }
    for (TaxonomyLevelRow row : rows) {
        for (FlexiTreeTableNode parent = row.getParent(); parent != null; parent = parent.getParent()) {
            ((TaxonomyLevelRow) parent).incrementNumberOfChildren();
        }
    }
    Collections.sort(rows, new FlexiTreeNodeComparator());
    model.setObjects(rows);
    tableEl.reset(resetPage, resetInternal, true);
}
Also used : FlexiTreeTableNode(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeTableNode) HashMap(java.util.HashMap) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) TaxonomyLevelSearchParameters(org.olat.modules.taxonomy.model.TaxonomyLevelSearchParameters) ArrayList(java.util.ArrayList) FlexiTreeNodeComparator(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTreeNodeComparator)

Example 52 with TaxonomyLevel

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

the class TypeTaxonomyLevelController method getAvailableTypes.

private List<TaxonomyLevelType> getAvailableTypes() {
    List<TaxonomyLevelType> allowedTypes = new ArrayList<>(taxonomyService.getTaxonomyLevelTypes(taxonomy));
    Set<TaxonomyLevelType> analyzedTypes = new HashSet<>();
    for (TaxonomyLevel level : levels) {
        TaxonomyLevel parentLevel = level.getParent();
        if (parentLevel != null && parentLevel.getType() != null && !analyzedTypes.contains(parentLevel.getType())) {
            TaxonomyLevelType parentType = parentLevel.getType();
            List<TaxonomyLevelType> allowedSubTypes = new ArrayList<>();
            Set<TaxonomyLevelTypeToType> typesToTypes = parentType.getAllowedTaxonomyLevelSubTypes();
            for (TaxonomyLevelTypeToType typeToType : typesToTypes) {
                allowedSubTypes.add(typeToType.getAllowedSubTaxonomyLevelType());
            }
            if (allowedSubTypes.size() > 0) {
                allowedTypes.retainAll(allowedSubTypes);
            }
        }
    }
    return allowedTypes;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType) HashSet(java.util.HashSet)

Example 53 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.

the class DocumentPoolManagerTest method hasCompetenceByTaxonomy_negative.

@Test
public void hasCompetenceByTaxonomy_negative() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
    String levelId = "DP-Lev. " + UUID.randomUUID();
    Taxonomy taxonomy = getDocumentPoolTaxonomy();
    TaxonomyLevel level = taxonomyLevelDao.createTaxonomyLevel(levelId, "Competence level", "A competence", null, null, null, null, taxonomy);
    dbInstance.commitAndCloseSession();
    Assert.assertNotNull(level);
    boolean hasCompetence = documentPoolManager.hasValidCompetence(id);
    Assert.assertFalse(hasCompetence);
}
Also used : Taxonomy(org.olat.modules.taxonomy.Taxonomy) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 54 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.

the class TaxonomyCompetenceDAOTest method createTaxonomyCompetence.

@Test
public void createTaxonomyCompetence() {
    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();
    Assert.assertNotNull(competence);
    Assert.assertNotNull(competence.getCreationDate());
}
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 55 with TaxonomyLevel

use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.

the class TaxonomyCompetenceDAOTest method getCompetenceByTaxonomyAndCompetenceTypes.

@Test
public void getCompetenceByTaxonomyAndCompetenceTypes() {
    // make 2 taxonomy trees
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
    Taxonomy taxonomy1 = taxonomyDao.createTaxonomy("ID-31", "Competence", "", null);
    TaxonomyLevel level1 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-1", "Competence level taxonomy 1", "A competence", null, null, null, null, taxonomy1);
    TaxonomyCompetence competence1 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level1, id, null);
    Taxonomy taxonomy2 = taxonomyDao.createTaxonomy("ID-32", "Competence", "", null);
    TaxonomyLevel level2 = taxonomyLevelDao.createTaxonomyLevel("ID-Level-2", "Competence level taxonomy 2", "A competence", null, null, null, null, taxonomy2);
    TaxonomyCompetence competence2 = taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, id, null);
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.have, level2, id, null);
    Identity otherId = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-5");
    taxonomyCompetenceDao.createTaxonomyCompetence(TaxonomyCompetenceTypes.target, level2, otherId, null);
    dbInstance.commitAndCloseSession();
    // check the competences of the 2 taxonomy trees
    List<TaxonomyCompetence> loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date(), TaxonomyCompetenceTypes.target);
    Assert.assertNotNull(loadedCompetences1);
    Assert.assertEquals(1, loadedCompetences1.size());
    Assert.assertEquals(competence1, loadedCompetences1.get(0));
    loadedCompetences1 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy1, id, new Date(), TaxonomyCompetenceTypes.have);
    Assert.assertEquals(0, loadedCompetences1.size());
    List<TaxonomyCompetence> loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date(), TaxonomyCompetenceTypes.target);
    Assert.assertNotNull(loadedCompetences2);
    Assert.assertEquals(1, loadedCompetences2.size());
    Assert.assertEquals(competence2, loadedCompetences2.get(0));
    loadedCompetences2 = taxonomyCompetenceDao.getCompetencesByTaxonomy(taxonomy2, id, new Date(), TaxonomyCompetenceTypes.manage, TaxonomyCompetenceTypes.teach);
    Assert.assertEquals(0, loadedCompetences2.size());
}
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) Date(java.util.Date) Test(org.junit.Test)

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