Examples of CourseEditorTreeNode


Examples of org.olat.course.tree.CourseEditorTreeNode

   */
  private List<StatusDescription> checkRefs(List<CourseEditorTreeNode> courseEditorTreeNodes) {
    // course Editor Nodes With Damaged Reference
    List<StatusDescription> cetnDamaged = new ArrayList<StatusDescription>();
    for (Iterator<CourseEditorTreeNode> iter = courseEditorTreeNodes.iterator(); iter.hasNext();) {
      CourseEditorTreeNode cetn = iter.next();
      CourseNode cn = cetn.getCourseNode();
      /*
       * for those coursenodes which need a reference to a repository entry to
       * function properly, check that the reference is valid
       */
      if (cn.needsReferenceToARepositoryEntry()) {
        RepositoryEntry referencedEntry = cn.getReferencedRepositoryEntry();
        if (referencedEntry == null) {
          cetnDamaged.add(new StatusDescription(ValidationStatus.ERROR, "pbl.error.refs", "pbl.error.refs", new String[] { cetn.getTitle()
              + "(id:" + cetn.getIdent() + " )" }, PACKAGE));
        }
      }
    }
    return cetnDamaged;
  }
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

   */
  private void convertInCourseEditorTreeNode(CourseEditorTreeNode courseEditorTreeNode, CourseNode node) {
    int childCnt = node.getChildCount();
    for (int i = 0; i < childCnt; i++) {
      CourseNode childNode = (CourseNode) node.getChildAt(i);
      CourseEditorTreeNode newEditorNode = new CourseEditorTreeNode(childNode);
      courseEditorTreeNode.addChild(newEditorNode);
      convertInCourseEditorTreeNode(newEditorNode, childNode);
      childNode.removeAllChildren(); // remove all children after calling convertInCourseEditorTreeNode
    }
  }
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

     * use book keeping lists for publish event
     */
    Set<String> deletedCourseNodeIds = new HashSet<String>();
    if (editorModelDeletedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelDeletedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        deletedCourseNodeIds.add(cn.getIdent());
      }
    }
    Set<String> insertedCourseNodeIds = new HashSet<String>();
    if (editorModelInsertedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelInsertedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        insertedCourseNodeIds.add(cn.getIdent());
      }
    }
    Set<String> modifiedCourseNodeIds = new HashSet<String>();
    if (editorModelModifiedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelModifiedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        modifiedCourseNodeIds.add(cn.getIdent());
      }
    }
    /*
     * broadcast PRE PUBLISH event that a publish will take place
     */
    PublishEvent beforePublish = new PublishEvent(editorTreeModel.getLatestPublishTimestamp(), course, PublishEvent.EVENT_IDENTIFIER);
    beforePublish.setDeletedCourseNodeIds(deletedCourseNodeIds);
    beforePublish.setInsertedCourseNodeIds(insertedCourseNodeIds);
    beforePublish.setModifiedCourseNodeIds(modifiedCourseNodeIds);
    beforePublish.setState(PublishEvent.PRE_PUBLISH);
    // old course structure accessible
    orec.fireEventToListenersOf(beforePublish, course);
    /*
     * TODO:pb: disucss with fj: listeners could add information to
     * beforePublish event such as a right to veto or add identities who is
     * currently in the course, thus stopping the publishing author from
     * publishing! i.e. if people are in a test or something like this.... we
     * could the ask here beforePublish.accepted() and proceed only in this
     * case.
     */
    //
    /*
     * remove new nodes which were marked as delete and deletion is published.
     */
    File exportDirectory = CourseFactory.getOrCreateDataExportDirectory(identity, course.getCourseTitle());
    UserManager um = UserManager.getInstance();
    String charset = um.getUserCharset(identity);
    if (editorModelDeletedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelDeletedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        // moved node with a parent deleted (deletion published) -> oldCn ==
        // null
        if (oldCn != null) {
          if (!(cn.getIdent().equals(oldCn.getIdent()))) { throw new AssertException("deleted cn.getIdent != oldCn.getIdent"); }
        }
        cetn.removeFromParent();
        if (!cetn.isNewnode()) {
          // only clean up and archive of nodes which were already in run
          // save data, remove references
          deleteRefs(oldCn);
          oldCn.archiveNodeData(locale, course, exportDirectory, charset);
          // 2) delete all user data
          oldCn.cleanupOnDelete(course);
        }
      }
    }
    /*
     * mark modified ones as no longer dirty
     */
    if (editorModelModifiedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelModifiedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        // moved node with a parent deleted (deletion published) -> oldCn ==
        // null
        if (oldCn != null) {
          if (!(cn.getIdent().equals(oldCn.getIdent()))) { throw new AssertException("deleted cn.getIdent != oldCn.getIdent"); }
        }
        cetn.setDirty(false);
        //
        updateRefs(cn, oldCn);
      }
    }
    /*
     * mark newly published ones is no longer new and dirty
     */
    if (editorModelInsertedNodes.size() > 0) {
      for (Iterator<CourseEditorTreeNode> iter = editorModelInsertedNodes.iterator(); iter.hasNext();) {
        CourseEditorTreeNode cetn = iter.next();
        CourseNode cn = cetn.getCourseNode();
        CourseNode oldCn = existingCourseRun.getNode(cetn.getIdent());
        if (oldCn != null) { throw new AssertException("new node has an oldCN??"); }
        cetn.setDirty(false);
        cetn.setNewnode(false);
        //
        updateRefs(cn, null);
      }
    }
    /*
 
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

   
    CourseEditorTreeModel cetm = course.getEditorTreeModel();
    for (int i = 0; i < nodeIdsToPublish.size(); i++) {
      msg.append("<li>");
      String nodeId = (String) nodeIdsToPublish.get(i);
      CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(nodeId);
      CourseNode cn = cetm.getCourseNode(nodeId);
      msg.append(cn.getShortTitle());
      if (cetn.isDeleted() && !cetn.isNewnode()) {
        //use locale of this initialized translator.
        String onDeleteMessage = cn.informOnDelete(translator.getLocale(), course);
        if (onDeleteMessage != null) {
          msg.append("<br /><font color=\"red\">");
          msg.append(onDeleteMessage);
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

    public void visit(INode node) {
      /*
       * DO NOT add or delete nodes via editorTreeModel, .....................
       * or the CourseEditorTreeNode cetn !! .................................
       */
      CourseEditorTreeNode cetn = (CourseEditorTreeNode) node;
      if (cetn == root && publishNodeIds.contains(cetn.getIdent()) ) {
        // root node changed and published
        CourseNode clone = (CourseNode)XStreamHelper.xstreamClone(cetn.getCourseNode());
        resultingCourseRun.setRootNode(clone);
        editorModelModifiedNodes.add(cetn);// TODO:pb: Review  Change to fic OLAT-1644
        return;
      }
      if (cetn == root) { // TODO:pb: Review Change to fix OLAT-1644
        // root node
        CourseNode clone = (CourseNode)XStreamHelper.xstreamClone(cetn.getCourseNode());
        resultingCourseRun.setRootNode(clone);
        return;
      }
      /*
       * check that root exist in newRunStruct
       */
      if (resultingCourseRun.getRootNode() == null) { throw new AssertException("No Root node??"); }
      // node is selected by user to be published
      boolean publishNode = publishNodeIds.contains(cetn.getIdent());
      // this node is already in the runstructure -> keep ident!
      boolean alreadyInRun = null != existingRun.getNode(cetn.getCourseNode().getIdent());
      // node has changed and exists in the runstructure
      boolean dirtyOnly = cetn.isDirty() && !cetn.isDeleted() && !cetn.isNewnode();
      boolean unchanged = !cetn.isDirty() && !cetn.isDeleted() && !cetn.isNewnode();

      // check if this node is not already somehow no longer interesting
      if (skippableNodes.contains(cetn) || editorModelDeletedNodes.contains(cetn)) {
        // skip
        return;
      }
      if (!publishNode && alreadyInRun) {
        if (unchanged) {
          // already published, add it as it is. Silent "re-publish"
          addNodeTo(resultingCourseRun, cetn);
        } else {
          // TODO:pb:REVIEW Change to fix OLAT-1644
          // changed in edit but not published => take old from existingRun
          addNodeTo(resultingCourseRun, existingRun.getNode(cetn.getIdent()), cetn);
        }
        return;
      } else if (publishNode && !alreadyInRun) {
        if (dirtyOnly) {
          // publish modified node which was in the run once. Then moved under a
          // new node and its former parent is deleted.
          addNodeTo(resultingCourseRun, cetn);
          editorModelModifiedNodes.add(cetn);
        } else if (cetn.isNewnode() && cetn.isDeleted()) {
          // publish deletion of a new node
          editorModelDeletedNodes.add(cetn);
          List getsAlsoDeleted = new ArrayList();
          collectSubTreeNodesStartingFrom(cetn, getsAlsoDeleted);
          // whole subtree added, marked as being deleted
          editorModelDeletedNodes.addAll(getsAlsoDeleted);
          return;
        } else if (cetn.isNewnode() && !cetn.isDeleted()) {
          // publish new node
          addNodeTo(resultingCourseRun, cetn);
          editorModelInsertedNodes.add(cetn);
          return;
        } else {
          // ...!cetn.isNewnode() && cetn.isDeleted()
          // this state is not possible
          throw new AssertException("try to publish node [" + cetn.getTitle() + " " + cetn.getIdent()
              + "]which says it is not new but also not in the runstructure.");
        }
      } else if (publishNode && alreadyInRun) {
        if (dirtyOnly) {
          // publish modified node
          addNodeTo(resultingCourseRun, cetn);
          editorModelModifiedNodes.add(cetn);
          return;
        } else if (!cetn.isNewnode() && cetn.isDeleted()) {
          // publish deletion of a node
          editorModelDeletedNodes.add(cetn);
          List getsAlsoDeleted = new ArrayList();
          collectSubTreeNodesStartingFrom(cetn, getsAlsoDeleted);
          // whole subtree added, marked as being deleted
          editorModelDeletedNodes.addAll(getsAlsoDeleted);
          return;
        } else if (cetn.isNewnode() && !cetn.isDeleted()) {
          // this state is not possible
          throw new AssertException(cetn.getTitle() + " - try to publish node which says it is new but also exists in the runstructure.");
        } else {
          // ...cetn.isNewnode() && cetn.isDeleted()
          // this state is not possible
          throw new AssertException(cetn.getTitle() + " - try to publish node which says it is new but also exists in the runstructure.");
        }
      } else {
        // ...(!publishNode && !alreadyInRun){
        // check condition, and add all subnodes to be skipped
        if (!cetn.isNewnode()) {
          throw new AssertException(cetn.getTitle()+" - node is not to publish and not in run -> hence it should be isNewnode() == true, but it is not!!"); }
        List skippable = new ArrayList();
        collectSubTreeNodesStartingFrom(cetn, skippable);
        // remember this new node with its subtree as not being published
        // there may float a dirty node in the subtree, which got there by
        // moving
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

     */
    private void addNodeTo(final Structure newRunStruct, CourseEditorTreeNode cetn) {
      CourseNode clone = (CourseNode) XStreamHelper.xstreamClone(cetn.getCourseNode());
      clone.removeAllChildren();// children get also visited
      // parent in the course editor model
      CourseEditorTreeNode parentCetn = (CourseEditorTreeNode) cetn.getParent();
      CourseNode parent = parentCetn.getCourseNode();
      CourseNode parentClone = newRunStruct.getNode(parent.getIdent());
      parentClone.addChild(clone);
    }
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

     */
    private void addNodeTo(final Structure newRunStruct, CourseNode courseNode, CourseEditorTreeNode cetn) {
      CourseNode clone = (CourseNode) XStreamHelper.xstreamClone(courseNode);
      clone.removeAllChildren();// children get also visited
      // parent in the course editor model
      CourseEditorTreeNode parentCetn = (CourseEditorTreeNode) cetn.getParent();
      CourseNode parent = parentCetn.getCourseNode();
      CourseNode parentClone = newRunStruct.getNode(parent.getIdent());
      parentClone.addChild(clone);
    }
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

    } else if (source == keepOpenWarningButton){
      warningIsOpen = Boolean.TRUE;
      main.contextPut("warningIsOpen", warningIsOpen);
    } else if (source == undelButton){
      String ident = menuTree.getSelectedNode().getIdent();
      CourseEditorTreeNode activeNode = (CourseEditorTreeNode) cetm.getNodeById(ident);
      euce.getCourseEditorEnv().setCurrentCourseNodeId(activeNode.getIdent());
     
      CourseFactory.saveCourseEditorTreeModel(course.getResourceableId());
      cetm.markUnDeleted(activeNode);
      menuTree.setDirty(true);
      // show edit panels again
      initNodeEditor(ureq, activeNode.getCourseNode());
      tabbedNodeConfig.setVisible(true);
      toolC.setEnabled(CMD_DELNODE, true);
      toolC.setEnabled(CMD_MOVENODE, true);
      toolC.setEnabled(CMD_COPYNODE, true);
      main.setPage(VELOCITY_ROOT + "/index.html");
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

   * @param ureq
   * @param nodeId
   */
  private void updateViewForSelectedNodeId(UserRequest ureq, String nodeId) {
   
    CourseEditorTreeNode cetn = (CourseEditorTreeNode) cetm.getNodeById(nodeId);
    // udpate the current node in the course editor environment
    euce.getCourseEditorEnv().setCurrentCourseNodeId(nodeId);
    // Start necessary controller for selected node

    if (cetn.isDeleted()) {
      tabbedNodeConfig.setVisible(false);
      toolC.setEnabled(CMD_DELNODE, false);
      toolC.setEnabled(CMD_MOVENODE, false);
      toolC.setEnabled(CMD_COPYNODE, false);
      if (((CourseEditorTreeNode) cetn.getParent()).isDeleted()) main.setPage(VELOCITY_ROOT + "/deletednode.html");
      else main.setPage(VELOCITY_ROOT + "/undeletenode.html");
    } else {
      tabbedNodeConfig.setVisible(true);     
      toolC.setEnabled(CMD_DELNODE, true);
      toolC.setEnabled(CMD_MOVENODE, true);
      toolC.setEnabled(CMD_COPYNODE, true);
      initNodeEditor(ureq, cetn.getCourseNode());
      main.setPage(VELOCITY_ROOT + "/index.html");         
    }
  }
View Full Code Here

Examples of org.olat.course.tree.CourseEditorTreeNode

        if (tn.getParent() == null) {
          showError(NLS_MOVECOPYNODE_ERROR_ROOTNODE);
          return;
        }
       
        CourseEditorTreeNode cetn = cetm.getCourseEditorNodeById(tn.getIdent());
        moveCopyController = new MoveCopySubtreeController(ureq, getWindowControl(), course, cetn, event.getCommand().equals(CMD_COPYNODE));       
        this.listenTo(moveCopyController);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), moveCopyController.getInitialComponent(), true, translate(NLS_INSERTNODE_TITLE));
        cmc.activate();
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.