Package org.encuestame.utils.json

Examples of org.encuestame.utils.json.SearchBean


            final HttpServletRequest httpServletRequest){
        final List<SearchBean> tweetPollsBean = new ArrayList<SearchBean>();
        for (TweetPoll tweetPoll : listTweetPolls) {
             final List<TweetPollSwitch> answers = this.getTweetPollSwitch(tweetPoll);
             // Convertir Tweetpoll a SearchTweetpollBean
             final SearchBean unitTweetPoll = ConvertDomainBean.convertTweetPollToSearchBean(tweetPoll);
             final List<TweetPollAnswerSwitchBean> listSwitchs = new ArrayList<TweetPollAnswerSwitchBean>();
             if (results) {
                 final List<TweetPollResultsBean> list = new ArrayList<TweetPollResultsBean>();
                 for (TweetPollSwitch tweetPollSwitch : answers) {
                     final TweetPollAnswerSwitchBean answerResults = ConvertDomainBean.convertTweetPollSwitchToBean(tweetPollSwitch, httpServletRequest);
                     final TweetPollResultsBean rBean = this.getVotesByTweetPollAnswerId(tweetPoll.getTweetPollId(), tweetPollSwitch.getAnswers());
                     answerResults.setResultsBean(rBean);
                     list.add(rBean);
                     listSwitchs.add(answerResults);
                }
                 this.calculatePercents(list);
             }
             unitTweetPoll.setAnswerSwitchBeans(listSwitchs);
             tweetPollsBean.add(unitTweetPoll);
        }
        return tweetPollsBean;
    }
View Full Code Here


        return unitTweetPoll;
    }

    public static final SearchBean convertTweetPollToSearchBean(
            final TweetPoll tweetPoll) {
        final SearchBean unitTweetPoll = new SearchBean();
        unitTweetPoll.setId(tweetPoll.getTweetPollId());
        unitTweetPoll.setScheduleDate(tweetPoll.getScheduleDate());
        unitTweetPoll.setCreateDate(DateUtil.getFormatDate(tweetPoll
                .getCreateDate()));
        unitTweetPoll.setCreateDateComparable(tweetPoll.getCreateDate());
        unitTweetPoll
                .setAllowLiveResults(tweetPoll.getAllowLiveResults() == null ? false
                        : tweetPoll.getAllowLiveResults());
        unitTweetPoll
                .setResumeLiveResults(tweetPoll.getResumeLiveResults() == null ? false
                        : tweetPoll.getResumeLiveResults());
        unitTweetPoll.setModeratedComments(tweetPoll.getShowComments() == null ? false : (tweetPoll.getShowComments().equals(
                CommentOptions.MODERATE) ? true : false));
        unitTweetPoll
                .setSchedule(tweetPoll.getScheduleTweetPoll() == null ? false
                        : tweetPoll.getScheduleTweetPoll());
        unitTweetPoll
                .setResultNotification(tweetPoll.getResultNotification() == null ? false
                        : tweetPoll.getResultNotification());
        unitTweetPoll.setUserId(tweetPoll.getTweetOwner().getUid());
        unitTweetPoll
                .setOwnerUsername(tweetPoll.getEditorOwner() == null ? null
                        : tweetPoll.getEditorOwner().getUsername());
        unitTweetPoll.setCaptcha(tweetPoll.getCaptcha() == null ? false
                : tweetPoll.getCaptcha());
        unitTweetPoll
                .setCloseNotification(tweetPoll.getCloseNotification() == null ? false
                        : tweetPoll.getCloseNotification());
        unitTweetPoll.setFavourites(tweetPoll.getFavourites() == null ? false
                : tweetPoll.getFavourites());
        unitTweetPoll.setCompleted(tweetPoll.getCompleted() == null ? false
                : tweetPoll.getCompleted());
        unitTweetPoll.setQuestionBean(convertQuestionsToBean(tweetPoll
                .getQuestion()));
        unitTweetPoll.setHits(tweetPoll.getHits() == null ? EnMeUtils.VOTE_MIN
                : tweetPoll.getHits());
        unitTweetPoll
                .setAllowRepeatedVotes(tweetPoll.getAllowRepatedVotes() == null ? false
                        : tweetPoll.getAllowRepatedVotes());
        unitTweetPoll.setHashTags(ConvertDomainBean
                .convertListHashTagsToBean(new ArrayList<HashTag>(tweetPoll
                        .getHashTags())));
        unitTweetPoll
                .setTotalVotes(tweetPoll.getNumbervotes() == null ? EnMeUtils.VOTE_MIN
                        : Long.valueOf(tweetPoll.getNumbervotes()));
        unitTweetPoll.setCreatedDateAt(tweetPoll.getCreateDate());
        unitTweetPoll
                .setLimitVotesDate(tweetPoll.getDateLimit() == null ? false
                        : tweetPoll.getDateLimit());
        unitTweetPoll.setUpdateDate(tweetPoll.getUpdatedDate());
        if (tweetPoll.getDateLimit() != null
                && tweetPoll.getDateLimited() != null) {
            unitTweetPoll
                    .setDateToLimit(tweetPoll.getDateLimited() == null ? null
                            : DateUtil.DOJO_DATE_FORMAT.format(tweetPoll
                                    .getDateLimited()));
        }
        unitTweetPoll
                .setRelevance(tweetPoll.getRelevance() == null ? EnMeUtils.RATE_DEFAULT
                        : tweetPoll.getRelevance());
        unitTweetPoll.setItemType(TypeSearchResult.TWEETPOLL.toString()
                .toLowerCase());
        return unitTweetPoll;
    }
View Full Code Here

        return unitTweetPoll;
    }

    public static final SearchBean convertPollToSearchBean(
            final Poll poll) {
        final SearchBean pollSearch = new SearchBean();
        pollSearch.setId(poll.getPollId());

        pollSearch.setCreateDate(DateUtil.getFormatDate(poll.getCreateDate()));
        pollSearch.setCreateDateComparable(poll.getCreateDate());
        pollSearch.setAllowLiveResults(Boolean.TRUE);
        //poll.getShowResults() == null ? false : poll.getShowResults()

        pollSearch.setModeratedComments(poll.getShowComments() == null ? false : (poll.getShowComments().equals(
                CommentOptions.MODERATE) ? true : false));

        pollSearch
                .setResultNotification(poll.getNotifications() == null ? false
                        : poll.getNotifications());
        pollSearch.setUserId(poll.getEditorOwner().getUid());
        pollSearch.setOwnerUsername(poll.getEditorOwner() == null ? null
                        : poll.getEditorOwner().getUsername());
         pollSearch.setFavourites(poll.getFavourites() == null ? false
                : poll.getFavourites());
        pollSearch.setCompleted(poll.getPollCompleted() == null ? false
                : poll.getPollCompleted());
        pollSearch.setQuestionBean(convertQuestionsToBean(poll
                .getQuestion()));
        pollSearch.setHits(poll.getHits() == null ? EnMeUtils.VOTE_MIN
                : poll.getHits());

        pollSearch.setHashTags(ConvertDomainBean
                .convertListHashTagsToBean(new ArrayList<HashTag>(poll
                        .getHashTags())));
        pollSearch
                .setTotalVotes(poll.getNumbervotes() == null ? EnMeUtils.VOTE_MIN
                        : Long.valueOf(poll.getNumbervotes()));
        pollSearch.setCreatedDateAt(poll.getCreateDate());
        pollSearch
                .setLimitVotesDate(poll.getCloseAfterDate() == null ? false
                        : poll.getCloseAfterDate());
        pollSearch.setUpdateDate(poll.getUpdatedDate());
        if (poll.getClosedQuota() != null
                && poll.getClosedDate() != null) {
            pollSearch
                    .setDateToLimit(poll.getClosedDate() == null ? null
                            : DateUtil.DOJO_DATE_FORMAT.format(poll
                                    .getClosedDate()));
        }
        pollSearch
                .setRelevance(poll.getRelevance() == null ? EnMeUtils.RATE_DEFAULT
                        : poll.getRelevance());
        pollSearch.setItemType(TypeSearchResult.POLL.toString()
                .toLowerCase());
        return pollSearch;
    }
View Full Code Here

TOP

Related Classes of org.encuestame.utils.json.SearchBean

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.