Search in sources :

Example 1 with TaxonomyLevelType

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

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 2 with TaxonomyLevelType

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

the class TaxonomyServiceImpl method cloneTaxonomyLevelType.

@Override
public TaxonomyLevelType cloneTaxonomyLevelType(TaxonomyLevelTypeRef levelType) {
    TaxonomyLevelType clonedType = taxonomyLevelTypeDao.cloneTaxonomyLevelType(levelType);
    List<TaxonomyLevelTypeToType> allowSubTypesToTypes = taxonomyLevelTypeToTypeDao.getAllowedSubTypes(levelType);
    if (allowSubTypesToTypes.size() > 0) {
        for (TaxonomyLevelTypeToType allowSubTypeToType : allowSubTypesToTypes) {
            taxonomyLevelTypeToTypeDao.addAllowedSubType(clonedType, allowSubTypeToType.getAllowedSubTaxonomyLevelType());
        }
    }
    return clonedType;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType)

Example 3 with TaxonomyLevelType

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

the class EditTaxonomyLevelController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (level == null || level.getKey() == null) {
        String[] pathKeys;
        String[] pathValues;
        if (parentLevel == null) {
            List<String> pathKeyList = new ArrayList<>();
            List<String> pathValueList = new ArrayList<>();
            buildPathKeysAndValues(pathKeyList, pathValueList);
            pathKeys = pathKeyList.toArray(new String[pathKeyList.size()]);
            pathValues = pathValueList.toArray(new String[pathValueList.size()]);
        } else {
            pathKeys = new String[] { parentLevel.getKey().toString() };
            pathValues = new String[] { parentLevel.getMaterializedPathIdentifiers() };
        }
        pathEl = uifactory.addDropdownSingleselect("level.path", "taxonomy.level.path", formLayout, pathKeys, pathValues, null);
        pathEl.setEnabled(parentLevel == null);
    }
    String identifier = level == null ? "" : level.getIdentifier();
    identifierEl = uifactory.addTextElement("level.identifier", "level.identifier", 255, identifier, formLayout);
    identifierEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.identifier));
    identifierEl.setMandatory(true);
    String displayName = level == null ? "" : level.getDisplayName();
    displayNameEl = uifactory.addTextElement("level.displayname", "level.displayname", 255, displayName, formLayout);
    displayNameEl.setMandatory(true);
    displayNameEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.displayName));
    if (!StringHelper.containsNonWhitespace(displayName)) {
        displayNameEl.setFocus(true);
    }
    List<TaxonomyLevelType> types = getTypes();
    String[] typeKeys = new String[types.size() + 1];
    String[] typeValues = new String[types.size() + 1];
    typeKeys[0] = "";
    typeValues[0] = "-";
    for (int i = types.size(); i-- > 0; ) {
        typeKeys[i + 1] = types.get(i).getKey().toString();
        typeValues[i + 1] = types.get(i).getDisplayName();
    }
    taxonomyLevelTypeEl = uifactory.addDropdownSingleselect("level.type", "level.type", formLayout, typeKeys, typeValues, null);
    taxonomyLevelTypeEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.type));
    boolean typeFound = false;
    if (level != null && level.getType() != null) {
        String selectedTypeKey = level.getType().getKey().toString();
        for (String typeKey : typeKeys) {
            if (typeKey.equals(selectedTypeKey)) {
                taxonomyLevelTypeEl.select(selectedTypeKey, true);
                typeFound = true;
                break;
            }
        }
    }
    if (!typeFound) {
        taxonomyLevelTypeEl.select(typeKeys[0], true);
    }
    String sortOrder = level == null || level.getSortOrder() == null ? "" : level.getSortOrder().toString();
    sortOrderEl = uifactory.addTextElement("level.sort.order", "level.sort.order", 255, sortOrder, formLayout);
    sortOrderEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.displayName));
    String description = level == null ? "" : level.getDescription();
    descriptionEl = uifactory.addRichTextElementForStringDataCompact("level.description", "level.description", description, 10, 60, null, formLayout, ureq.getUserSession(), getWindowControl());
    descriptionEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.description));
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
    uifactory.addFormSubmitButton("save", buttonsCont);
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 4 with TaxonomyLevelType

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

the class EditTaxonomyLevelController method getTypes.

private List<TaxonomyLevelType> getTypes() {
    List<TaxonomyLevelType> types = new ArrayList<>();
    if (level != null) {
        List<TaxonomyLevel> parentLine = taxonomyService.getTaxonomyLevelParentLine(level, taxonomy);
        for (int i = parentLine.size() - 1; i-- > 0; ) {
            TaxonomyLevel parent = parentLine.get(i);
            TaxonomyLevelType parentType = parent.getType();
            if (parentType != null) {
                Set<TaxonomyLevelTypeToType> typeToTypes = parentType.getAllowedTaxonomyLevelSubTypes();
                for (TaxonomyLevelTypeToType typeToType : typeToTypes) {
                    if (typeToType != null) {
                        types.add(typeToType.getAllowedSubTaxonomyLevelType());
                    }
                }
                break;
            }
        }
    }
    if (types.isEmpty()) {
        types.addAll(taxonomyService.getTaxonomyLevelTypes(taxonomy));
    } else if (level != null && level.getType() != null) {
        if (!types.contains(level.getType())) {
            types.add(level.getType());
        }
    }
    return types;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevel(org.olat.modules.taxonomy.TaxonomyLevel) ArrayList(java.util.ArrayList) TaxonomyLevelTypeToType(org.olat.modules.taxonomy.TaxonomyLevelTypeToType)

Example 5 with TaxonomyLevelType

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

the class TaxonomyLevelTypeDAO method cloneTaxonomyLevelType.

public TaxonomyLevelType cloneTaxonomyLevelType(TaxonomyLevelTypeRef typeRef) {
    TaxonomyLevelType reloadedType = loadTaxonomyLevelTypeByKey(typeRef.getKey());
    TaxonomyLevelTypeImpl type = new TaxonomyLevelTypeImpl();
    type.setCreationDate(new Date());
    type.setLastModified(type.getCreationDate());
    type.setIdentifier(reloadedType.getIdentifier() + " (Copy)");
    type.setDisplayName(reloadedType.getDisplayName());
    type.setDescription(reloadedType.getDescription());
    type.setExternalId("");
    // default settings
    type.setDocumentsLibraryManageCompetenceEnabled(reloadedType.isDocumentsLibraryManageCompetenceEnabled());
    type.setDocumentsLibraryTeachCompetenceReadEnabled(reloadedType.isDocumentsLibraryTargetCompetenceReadEnabled());
    type.setDocumentsLibraryTeachCompetenceReadParentLevels(reloadedType.getDocumentsLibraryTeachCompetenceReadParentLevels());
    type.setDocumentsLibraryTeachCompetenceWriteEnabled(reloadedType.isDocumentsLibraryTeachCompetenceWriteEnabled());
    type.setDocumentsLibraryHaveCompetenceReadEnabled(reloadedType.isDocumentsLibraryHaveCompetenceReadEnabled());
    type.setDocumentsLibraryTargetCompetenceReadEnabled(reloadedType.isDocumentsLibraryTargetCompetenceReadEnabled());
    // root
    type.setTaxonomy(reloadedType.getTaxonomy());
    dbInstance.getCurrentEntityManager().persist(type);
    return type;
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevelTypeImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeImpl) Date(java.util.Date)

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