Examples of TweetPoll


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

     * Save Tweet Id.
     * @param tweetPollBean {@link TweetPollBean}
     * @throws EnMeExpcetion exception
     */
    public void saveTweetId(final TweetPollBean tweetPollBean) throws EnMeExpcetion{
        final TweetPoll tweetPoll = getTweetPollDao().getTweetPollById(tweetPollBean.getId());
        if(tweetPoll != null){
            //tweetPoll.setTweetId(tweetPollBean.getTweetId());
            //tweetPoll.setPublicationDateTweet(tweetPollBean.getPublicationDateTweet());
            tweetPoll.setPublishTweetPoll(Boolean.TRUE);
            getTweetPollDao().saveOrUpdate(tweetPoll);
        }else{
            throw new EnMeExpcetion("tweet poll not found");
        }
    }
View Full Code Here

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

     * @throws EnMeExpcetion exception
     */
    public String generateTweetPollText(final TweetPollBean tweetPoll, final String url) throws EnMeExpcetion{
        String tweetQuestionText = "";
        try{
            final TweetPoll tweetPollDomain = getTweetPollDao().getTweetPollById(tweetPoll.getId());
            tweetQuestionText = tweetPollDomain.getQuestion().getQuestion();
            final List<QuestionAnswer> answers = getQuestionDao().getAnswersByQuestionId(tweetPollDomain.getQuestion().getQid());
            if (answers.size() == 2) {
                for (final QuestionAnswer questionsAnswers : answers) {
                    tweetQuestionText += " "+questionsAnswers.getAnswer()+" "+buildUrlAnswer(questionsAnswers, url);
                }
            }
View Full Code Here

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

     * @param tweetPollBean {@link TweetPollBean}
     * @param question {@link Question}.
     * @return
     */
    private TweetPoll newTweetPoll(final TweetPollBean tweetPollBean, Question question){
        final TweetPoll tweetPollDomain = new TweetPoll();
        log.debug(tweetPollBean.toString());
        tweetPollDomain.setQuestion(question);
        tweetPollDomain.setCloseNotification(tweetPollBean.getCloseNotification());
        tweetPollDomain.setCompleted(Boolean.FALSE);
        tweetPollDomain.setCaptcha(tweetPollBean.getCaptcha());
        tweetPollDomain.setAllowLiveResults(tweetPollBean.getAllowLiveResults());
        tweetPollDomain.setLimitVotes(tweetPollBean.getLimitVotes());
        tweetPollDomain.setLimitVotesEnabled((tweetPollBean.getLimitVotesEnabled()));
        UserAccount acc = null;
        try {
            acc = getUserAccount(getUserPrincipalUsername());
        } catch (EnMeNoResultsFoundException e) {
           log.error("User not found");
        }
        tweetPollDomain.setTweetOwner(acc.getAccount());
        tweetPollDomain.setEditorOwner(getUserAccountonSecurityContext());
        tweetPollDomain.setResultNotification(tweetPollBean.getResultNotification());
        tweetPollDomain.setPublishTweetPoll(Boolean.FALSE);
        tweetPollDomain.setRelevance(EnMeUtils.RATE_DEFAULT);
        tweetPollDomain.setHits(EnMeUtils.VOTE_DEFAULT);
        tweetPollDomain.setLikeVote(EnMeUtils.LIKE_DEFAULT);
        tweetPollDomain.setNumbervotes(EnMeUtils.VOTE_DEFAULT);
        tweetPollDomain.setDislikeVote(EnMeUtils.DISLIKE_DEFAULT);
        tweetPollDomain.setCreateDate(Calendar.getInstance().getTime());
        tweetPollDomain.setScheduleTweetPoll(tweetPollBean.getSchedule());
        tweetPollDomain.setScheduleDate(tweetPollBean.getScheduleDate());
        tweetPollDomain.setUpdatedDate(Calendar.getInstance().getTime());
        tweetPollDomain.setDateLimit((tweetPollBean.getLimitVotesDate() == null ? true : tweetPollBean.getLimitVotesDate()));
        final Calendar limit = Calendar.getInstance();
        limit.add(Calendar.DAY_OF_YEAR, 7); //TODO: define when is the default limit for each tweetpoll.
        tweetPollDomain.setDateLimited(limit.getTime());
        this.getTweetPollDao().saveOrUpdate(tweetPollDomain);
        return tweetPollDomain;
    }
View Full Code Here

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

            final Question question = createTweetPollQuestion(questionName, user);
            log.debug("question found:{" + question);
            if (question == null) {
                throw new EnMeNoResultsFoundException("question not found");
            } else {
                final TweetPoll tweetPollDomain = newTweetPoll(tweetPollBean, question);
                //save Hash tags for this tweetPoll.
                log.debug("HashTag size:{"+tweetPollBean.getHashTags().size());
                //update TweetPoll.
                if (tweetPollBean.getHashTags().size() > 0) {
                    tweetPollDomain.getHashTags().addAll(retrieveListOfHashTags(tweetPollBean.getHashTags()));
                    log.debug("Update Hash Tag");
                    getTweetPollDao().saveOrUpdate(tweetPollDomain);
                }
                //update tweetpoll switch support
                this.updateTweetPollSwitchSupport(tweetPollDomain, request);
View Full Code Here

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

     * (non-Javadoc)
     * @see org.encuestame.business.service.imp.ITweetPollService#updateTweetPoll(org.encuestame.persistence.domain.tweetpoll.TweetPoll, java.lang.String[], java.util.List)
     */
    public TweetPoll updateTweetPoll(final TweetPollBean tweetPollBean) throws EnMeNoResultsFoundException {
        log.debug("Updated tweetpoll with id :"+tweetPollBean.getId());
        final TweetPoll tweetPoll = getTweetPoll(tweetPollBean.getId(), getUserPrincipalUsername());
        Assert.notNull(tweetPoll);
        if (tweetPoll == null) {
            throw new EnMeTweetPollNotFoundException();
        }
        //TODO: disabled to create hashtag directly from own service.
        //final List<HashTag> newList = retrieveListOfHashTags(tweetPollBean.getHashTags());
        //log.debug("new list of hashtags size: "+newList.size());

        //update question name.
        final Question questionDomain = tweetPoll.getQuestion();
        Assert.notNull(questionDomain);
        questionDomain.setQuestion(tweetPollBean.getQuestionBean().getQuestionName());
        questionDomain.setSlugQuestion(RestFullUtil.slugify(tweetPollBean.getQuestionBean().getQuestionName()));
        questionDomain.setCreateDate(Calendar.getInstance().getTime());
        getQuestionDao().saveOrUpdate(questionDomain);

        //update hashtags.
        //TODO: disabled to create hashtag directly from own service.
        //tweetPoll.getHashTags().addAll(retrieveListOfHashTags(tweetPollBean.getHashTags())); //TODO check if this action remove old hashtags.

        //update options.
        tweetPoll.setAllowLiveResults(tweetPollBean.getAllowLiveResults());
        tweetPoll.setAllowRepatedVotes(tweetPollBean.getAllowRepeatedVotes());
        tweetPoll.setCaptcha(tweetPollBean.getCaptcha());
        tweetPoll.setCloseNotification(tweetPollBean.getCloseNotification());
        tweetPoll.setLimitVotes(tweetPollBean.getLimitVotes());
        tweetPoll.setLimitVotesEnabled(tweetPollBean.getLimitVotesEnabled());
        tweetPoll.setMaxRepeatedVotes(tweetPollBean.getMaxRepeatedVotes());
        tweetPoll.setResultNotification(tweetPollBean.getResultNotification());
        tweetPoll.setResumeLiveResults(tweetPollBean.getResumeLiveResults());
        tweetPoll.setScheduleDate(tweetPollBean.getScheduleDate());
        tweetPoll.setResumeTweetPollDashBoard(tweetPollBean.getResumeTweetPollDashBoard());
        tweetPoll.setUpdatedDate(Calendar.getInstance().getTime());
        getTweetPollDao().saveOrUpdate(tweetPoll);
        log.debug("removing answers for tweetpoll id: "+tweetPoll.getTweetPollId());

        /*
         * answer auto-save handler.
         */
        //no make sense remove all questions. disabled.
View Full Code Here

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

    */
    public List<Schedule> createTweetPollScheduled(
            final TweetPollScheduledBean bean,
            final TypeSearchResult searchResult) throws EnMeExpcetion, EnMeNoResultsFoundException {
        final List<Schedule> list = new ArrayList<Schedule>();
        final TweetPoll tp = this.getTweetPollById(bean.getId());
        if (tp.getScheduleTweetPoll() != null || !tp.getScheduleTweetPoll()) {
            tp.setScheduleTweetPoll(Boolean.TRUE);
            getTweetPollDao().saveOrUpdate(tp);
        }
        final String tweetText = generateTweetPollContent(tp);
        for (SocialAccountBean socialBean : bean.getSocialAccounts()) {
            final SocialAccount soc = getAccountDao().getSocialAccountById(socialBean.getAccountId());
            final Schedule schedule = new Schedule();
            schedule.setScheduleDate(tp.getScheduleDate());
            schedule.setTpoll(tp);
            schedule.setTypeSearch(searchResult);
            schedule.setTweetText(tweetText);
            schedule.setSocialAccount(soc);
            schedule.setStatus(Status.FAILED);
View Full Code Here

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

    /*
     * (non-Javadoc)
     * @see org.encuestame.core.service.imp.ITweetPollService#getTweetPollPublishedById(java.lang.Long)
     */
    public TweetPoll getTweetPollPublishedById(final Long tweetPollId) throws EnMeNoResultsFoundException{
        final TweetPoll tweetPoll = getTweetPollDao().getPublicTweetPollById(tweetPollId);
        if (tweetPoll == null) {
            throw new EnMeNoResultsFoundException("tweetpoll [" + tweetPollId
                    + "] is not published");
        }
        return tweetPoll;
View Full Code Here

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

   /*
    * (non-Javadoc)
    * @see org.encuestame.core.service.imp.ITweetPollService#getTweetPollByIdSlugName(java.lang.Long, java.lang.String)
    */
    public TweetPoll getTweetPollByIdSlugName(final Long tweetPollId, final String slug) throws EnMeNoResultsFoundException {
        TweetPoll tweetPoll;
        try {
                tweetPoll = getTweetPollDao().getTweetPollByIdandSlugName(tweetPollId, slug);
            if (tweetPoll == null) {
                log.error("tweet poll invalid with this id "+tweetPollId);
                throw new EnMeTweetPollNotFoundException("tweet poll invalid with this id "+tweetPollId);
View Full Code Here

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

    public List<TweetPollResultsBean> getResultsByTweetPollId(final Long tweetPollId) throws EnMeNoResultsFoundException{
        if (log.isDebugEnabled()) {
            log.debug("getResultsByTweetPollId "+tweetPollId);
        }
        final List<TweetPollResultsBean> pollResults = new ArrayList<TweetPollResultsBean>();
        final TweetPoll tweetPoll = getTweetPollById(tweetPollId, null);
        if (log.isDebugEnabled()) {
           // log.debug("Answers Size "+tweetPoll.getQuestion().getQuestionsAnswers().size());
            log.debug("tweetPoll "+tweetPoll);
        }
        for (QuestionAnswer questionsAnswer : getQuestionDao().getAnswersByQuestionId(tweetPoll.getQuestion().getQid())) {
              if (log.isDebugEnabled()) {
                  log.debug("Question Name " + tweetPoll.getQuestion().getQuestion());
              }
              pollResults.add(this.getVotesByTweetPollAnswerId(tweetPollId, questionsAnswer));
        }
        this.calculatePercents(pollResults);
        return pollResults;
View Full Code Here

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

     */
    public void addTweetPollToFolder(final Long folderId, final String username, final Long tweetPollId)
           throws EnMeNoResultsFoundException {
        final TweetPollFolder tpfolder = this.getTweetPollFolderByFolderId(folderId);
         if (tpfolder != null) {
             final TweetPoll tpoll = this.getTweetPollById(tweetPollId);
             tpoll.setTweetPollFolder(tpfolder);
             getTweetPollDao().saveOrUpdate(tpoll);
         } else {
             throw new EnMeNoResultsFoundException("tweetPoll folder not found");
         }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.