Search in sources :

Example 16 with TaxonomyLevelType

use of org.olat.modules.taxonomy.TaxonomyLevelType 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 17 with TaxonomyLevelType

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

the class TaxonomyLevelTypesEditController method doEditLevelType.

private void doEditLevelType(UserRequest ureq, TaxonomyLevelTypeRef type) {
    TaxonomyLevelType reloadedType = taxonomyService.getTaxonomyLevelType(type);
    editLevelTypeCtrl = new EditTaxonomyLevelTypeController(ureq, this.getWindowControl(), reloadedType, taxonomy);
    listenTo(editLevelTypeCtrl);
    cmc = new CloseableModalController(getWindowControl(), "close", editLevelTypeCtrl.getInitialComponent(), true, translate("edit"));
    listenTo(cmc);
    cmc.activate();
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType)

Example 18 with TaxonomyLevelType

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

the class DocumentPoolManagerTest method hasCompetenceByTaxonomy_teachWrite.

@Test
public void hasCompetenceByTaxonomy_teachWrite() {
    // create a level and competence with a type teach
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
    TaxonomyLevelType type = createTypeLevelCompetence(id, null, TaxonomyCompetenceTypes.teach);
    // set read for teach competence
    type.setDocumentsLibraryTeachCompetenceWriteEnabled(true);
    type = taxonomyLevelTypeDao.updateTaxonomyLevelType(type);
    dbInstance.commitAndCloseSession();
    boolean hasCompetence = documentPoolManager.hasValidCompetence(id);
    Assert.assertTrue(hasCompetence);
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 19 with TaxonomyLevelType

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

the class DocumentPoolManagerTest method hasCompetenceByTaxonomy_target.

@Test
public void hasCompetenceByTaxonomy_target() {
    // create a level and competence with a type teach
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
    TaxonomyLevelType type = createTypeLevelCompetence(id, null, TaxonomyCompetenceTypes.target);
    // set read for teach competence
    type.setDocumentsLibraryTargetCompetenceReadEnabled(true);
    type = taxonomyLevelTypeDao.updateTaxonomyLevelType(type);
    dbInstance.commitAndCloseSession();
    boolean hasCompetence = documentPoolManager.hasValidCompetence(id);
    Assert.assertTrue(hasCompetence);
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 20 with TaxonomyLevelType

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

the class DocumentPoolManagerTest method hasCompetenceByTaxonomy_have.

@Test
public void hasCompetenceByTaxonomy_have() {
    // create a level and competence with a type teach
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
    TaxonomyLevelType type = createTypeLevelCompetence(id, null, TaxonomyCompetenceTypes.have);
    // set read for teach competence
    type.setDocumentsLibraryHaveCompetenceReadEnabled(true);
    type = taxonomyLevelTypeDao.updateTaxonomyLevelType(type);
    dbInstance.commitAndCloseSession();
    boolean hasCompetence = documentPoolManager.hasValidCompetence(id);
    Assert.assertTrue(hasCompetence);
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Aggregations

TaxonomyLevelType (org.olat.modules.taxonomy.TaxonomyLevelType)92 Test (org.junit.Test)40 Taxonomy (org.olat.modules.taxonomy.Taxonomy)32 TaxonomyLevel (org.olat.modules.taxonomy.TaxonomyLevel)32 ArrayList (java.util.ArrayList)26 Identity (org.olat.core.id.Identity)20 TaxonomyLevelTypeToType (org.olat.modules.taxonomy.TaxonomyLevelTypeToType)16 URI (java.net.URI)14 HttpResponse (org.apache.http.HttpResponse)14 TaxonomyLevelTypeRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl)14 Path (javax.ws.rs.Path)12 List (java.util.List)10 Produces (javax.ws.rs.Produces)10 Collectors (java.util.stream.Collectors)8 TaxonomyLevelRefImpl (org.olat.modules.taxonomy.model.TaxonomyLevelRefImpl)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 PUT (javax.ws.rs.PUT)6 HttpGet (org.apache.http.client.methods.HttpGet)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6