use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class MoveTaxonomyLevelController method loadModel.
private void loadModel() {
new TaxonomyAllTreesBuilder().loadTreeModel(taxonomyModel, taxonomy);
// remove children of the level to move
for (TaxonomyLevel levelToMove : levelsToMove) {
TreeNode nodeToMove = taxonomyModel.getNodeById(TaxonomyAllTreesBuilder.nodeKey(levelToMove));
nodeToMove.removeAllChildren();
}
// remove the level with
List<TreeNode> openedNodes = new ArrayList<>();
filterByAllowedTypes(taxonomyModel.getRootNode(), openedNodes);
taxonomyModel.sort(taxonomyModel.getRootNode());
List<String> nodeIds = openedNodes.stream().map(node -> node.getIdent()).collect(Collectors.toList());
taxonomyEl.setOpenNodeIds(nodeIds);
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class MoveTaxonomyLevelController method getAllowedTypes.
private Set<TaxonomyLevelType> getAllowedTypes() {
List<TaxonomyLevelType> allTypes = new ArrayList<>(taxonomyService.getTaxonomyLevelTypes(taxonomy));
Map<TaxonomyLevelType, Set<TaxonomyLevelType>> subToParentTypes = new HashMap<>();
for (TaxonomyLevelType type : allTypes) {
Set<TaxonomyLevelTypeToType> typesToTypes = type.getAllowedTaxonomyLevelSubTypes();
for (TaxonomyLevelTypeToType typeToType : typesToTypes) {
TaxonomyLevelType subTyp = typeToType.getAllowedSubTaxonomyLevelType();
subToParentTypes.computeIfAbsent(subTyp, t -> new HashSet<>()).add(type);
}
}
Set<TaxonomyLevelType> analyzedTypes = new HashSet<>();
for (TaxonomyLevel level : levelsToMove) {
TaxonomyLevelType levelType = level.getType();
if (levelType != null && !analyzedTypes.contains(levelType)) {
analyzedTypes.add(levelType);
Set<TaxonomyLevelType> allowed = subToParentTypes.get(levelType);
if (allowed != null) {
allTypes.retainAll(allowed);
}
}
}
return new HashSet<>(allTypes);
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TaxonomyTreeTableController method getSelectedTaxonomyLevels.
private List<TaxonomyLevel> getSelectedTaxonomyLevels(TaxonomyLevelManagedFlag flag) {
Set<Integer> indexList = tableEl.getMultiSelectedIndex();
List<TaxonomyLevel> allowedLevels = new ArrayList<>(indexList.size());
for (Integer index : indexList) {
TaxonomyLevelRow row = model.getObject(index.intValue());
if (!TaxonomyLevelManagedFlag.isManaged(row.getManagedFlags(), flag)) {
TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(row);
if (taxonomyLevel != null) {
allowedLevels.add(taxonomyLevel);
}
}
}
return allowedLevels;
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TaxonomyTreeTableController method doAssignType.
private void doAssignType(UserRequest ureq) {
if (typeLevelCtrl != null)
return;
List<TaxonomyLevel> levelsToMerge = getSelectedTaxonomyLevels(TaxonomyLevelManagedFlag.type);
if (levelsToMerge.isEmpty()) {
showWarning("warning.atleastone.level");
} else {
typeLevelCtrl = new TypeTaxonomyLevelController(ureq, getWindowControl(), levelsToMerge, taxonomy);
listenTo(typeLevelCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", typeLevelCtrl.getInitialComponent(), true, translate("type.taxonomy.level"));
listenTo(cmc);
cmc.activate();
}
}
use of org.olat.modules.taxonomy.TaxonomyLevel in project OpenOLAT by OpenOLAT.
the class TaxonomyTreeTableController method doConfirmDelete.
private void doConfirmDelete(UserRequest ureq, TaxonomyLevelRow row) {
if (TaxonomyLevelManagedFlag.isManaged(row.getManagedFlags(), TaxonomyLevelManagedFlag.delete)) {
showWarning("warning.atleastone.level");
return;
}
TaxonomyLevel taxonomyLevel = taxonomyService.getTaxonomyLevel(row);
List<TaxonomyLevel> levelToDelete = Collections.singletonList(taxonomyLevel);
confirmDeleteCtrl = new DeleteTaxonomyLevelController(ureq, getWindowControl(), levelToDelete, taxonomy);
listenTo(confirmDeleteCtrl);
String title = translate("confirmation.delete.level.title");
cmc = new CloseableModalController(getWindowControl(), "close", confirmDeleteCtrl.getInitialComponent(), true, title);
listenTo(cmc);
cmc.activate();
}
Aggregations