コード例 #1
0
  public PostModel clone() {
    PostModel p2 = new PostModel();
    p2.setPoster(getPoster());
    p2.setGroup(group);
    p2.setSubject(subject);
    p2.setIntro(intro);
    p2.setBody(body);
    p2.setDate(date);
    p2.setTags(tags);
    p2.setParent(parent);
    p2.setReplies(replies);
    p2.newReplies = newReplies;
    p2.setEmailed(emailed);

    return p2;
  }
コード例 #2
0
  public static PostModel newPost(
      UserModel currentUser,
      GroupModel targetGroup,
      String subject,
      String intro,
      String body,
      String unsplitTags,
      boolean whiteboard) {
    Session hibernateSession = HibernateUtil.currentSession();
    PostModel p = new PostModel();
    hibernateSession.save(p);
    AjaxServlet.invalidateFrontPageCache(targetGroup.getId());

    p.setSubject(subject);
    p.setIntro(intro);

    if (!body.trim().equals("")) {
      p.setBody(body);
    }

    targetGroup.addPost(p);

    for (String tag : TagLogic.extractTagNames(unsplitTags)) {
      p.addTag(TagModel.getOrCreateTag(tag));
    }

    currentUser.addPost(p);

    hibernateSession.flush();

    if (whiteboard) {
      p.setWhiteboard(WhiteboardModel.newWhiteboard(null, p, null));
    }
    Helpers.currentDailyStats().logPost();

    p.setSearchable(SearchableModel.newSearchable(p, null, null));

    return p;
  }