use of org.olat.modules.taxonomy.TaxonomyLevelType in project OpenOLAT by OpenOLAT.
the class DocumentPoolManagerTest method hasCompetenceByTaxonomy_teachWrite.
@Test
public void hasCompetenceByTaxonomy_teachWrite() {
// create a level and competence with a type teach
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("competent-8");
TaxonomyLevelType type = createTypeLevelCompetence(id, null, TaxonomyCompetenceTypes.teach);
// set read for teach competence
type.setDocumentsLibraryTeachCompetenceWriteEnabled(true);
type = taxonomyLevelTypeDao.updateTaxonomyLevelType(type);
dbInstance.commitAndCloseSession();
boolean hasCompetence = documentPoolManager.hasValidCompetence(id);
Assert.assertTrue(hasCompetence);
}
use of org.olat.modules.taxonomy.TaxonomyLevelType in project OpenOLAT by OpenOLAT.
the class TaxonomyServiceImpl method cloneTaxonomyLevelType.
@Override
public TaxonomyLevelType cloneTaxonomyLevelType(TaxonomyLevelTypeRef levelType) {
TaxonomyLevelType clonedType = taxonomyLevelTypeDao.cloneTaxonomyLevelType(levelType);
List<TaxonomyLevelTypeToType> allowSubTypesToTypes = taxonomyLevelTypeToTypeDao.getAllowedSubTypes(levelType);
if (allowSubTypesToTypes.size() > 0) {
for (TaxonomyLevelTypeToType allowSubTypeToType : allowSubTypesToTypes) {
taxonomyLevelTypeToTypeDao.addAllowedSubType(clonedType, allowSubTypeToType.getAllowedSubTaxonomyLevelType());
}
}
return clonedType;
}
use of org.olat.modules.taxonomy.TaxonomyLevelType in project OpenOLAT by OpenOLAT.
the class EditTaxonomyLevelController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (level == null || level.getKey() == null) {
String[] pathKeys;
String[] pathValues;
if (parentLevel == null) {
List<String> pathKeyList = new ArrayList<>();
List<String> pathValueList = new ArrayList<>();
buildPathKeysAndValues(pathKeyList, pathValueList);
pathKeys = pathKeyList.toArray(new String[pathKeyList.size()]);
pathValues = pathValueList.toArray(new String[pathValueList.size()]);
} else {
pathKeys = new String[] { parentLevel.getKey().toString() };
pathValues = new String[] { parentLevel.getMaterializedPathIdentifiers() };
}
pathEl = uifactory.addDropdownSingleselect("level.path", "taxonomy.level.path", formLayout, pathKeys, pathValues, null);
pathEl.setEnabled(parentLevel == null);
}
String identifier = level == null ? "" : level.getIdentifier();
identifierEl = uifactory.addTextElement("level.identifier", "level.identifier", 255, identifier, formLayout);
identifierEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.identifier));
identifierEl.setMandatory(true);
String displayName = level == null ? "" : level.getDisplayName();
displayNameEl = uifactory.addTextElement("level.displayname", "level.displayname", 255, displayName, formLayout);
displayNameEl.setMandatory(true);
displayNameEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.displayName));
if (!StringHelper.containsNonWhitespace(displayName)) {
displayNameEl.setFocus(true);
}
List<TaxonomyLevelType> types = getTypes();
String[] typeKeys = new String[types.size() + 1];
String[] typeValues = new String[types.size() + 1];
typeKeys[0] = "";
typeValues[0] = "-";
for (int i = types.size(); i-- > 0; ) {
typeKeys[i + 1] = types.get(i).getKey().toString();
typeValues[i + 1] = types.get(i).getDisplayName();
}
taxonomyLevelTypeEl = uifactory.addDropdownSingleselect("level.type", "level.type", formLayout, typeKeys, typeValues, null);
taxonomyLevelTypeEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.type));
boolean typeFound = false;
if (level != null && level.getType() != null) {
String selectedTypeKey = level.getType().getKey().toString();
for (String typeKey : typeKeys) {
if (typeKey.equals(selectedTypeKey)) {
taxonomyLevelTypeEl.select(selectedTypeKey, true);
typeFound = true;
break;
}
}
}
if (!typeFound) {
taxonomyLevelTypeEl.select(typeKeys[0], true);
}
String sortOrder = level == null || level.getSortOrder() == null ? "" : level.getSortOrder().toString();
sortOrderEl = uifactory.addTextElement("level.sort.order", "level.sort.order", 255, sortOrder, formLayout);
sortOrderEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.displayName));
String description = level == null ? "" : level.getDescription();
descriptionEl = uifactory.addRichTextElementForStringDataCompact("level.description", "level.description", description, 10, 60, null, formLayout, ureq.getUserSession(), getWindowControl());
descriptionEl.setEnabled(!TaxonomyLevelManagedFlag.isManaged(level, TaxonomyLevelManagedFlag.description));
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
uifactory.addFormSubmitButton("save", buttonsCont);
}
use of org.olat.modules.taxonomy.TaxonomyLevelType in project OpenOLAT by OpenOLAT.
the class EditTaxonomyLevelController method getTypes.
private List<TaxonomyLevelType> getTypes() {
List<TaxonomyLevelType> types = new ArrayList<>();
if (level != null) {
List<TaxonomyLevel> parentLine = taxonomyService.getTaxonomyLevelParentLine(level, taxonomy);
for (int i = parentLine.size() - 1; i-- > 0; ) {
TaxonomyLevel parent = parentLine.get(i);
TaxonomyLevelType parentType = parent.getType();
if (parentType != null) {
Set<TaxonomyLevelTypeToType> typeToTypes = parentType.getAllowedTaxonomyLevelSubTypes();
for (TaxonomyLevelTypeToType typeToType : typeToTypes) {
if (typeToType != null) {
types.add(typeToType.getAllowedSubTaxonomyLevelType());
}
}
break;
}
}
}
if (types.isEmpty()) {
types.addAll(taxonomyService.getTaxonomyLevelTypes(taxonomy));
} else if (level != null && level.getType() != null) {
if (!types.contains(level.getType())) {
types.add(level.getType());
}
}
return types;
}
use of org.olat.modules.taxonomy.TaxonomyLevelType in project OpenOLAT by OpenOLAT.
the class TaxonomyLevelTypeDAO method cloneTaxonomyLevelType.
public TaxonomyLevelType cloneTaxonomyLevelType(TaxonomyLevelTypeRef typeRef) {
TaxonomyLevelType reloadedType = loadTaxonomyLevelTypeByKey(typeRef.getKey());
TaxonomyLevelTypeImpl type = new TaxonomyLevelTypeImpl();
type.setCreationDate(new Date());
type.setLastModified(type.getCreationDate());
type.setIdentifier(reloadedType.getIdentifier() + " (Copy)");
type.setDisplayName(reloadedType.getDisplayName());
type.setDescription(reloadedType.getDescription());
type.setExternalId("");
// default settings
type.setDocumentsLibraryManageCompetenceEnabled(reloadedType.isDocumentsLibraryManageCompetenceEnabled());
type.setDocumentsLibraryTeachCompetenceReadEnabled(reloadedType.isDocumentsLibraryTargetCompetenceReadEnabled());
type.setDocumentsLibraryTeachCompetenceReadParentLevels(reloadedType.getDocumentsLibraryTeachCompetenceReadParentLevels());
type.setDocumentsLibraryTeachCompetenceWriteEnabled(reloadedType.isDocumentsLibraryTeachCompetenceWriteEnabled());
type.setDocumentsLibraryHaveCompetenceReadEnabled(reloadedType.isDocumentsLibraryHaveCompetenceReadEnabled());
type.setDocumentsLibraryTargetCompetenceReadEnabled(reloadedType.isDocumentsLibraryTargetCompetenceReadEnabled());
// root
type.setTaxonomy(reloadedType.getTaxonomy());
dbInstance.getCurrentEntityManager().persist(type);
return type;
}
Aggregations