Search in sources :

Example 36 with TaxonomyLevelType

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

the class TaxonomyWebService method putTaxonomyLevelType.

/**
 * Create or Update a taxonomy level's type.
 *
 * @response.representation.200.qname {http://www.example.com}taxonomyLevelTypeVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc A taxonomy level type
 * @response.representation.200.example {@link org.olat.modules.taxonomy.restapi.Examples#SAMPLE_TAXONOMYLEVELTYPEVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The taxonomy level type to update was not found
 * @param taxonomyKey The taxonomy tree
 * @param httpRequest  The HTTP request
 * @param typeVo The taxonomy level type to create or update
 * @return The created/updated taxonomy level type
 */
@PUT
@Path("types")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response putTaxonomyLevelType(TaxonomyLevelTypeVO typeVo) {
    TaxonomyLevelType type;
    if (typeVo.getKey() != null) {
        type = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(typeVo.getKey()));
        if (type == null) {
            return Response.serverError().status(Status.NOT_FOUND).build();
        }
        if (typeVo.getIdentifier() != null) {
            type.setIdentifier(typeVo.getIdentifier());
        }
        if (typeVo.getDisplayName() != null) {
            type.setDisplayName(typeVo.getDisplayName());
        }
        if (typeVo.getDescription() != null) {
            type.setDescription(typeVo.getDescription());
        }
        if (typeVo.getExternalId() != null) {
            type.setExternalId(typeVo.getExternalId());
        }
    } else {
        type = taxonomyService.createTaxonomyLevelType(typeVo.getIdentifier(), typeVo.getDisplayName(), typeVo.getDescription(), typeVo.getExternalId(), taxonomy);
    }
    if (typeVo.getManagedFlags() != null) {
        type.setManagedFlags(TaxonomyLevelTypeManagedFlag.toEnum(typeVo.getManagedFlags()));
    }
    if (typeVo.getCssClass() != null) {
        type.setCssClass(typeVo.getCssClass());
    }
    if (typeVo.getVisible() != null) {
        type.setVisible(typeVo.getVisible().booleanValue());
    }
    if (typeVo.getDocumentsLibraryEnabled() != null) {
        type.setDocumentsLibraryEnabled(typeVo.getDocumentsLibraryEnabled().booleanValue());
    }
    if (typeVo.getDocumentsLibraryManagerCompetenceEnabled() != null) {
        type.setDocumentsLibraryManageCompetenceEnabled(typeVo.getDocumentsLibraryManagerCompetenceEnabled().booleanValue());
    }
    if (typeVo.getDocumentsLibraryTeachCompetenceReadEnabled() != null) {
        type.setDocumentsLibraryTeachCompetenceReadEnabled(typeVo.getDocumentsLibraryTeachCompetenceReadEnabled().booleanValue());
    }
    if (typeVo.getDocumentsLibraryTeachCompetenceReadParentLevels() != null) {
        type.setDocumentsLibraryTeachCompetenceReadParentLevels(typeVo.getDocumentsLibraryTeachCompetenceReadParentLevels().intValue());
    }
    if (typeVo.getDocumentsLibraryTeachCompetenceWriteEnabled() != null) {
        type.setDocumentsLibraryTeachCompetenceWriteEnabled(typeVo.getDocumentsLibraryTeachCompetenceWriteEnabled().booleanValue());
    }
    if (typeVo.getDocumentsLibraryHaveCompetenceReadEnabled() != null) {
        type.setDocumentsLibraryHaveCompetenceReadEnabled(typeVo.getDocumentsLibraryHaveCompetenceReadEnabled().booleanValue());
    }
    if (typeVo.getDocumentsLibraryTargetCompetenceReadEnabled() != null) {
        type.setDocumentsLibraryTargetCompetenceReadEnabled(typeVo.getDocumentsLibraryTargetCompetenceReadEnabled().booleanValue());
    }
    type = taxonomyService.updateTaxonomyLevelType(type);
    return Response.ok(new TaxonomyLevelTypeVO(type)).build();
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) TaxonomyLevelTypeRefImpl(org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 37 with TaxonomyLevelType

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

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

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

the class TypeTaxonomyLevelController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (availableTypes.isEmpty()) {
        if (formLayout instanceof FormLayoutContainer) {
            FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
            layoutCont.contextPut("errorMsg", translate("error.found.no.allowed.sub.types"));
        }
        uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
    } else {
        String[] theKeys = new String[availableTypes.size()];
        String[] theValues = new String[availableTypes.size()];
        for (int i = availableTypes.size(); i-- > 0; ) {
            TaxonomyLevelType type = availableTypes.get(i);
            theKeys[i] = type.getKey().toString();
            theValues[i] = type.getDisplayName();
        }
        typeEl = uifactory.addDropdownSingleselect("types", "level.types.to.assign", formLayout, theKeys, theValues, null);
        uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
        uifactory.addFormSubmitButton("assign.type", formLayout);
    }
}
Also used : TaxonomyLevelType(org.olat.modules.taxonomy.TaxonomyLevelType) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)

Example 39 with TaxonomyLevelType

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

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

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

the class DocumentPoolAdminPermissionsController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    List<String> names = new ArrayList<>(levelTypes.size());
    for (TaxonomyLevelType levelType : levelTypes) {
        EditTaxonomyLevelDocumentTypeController levelTypeCtrl = new EditTaxonomyLevelDocumentTypeController(ureq, getWindowControl(), levelType, mainForm);
        listenTo(levelTypeCtrl);
        String name = "perm_" + (++counter);
        formLayout.add(name, levelTypeCtrl.getInitialFormItem());
        typeCtrlList.add(levelTypeCtrl);
        names.add(name);
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("permissions", names);
    }
    FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonsCont);
    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)

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