use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project OpenOLAT by OpenOLAT.
the class TaxonomyWebService method getAllowedSubTaxonomyLevelTypes.
/**
* Get the allowed sub-types of a specified 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 An array of taxonomy level types
* @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 was not found
* @param taxonomyKey The taxonomy tree
* @param httpRequest The HTTP request
* @param typeKey The primary key of the taxonomy level type
* @return An array of taxonomy level types
*/
@GET
@Path("types/{typeKey}/allowedSubTypes")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAllowedSubTaxonomyLevelTypes(@PathParam("typeKey") Long typeKey) {
TaxonomyLevelType type = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(typeKey));
if (type == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
Set<TaxonomyLevelTypeToType> typeToTypes = type.getAllowedTaxonomyLevelSubTypes();
List<TaxonomyLevelTypeVO> subTypeVOes = new ArrayList<>(typeToTypes.size());
for (TaxonomyLevelTypeToType typeToType : typeToTypes) {
TaxonomyLevelType subType = typeToType.getAllowedSubTaxonomyLevelType();
subTypeVOes.add(new TaxonomyLevelTypeVO(subType));
}
return Response.ok(subTypeVOes.toArray(new TaxonomyLevelTypeVO[subTypeVOes.size()])).build();
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project openolat by klemens.
the class TaxonomyWebService method allowSubTaxonomyLevelType.
/**
* Add a sub-type to a specified 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 The sub type was added to the allowed sub types
* @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 was not found
* @param taxonomyKey The taxonomy tree
* @param typeKey The type
* @param subTypeKey The sub type
* @param httpRequest The HTTP request
* @return Nothing
*/
@PUT
@Path("types/{typeKey}/allowedSubTypes/{subTypeKey}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response allowSubTaxonomyLevelType(@PathParam("typeKey") Long typeKey, @PathParam("subTypeKey") Long subTypeKey) {
TaxonomyLevelType type = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(typeKey));
TaxonomyLevelType subType = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(subTypeKey));
if (type == null || subType == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
taxonomyService.taxonomyLevelTypeAllowSubType(type, subType);
return Response.ok().build();
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl 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.model.TaxonomyLevelTypeRefImpl in project OpenOLAT by OpenOLAT.
the class TaxonomyWebService method allowSubTaxonomyLevelType.
/**
* Add a sub-type to a specified 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 The sub type was added to the allowed sub types
* @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 was not found
* @param taxonomyKey The taxonomy tree
* @param typeKey The type
* @param subTypeKey The sub type
* @param httpRequest The HTTP request
* @return Nothing
*/
@PUT
@Path("types/{typeKey}/allowedSubTypes/{subTypeKey}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response allowSubTaxonomyLevelType(@PathParam("typeKey") Long typeKey, @PathParam("subTypeKey") Long subTypeKey) {
TaxonomyLevelType type = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(typeKey));
TaxonomyLevelType subType = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(subTypeKey));
if (type == null || subType == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
taxonomyService.taxonomyLevelTypeAllowSubType(type, subType);
return Response.ok().build();
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project OpenOLAT by OpenOLAT.
the class TaxonomyWebService method disalloweSubTaxonomyLevelType.
/**
* Remove a sub-type to a specified taxonomy level's type.
*
* @response.representation.200.doc The sub type was removed sucessfully
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The taxonomy level type was not found
* @param taxonomyKey The taxonomy tree
* @param typeKey The type
* @param subTypeKey The sub type to remove
* @param httpRequest The HTTP request
* @return Nothing
*/
@DELETE
@Path("types/{typeKey}/allowedSubTypes/{subTypeKey}")
public Response disalloweSubTaxonomyLevelType(@PathParam("typeKey") Long typeKey, @PathParam("subTypeKey") Long subTypeKey) {
TaxonomyLevelType type = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(typeKey));
TaxonomyLevelType subType = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(subTypeKey));
if (type == null || subType == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
taxonomyService.taxonomyLevelTypeDisallowSubType(type, subType);
return Response.ok().build();
}
Aggregations