Package org.olat.core.util.tree

Examples of org.olat.core.util.tree.TreeVisitor


          }
          insertParent.insert(moveCopyFrom, insertPos);

          moveCopyFrom.setDirty(true);
          //mark subtree as dirty
          TreeVisitor tv = new TreeVisitor( new Visitor() {
            public void visit(INode node) {
              CourseEditorTreeNode cetn = (CourseEditorTreeNode)node;
              cetn.setDirty(true);
            }
          },moveCopyFrom,true);
          tv.visitAll();         
          CourseFactory.saveCourseEditorTreeModel(course.getResourceableId()); // TODO: pb: Review : Add by chg to FIX OLAT-1662
          this.showInfo("movecopynode.info.condmoved");

          ThreadLocalUserActivityLogger.log(CourseLoggingAction.COURSE_EDITOR_NODE_MOVED, getClass());
          fireEvent(ureq, Event.DONE_EVENT);
View Full Code Here


          }
        }
      }
    };
    // not visit beginning at the root node
    TreeVisitor tv = new TreeVisitor(visitor, rootNode, false);
    tv.visitAll();

    return nodes;
  }
View Full Code Here

    // export any node data
    File fExportedDataDir = new File(exportDirectory, EXPORTED_DATA_FOLDERNAME);
    fExportedDataDir.mkdirs();
    log.info("exportToFilesystem: exporting course "+this+": exporting all nodes...");
    Visitor visitor = new NodeExportVisitor(fExportedDataDir, this);
    TreeVisitor tv = new TreeVisitor(visitor, getEditorTreeModel().getRootNode(), true);
    tv.visitAll();
    log.info("exportToFilesystem: exporting course "+this+": exporting all nodes...done.");
   
    //OLAT-5368: do intermediate commit to avoid transaction timeout
    // discussion intermediatecommit vs increased transaction timeout:
    //  pro intermediatecommit: not much
View Full Code Here

    // breadth first traversal gives an easier order of evaluation for debugging
    // however, for live it is absolutely mandatory to use depth first since using breadth first
    // the score accoutings local cache hash map will never be used. this can slow down things like
    // crazy (course with 10 tests, 300 users and some crazy score and passed calculations will have
    // 10 time performance differences)
    TreeVisitor tv = new TreeVisitor(this, root, true); // true=depth first
    tv.visitAll();
  }
View Full Code Here

     * the tree is visited and the book keeping lists are filled. the visitor
     * itself does not delete or modify neither runstructure nor editor tree
     * model. The whole complexity of published is encapsulated in the visitor.
     */
    Visitor nodePublishV = new NodePublishVisitor(editorRoot, nodesIdsToPublish, existingCourseRun);
    TreeVisitor tv = new TreeVisitor(nodePublishV, editorRoot, visitChildrenFirst);
    tv.visitAll();
    /*
     *
     */

  }
 
View Full Code Here

   */
  private Map<String, List<String>> checkReferencesFor(TreeNode tn) {
    final CourseEditorTreeModel cetm = CourseFactory.getCourseEditSession(ores.getResourceableId()).getEditorTreeModel();
     //create a list of all nodes in the selected subtree
    final Set<String> allSubTreeids = new HashSet<String>();
    TreeVisitor tv = new TreeVisitor(new Visitor() {
      public void visit(INode node) {
        allSubTreeids.add(node.getIdent());
      }
    }, tn, true);
    tv.visitAll();
     //find all references pointing from outside the subtree into the subtree or
     //on the subtree root node.
    final Map<String, List<String>> allRefs = new HashMap<String, List<String>>();
    tv = new TreeVisitor(new Visitor() {
      public void visit(INode node) {
        List referencingNodes = euce.getCourseEditorEnv().getReferencingNodeIdsFor(node.getIdent());
        // subtract the inner nodes. This allows to delete a whole subtree if
        // only references residing completly inside the subtree are active.
        referencingNodes.removeAll(allSubTreeids);
        if (referencingNodes.size() > 0) {
          List<String> nodeNames = new ArrayList<String>();
          for (Iterator iter = referencingNodes.iterator(); iter.hasNext();) {
            String nodeId = (String) iter.next();
            CourseNode cn = cetm.getCourseNode(nodeId);
            nodeNames.add(cn.getShortTitle());
          }
          allRefs.put(node.getIdent(), nodeNames);
        }
      }
    }, tn, true);
    // traverse all nodes from the deletion startpoint
    tv.visitAll();
    // allRefs contains now all references, or zero if ready for delete.
    return allRefs;
  }
View Full Code Here

    String currentNodeWas = currentCourseNodeId;
    // reset all
    softRefs = new HashMap();
    nodeRefs = new HashMap<String, Set<String>>();
    Visitor v = new CollectConditionExpressionsVisitor();
    (new TreeVisitor(v, cetm.getRootNode(), true)).visitAll();
    for (Iterator iter = softRefs.keySet().iterator(); iter.hasNext();) {
      String nodeId = (String) iter.next();
      List conditionExprs = (List) softRefs.get(nodeId);
      for (int i = 0; i < conditionExprs.size(); i++) {
        ConditionExpression ce = (ConditionExpression) conditionExprs.get(i);
        // DO NOT validateConditionExpression(ce) as this is already done in the
        // CollectConditionExpressionsVisitor
        Set<String> refs = new HashSet<String>(ce.getSoftReferencesOf("courseNodeId"));
        if (refs != null && refs.size() > 0) {
          Set<String> oldOnes = nodeRefs.put(nodeId, null);
          if (oldOnes != null) {
            refs.addAll(oldOnes);
          }
          nodeRefs.put(nodeId, refs);
        }
      }

    }
    // refresh,create status descriptions of the course
    statusDescs = new HashMap();
    v = new CollectStatusDescriptionVisitor(this);
    (new TreeVisitor(v, cetm.getRootNode(), true)).visitAll();
    //
    currentCourseNodeId = currentNodeWas;
  }
View Full Code Here

    DirectedEdgeFactory def = new EdgeFactories.DirectedEdgeFactory();
    /*
     * add the course structure as directed graph, where
     */
    Visitor v = new Convert2DGVisitor(dg);
    (new TreeVisitor(v, cetm.getRootNode(), true)).visitAll();
    /*
     * iterate over nodeRefs, add each not existing node id as vertex, for each
     * key - child relation add an edge to the directed graph.
     */
    Iterator<String> keys = nodeRefs.keySet().iterator();
View Full Code Here

    forumFormatter.openForum();
    for (Iterator iterTop = topNodeList.iterator(); iterTop.hasNext();){
      MessageNode mn = (MessageNode) iterTop.next();
      //a new top thread starts, inform formatter
      forumFormatter.openThread();
      TreeVisitor tv = new TreeVisitor(forumFormatter, mn, false);
      tv.visitAll();
      //commit
      formattedForum.append(forumFormatter.closeThread());
    }
    return formattedForum.append(forumFormatter.closeForum().toString()).toString();
  }
View Full Code Here

   */
  private String formatThread(MessageNode mn, ForumFormatter forumFormatter, Map metaInfo){
    forumFormatter.setForumMetaInformation(metaInfo);
    StringBuilder formattedThread = new StringBuilder();
    forumFormatter.openThread();
    TreeVisitor tv = new TreeVisitor(forumFormatter, mn, false);
    tv.visitAll();
    return formattedThread.append(formattedThread.append(forumFormatter.closeThread())).toString();
  }
View Full Code Here

TOP

Related Classes of org.olat.core.util.tree.TreeVisitor

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.