Package org.olat.modules.fo

Examples of org.olat.modules.fo.MessageNode


   */
  public String applyFormatterForOneThread(ForumFormatter forumFormatter, long forumId, long topMessageId){
    Tracing.logInfo("Archiving forum.thread: "+forumId+"."+topMessageId, ForumArchiveManager.class);
    Map metaInfo = new HashMap();
    metaInfo.put(ForumFormatter.MANDATORY_METAINFO_KEY ,new Long(forumId));
    MessageNode topMessageNode = convertToThreadTree(topMessageId);
    return formatThread(topMessageNode, forumFormatter, metaInfo);
  }
View Full Code Here


   
    for (Iterator iterTop = messages.iterator(); iterTop.hasNext();) {
      Message msg = (Message) iterTop.next();
      if (msg.getParent() == null) {
        iterTop.remove();
        MessageNode topNode = new MessageNode(msg);
        if(topNode.isHidden() && (forumCallback==null || (forumCallback!=null && forumCallback.mayEditMessageAsModerator()))) {
          addChildren(messages, topNode);
          topNodeList.add(topNode);
        else if(!topNode.isHidden()) {
          addChildren(messages, topNode);
          topNodeList.add(topNode);
        }
      }
    } 
View Full Code Here

   * @param metaInfo
   * @return the top message node with all its children
   */
  private MessageNode convertToThreadTree(long topMessageId){
    List messages;
    MessageNode topNode = null;
    ForumManager fm = ForumManager.getInstance();
    Long l = new Long(topMessageId);
    messages = fm.getThread(l);
    for (Iterator iterTop = messages.iterator(); iterTop.hasNext();) {
      Message msg = (Message) iterTop.next();
      if (msg.getParent() == null) {
        iterTop.remove();
        topNode = new MessageNode(msg);
        addChildren(messages, topNode);
      }
    }
    return topNode;
  }
View Full Code Here

 
  private void addChildren(List messages, MessageNode mn){
    for(Iterator iterMsg = messages.iterator();iterMsg.hasNext();){
      Message msg = (Message) iterMsg.next();
      if ((msg.getParent() != null) && (msg.getParent().getKey() == mn.getKey())){
        MessageNode childNode = new MessageNode(msg);
        mn.addChild(childNode);
        //FIXME:as:c next line is not necessary
        childNode.setParent(mn);
        addChildren(messages, childNode);
      }
    }
  }
View Full Code Here

  private String formatForum(List topNodeList, ForumFormatter forumFormatter, Map metaInfo){
    forumFormatter.setForumMetaInformation(metaInfo);
    StringBuilder formattedForum = new StringBuilder();
    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
View Full Code Here

  /**
   * @see org.olat.core.util.tree.Visitor#visit(org.olat.core.util.nodes.INode)
   */
  public void visit(INode node) {
    MessageNode mn = (MessageNode) node;

    if (isTopThread) {
      if(filePerThread){
        //make a file per thread
        //to have a meaningful filename we create the file here
        String filName = "Thread_" + mn.getKey().toString();
        tempContainer = makeTempVFSContainer();     
        this.vfsFil=tempContainer.resolve(filName + ".rtf");
        if(vfsFil==null){
          tempContainer.createChildLeaf(filName + ".rtf");
          this.vfsFil=tempContainer.resolve(filName + ".rtf");
        }
      }
      //important!
      isTopThread = false;
    }
    // Message Title
    sb.append("{\\pard \\brdrb\\brdrs\\brdrw10 \\f1\\fs30\\b ");
    sb.append(getImageRTF(mn));
    sb.append(getTitlePrefix(mn));
    sb.append(mn.getTitle());
    sb.append("\\par}");
    // Message Body
    sb.append("{\\pard \\f0");
    sb.append(convertHTMLMarkupToRTF(mn.getBody()));
    sb.append("\\par}");
    // Message key
    sb.append("{\\pard \\f0\\fs15 Message key: ");
    sb.append(mn.getKey());
    sb.append("} \\line ");
    sb.append("{\\pard \\f0\\fs15 created: ");
    // Creator and creation date
    sb.append(mn.getCreator().getUser().getProperty(UserConstants.FIRSTNAME, null));
    sb.append(", ");
    sb.append(mn.getCreator().getUser().getProperty(UserConstants.LASTNAME, null));
    sb.append(" ");
    sb.append(mn.getCreationDate().toString());
    // Modifier and modified date
    Identity modifier = mn.getModifier();
    if (modifier != null) {
      sb.append(" \\line modified: ");
      sb.append(modifier.getUser().getProperty(UserConstants.FIRSTNAME, null));
      sb.append(", ");
      sb.append(modifier.getUser().getProperty(UserConstants.LASTNAME,  null));
      sb.append(" ");
      sb.append(mn.getModifiedDate().toString());
    }
    sb.append(" \\par}");
    // attachment(s)
    OlatRootFolderImpl msgContainer = fm.getMessageContainer((Long)(getMetainfo(ForumFormatter.MANDATORY_METAINFO_KEY)), mn.getKey());
    List attachments = msgContainer.getItems();
    if (attachments != null && attachments.size() > 0){
      VFSItem item = container.resolve("attachments");
      if (item == null){
        item = container.createChildContainer("attachments");
View Full Code Here

TOP

Related Classes of org.olat.modules.fo.MessageNode

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.