use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project openolat by klemens.
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 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();
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project openolat by klemens.
the class TaxonomyWebService method putTaxonomyLevel.
/**
* Create or update a taxonomy level. The method changes to tree structure, a
* null parent key will make the level a root one, a new parent key will move
* the level.
*
* @response.representation.200.qname {http://www.example.com}taxonomyLevelVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc A taxonomy level
* @response.representation.200.example {@link org.olat.modules.taxonomy.restapi.Examples#SAMPLE_TAXONOMYLEVELVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc An existant level was not found
* @param taxonomyKey The taxonomy tree where this level is
* @param httpRequest The HTTP request
* @param levelVo The roll call to update
* @return The updated roll call
*/
@PUT
@Path("levels")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response putTaxonomyLevel(TaxonomyLevelVO levelVo) {
TaxonomyLevel parentLevel = null;
if (levelVo.getParentKey() != null) {
parentLevel = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(levelVo.getParentKey()));
}
TaxonomyLevel level;
if (levelVo.getKey() != null) {
level = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(levelVo.getKey()));
if (levelVo.getIdentifier() != null) {
level.setIdentifier(levelVo.getIdentifier());
}
if (levelVo.getDisplayName() != null) {
level.setDisplayName(levelVo.getDisplayName());
}
if (levelVo.getDescription() != null) {
level.setDescription(levelVo.getDescription());
}
if (levelVo.getExternalId() != null) {
level.setExternalId(levelVo.getExternalId());
}
if (levelVo.getTypeKey() != null) {
TaxonomyLevelType type = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(levelVo.getTypeKey()));
level.setType(type);
}
if (levelVo.getManagedFlags() != null) {
level.setManagedFlags(TaxonomyLevelManagedFlag.toEnum(levelVo.getManagedFlags()));
}
level = taxonomyService.updateTaxonomyLevel(level);
} else {
level = taxonomyService.createTaxonomyLevel(levelVo.getIdentifier(), levelVo.getDisplayName(), levelVo.getDescription(), levelVo.getExternalId(), TaxonomyLevelManagedFlag.toEnum(levelVo.getManagedFlags()), parentLevel, taxonomy);
if (levelVo.getTypeKey() != null) {
TaxonomyLevelType type = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(levelVo.getTypeKey()));
level.setType(type);
level = taxonomyService.updateTaxonomyLevel(level);
}
}
if ((level.getParent() != null && levelVo.getParentKey() == null) || (level.getParent() == null && levelVo.getParentKey() != null) || (level.getParent() != null && !level.getParent().getKey().equals(levelVo.getParentKey()))) {
TaxonomyLevel newParentLevel = null;
if (levelVo.getParentKey() != null) {
newParentLevel = taxonomyService.getTaxonomyLevel(new TaxonomyLevelRefImpl(levelVo.getParentKey()));
}
level = taxonomyService.moveTaxonomyLevel(level, newParentLevel);
}
TaxonomyLevelVO newLevelVo = new TaxonomyLevelVO(level);
return Response.ok(newLevelVo).build();
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project openolat by klemens.
the class TypeTaxonomyLevelController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String selectedTypeKey = typeEl.getSelectedKey();
TaxonomyLevelType selectedType = taxonomyService.getTaxonomyLevelType(new TaxonomyLevelTypeRefImpl(Long.valueOf(selectedTypeKey)));
for (TaxonomyLevel level : levels) {
level.setType(selectedType);
level = taxonomyService.updateTaxonomyLevel(level);
}
fireEvent(ureq, Event.CHANGED_EVENT);
}
Aggregations