use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogTreeModel method buildTree.
/**
* Build the selection tree from the given list of entries
* @param entryList
* @return The root node of the tree
*/
private GenericTreeNode buildTree(List<CatalogEntry> entryList) {
GenericTreeNode rootNode = null;
// build the tree - note that the entry list is not ordered in any way
if (entryList != null) {
for (CatalogEntry elem : entryList) {
// create a tree node and add it to the entry map
GenericTreeNode n = addNode(elem);
if (n != null) {
// a node was created, keep it as a potential root node candidate
rootNode = addNode(elem);
}
}
}
// walk to the final root node of the tree
while (rootNode != null && rootNode.getParent() != null) {
rootNode = (GenericTreeNode) rootNode.getParent();
}
// we always need a root
if (rootNode == null) {
rootNode = new GenericTreeNode("keine Node :(", null);
}
calculateAccessibility(rootNode);
return rootNode;
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class OverviewRepositoryListController method doOpenCatalog.
private CatalogNodeController doOpenCatalog(UserRequest ureq) {
if (!repositoryModule.isCatalogEnabled() || !repositoryModule.isCatalogBrowsingEnabled()) {
return null;
}
cleanUp();
List<CatalogEntry> entries = catalogManager.getRootCatalogEntries();
CatalogEntry rootEntry = null;
if (entries.size() > 0) {
rootEntry = entries.get(0);
}
OLATResourceable ores = OresHelper.createOLATResourceableInstance("Catalog", 0l);
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapBusinessPath(ores));
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ores, null, getWindowControl());
catalogStackPanel = new BreadcrumbedStackedPanel("catstack", getTranslator(), this);
catalogCtrl = new CatalogNodeController(ureq, bwControl, getWindowControl(), rootEntry, catalogStackPanel, false);
catalogStackPanel.pushController(translate("search.catalog"), catalogCtrl);
listenTo(catalogCtrl);
currentCtrl = catalogCtrl;
addToHistory(ureq, catalogCtrl);
mainVC.put("segmentCmp", catalogStackPanel);
return catalogCtrl;
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
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 klemens.
the class CatalogNodeManagerController method activate.
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if (entries == null || entries.isEmpty()) {
return;
}
ContextEntry entry = entries.get(0);
String type = entry.getOLATResourceable().getResourceableTypeName();
if ("CatalogEntry".equalsIgnoreCase(type)) {
Long entryKey = entry.getOLATResourceable().getResourceableId();
if (entryKey != null && entryKey.longValue() > 0) {
activateRoot(ureq, entryKey);
}
} else if ("Node".equalsIgnoreCase(type)) {
// the "Node" is only for internal usage
StateEntry stateEntry = entry.getTransientState();
if (stateEntry instanceof CatalogStateEntry) {
CatalogEntry catEntry = ((CatalogStateEntry) stateEntry).getEntry();
CatalogNodeManagerController nextCtrl = selectCatalogEntry(ureq, catEntry);
if (nextCtrl != null && entries.size() > 1) {
nextCtrl.activate(ureq, entries.subList(1, entries.size()), null);
}
}
}
}
use of org.olat.repository.CatalogEntry in project openolat by klemens.
the class CatalogNodeManagerController method doAddCategory.
private void doAddCategory(UserRequest ureq) {
removeAsListenerAndDispose(addEntryCtrl);
removeAsListenerAndDispose(cmc);
catModificationLock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(lockRes, getIdentity(), LOCK_TOKEN);
if (catModificationLock.isSuccess()) {
CatalogEntry ce = catalogManager.createCatalogEntry();
addEntryCtrl = new CatalogEntryEditController(ureq, getWindowControl(), ce, catalogEntry);
addEntryCtrl.setElementCssClass("o_sel_catalog_add_category_popup");
listenTo(addEntryCtrl);
cmc = new CloseableModalController(getWindowControl(), "close", addEntryCtrl.getInitialComponent(), true, translate("tools.add.catalog.category"));
listenTo(cmc);
cmc.activate();
} else {
String ownerName = userManager.getUserDisplayName(catModificationLock.getOwner());
showError("catalog.locked.by", ownerName);
}
}
Aggregations