Search in sources :

Example 46 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

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 47 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogNodeManagerController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // one mapper for all users
    flc.contextPut("mapperThumbnailUrl", mapperThumbnailKey.getUrl());
    int level = 0;
    CatalogEntry parent = catalogEntry.getParent();
    while (parent != null) {
        level++;
        parent = parent.getParent();
    }
    flc.contextPut("catalogLevel", level);
    String url = Settings.getServerContextPathURI() + "/url/CatalogEntry/" + catalogEntry.getKey();
    if (loginModule.isGuestLoginLinksEnabled()) {
        flc.contextPut("guestExtLink", url + "?guest=true&amp;lang=" + getLocale().getLanguage());
    }
    if (!isGuest) {
        flc.contextPut("extLink", url);
    }
    FlexiTableColumnModel entriesColumnsModel = getCatalogFlexiTableColumnModel("opened-");
    entriesModel = new CatalogEntryRowModel(entriesColumnsModel);
    entriesEl = uifactory.addTableElement(getWindowControl(), "entries", entriesModel, getTranslator(), formLayout);
    FlexiTableColumnModel closedEntriesColumnsModel = getCatalogFlexiTableColumnModel("closed-");
    closedEntriesModel = new CatalogEntryRowModel(closedEntriesColumnsModel);
    closedEntriesEl = uifactory.addTableElement(getWindowControl(), "closedEntries", closedEntriesModel, getTranslator(), formLayout);
}
Also used : CatalogEntry(org.olat.repository.CatalogEntry) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)

Example 48 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

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 49 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

the class CatalogNodeManagerController method doMoveCategory.

private void doMoveCategory(UserRequest ureq, CatalogEntryRow row) {
    removeAsListenerAndDispose(cmc);
    removeAsListenerAndDispose(entryResourceMoveCtrl);
    CatalogEntry moveMe = catalogManager.getCatalogEntryBy(row, catalogEntry);
    if (moveMe != null) {
        entryResourceMoveCtrl = new CatalogEntryMoveController(getWindowControl(), ureq, moveMe, getTranslator());
        listenTo(entryResourceMoveCtrl);
        cmc = new CloseableModalController(getWindowControl(), "close", entryResourceMoveCtrl.getInitialComponent(), true, translate("tools.move.catalog.entry"));
        listenTo(cmc);
        cmc.activate();
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) CatalogEntry(org.olat.repository.CatalogEntry)

Example 50 with CatalogEntry

use of org.olat.repository.CatalogEntry in project openolat by klemens.

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)

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