Package com.agiletec.plugins.jpcontentfeedback.aps.system.services.contentfeedback.comment.model

Examples of com.agiletec.plugins.jpcontentfeedback.aps.system.services.contentfeedback.comment.model.Comment


      if (this.getCurrentUser().getUsername().equalsIgnoreCase(SystemConstants.GUEST_USER_NAME) && !anomymousCommentsAllowed) {
        ApsSystemUtils.getLogger().info("anomymous comments not allowed");
        return BaseAction.USER_NOT_ALLOWED;
      }

      Comment comment = new Comment();
      String contentId = this.getCurrentContentId();
      if (this.isAuth(contentId)) {
        String commentsModeration = this.getShowletParam(ContentFeedbackWidgetAction.WIDGET_PARAM_COMMENT_MODERATED);
        boolean moderation = null != commentsModeration && commentsModeration.equalsIgnoreCase("true");
        if (moderation) {
          comment.setStatus(Comment.STATUS_TO_APPROVE);
          this.addActionMessage(this.getText("jpcontentfeedback_MESSAGE_TO_APPROVED"));
        } else {
          comment.setStatus(Comment.STATUS_APPROVED);
        }
        comment.setComment(this.getCommentText());
        comment.setContentId(contentId);
        comment.setUsername(this.getCurrentUser().getUsername());
        this.getCommentManager().addComment(comment);
      }
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "addComment");
      return FAILURE;
View Full Code Here




  public void testAddRatingToComment() throws Throwable{
    IRating rating = null;
    Comment comment = null;
    int COMMENT_ID = -1;
    try {
      comment = createNewComment();
      comment.setContentId(CONTENT_ID);
      this._commentManager.addComment(comment);
      List<String> listaCommenti = this._commentManager.searchCommentIds(null);
      assertEquals(1, listaCommenti.size());
      COMMENT_ID = Integer.parseInt(listaCommenti.get(0));
      this._retingManager.addRatingToComment(COMMENT_ID,1);
      rating = this._retingManager.getCommentRating(COMMENT_ID);
      assertNotNull(rating);
      assertEquals(1, rating.getVoters());
      assertEquals(1, rating.getSumvote());
      //Inserimento di altri 3 voti:
      this._retingManager.addRatingToComment(COMMENT_ID, 1);
      this._retingManager.addRatingToComment(COMMENT_ID, 2);
      this._retingManager.addRatingToComment(COMMENT_ID, 4);
      rating = this._retingManager.getCommentRating(COMMENT_ID);
      assertNotNull(rating);
      assertEquals(4, rating.getVoters());
      assertEquals(8, rating.getSumvote());
    } catch (Throwable t) {
      t.printStackTrace();
      throw t;
    } finally {
      if (comment!=null){
        this._commentManager.deleteComment(comment.getId());
      }
    }

  }
View Full Code Here

  }


  private Comment createNewComment(){
    Comment comment = new Comment();
    comment.setComment("Testo del commento");
    comment.setStatus(Comment.STATUS_APPROVED);
    comment.setUsername("username");
    return comment;

  }
View Full Code Here

    super.setUp();
    this.init();
  }

  public void testAddGetComment() throws Throwable{
    Comment comment = null;
    try {

      IContentManager contentManager = (IContentManager) this.getService(JacmsSystemConstants.CONTENT_MANAGER);
      Content content = contentManager.loadContent("ART1", true);
      if (content==null){
        fail();
      }
      List<String> listaIds = this._commentManager.searchCommentIds(null);
      assertEquals(0,listaIds.size());
      comment = createNewComment();
      comment.setContentId(content.getId());
      this._commentManager.addComment(comment);
      assertNotNull(comment.getId());
      IComment commentRead = this._commentManager.getComment(comment.getId());
      assertEquals(comment.getComment(), commentRead.getComment());
      assertEquals(comment.getStatus(), commentRead.getStatus());
      assertEquals(comment.getUsername(), commentRead.getUsername());
      assertEquals(comment.getId(), commentRead.getId());
      assertEquals(Comment.STATUS_TO_APPROVE, commentRead.getStatus());

      CommentSearchBean searchBean = new CommentSearchBean();
      searchBean.setComment("Testo ");
      listaIds = this._commentManager.searchCommentIds(searchBean);
      assertEquals(1, listaIds.size());

    // Ricerca per data successiva a publicazione
      searchBean = new CommentSearchBean();
      searchBean.setComment("Testo ");
      searchBean.setCreationFROMDate(new Date(System.currentTimeMillis()+24*60*60*1000));
      searchBean.setStatus(0);
      searchBean.setUsername("username");
      listaIds = this._commentManager.searchCommentIds(searchBean);
      assertEquals(0, listaIds.size());

    // Ricerca elemento esatto con qualsiasi stato
      searchBean = new CommentSearchBean();
      searchBean.setComment("Testo ");
      searchBean.setCreationFROMDate(new Date(System.currentTimeMillis()));
      searchBean.setStatus(0);
      searchBean.setUsername("username");
      listaIds = this._commentManager.searchCommentIds(searchBean);
      assertEquals(1, listaIds.size());

    // Ricerca per commento errato
      searchBean = new CommentSearchBean();
      searchBean.setComment("ciccio");
      listaIds = this._commentManager.searchCommentIds(searchBean);
      assertEquals(0, listaIds.size());

    // Ricerca per titolo errato
      searchBean = new CommentSearchBean();
      searchBean.setComment("ciccio");
      searchBean.setStatus(Comment.STATUS_NOT_APPROVED);
      listaIds = this._commentManager.searchCommentIds(searchBean);
      assertEquals(0, listaIds.size());
      // Ricerca per titolo errato
      searchBean = new CommentSearchBean();
      searchBean.setStatus(Comment.STATUS_TO_APPROVE);
      listaIds = this._commentManager.searchCommentIds(searchBean);
      assertEquals(1, listaIds.size());

    } catch (Throwable t) {
      t.printStackTrace();
      throw t;
    } finally {
      if (comment != null ){
        this._commentManager.deleteComment(comment.getId());
      }
    }
  }
View Full Code Here

      }
    }
  }

  public void testAddUpdateDeleteComment() throws Throwable{
    Comment comment = null;
    try {
      IContentManager contentManager = (IContentManager) this.getService(JacmsSystemConstants.CONTENT_MANAGER);
      Content content = contentManager.loadContent("ART1", true);
      if (content==null){
        fail();
      }
      List<String> listaIds = this._commentManager.searchCommentIds(null);
      assertEquals(0,listaIds.size());
      comment = createNewComment();
      comment.setContentId(content.getId());
      this._commentManager.addComment(comment);
      assertNotNull(comment.getId());
      IComment commentRead = this._commentManager.getComment(comment.getId());
      assertEquals(comment.getComment(), commentRead.getComment());
      assertEquals(comment.getStatus(), commentRead.getStatus());
      assertEquals(comment.getUsername(), commentRead.getUsername());
      assertEquals(comment.getId(), commentRead.getId());

      this._commentManager.updateCommentStatus(comment.getId(), Comment.STATUS_NOT_APPROVED);
      commentRead = this._commentManager.getComment(comment.getId());
      assertEquals(Comment.STATUS_NOT_APPROVED, commentRead.getStatus());

      this._commentManager.deleteComment(comment.getId());
      assertNull(this._commentManager.getComment(comment.getId()));

    } catch (Throwable t) {
      t.printStackTrace();
      throw t;
    } finally {
      if (comment != null ){
        this._commentManager.deleteComment(comment.getId());
      }
    }
  }
View Full Code Here

      }
    }
  }

  private Comment createNewComment(){
    Comment comment = new Comment();
    comment.setComment("Testo del commento");
    comment.setStatus(Comment.STATUS_TO_APPROVE);
    comment.setUsername("username");
    return comment;

  }
View Full Code Here

  }

  @Override
  public Comment getComment(int id) {
    Comment comment = null;
    Connection conn = null;
    PreparedStatement stat = null;
    ResultSet res =null;
    try {
      conn = this.getConnection();
View Full Code Here

   * @param res
   * @return
   * @throws ApsSystemException
   */
  private Comment popualteComment(ResultSet res) throws ApsSystemException {
    Comment comment = new Comment();
    try {
      comment.setId(res.getInt("id"));
      comment.setContentId(res.getString("contentid"));
      Timestamp creationDate = res.getTimestamp("creationDate");
      if (null != creationDate) {
        comment.setCreationDate(new Date(creationDate.getTime()));
      }
      comment.setComment(res.getString("usercomment"));
      comment.setStatus(res.getInt("status"));
      comment.setUsername(res.getString("username"));
    } catch (Throwable t) {
      throw new ApsSystemException("Errore loading comment", t);
    }
    return comment;
  }
View Full Code Here

      throw t;
    }
  }

  public void testAddSearchUpdateComment() throws Throwable{
    Comment comment = null;
    try{
      this.setUserOnSession("admin");
      this.initAction("/do/jpcontentfeedback/Comments", "search");
      this.addParameter("status", Comment.STATUS_TO_APPROVE);
      String result = this.executeAction();
      assertEquals(Action.SUCCESS, result);
      ContentFeedbackAction action = (ContentFeedbackAction)this.getAction();
      List<String> listaIds = action.getCommentIds();
      assertEquals(0, listaIds.size());

      comment = createNewComment();
      this._commentManager.addComment(comment);

      this.initAction("/do/jpcontentfeedback/Comments", "search");
      this.addParameter("status", Comment.STATUS_TO_APPROVE);
      result = this.executeAction();
      assertEquals(Action.SUCCESS, result);
      action = (ContentFeedbackAction)this.getAction();
      listaIds = action.getCommentIds();
      assertEquals(1, listaIds.size());

      this.initAction("/do/jpcontentfeedback/Comments", "view");
      this.addParameter("selectedComment", comment.getId());
      result = this.executeAction();
      assertEquals(Action.SUCCESS, result);
      action = (ContentFeedbackAction)this.getAction();
      assertNotNull(action.getComment());

      this.initAction("/do/jpcontentfeedback/Comments", "updateStatus");
      this.addParameter("selectedComment", comment.getId());
      this.addParameter("status", Comment.STATUS_APPROVED);
      result = this.executeAction();
      assertEquals(Action.SUCCESS, result);

      this.initAction("/do/jpcontentfeedback/Comments", "search");
      this.addParameter("status", Comment.STATUS_APPROVED);
      result = this.executeAction();
      assertEquals(Action.SUCCESS, result);
      action = (ContentFeedbackAction)this.getAction();
      listaIds = action.getCommentIds();
      assertEquals(1, listaIds.size());

      this.initAction("/do/jpcontentfeedback/Comments", "delete");
      this.addParameter("selectedComment", comment.getId());
      this.addParameter("strutsAction", ApsAdminSystemConstants.DELETE);
      result = this.executeAction();
      assertEquals(Action.SUCCESS, result);

      this.initAction("/do/jpcontentfeedback/Comments", "search");
View Full Code Here

      }
    }
  }

  private Comment createNewComment(){
    Comment comment = new Comment();
    comment.setComment("Testo del commento");
    comment.setContentId("ART1");
    comment.setStatus(Comment.STATUS_TO_APPROVE);
    comment.setUsername("username");
    return comment;

  }
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpcontentfeedback.aps.system.services.contentfeedback.comment.model.Comment

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.