use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class MetadataBulkChangeController method formOKGeneral.
private void formOKGeneral(QuestionItemImpl itemImpl) {
if (isEnabled(topicEl))
itemImpl.setTopic(topicEl.getValue());
if (isEnabled(keywordsEl))
itemImpl.setKeywords(keywordsEl.getValue());
if (isEnabled(coverageEl))
itemImpl.setCoverage(coverageEl.getValue());
if (isEnabled(addInfosEl))
itemImpl.setAdditionalInformations(addInfosEl.getValue());
if (isEnabled(languageEl))
itemImpl.setLanguage(languageEl.getValue());
if (isEnabled(taxonomyLevelEl)) {
String selectedKey = taxonomyLevelEl.getSelectedKey();
TaxonomyLevel taxonomyLevel = qpoolTaxonomyTreeBuilder.getTaxonomyLevel(selectedKey);
itemImpl.setTaxonomyLevel(taxonomyLevel);
}
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class QPoolTaxonomyTreeBuilder method computeIntendention.
private StringBuilder computeIntendention(TaxonomyLevel level, StringBuilder intendation) {
TaxonomyLevel parent = level.getParent();
if (parent != null && selectableTaxonomyLevels.contains(parent)) {
intendation = intendation.append(INTENDING).append(INTENDING).append(INTENDING).append(INTENDING);
computeIntendention(parent, intendation);
}
return intendation;
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class QPoolTaxonomyTreeBuilder method prefillSelectableTaxonomyLevelsArrays.
private void prefillSelectableTaxonomyLevelsArrays() {
selectableKeys = new String[selectableTaxonomyLevels.size()];
selectableValues = new String[selectableTaxonomyLevels.size()];
taxonomicPaths = new String[selectableTaxonomyLevels.size()];
for (int i = selectableTaxonomyLevels.size(); i-- > 0; ) {
TaxonomyLevel level = selectableTaxonomyLevels.get(i);
selectableKeys[i] = Long.toString(level.getKey());
selectableValues[i] = computeIntendention(level, new StringBuilder()).append(level.getDisplayName()).toString();
taxonomicPaths[i] = level.getMaterializedPathIdentifiers();
}
addEmptyEntry();
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class QPoolTaxonomyTreeBuilder method prefillTaxonomyLevels.
private void prefillTaxonomyLevels(INode node) {
if (node instanceof TaxonomyLevelNode) {
TaxonomyLevelNode taxonomyLevelNode = (TaxonomyLevelNode) node;
TaxonomyLevel level = taxonomyLevelNode.getTaxonomyLevel();
if (level != null) {
if (acceptSelectableNode(level)) {
selectableTaxonomyLevels.add(taxonomyLevelNode.getTaxonomyLevel());
}
if (acceptTreeNode(level)) {
treeTaxonomyLevels.add(taxonomyLevelNode.getTaxonomyLevel());
}
}
for (int i = 0; i < node.getChildCount(); i++) {
prefillTaxonomyLevels(taxonomyLevelNode.getChildAt(i));
}
}
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project openolat by klemens.
the class QPoolTaxonomyTreeBuilder method buildTreeModel.
public TreeModel buildTreeModel() {
GenericTreeModel gtm = new GenericTreeModel();
TaxonomyLevelNode root = new TaxonomyLevelNode();
gtm.setRootNode(root);
List<TaxonomyLevel> taxonomyLevels = qpoolService.getTaxonomyLevels();
Map<Long, TaxonomyLevel> keytoLevels = taxonomyLevels.stream().collect(Collectors.toMap(l -> l.getKey(), l -> l));
Map<Long, TaxonomyLevelNode> fieldKeyToNode = new HashMap<>();
for (TaxonomyLevel taxonomyLevel : taxonomyLevels) {
Long key = taxonomyLevel.getKey();
TaxonomyLevelNode node = fieldKeyToNode.get(key);
if (node == null) {
node = new TaxonomyLevelNode(taxonomyLevel);
TaxonomyLevelType type = taxonomyLevel.getType();
if (type != null && StringHelper.containsNonWhitespace(type.getCssClass())) {
node.setIconCssClass(type.getCssClass());
}
fieldKeyToNode.put(key, node);
}
TaxonomyLevel parentLevel = taxonomyLevel.getParent();
if (parentLevel == null) {
// this is a root
root.addChild(node);
} else {
Long parentKey = parentLevel.getKey();
TaxonomyLevelNode parentNode = fieldKeyToNode.get(parentKey);
if (parentNode == null) {
// to use the fetched type
parentLevel = keytoLevels.get(parentKey);
parentNode = new TaxonomyLevelNode(parentLevel);
TaxonomyLevelType type = parentLevel.getType();
if (type != null && StringHelper.containsNonWhitespace(type.getCssClass())) {
parentNode.setIconCssClass(type.getCssClass());
}
fieldKeyToNode.put(parentKey, parentNode);
}
parentNode.addChild(node);
}
}
sort(root);
return gtm;
}
Aggregations