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