use of org.olat.modules.taxonomy.model.TaxonomyTreeNode in project openolat by klemens.
the class DocumentPoolMainController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty()) {
if (taxonomyTree.getTreeModel().getRootNode().getChildCount() > 0) {
doSelectTaxonomy(ureq);
}
} else {
String resourceName = entries.get(0).getOLATResourceable().getResourceableTypeName();
if ("Templates".equals(resourceName) || resourceName.startsWith("path=")) {
TreeNode rootNode = taxonomyTree.getTreeModel().getRootNode();
if (rootNode.getChildCount() > 0) {
TaxonomyTreeNode node = (TaxonomyTreeNode) rootNode.getChildAt(0);
if (node.getType() == TaxonomyTreeNodeType.templates) {
DocumentDirectoryController directoryCtrl = doSelectTemplatesDirectory(ureq, node);
if (directoryCtrl != null) {
taxonomyTree.setSelectedNode(node);
List<ContextEntry> subEntries = entries.subList(1, entries.size());
directoryCtrl.activate(ureq, subEntries, entries.get(0).getTransientState());
}
}
}
} else if ("TaxonomyLevel".equalsIgnoreCase(resourceName)) {
String levelKey = entries.get(0).getOLATResourceable().getResourceableId().toString();
TaxonomyTreeNode node = (TaxonomyTreeNode) taxonomyTree.getTreeModel().getNodeById(levelKey);
if (node != null) {
DocumentPoolLevelController levelCtrl = doSelectTaxonomyLevel(ureq, node);
if (levelCtrl != null) {
taxonomyTree.setSelectedNode(node);
List<ContextEntry> subEntries = entries.subList(1, entries.size());
levelCtrl.activate(ureq, subEntries, entries.get(0).getTransientState());
}
}
}
}
}
use of org.olat.modules.taxonomy.model.TaxonomyTreeNode in project openolat by klemens.
the class DocumentPoolMainController method doSelectTaxonomyLevel.
private DocumentPoolLevelController doSelectTaxonomyLevel(UserRequest ureq, TaxonomyTreeNode node) {
if (isTaxonomyAdmin || node.isCanRead() || node.isCanWrite()) {
TaxonomyLevel level = node.getTaxonomyLevel();
SubscriptionContext subscriptionCtx = notificationsHandler.getTaxonomyDocumentsLibrarySubscriptionContext();
TaxonomyVFSSecurityCallback secCallback = new TaxonomyVFSSecurityCallback(node, subscriptionCtx);
OLATResourceable ores = OresHelper.createOLATResourceableInstance("TaxonomyLevel", node.getTaxonomyLevel().getKey());
WindowControl bwControl = addToHistory(ureq, ores, null);
DocumentPoolLevelController levelCtrl = new DocumentPoolLevelController(ureq, bwControl, level, node, secCallback);
listenTo(levelCtrl);
String displayName = level.getDisplayName();
content.popUpToRootController(ureq);
List<TreeNode> parentLines = TreeHelper.getTreePath(node);
for (int i = 1; i < parentLines.size() - 1; i++) {
TreeNode parent = parentLines.get(i);
content.pushController(parent.getTitle(), null, parent);
}
content.pushController(displayName, levelCtrl);
return levelCtrl;
}
return null;
}
use of org.olat.modules.taxonomy.model.TaxonomyTreeNode in project openolat by klemens.
the class DocumentPoolNotificationsHandler method createSubscriptionInfo.
@Override
public SubscriptionInfo createSubscriptionInfo(Subscriber subscriber, Locale locale, Date compareDate) {
Publisher p = subscriber.getPublisher();
Date latestNews = p.getLatestNewsDate();
try {
SubscriptionInfo si;
String taxonomyKey = documentPoolModule.getTaxonomyTreeKey();
if (notificationsManager.isPublisherValid(p) && compareDate.before(latestNews) && StringHelper.isLong(taxonomyKey)) {
Taxonomy taxonomy = taxonomyService.getTaxonomy(new TaxonomyRefImpl(new Long(taxonomyKey)));
if (taxonomy == null) {
return notificationsManager.getNoSubscriptionInfo();
}
Identity identity = subscriber.getIdentity();
Roles roles = securityManager.getRoles(identity);
boolean isTaxonomyAdmin = roles.isOLATAdmin();
Translator translator = Util.createPackageTranslator(DocumentPoolMainController.class, locale);
String templates = translator.translate("document.pool.templates");
TaxonomyTreeBuilder builder = new TaxonomyTreeBuilder(taxonomy, identity, null, isTaxonomyAdmin, documentPoolModule.isTemplatesDirectoryEnabled(), templates, locale);
TreeModel model = builder.buildTreeModel();
si = new SubscriptionInfo(subscriber.getKey(), p.getType(), getTitleItemForPublisher(), null);
new TreeVisitor(node -> {
TaxonomyTreeNode tNode = (TaxonomyTreeNode) node;
if (tNode.getTaxonomyLevel() != null && tNode.isDocumentsLibraryEnabled() && tNode.isCanRead()) {
VFSContainer container = taxonomyService.getDocumentsLibrary(tNode.getTaxonomyLevel());
String prefixBusinessPath = "[DocumentPool:" + taxonomy.getKey() + "][TaxonomyLevel:" + tNode.getTaxonomyLevel().getKey() + "][path=";
createSubscriptionInfo(container, prefixBusinessPath, compareDate, si, p, translator);
} else if (tNode.getType() == TaxonomyTreeNodeType.templates) {
VFSContainer container = taxonomyService.getDocumentsLibrary(taxonomy);
String prefixBusinessPath = "[DocumentPool:" + taxonomy.getKey() + "][Templates:0s][path=";
createSubscriptionInfo(container, prefixBusinessPath, compareDate, si, p, translator);
}
}, model.getRootNode(), false).visitAll();
} else {
si = NotificationsManager.getInstance().getNoSubscriptionInfo();
}
return si;
} catch (Exception e) {
log.error("Cannot create document pool notifications for subscriber: " + subscriber.getKey(), e);
return notificationsManager.getNoSubscriptionInfo();
}
}
use of org.olat.modules.taxonomy.model.TaxonomyTreeNode in project openolat by klemens.
the class DocumentPoolWebDAVMergeSource method loadRecursiveMergedContainers.
private VFSContainer loadRecursiveMergedContainers(Taxonomy taxonomy, INode node) {
VFSContainer container = null;
if (node instanceof TaxonomyTreeNode) {
TaxonomyTreeNode taxonomyNode = (TaxonomyTreeNode) node;
String name = RequestUtil.normalizeFilename(taxonomyNode.getTitle());
VirtualContainer levelContainer = new VirtualContainer(name);
levelContainer.setLocalSecurityCallback(new DefaultVFSSecurityCallback());
boolean hasDocuments = false;
if (taxonomyNode.getType() == TaxonomyTreeNodeType.templates) {
// the templates
return addTemplates(taxonomyNode, taxonomy);
} else if (taxonomyNode.getTaxonomyLevel() != null && taxonomyNode.isDocumentsLibraryEnabled() && taxonomyNode.isCanRead()) {
// the real thing
levelContainer.addItem(addDocument(taxonomyNode));
hasDocuments = true;
}
for (int i = 0; i < node.getChildCount(); i++) {
VFSContainer childContainer = loadRecursiveMergedContainers(taxonomy, node.getChildAt(i));
if (childContainer != null) {
levelContainer.addItem(childContainer);
hasDocuments = true;
}
}
container = hasDocuments ? levelContainer : null;
}
return container;
}
use of org.olat.modules.taxonomy.model.TaxonomyTreeNode in project OpenOLAT by OpenOLAT.
the class TaxonomyTreeBuilder method computePermissionsRecursive.
private void computePermissionsRecursive(TaxonomyTreeNode node, Map<TaxonomyLevel, List<TaxonomyCompetenceTypes>> levelToCompetences) {
boolean hasRead = node.isCanRead();
boolean hasWrite = node.isCanWrite();
if (node.getType() == TaxonomyTreeNodeType.lostAndFound) {
hasRead = isTaxonomyAdmin;
hasWrite = isTaxonomyAdmin;
node.setCanRead(hasRead);
node.setCanWrite(hasWrite);
} else if (node.getTaxonomyLevel() != null) {
TaxonomyLevel level = node.getTaxonomyLevel();
TaxonomyLevelType type = level.getType();
if (type != null) {
List<TaxonomyCompetenceTypes> competences = levelToCompetences.get(level);
if (competences != null && competences.size() > 0) {
for (TaxonomyCompetenceTypes competence : competences) {
hasRead |= hasReadAccess(type, competence);
hasWrite |= hasWriteAccess(type, competence);
if (competence == TaxonomyCompetenceTypes.teach && type.getDocumentsLibraryTeachCompetenceReadParentLevels() > 0) {
int parentLevels = type.getDocumentsLibraryTeachCompetenceReadParentLevels();
TaxonomyTreeNode parent = (TaxonomyTreeNode) node.getParent();
for (int i = parentLevels; i-- > 0 && parent != null; ) {
parent.setCanRead(true);
parent = (TaxonomyTreeNode) parent.getParent();
}
}
}
} else if (isTaxonomyAdmin) {
hasRead |= hasReadAccess(type, null);
hasWrite |= hasWriteAccess(type, null);
}
}
node.setCanRead(hasRead);
node.setCanWrite(hasWrite);
} else if (node.getType() == TaxonomyTreeNodeType.templates) {
hasRead = true;
hasWrite = isTaxonomyAdmin;
node.setCanRead(hasRead);
node.setCanWrite(hasWrite);
}
for (int i = node.getChildCount(); i-- > 0; ) {
TaxonomyTreeNode child = (TaxonomyTreeNode) node.getChildAt(i);
child.setCanRead(hasRead);
child.setCanWrite(hasWrite);
computePermissionsRecursive(child, levelToCompetences);
}
}
Aggregations