Package org.encuestame.utils.json

Examples of org.encuestame.utils.json.TweetPollBean


            final Options options = new Options();
            log.debug("Autosave TweetPoll Id --> " + tweetPollId);
            log.debug("Autosave Question --> " + question);
            final Map<String, Object> jsonResponse = new HashMap<String, Object>();
            if (tweetPollId == null && question != null && !question.isEmpty()) {
                  final TweetPollBean tweetPollBean = this.fillTweetPoll(
                          options, question, user, null);
                  //new tweetpoll domain.
                  final TweetPoll tp = createTweetPoll(tweetPollBean);
                  //retrieve answers stored.
                  final TweetPollBean tpB = ConvertDomainBean.convertTweetPollToBean(tp);
                  log.debug("Tweetpoll Created --->" + tpB.toString());
                  jsonResponse.put("tweetPoll", tpB);
             } else if (tweetPollId != null && question != null) {
                 options.setCaptcha(captcha);
                 options.setFollowDashBoard(onDashboard);
                 options.setLimitVotes(limitVotes);
                 options.setLiveResults(liveResults);
                 options.setScheduled(isScheduled);
                 options.setScheduledDate(filterValue(scheduledDate));
                 options.setScheduledTime(scheduldedTime);
                 options.setMaxLimitVotes(votesToLimit);
                 options.setFollowDashBoard(onDashboard);
                 options.setRepeatedVotes(repeatedVotes);
                 options.setMaxRepeatedVotes(repeatedVotesNum);
                 options.setResumeLiveResults(resumeLiveResults);
                  //update tweetPoll
                 final TweetPollBean tweetPollBean = this.fillTweetPoll(options, question, user, tweetPollId);
                 ConvertDomainBean.convertTweetPollToBean(updateTweetPoll(tweetPollBean));
                 log.debug("Tweetpoll Updated --->" + tweetPollBean.toString());
                 jsonResponse.put("tweetPoll", tweetPollBean);
             } else {
                 setError("create tweetpoll bad request", response);
             }
            setItemResponse(jsonResponse);
View Full Code Here


    private TweetPollBean fillTweetPoll(
            final Options options,
            final String question,
            final UserAccount user,
            final Long tweetPollId) throws ParseException{
        final TweetPollBean tweetPollBean = new TweetPollBean();
        log.debug("fillTweetPoll options" + options.toString());
        log.debug("fillTweetPoll user" +user.toString());
        log.debug("fillTweetPoll question" + question.toString());
        log.debug("fillTweetPoll tweetPollId" + tweetPollId);
        if (tweetPollId != null) {
            tweetPollBean.setId(tweetPollId);
        }
        // save create tweet poll
        tweetPollBean.setUserId(user.getAccount().getUid());
        //defined values.
        tweetPollBean.setCloseNotification(Boolean.TRUE); //TOOD: ????
        tweetPollBean.setResultNotification(Boolean.TRUE);
        //resume live results.
        tweetPollBean.setResumeLiveResults(options.getResumeLiveResults());
        //follow on dashboard.
        tweetPollBean.setResumeTweetPollDashBoard(options.getFollowDashBoard());
        //captcha.
        tweetPollBean.setCaptcha(options.getCaptcha());
        //live results
        tweetPollBean.setAllowLiveResults(options.getLiveResults());
        //repeated votes
        tweetPollBean.setAllowRepeatedVotes(options.getRepeatedVotes());
        if (options.getRepeatedVotes()) {
            tweetPollBean.setMaxRepeatedVotes(options.getMaxRepeatedVotes());
        }
        //scheduled
        tweetPollBean.setSchedule(options.getScheduled());
        if (options.getScheduled()) {
            //eg. format 5/25/11 10:45:00
            final StringBuilder builder = new StringBuilder(options.getScheduledDate());
            builder.append(" ");
            builder.append(options.getScheduledTime());
            tweetPollBean.setScheduleDate(DateUtil.parseDate(builder.toString(), DateUtil.COMPLETE_FORMAT_TIME));
        }
        //limit votes
        tweetPollBean.setLimitVotesEnabled(options.getLimitVotes());
        if (options.getLimitVotes()) {
            tweetPollBean.setLimitVotes(options.getMaxLimitVotes());
        }
        //question
        tweetPollBean.setQuestionBean(new QuestionBean(question));
        log.debug("fillTweetPoll: "+tweetPollBean);
        return tweetPollBean;
    }
View Full Code Here

     * Unit {@link TweetPollBean}.
     */
    @Test
    public void testUnitTweetPoll(){
        final Date myDate = new Date();
        final TweetPollBean tweetPoll = new TweetPollBean();
        tweetPoll.setId(1L);
        tweetPoll.setAllowLiveResults(true);
        tweetPoll.setCloseNotification(true);
        tweetPoll.setPublishPoll(true);
        tweetPoll.setUserId(1L);
        tweetPoll.setQuestionBean(new QuestionBean());
        tweetPoll.setResultNotification(true);
        List<ResumeResultTweetPoll> results = new ArrayList<ResumeResultTweetPoll>();
        tweetPoll.setResults(results);
        tweetPoll.setSchedule(true);
        tweetPoll.setScheduleDate(myDate);
        tweetPoll.setCompleted(true);
        tweetPoll.setTweetUrl("http://www.encuestame.org");
        assertNotNull(tweetPoll.getCompleted());
        tweetPoll.setCaptcha(true);
        tweetPoll.setLimitVotes(12345);
        tweetPoll.setResumeLiveResults(true);
        tweetPoll.setCreateDate(myDate.toString());
        tweetPoll.setFavorite(Boolean.TRUE);
        assertNotNull(tweetPoll.getScheduleDate());
        assertNotNull(tweetPoll.getId());
        assertNotNull(tweetPoll.getAllowLiveResults());
        assertNotNull(tweetPoll.getCloseNotification());
        assertNotNull(tweetPoll.getPublishPoll());
        assertNotNull(tweetPoll.getQuestionBean());
        assertNotNull(tweetPoll.getResultNotification());
        assertNotNull(tweetPoll.getSchedule());
        assertNotNull(tweetPoll.getUserId());
        assertEquals(tweetPoll.getResults().size(), 0);
        assertNotNull(tweetPoll.getCaptcha());
        assertNotNull(tweetPoll.getLimitVotes());
        assertNotNull(tweetPoll.getResumeLiveResults());
    }
View Full Code Here

    public TweetPoll createTweetPoll(
            final String question,
            String[] hashtags,
            UserAccount user) throws EnMeExpcetion{
        //create new tweetPoll
        final TweetPollBean tweetPollBean = new TweetPollBean();
        tweetPollBean.getHashTags().addAll(fillListOfHashTagsBean(hashtags));
        // save create tweet poll
        tweetPollBean.setUserId(user.getAccount().getUid());
        tweetPollBean.setCloseNotification(Boolean.FALSE);
        tweetPollBean.setResultNotification(Boolean.FALSE);
        //tweetPollBean.setPublishPoll(Boolean.TRUE); // always TRUE
        tweetPollBean.setSchedule(Boolean.FALSE);
        return getTweetPollService().createTweetPoll(tweetPollBean, question, user, null);
    }
View Full Code Here

         tpResultsBean.setVotes(vote);
         return tpResultsBean;
     }

     public TweetPollBean createTweetPollBean(){
         final TweetPollBean tpBean = new TweetPollBean();
         final Date myDate = new Date();
         tpBean.setAllowLiveResults(Boolean.TRUE);
         tpBean.setAllowRepeatedVotes(Boolean.TRUE);
         tpBean.setAnswerSwitchBeans(null);
         tpBean.setCaptcha(Boolean.TRUE);
         tpBean.setCloseNotification(Boolean.TRUE);
         tpBean.setCompleted(Boolean.TRUE);
         tpBean.setCreateDate(myDate.toString());
         tpBean.setDateToLimit(myDate.toString());
         tpBean.setDislikeVote(780L);
         tpBean.setFavorite(Boolean.TRUE);
         tpBean.setHashTags(null);
         tpBean.setHits(180L);
         tpBean.setId(null);
         tpBean.setItemType("TWEETPOLL");
         tpBean.setLikeVote(400L);
         tpBean.setLimitVotes(500);
         tpBean.setLimitVotesEnabled(Boolean.FALSE);
         tpBean.setMaxRepeatedVotes(2);
         tpBean.setOwnerUsername("jhonny");
         tpBean.setPublishPoll(Boolean.TRUE);
         tpBean.setQuestionBean(null);
         tpBean.setRelativeTime(null);
         tpBean.setRelevance(890L);
         tpBean.setResultNotification(Boolean.TRUE);
         tpBean.setResults(null);
         tpBean.setResumeLiveResults(Boolean.TRUE);
         tpBean.setResumeTweetPollDashBoard(null);
         tpBean.setSchedule(Boolean.TRUE);
         tpBean.setScheduleDate(myDate);
         tpBean.setTotalVotes(503L);
         tpBean.setTweetUrl(null);
         tpBean.setUpdateDate(null);
         tpBean.setUserId(null);
         return tpBean;
     }
View Full Code Here

            final String period){
        final List<TweetPoll> tweetPolls = getTweetPollDao().retrieveTweetsByUserId(keyword, userId, maxResults, start, isCompleted, isScheduled, isPublished, isFavourite, period);

        final List<TweetPollBean> tweetPollsBean = new ArrayList<TweetPollBean>();
        for (TweetPoll tweetPoll : tweetPolls) {
            final TweetPollBean unitTweetPoll = ConvertDomainBean.convertTweetPollToBean(tweetPoll);
             unitTweetPoll.getQuestionBean().setListAnswers(this.retrieveAnswerByQuestionId(unitTweetPoll.getQuestionBean().getId()));
             tweetPollsBean.add(unitTweetPoll);
        }
        return tweetPollsBean;
    }
View Full Code Here

            final Boolean results,
            final HttpServletRequest httpServletRequest){
        final List<TweetPollBean> tweetPollsBean = new ArrayList<TweetPollBean>();
        for (TweetPoll tweetPoll : listTweetPolls) {
             final List<TweetPollSwitch> answers = this.getTweetPollSwitch(tweetPoll);
             final TweetPollBean unitTweetPoll = ConvertDomainBean.convertTweetPollToBean(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

        for (QuestionBean question : tpListQuestions) {
            /*
             * TWEETPOLL
             */
            final TweetPollBean tweetPollBean = new TweetPollBean();
            //tweetPollBean.getHashTags().addAll();
            // save create tweet poll
            double randomUser = RandomUtils.nextInt(totalUsers);
            UserAccount u = userAccount.get(Double.valueOf(randomUser).intValue());
            SecurityUtils.authenticate(u);
            tweetPollBean.setUserId(u.getAccount().getUid());
            tweetPollBean.setCloseNotification(Boolean.FALSE);
           
            tweetPollBean.setResultNotification(Boolean.FALSE);           
            // all published by default
            tweetPollBean.setPublishPoll(Boolean.TRUE);
            // publish aleatory a publish poll.
//            int publish = RandomUtils.nextInt(10);
//            if (publish <= 7) {
//                tweetPollBean.setPublishPoll(Boolean.TRUE); // always TRUE
//            }
            // no scheduled tp in the demo data
            tweetPollBean.setSchedule(Boolean.FALSE);
            try {
                //final Question qm = createQuestion(question, u, QuestionPattern.CUSTOMIZABLE_SELECTION);
                final TweetPoll tweetPollDomain = getTweetPollService().createTweetPoll(tweetPollBean, question.getQuestionName(), u, null);

                //force to be published
View Full Code Here

   *             exception
   */
  @Test
  @Category(DefaultTest.class)
  public void testCreateTweetPoll() throws EnMeExpcetion {
    final TweetPollBean tweetPollBean = new TweetPollBean();
    questionBean.setId(question.getQid());
    tweetPollBean.setQuestionBean(questionBean);
    tweetPollBean.setPublishPoll(true);
    tweetPollBean.setScheduleDate(new Date());
    tweetPollBean.setCompleted(false);
    tweetPollBean.setUserId(this.user.getUid());
    // createTweetPoll(TweetPollBean, String, String[], UserAccount)
    String[] a = { "yes", "no" };
    // final TweetPoll tweetPoll =
    // this.tweetPollService.createTweetPoll(tweetPollBean, "", a,
    // this.userAccount);
View Full Code Here

    answersSaveTweet.add(createAnswersBean("GTJU", "Yes",
        questionSave.getQid()));

    questionBean = createUnitQuestionBean(questionSave.getQuestion(), 1L,
        usersave.getUid(), answersSaveTweet);
    final TweetPollBean unitTweetPoll = createUnitTweetPollPublicated(
        new Date(), true, tweetUrl, usersave.getUid(),
        this.questionBean, null);
    unitTweetPoll.setId(tweetPoll.getTweetPollId());
    // final String s =
    // this.tweetPollService.generateTweetPollText(unitTweetPoll, tweetUrl);
    // final Status status = this.tweetPollService.publicTweetPoll(s,
    // userpao.getTwitterAccount(), userpao.getTwitterPassword());
    // assertNotNull(status.getId());
View Full Code Here

TOP

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

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.