use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project OpenOLAT by OpenOLAT.
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 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 OpenOLAT.
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);
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project OpenOLAT by OpenOLAT.
the class EditTaxonomyLevelController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (level == null) {
TaxonomyLevel selectedParentLevel = null;
if (parentLevel == null) {
if (pathEl != null && pathEl.isEnabled() && pathEl.isOneSelected() && !"-".equals(pathEl.getSelectedKey())) {
TaxonomyLevelRef ref = new TaxonomyLevelRefImpl(new Long(pathEl.getSelectedKey()));
selectedParentLevel = taxonomyService.getTaxonomyLevel(ref);
}
} else {
selectedParentLevel = parentLevel;
}
level = taxonomyService.createTaxonomyLevel(identifierEl.getValue(), displayNameEl.getValue(), descriptionEl.getValue(), null, null, selectedParentLevel, taxonomy);
} else {
level = taxonomyService.getTaxonomyLevel(level);
level.setIdentifier(identifierEl.getValue());
level.setDisplayName(displayNameEl.getValue());
level.setDescription(descriptionEl.getValue());
}
String selectedTypeKey = taxonomyLevelTypeEl.getSelectedKey();
if (StringHelper.containsNonWhitespace(selectedTypeKey)) {
TaxonomyLevelTypeRef typeRef = new TaxonomyLevelTypeRefImpl(new Long(selectedTypeKey));
TaxonomyLevelType type = taxonomyService.getTaxonomyLevelType(typeRef);
level.setType(type);
} else {
level.setType(null);
}
if (StringHelper.isLong(sortOrderEl.getValue())) {
level.setSortOrder(new Integer(sortOrderEl.getValue()));
} else {
level.setSortOrder(null);
}
level = taxonomyService.updateTaxonomyLevel(level);
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.modules.taxonomy.model.TaxonomyLevelTypeRefImpl in project openolat by klemens.
the class EditTaxonomyLevelController method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (level == null) {
TaxonomyLevel selectedParentLevel = null;
if (parentLevel == null) {
if (pathEl != null && pathEl.isEnabled() && pathEl.isOneSelected() && !"-".equals(pathEl.getSelectedKey())) {
TaxonomyLevelRef ref = new TaxonomyLevelRefImpl(new Long(pathEl.getSelectedKey()));
selectedParentLevel = taxonomyService.getTaxonomyLevel(ref);
}
} else {
selectedParentLevel = parentLevel;
}
level = taxonomyService.createTaxonomyLevel(identifierEl.getValue(), displayNameEl.getValue(), descriptionEl.getValue(), null, null, selectedParentLevel, taxonomy);
} else {
level = taxonomyService.getTaxonomyLevel(level);
level.setIdentifier(identifierEl.getValue());
level.setDisplayName(displayNameEl.getValue());
level.setDescription(descriptionEl.getValue());
}
String selectedTypeKey = taxonomyLevelTypeEl.getSelectedKey();
if (StringHelper.containsNonWhitespace(selectedTypeKey)) {
TaxonomyLevelTypeRef typeRef = new TaxonomyLevelTypeRefImpl(new Long(selectedTypeKey));
TaxonomyLevelType type = taxonomyService.getTaxonomyLevelType(typeRef);
level.setType(type);
} else {
level.setType(null);
}
if (StringHelper.isLong(sortOrderEl.getValue())) {
level.setSortOrder(new Integer(sortOrderEl.getValue()));
} else {
level.setSortOrder(null);
}
level = taxonomyService.updateTaxonomyLevel(level);
fireEvent(ureq, Event.DONE_EVENT);
}
Aggregations