use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogNodeManagerController method activateRoot.
/**
* Build an internal business path made of "Node" with the category
* as state entry to prevent loading several times the same entries.
*
* @param ureq
* @param entryKey
*/
private void activateRoot(UserRequest ureq, Long entryKey) {
List<ContextEntry> parentLine = new ArrayList<>();
for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node.getParent() != null; node = node.getParent()) {
OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
ctxEntry.setTransientState(new CatalogStateEntry(node));
parentLine.add(ctxEntry);
}
Collections.reverse(parentLine);
activate(ureq, parentLine, null);
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogNodeManagerController method loadNodesChildren.
protected void loadNodesChildren() {
List<CatalogEntry> childCe = catalogManager.getNodesChildrenOf(catalogEntry);
Collections.sort(childCe, new CatalogEntryComparator(getLocale()));
List<String> subCategories = new ArrayList<>();
int count = 0;
for (CatalogEntry entry : childCe) {
if (entry.getType() == CatalogEntry.TYPE_NODE) {
String cmpId = "cat_" + (++count);
VFSLeaf img = catalogManager.getImage(entry);
if (img != null) {
String imgId = "image_" + count;
flc.contextPut(imgId, img.getName());
}
flc.contextPut("k" + cmpId, entry.getKey());
String title = StringHelper.escapeHtml(entry.getName());
Link link = LinkFactory.createCustomLink(cmpId, "select_node", cmpId, Link.LINK + Link.NONTRANSLATED, flc.getFormItemComponent(), this);
link.setIconLeftCSS("o_icon o_icon_catalog_sub");
link.setCustomDisplayText(title);
link.setUserObject(entry.getKey());
subCategories.add(Integer.toString(count));
String titleId = "title_" + count;
flc.contextPut(titleId, title);
}
}
flc.contextPut("subCategories", subCategories);
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogEntryAddController method insertNode.
protected void insertNode(UserRequest ureq, Long newParentId) {
CatalogEntry newParent = catalogManager.loadCatalogEntry(newParentId);
// check first if this repo entry is already attached to this new parent
List<CatalogEntry> existingChildren = catalogManager.getChildrenOf(newParent);
for (CatalogEntry existingChild : existingChildren) {
RepositoryEntry existingRepoEntry = existingChild.getRepositoryEntry();
if (existingRepoEntry != null && existingRepoEntry.equalsByPersistableKey(toBeAddedEntry)) {
showError("catalog.tree.add.already.exists", toBeAddedEntry.getDisplayname());
return;
}
}
CatalogEntry newEntry = catalogManager.createCatalogEntry();
newEntry.setRepositoryEntry(toBeAddedEntry);
newEntry.setName(toBeAddedEntry.getDisplayname());
newEntry.setDescription(toBeAddedEntry.getDescription());
newEntry.setType(CatalogEntry.TYPE_LEAF);
newEntry.setOwnerGroup(BaseSecurityManager.getInstance().createAndPersistSecurityGroup());
// save entry
catalogManager.addCatalogEntry(newParent, newEntry);
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogNodeController method activateRoot.
/**
* Build an internal business path made of "Node" with the category
* as state entry to prevent loading several times the same entries.
*
* @param ureq
* @param entryKey
*/
private void activateRoot(UserRequest ureq, Long entryKey) {
List<ContextEntry> parentLine = new ArrayList<>();
for (CatalogEntry node = catalogManager.getCatalogEntryByKey(entryKey); node != null && node.getParent() != null; node = node.getParent()) {
OLATResourceable nodeRes = OresHelper.createOLATResourceableInstance("Node", node.getKey());
ContextEntry ctxEntry = BusinessControlFactory.getInstance().createContextEntry(nodeRes);
ctxEntry.setTransientState(new CatalogStateEntry(node));
parentLine.add(ctxEntry);
}
Collections.reverse(parentLine);
activate(ureq, parentLine, null);
}
use of org.olat.repository.CatalogEntry in project OpenOLAT by OpenOLAT.
the class CatalogTreeModel method calculateAccessibility.
/**
* Limit accessability to node to the nodes that are owned by the current user
*/
private void calculateAccessibility(GenericTreeNode rootNode) {
GenericTreeNode node = null;
// first : allow access to all children of the owned entries
if (ownedEntries != null) {
for (CatalogEntry entry : ownedEntries) {
node = entryMap.get(entry.getKey());
changeAccessibility(node, true);
}
}
// to avoid circles and not dissolve elements from the catalog root )
if (entryToMove != null && entryToMove.getType() == CatalogEntry.TYPE_NODE) {
node = entryMap.get(entryToMove.getKey());
changeAccessibility(node, false);
}
// entries are owned, we assume that all entries can be selected by user
if (entryToMove == null && ownedEntries == null) {
changeAccessibility(rootNode, true);
}
}
Aggregations