Package org.uned.agonzalo16.bitacora.domain

Examples of org.uned.agonzalo16.bitacora.domain.Article


  public void testFindByArticle() {
    Blog blog = createBlog();
    Article article1 = createArticle(blog);
    Article article2 = createArticle(blog);
    for (int i = 0; i < 10; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article1);
      comment.setUser(createUser());

      commentDao.merge(comment);
    }

    for (int i = 10; i < 30; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article2);
      comment.setUser(createUser());

      commentDao.merge(comment);
    }

    List<Comment> article1Comments = commentDao.findByArticle(article1);
View Full Code Here


  public void testCountByArticle() {
    Blog blog = createBlog();
    Article article1 = createArticle(blog);
    Article article2 = createArticle(blog);
    for (int i = 0; i < 10; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article1);
      comment.setUser(createUser());

      commentDao.merge(comment);
    }

    for (int i = 10; i < 30; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article2);
      comment.setUser(createUser());

      commentDao.merge(comment);
    }

    assertEquals("10 comments in article 1", commentDao.countByArticle(article1), 10);
View Full Code Here

  public void testDeleteAricleWithComments() {
    Blog blog = createBlog();
    Article article1 = createArticle(blog);
    Article article2 = createArticle(blog);
    for (int i = 0; i < 10; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article1);
      comment.setUser(createUser());

      commentDao.merge(comment);
    }

    for (int i = 10; i < 30; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article2);
      comment.setUser(createUser());

      commentDao.merge(comment);
    }

    assertEquals("30 comments", commentDao.findAll().size(), 30);
View Full Code Here

  public void testFidByUser() {
    Article article = createArticle(createBlog());
    User user1 = createUser();
    User user2 = createUser();
    for (int i = 0; i < 10; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article);
      comment.setUser(user1);

      commentDao.merge(comment);
    }

    for (int i = 10; i < 30; i++) {
      Comment comment = new Comment();
      comment.setContent("comment " + i);
      comment.setCreationDate(new Date());
      comment.setArticle(article);
      comment.setUser(user2);

      commentDao.merge(comment);
    }

    List<Comment> user1Comments = commentDao.findByUser(user1);
View Full Code Here

      return "contributor/article/create";
    }

    Article article = articleDao.get(form.getArticleId());

    Comment comment = new Comment();
    comment.setContent(form.getContent());
    comment.setCreationDate(new Date());
    comment.setArticle(article);
    comment.setUser(userDao.get(user.getId()));

    if (form.getParentArticleId() != null) {
      comment.setParentComment(commentDao.get(article, form.getParentArticleId()));
    }

    commentDao.merge(comment);

    return "redirect:/article/" + form.getArticleId();
View Full Code Here

    return "redirect:/article/" + form.getArticleId();
  }

  @RequestMapping(method = RequestMethod.POST, value = "/delete")
  public String delete(@ModelAttribute("article") CommentDeleteForm form) {
    Comment comment = commentDao.get(articleDao.get(form.getArticleId()), form.getCommentId());
    comment.setDeleted(true);
    comment.setDeleteReason(form.getReason());

    commentDao.merge(comment);

    return "redirect:/article/" + comment.getArticle().getId();
  }
View Full Code Here

  @Autowired
  private CommentDao commentDao;

  public List<CommentTree> createCommentsTree(Article article) {

    Comment falseComment = new Comment();
    falseComment.setId(-1L);
    CommentTree root = new CommentTree(falseComment);

    // para que la creación del árbol funcione los artículos se deben
    // obtener en el orden que se crearon. Para no procesar los nodos hijos
    // antes que los padres
View Full Code Here

  }

  @RequestMapping(method = RequestMethod.GET, value = "/show/{id}")
  public String show(@PathVariable("id") Long id, Model model, @ModelAttribute("userAttribute") AuthenticatedUser user) {
    User authUser = userDao.get(user.getId());
    Message msg = messageDao.get(id);
    model.addAttribute("message", msg);
    model.addAttribute("reply", !msg.getOrigin().equals(authUser));

    if (!msg.getRead() && msg.getDestination().equals(authUser)) {
      msg.setRead(true);
      messageDao.merge(msg);
    }

    return "message/show";
  }
View Full Code Here

    if (destination == null) {
      result.rejectValue("destination", "invalidusername", "invalidusername");
      return "message/create";
    }

    Message msg = new Message();
    msg.setCreationDate(new Date());
    msg.setSubject(form.getSubject());
    msg.setContent(form.getContent());
    msg.setOrigin(userDao.get(user.getId()));
    msg.setDestination(destination);

    messageDao.merge(msg);

    return "redirect:/message/listReceive";
  }
View Full Code Here

  }

  @RequestMapping(method = RequestMethod.GET, value = "/reply/{id}")
  public String reply(@PathVariable("id") Long id, Model model) {
    MessageForm form = new MessageForm();
    Message msg = messageDao.get(id);
    form.setSubject("[RE] " + msg.getSubject());
    form.setDestination(msg.getOrigin().getUsername());

    model.addAttribute("message", form);
    return "message/create";
  }
View Full Code Here

TOP

Related Classes of org.uned.agonzalo16.bitacora.domain.Article

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.