Search in sources :

Example 91 with CatalogEntry

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;
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) CatalogEntry(org.olat.repository.CatalogEntry)

Example 92 with CatalogEntry

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;
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) CatalogEntry(org.olat.repository.CatalogEntry) WindowControl(org.olat.core.gui.control.WindowControl) BreadcrumbedStackedPanel(org.olat.core.gui.components.stack.BreadcrumbedStackedPanel) CatalogNodeController(org.olat.repository.ui.catalog.CatalogNodeController)

Example 93 with CatalogEntry

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);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) CatalogEntry(org.olat.repository.CatalogEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 94 with CatalogEntry

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);
            }
        }
    }
}
Also used : StateEntry(org.olat.core.id.context.StateEntry) CatalogEntry(org.olat.repository.CatalogEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 95 with CatalogEntry

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);
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CatalogEntry(org.olat.repository.CatalogEntry)

Aggregations

CatalogEntry (org.olat.repository.CatalogEntry)122 Test (org.junit.Test)30 CatalogEntryVO (org.olat.restapi.support.vo.CatalogEntryVO)30 URI (java.net.URI)28 HttpResponse (org.apache.http.HttpResponse)28 Identity (org.olat.core.id.Identity)28 ArrayList (java.util.ArrayList)20 Path (javax.ws.rs.Path)18 SecurityGroup (org.olat.basesecurity.SecurityGroup)18 RepositoryEntry (org.olat.repository.RepositoryEntry)18 Produces (javax.ws.rs.Produces)14 HttpPut (org.apache.http.client.methods.HttpPut)12 GET (javax.ws.rs.GET)10 WebApplicationException (javax.ws.rs.WebApplicationException)10 HttpPost (org.apache.http.client.methods.HttpPost)10 OLATResourceable (org.olat.core.id.OLATResourceable)10 ContextEntry (org.olat.core.id.context.ContextEntry)10 LockResult (org.olat.core.util.coordinate.LockResult)10 CatalogManager (org.olat.repository.manager.CatalogManager)8 Link (org.olat.core.gui.components.link.Link)6