示例#1
0
  public boolean getHasChild() {
    List childList = messageManager.getFirstLevelChildMsgs(this.getMessage().getId());
    if ((childList != null) && (childList.size() > 0)) hasChild = true;
    else hasChild = false;

    return hasChild;
  }
  private int getTotalChildNo(PrivateMessageDecoratedBean dmb, List beanList) {
    MessageForumsMessageManager messageManager =
        (MessageForumsMessageManager)
            ComponentManager.get(
                "org.sakaiproject.api.app.messageforums.MessageForumsMessageManager");
    List allChild = new ArrayList();
    messageManager.getChildMsgs(dmb.getMsg().getId(), allChild);
    int no = 0;

    for (int i = 0; i < beanList.size(); i++) {
      PrivateMessageDecoratedBean thisBean = (PrivateMessageDecoratedBean) beanList.get(i);
      for (int j = 0; j < allChild.size(); j++) {
        Message child = (Message) allChild.get(j);
        if (thisBean.getMsg().getId().equals(child.getId())) {
          no++;
          break;
        }
      }
    }
    return no;
  }
示例#3
0
 /** @return Returns the hasAttachment. */
 public boolean isHasAttachment() {
   if (message == null) {
     return false;
   }
   message = messageManager.getMessageByIdWithAttachments(message.getId());
   if (message.getAttachments() == null) {
     return false;
   } else if (message.getAttachments().size() > 0) {
     return true;
   }
   /*    else (changed after not lazy loading attachments.)
   {
   	MessageForumsMessageManager mfmm =
   		(org.sakaiproject.api.app.messageforums.MessageForumsMessageManager)ComponentManager.get("org.sakaiproject.api.app.messageforums.MessageForumsMessageManager");
   	Message messageWithAttach = mfmm.getMessageByIdWithAttachments(message.getId());
   	if(messageWithAttach != null)
   	{
   		if(messageWithAttach.getAttachments().size()>0)
   			return true;
   	}
   }*/
   return false;
 }
示例#4
0
 public boolean getHasNotDeletedDescendant(final Long messageId) {
   List childList =
       messageManager.getFirstLevelChildMsgs(
           messageId == null ? this.getMessage().getId() : messageId);
   if ((childList != null) && (childList.size() > 0)) {
     hasNotDeletedChild = false;
     Iterator childIter = childList.iterator();
     while (childIter.hasNext() && !hasNotDeletedChild) {
       Message msg = (Message) childIter.next();
       if (!msg.getDeleted()) hasNotDeletedChild = true;
     }
     if (!hasNotDeletedChild) {
       // Maybe a descendant
       childIter = childList.iterator();
       while (childIter.hasNext() && !hasNotDeletedChild) {
         Message msg = (Message) childIter.next();
         if (getHasNotDeletedDescendant(msg.getId())) hasNotDeletedChild = true;
       }
     }
   } else {
     hasNotDeletedChild = false;
   }
   return hasNotDeletedChild;
 }
  private void renderThread(
      ResponseWriter writer,
      UIData data,
      int rows,
      Integer processed,
      int rowIndex,
      int rowStyles,
      int rowStyle,
      int columnStyle,
      int columnStyles,
      String columnClasses[],
      String rowClasses[],
      FacesContext context,
      List msgs,
      Message currentMsg) {
    Iterator kids = null;
    Iterator grandkids = null;

    for (int i = 0; i < msgs.size(); i++) {
      Message thisMsg = (Message) msgs.get(i);
      if (thisMsg.getId().equals(currentMsg.getId())) {
        msgs.remove(i);
        break;
      }
    }

    try {
      int processedInt = processed.intValue();
      if ((rows > 0) && (++processedInt > rows)) {
        processed = Integer.valueOf(processedInt);
        return;
      }
      data.setRowIndex(++rowIndex);
      if (!data.isRowAvailable()) {
        return;
      }

      writer.startElement("tr", data);
      if (rowStyles > 0) {
        writer.writeAttribute("class", rowClasses[rowStyle++], "rowClasses");
        if (rowStyle >= rowStyles) {
          rowStyle = 0;
        }
      }
      writer.writeText("\n", null);

      columnStyle = 0;
      kids = getColumns(data);
      while (kids.hasNext()) {
        UIColumn column = (UIColumn) kids.next();

        writer.startElement("td", column);
        if (columnStyles > 0) {
          writer.writeAttribute("class", columnClasses[columnStyle++], "columnClasses");
          if (columnStyle >= columnStyles) {
            columnStyle = 0;
          }
        }

        grandkids = getChildren(column);
        while (grandkids.hasNext()) {
          encodeRecursive(context, (UIComponent) grandkids.next());
        }

        writer.endElement("td");
        writer.writeText("\n", null);
      }

      writer.endElement("tr");
      writer.writeText("\n", null);
    } catch (Exception e) {
      e.printStackTrace();
    }

    MessageForumsMessageManager messageManager =
        (MessageForumsMessageManager)
            ComponentManager.get(
                "org.sakaiproject.api.app.messageforums.MessageForumsMessageManager");
    List replyMsgs = messageManager.getFirstLevelChildMsgs(currentMsg.getId());
    if (replyMsgs != null) {
      for (int i = 0; i < replyMsgs.size(); i++) {
        Message childM = (Message) replyMsgs.get(i);
        for (int j = 0; j < msgs.size(); j++) {
          Message remainMsg = (Message) msgs.get(j);
          if (childM.getId().equals(remainMsg.getId())) {
            renderThread(
                writer,
                data,
                rows,
                processed,
                rowIndex,
                rowStyles,
                rowStyle,
                columnStyle,
                columnStyles,
                columnClasses,
                rowClasses,
                context,
                msgs,
                remainMsg);
          }
        }
      }
    }
  }
示例#6
0
 public int getSubmissionCount(String user) {
   if (type == TYPE_FORUM_TOPIC)
     return messageManager.findAuhtoredMessageCountByTopicIdByUserId(id, user);
   else return messageManager.findAuthoredStatsForStudentByForumId(user, id).size();
 }