Search in sources :

Example 21 with CatalogEntry

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);
}
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 22 with CatalogEntry

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);
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) CatalogEntry(org.olat.repository.CatalogEntry) ArrayList(java.util.ArrayList) Link(org.olat.core.gui.components.link.Link)

Example 23 with CatalogEntry

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);
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) RepositoryEntry(org.olat.repository.RepositoryEntry)

Example 24 with CatalogEntry

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);
}
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 25 with CatalogEntry

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