Package org.encuestame.persistence.domain.tweetpoll

Examples of org.encuestame.persistence.domain.tweetpoll.TweetPollSwitch


                     if (shortUrl == null || shortUrl.isEmpty()) {
                         shortUrl = EnMePlaceHolderConfigurer.getProperty("short.default");
                     }
                     answerBean.setShortUrlType(ShortUrlProvider.get(shortUrl));
                     log.debug("new answer bean:{ "+answerBean.toString());
                     final TweetPollSwitch tweetPollSwitch = getTweetPollService()
                           .createTweetPollQuestionAnswer(answerBean, tweetPoll, request);
                     log.debug("new answer bean DOMAIN "+tweetPollSwitch.toString());
                     //log.debug("action questionAnswer "+questionAnswer);
                     jsonResponse.put("newAnswer", ConvertDomainBean.convertTweetPollSwitchToBean(tweetPollSwitch, request));
                     setItemResponse(jsonResponse);
                }
View Full Code Here


                    model.put("message", "Tweet Not Valid..");
                } else {
                    tweetId = filterValue(tweetId);
                    model.put("tweetId", tweetId);
                    log.info("search code->"+tweetId);
                    final TweetPollSwitch tweetPoll = getTweetPollService()
                            .getTweetPollDao().retrieveTweetsPollSwitch(tweetId);
                    model.addAttribute("tp_switch", tweetPoll);
                    final Boolean validateLimitVotes = getTweetPollService().validateLimitVotes(tweetPoll.getTweetPoll());
                    final Boolean restrictVotesByDate = getTweetPollService().validateVotesByDate(tweetPoll.getTweetPoll());
                     //NOTE: tweetpoll should be published to able to vote !!
                    if (tweetPoll == null || !tweetPoll.getTweetPoll().getPublishTweetPoll()) {
                        log.debug("tweetpoll answer not found");
                        model.put("message", getMessage("tp_no_valid"));
                    } else  if (tweetPoll.getTweetPoll().getCompleted()) {
                        log.debug("tweetpoll is archived");
                        model.put("message", getMessage("tweetpoll.votes.completed"));
                        pathVote = "completeTweetVote";
                        // Validate Limit Votes
                    } else if(validateLimitVotes) {
                         log.debug("tweetpoll reached limit votes");
                         model.put("message", getMessage("tweetpoll.votes.limited"));
                         pathVote = "LimitTweetVote";
                    } else {
                        log.info("Validate Votting");
                        log.info("IP" + IP);
                    try {
                        getTweetPollService().validateIpVote(IP,
                                tweetPoll.getTweetPoll());
                        if (!tweetPoll.getTweetPoll().getCaptcha()) {
                            getTweetPollService().tweetPollVote(tweetPoll, IP,
                                    Calendar.getInstance().getTime());
                            model.put("message", getMessage("tweetpoll.votes.acepted"));
                            pathVote = "tweetVoted";
                            log.debug("VOTED");
View Full Code Here

                result.reject("form.problems");
                //reload page.
                return "voteCaptcha";
             } else {
                 //Find Answer To Vote.
                 final TweetPollSwitch tweetPoll = getTweetPollService().getTweetPollDao()
                        .retrieveTweetsPollSwitch(code);
                 model.addAttribute("switch", tweetPoll);
                 //Validate Code.
                 if (tweetPoll == null || !tweetPoll.getTweetPoll().getPublishTweetPoll()) {
                     log.debug("tweetpoll answer not found");
                     return "badTweetVote";
                     //model.addAttribute("message", "Tweet Not Valid.");
                     }
                 else {
                     // Vote
                     try {
                         getTweetPollService().validateIpVote(IP, tweetPoll.getTweetPoll());
                         getTweetPollService().tweetPollVote(tweetPoll, IP, Calendar.getInstance().getTime());
                         return "tweetVoted";

                    } catch (Exception e) {
                         log.error("Bad tweetpoll process submit --- >" + e);
View Full Code Here

        // 4- Get total Usage by tweetpoll voted.

          final QuestionAnswer questionsAnswers1 = createQuestionAnswer("yes", question, "7891011");
          final QuestionAnswer questionsAnswers2 = createQuestionAnswer("no", question, "7891012");

          final TweetPollSwitch tpollSwitch1 = createTweetPollSwitch(questionsAnswers1, myTweetPoll);
        final TweetPollSwitch tpollSwitch2 = createTweetPollSwitch(questionsAnswers2, myTweetPoll);

        createTweetPollResult(tpollSwitch1, "192.168.0.1");
        createTweetPollResult(tpollSwitch1, "192.168.0.2");
        createTweetPollResult(tpollSwitch2, "192.168.0.3");
        createTweetPollResult(tpollSwitch2, "192.168.0.4");
View Full Code Here

            final TweetPoll tp1 = (TweetPoll) getHibernateTemplate().find("from TweetPoll").get(0);
            final Question q1 = tp1.getQuestion();
            final QuestionAnswer a1 = createQuestionAnswer("yes", q1, "12345");
            final QuestionAnswer a2 = createQuestionAnswer("no", q1, "12346");
            this.tpswitch = createTweetPollSwitch(a1, tp1);
            final TweetPollSwitch tps2 = createTweetPollSwitch(a2, tp1);
        }
View Full Code Here

     */
    public TweetPollSwitch createTweetPollSwitch(
            final TweetPoll tweetPoll,
            final QuestionAnswer answer,
            final HttpServletRequest request) {
        final TweetPollSwitch tPollSwitch = new TweetPollSwitch();
        tPollSwitch.setAnswers(answer);
        tPollSwitch.setTweetPoll(tweetPoll);
        //FIXME: Verfy if it these code already exist.
        tPollSwitch.setCodeTweet(MD5Utils.shortMD5(Calendar.getInstance()
                .getTimeInMillis() + answer.getAnswer()));
        tPollSwitch.setDateUpdated(Calendar.getInstance().getTime());

        // vote without domain
        final StringBuffer voteUrlWithoutDomain = new StringBuffer();
        voteUrlWithoutDomain.append(this.TWEETPOLL_VOTE);
        voteUrlWithoutDomain.append(tPollSwitch.getCodeTweet());
        tPollSwitch.setRelativeUrl(voteUrlWithoutDomain.toString());


        final StringBuffer completeDomain = new StringBuffer();
        if (request != null) {
            final String domain = WidgetUtil.getDomain(request);
            completeDomain.append(domain);
        }
        completeDomain.append(voteUrlWithoutDomain.toString());
        log.debug("tweet poll answer vote :{" + voteUrlWithoutDomain.toString());
        if (InternetUtils.validateUrl(completeDomain.toString())) {
            log.debug("createTweetPollSwitch: URL IS VALID");
//      log.debug("createTweetPollSwitch: short url provider "+ answer.getProvider());
            tPollSwitch.setShortUrl(WidgetUtil.createShortUrl(answer.getProvider(), completeDomain.toString()));
        } else {
            log.debug("createTweetPollSwitch: url IS NOT valid");
            tPollSwitch.setShortUrl(completeDomain.toString());
            log.warn("Invalid format vote url:{" + voteUrlWithoutDomain.toString());
        }
        getTweetPollDao().saveOrUpdate(tPollSwitch);
        return tPollSwitch;
    }
View Full Code Here

        final List<QuestionAnswer> answers = this.getQuestionDao().getAnswersByQuestionId(tweetPoll.getQuestion().getQid());
        log.debug("updateTweetPollSwitchSupport answers size:{"+answers.size());
        //iterate answer for one question
        for (QuestionAnswer answer : answers) {
            //try to locate current switch if exist
            TweetPollSwitch tPollSwitch = getTweetPollDao().getAnswerTweetSwitch(tweetPoll, answer);
            if (tPollSwitch == null) {
                log.debug("created tweetpoll switch for tweetpoll:{"+tweetPoll.getTweetPollId());
                tPollSwitch = this.createTweetPollSwitch(tweetPoll, answer, httpServletRequest);
            } else {
                log.debug("updated tweetpoll switch:{"+tPollSwitch.getSwitchId()+" for tweetpoll :{"+tweetPoll.getTweetPollId());
            }
            //update answer url.
            answer.setUrlAnswer(tPollSwitch.getShortUrl()); //store url without short.
            getQuestionDao().saveOrUpdate(answer);
        }
    }
View Full Code Here

        if (questionAnswer == null) {
            throw new EnMeNoResultsFoundException("answer is missing");
        } else {
            //create tweet poll switch with tp and new answer.
            log.debug("createTweetPollQuestionAnswer: short url provider:{ "+questionAnswer.getProvider());
            final TweetPollSwitch tpSwitch = this.createTweetPollSwitch(tp, questionAnswer, request);
            return tpSwitch;
        }
    }
View Full Code Here

                for (QuestionAnswerBean questionAnswerBean : listOfAnswers) {
                    final QuestionAnswerBean answerBean = new QuestionAnswerBean(questionAnswerBean.getAnswers());
                    answerBean.setShortUrlType(ShortUrlProvider.NONE);
                    //create tweetpoll swithch
                    final TweetPollSwitch tweetPollSwitch = getTweetPollService().createTweetPollQuestionAnswer(answerBean, tweetPollDomain, null);
                    double totalVotes = getRandomNumberRange(0, EnMePlaceHolderConfigurer.getIntegerProperty("demo.votes.by.tppoll")) - 1;
                    log.debug(totalVotes+" Votes for this tweetpolls switch id "+tweetPollSwitch.getSwitchId());
                    for (int i = 0; i < totalVotes; i++) {
                        getTweetPollService().tweetPollVote(tweetPollSwitch, EnMeUtils.ipGenerator(), createRandomDate());
                    }
                    //social links.
                    //final List<SocialAccountBean> eeeee = getSecurity().getValidSocialAccounts(SocialProvider.TWITTER, true);
View Full Code Here

     * @param questionsAnswers  {@link QuestionAnswer}.
     * @param tweetPollDomain {@link TweetPoll}.
     * @return {@link TweetPollSwitch}.
     */
    public TweetPollSwitch createTweetPollSwitch(final QuestionAnswer questionsAnswers, final TweetPoll tweetPollDomain){
        final TweetPollSwitch tPollSwitch = new TweetPollSwitch();
        tPollSwitch.setAnswers(questionsAnswers);
        tPollSwitch.setTweetPoll(tweetPollDomain);
        tPollSwitch.setCodeTweet(questionsAnswers.getUniqueAnserHash());
        getTweetPoll().saveOrUpdate(tPollSwitch);
        return tPollSwitch;
    }
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.tweetpoll.TweetPollSwitch

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.