/** * Create vote support for each tweetpoll answer. * * @param questionId * @param tweetPoll */ public void updateTweetPollSwitchSupport( final TweetPoll tweetPoll, final HttpServletRequest httpServletRequest) { 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); } }