Package org.olat.catalog

Examples of org.olat.catalog.CatalogManager


    // moved, when moving leafs we don't check for ownership of the category
    if (toBeMovedEntry.getType() == CatalogEntry.TYPE_NODE) {
      ownedEntries = getOwnedEntries(ureq);
    }
   
    CatalogManager cm = CatalogManager.getInstance();
    CatalogEntry rootce = (CatalogEntry) cm.getRootCatalogEntries().get(0);
    // Build tree model
    treeModel = new CatalogAjaxTreeModel(rootce, toBeMovedEntry, ownedEntries, false, false);
   
    // Create the ajax tree controller, add it to your main view
    treeCtr = new TreeController(ureq, getWindowControl(), rootce.getName(), treeModel, null);
View Full Code Here


  protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == treeCtr) {
      if (event instanceof TreeNodeClickedEvent) {
        TreeNodeClickedEvent clickedEvent = (TreeNodeClickedEvent) event;
        // try to update the catalog
        CatalogManager cm = CatalogManager.getInstance();
        String nodeId = clickedEvent.getNodeId();
        Long newParentId = Long.parseLong(nodeId);
        CatalogEntry newParent = cm.loadCatalogEntry(newParentId);
        boolean hasAccess;
        if (toBeMovedEntry.getType() == CatalogEntry.TYPE_LEAF) {
          // Leafs can be attached anywhere in the catalog, no need to check for
          // category ownership
          hasAccess = true;
        } else {
          // Check if the user owns this category or one of the preceding
          // categories.
          hasAccess = cm.isEntryWithinCategory(newParent, ownedEntries);         
        }
        if (hasAccess) {
          // don't move entry right away, user must select submit button first
          selectedParent = newParent;
          // enable link, set dirty button class and trigger redrawing
View Full Code Here

  protected void event(UserRequest ureq, Component source, Event event) {
    if (source == cancelLink) {
      fireEvent(ureq, Event.CANCELLED_EVENT);         
    } else if (source == selectLink) {
      if (selectedParent != null) {
        CatalogManager cm = CatalogManager.getInstance();       
        boolean success = cm.moveCatalogEntry(toBeMovedEntry, selectedParent);
        if (success) {
          fireEvent(ureq, Event.DONE_EVENT);         
        } else {
          fireEvent(ureq, Event.FAILED_EVENT);
        }         
View Full Code Here

    this.toBeAddedEntry = toBeAddedEntry;
    // Main view is a velocity container
    contentVC = createVelocityContainer("catalogentryajaxadd");
    contentVC.contextPut("entryname", toBeAddedEntry.getDisplayname());
   
    CatalogManager cm = CatalogManager.getInstance();
    CatalogEntry rootce = (CatalogEntry) cm.getRootCatalogEntries().get(0);
    // Build tree model
    treeModel = new CatalogAjaxTreeModel(rootce, null, null, false, false);
   
    // Create the ajax tree controller, add it to your main view
    treeCtr = new TreeController(ureq, getWindowControl(), rootce.getName(), treeModel, null);
View Full Code Here

  protected void event(UserRequest ureq, Controller source, Event event) {
    if (source == treeCtr) {
      if (event instanceof TreeNodeClickedEvent) {
        TreeNodeClickedEvent clickedEvent = (TreeNodeClickedEvent) event;
        // build new entry for this catalog level
        CatalogManager cm = CatalogManager.getInstance();
        String nodeId = clickedEvent.getNodeId();
        Long newParentId = Long.parseLong(nodeId);
        CatalogEntry newParent = cm.loadCatalogEntry(newParentId);
        // check first if this repo entry is already attached to this new parent
        List<CatalogEntry> existingChildren = cm.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;
View Full Code Here

  protected void event(UserRequest ureq, Component source, Event event) {
    if (source == cancelLink) {
      fireEvent(ureq, Event.CANCELLED_EVENT);         
    } else if (source == selectLink) {
      if (selectedParent != null) {
        CatalogManager cm = CatalogManager.getInstance();
        CatalogEntry newEntry = cm.createCatalogEntry();
        newEntry.setRepositoryEntry(toBeAddedEntry);
        newEntry.setName(toBeAddedEntry.getDisplayname());
        newEntry.setDescription(toBeAddedEntry.getDescription());
        newEntry.setType(CatalogEntry.TYPE_LEAF);
        newEntry.setOwnerGroup(ManagerFactory.getManager().createAndPersistSecurityGroup());
        // save entry
        cm.addCatalogEntry(selectedParent, newEntry);
        fireEvent(ureq, Event.DONE_EVENT);               
      }
    }
  }
View Full Code Here

    if (source == selectionTree) {
      TreeEvent te = (TreeEvent) event;
      if (te.getCommand().equals(TreeEvent.COMMAND_TREENODE_CLICKED)) {

        GenericTreeNode node = (GenericTreeNode) selectionTree.getSelectedNode();
        CatalogManager cm = CatalogManager.getInstance();
        Long newParentId = Long.parseLong(node.getIdent());
        CatalogEntry newParent = cm.loadCatalogEntry(newParentId);
        if (!cm.moveCatalogEntry(moveMe, newParent)) {
          fireEvent(ureq, Event.FAILED_EVENT);
        } else {
          fireEvent(ureq, Event.DONE_EVENT);
        }
      } else if (te.getCommand().equals(TreeEvent.COMMAND_CANCELLED)) {
View Full Code Here

  public void event(UserRequest ureq, Component source, Event event) {
    if (source == selectionTree) {
      TreeEvent te = (TreeEvent) event;
      if (te.getCommand().equals(TreeEvent.COMMAND_TREENODE_CLICKED)) {
        GenericTreeNode node = (GenericTreeNode) selectionTree.getSelectedNode();
        CatalogManager cm = CatalogManager.getInstance();
        Long newParentId = Long.parseLong(node.getIdent());
        CatalogEntry newParent = cm.loadCatalogEntry(newParentId);
        // check first if this repo entry is already attached to this new parent
        List<CatalogEntry> existingChildren = cm.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 = cm.createCatalogEntry();
        newEntry.setRepositoryEntry(toBeAddedEntry);
        newEntry.setName(toBeAddedEntry.getDisplayname());
        newEntry.setDescription(toBeAddedEntry.getDescription());
        newEntry.setType(CatalogEntry.TYPE_LEAF);
        newEntry.setOwnerGroup(ManagerFactory.getManager().createAndPersistSecurityGroup());
        // save entry
        cm.addCatalogEntry(newParent, newEntry);
        fireEvent(ureq, Event.DONE_EVENT);

      } else if (te.getCommand().equals(TreeEvent.COMMAND_CANCELLED)) {
        fireEvent(ureq, Event.CANCELLED_EVENT);
      }
View Full Code Here

        DTabs dts = (DTabs) getWindowControl().getWindowBackOffice().getWindow().getAttribute("DTabs");
        dts.activateStatic(ureq, RepositorySite.class.getName(), "search.catalog:" + selectedCategoryLevel.getKey());
       
      } else if (action.equals(CategoriesListModel.ACTION_DELETE)) {
        // remove selected entry from the data model
        CatalogManager cm = CatalogManager.getInstance();
        List<CatalogEntry> children = cm.getChildrenOf(selectedCategoryLevel);
        // find all child element of this level that reference our repo entry
        for (CatalogEntry child : children) {
          RepositoryEntry childRepoEntry = child.getRepositoryEntry();
          if (childRepoEntry != null && childRepoEntry.equalsByPersistableKey(repoEntry)) {
            // remove from catalog
            cm.deleteCatalogEntry(child);
          }
        }
        // The catalog entry must have been deleted in the meantime by someone
        // else. In this case we just reload the table data model
        List<CatalogEntry> catalogEntries = CatalogManager.getInstance().getCatalogCategoriesFor(repoEntry);
View Full Code Here

   * @see org.olat.core.gui.control.generic.ajax.tree.TreeDataModel#getChildrenFor(java.lang.String)
   */
  @Override
  public List<AjaxTreeNode> getChildrenFor(String nodeId) {
    List<AjaxTreeNode> childNodes = new ArrayList<AjaxTreeNode>();
    CatalogManager cm = CatalogManager.getInstance();
    // load node with given id
    Long entryKey = Long.parseLong(nodeId);
    CatalogEntry entry = cm.loadCatalogEntry(entryKey);
    // load children of node and add them to the list
    List<CatalogEntry> childEntries = cm.getChildrenOf(entry);
    for (CatalogEntry childEntry : childEntries) {
      // don't add the to be moved child itself!
      if (toBeMovedEntry != null && toBeMovedEntry.getKey().equals(childEntry.getKey())) {
        continue;
      }     
View Full Code Here

TOP

Related Classes of org.olat.catalog.CatalogManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.