Package org.encuestame.utils.web

Examples of org.encuestame.utils.web.CommentBean


    private CommentBean createComment(
            final String mycomment,
            final Long tweetPollId,
            final String type,
            final Long relatedCommentId , boolean published) throws EnMeNoResultsFoundException, EnmeNotAllowedException {
        final CommentBean bean = new CommentBean();
         final TypeSearchResult typeResult = TypeSearchResult.getTypeSearchResult(filterValue(type));
         bean.setComment(filterValue(mycomment));
         bean.setCreatedAt(Calendar.getInstance().getTime());
         bean.setParentId(relatedCommentId);
         bean.setId(tweetPollId);
         bean.setType(typeResult);
         final Comment comment = getCommentService().createComment(bean);
         return ConvertDomainBean.convertCommentDomainToBean(comment);
    }
View Full Code Here


    /**
     * Test {@link CommentBean}.
     */
    @Test
    public void testCommentBean(){
        final CommentBean myCommentBean = new CommentBean();
        myCommentBean.setCommentId(1L);
        myCommentBean.setComment("My comment");
        myCommentBean.setCommentedBy("Jhonny");
        myCommentBean.setCommentedByUsername("jhonny");
        myCommentBean.setCreatedAt(new Date());
        myCommentBean.setDislikeVote(10L);
        myCommentBean.setLikeVote(50L);
        myCommentBean.setParentId(0L);
        myCommentBean.setType(TypeSearchResult.TWEETPOLL);
        myCommentBean.setUserAccountId(1L);
        assertNotNull(myCommentBean);
        assertNotNull(myCommentBean.getCommentId());
        assertNotNull(myCommentBean.getComment());
        assertNotNull(myCommentBean.getCommentedBy());
        assertNotNull(myCommentBean.getCommentedByUsername());
        assertNotNull(myCommentBean.getCreatedAt());
        assertNotNull(myCommentBean.getDislikeVote());
        assertNotNull(myCommentBean.getLikeVote());
        assertNotNull(myCommentBean.getParentId());
        assertNotNull(myCommentBean.getType());
        assertNotNull(myCommentBean.getUserAccountId());
    }
View Full Code Here

    private List<CommentBean> getComments() throws IOException {
        CSVReader csv = readCSVFile("comments.csv");
        String[] nextLine;
        final List<CommentBean> list = new ArrayList<CommentBean>();
        while ((nextLine = csv.readNext()) != null) {
            final CommentBean bean = new CommentBean();
            bean.setComment(nextLine[0]);
            list.add(bean);
        }
        return list;
    }
View Full Code Here

     * @throws EnMeNoResultsFoundException
     * @throws EnmeNotAllowedException
     */
    @Test
    public void testCreateComment() throws EnMeNoResultsFoundException, EnmeNotAllowedException{
        final CommentBean commentBean = createCommentBean("totally Agree", new Date(),
                getSpringSecurityLoggedUserAccount().getUid(), this.tweetPoll.getTweetPollId(), null);
        final Comment comment = getCommentsOperationsService().createComment(commentBean);
        assertNotNull(comment);
    }
View Full Code Here

     * @param commentDomain
     * @return
     */
    public static final CommentBean convertCommentDomainToBean(
            final Comment commentDomain) {
        final CommentBean commentBean = new CommentBean();
        Assert.assertNotNull(commentDomain);
        commentBean.setCommentId(commentDomain.getCommentId());
        commentBean.setComment(commentDomain.getComment());
        commentBean.setCreatedAt(commentDomain.getCreatedAt());
        commentBean
                .setDislikeVote(commentDomain.getDislikeVote() == null ? EnMeUtils.VOTE_MIN
                        : commentDomain.getDislikeVote());
        commentBean
                .setLikeVote(commentDomain.getLikeVote() == null ? EnMeUtils.VOTE_MIN
                        : commentDomain.getLikeVote());
        long id = 0;
        boolean set = false;
        String slug = "";
        /*
         * is possible refactor this part? ..
         */
        TypeSearchResult type = null;
        if (commentDomain.getPoll() != null && !set) {
            type = TypeSearchResult.POLL;
            id = commentDomain.getPoll().getPollId();
            commentBean.setType(TypeSearchResult.POLL);
            set = true;
            slug = commentDomain.getPoll().getQuestion().getSlugQuestion();
        }
        if (commentDomain.getTweetPoll() != null && !set) {
            type = TypeSearchResult.TWEETPOLL;
            id = commentDomain.getTweetPoll().getTweetPollId();
            commentBean.setType(TypeSearchResult.TWEETPOLL);
            set = true;
            slug = commentDomain.getTweetPoll().getQuestion().getSlugQuestion();
        }
        if (commentDomain.getSurvey() != null && !set) {
            type = TypeSearchResult.SURVEY;
            id = commentDomain.getSurvey().getSid();
            commentBean.setType(TypeSearchResult.SURVEY);
            set = true;
            // slug =
            // commentDomain.getTweetPoll().getQuestion().getSlugQuestion();
        }
        commentBean.setId(id);
        commentBean.setParentId(commentDomain.getParentId() == null ? null
                : commentDomain.getParentId());
        commentBean.setUserAccountId(commentDomain.getUser() == null ? null
                : commentDomain.getUser().getUid());
        commentBean.setCommentedBy(commentDomain.getUser().getCompleteName());
        commentBean.setCommentedByUsername(commentDomain.getUser()
                .getUsername());
        commentBean.setStatus(commentDomain.getCommentOptions());
        // url
        // tweetpoll/4/do-you-like-summer-season%3F
        if (type != null) {
            final StringBuffer url = new StringBuffer("/");
            url.append(TypeSearchResult.getUrlPrefix(type));
            url.append("/");
            url.append(id);
            url.append("/");
            url.append(slug);
            url.append("/#comment");
            url.append(commentDomain.getCommentId());
            commentBean.setCommentUrl(url.toString());
        }
        return commentBean;
    }
View Full Code Here

      * @param pollId
      * @return
      */
     public CommentBean createCommentBean(final String comment,
             final Date createdAt, final Long userId, final Long tweetPollId, final Long pollId){
         final CommentBean commentBean = new CommentBean();
         commentBean.setComment(comment);
         commentBean.setCreatedAt(createdAt);
         commentBean.setUserAccountId(userId);
         commentBean.setId(tweetPollId);
         commentBean.setType(TypeSearchResult.TWEETPOLL);
         return commentBean;
     }
View Full Code Here

TOP

Related Classes of org.encuestame.utils.web.CommentBean

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.