Package org.encuestame.persistence.domain.survey

Examples of org.encuestame.persistence.domain.survey.Poll


     * (non-Javadoc)
     * @see org.encuestame.core.service.imp.IPollService#updatePoll(org.encuestame.utils.web.PollBean)
     */
    public Poll updatePoll(final PollBean pollBean)
            throws EnMeNoResultsFoundException {
        final Poll poll = getPollById(pollBean.getId(),
                getUserPrincipalUsername());
        Assert.notNull(poll);
        final Question questionDomain = poll.getQuestion();
        questionDomain
                .setQuestion(pollBean.getQuestionBean().getQuestionName());
        questionDomain.setSlugQuestion(RestFullUtil.slugify(pollBean
                .getQuestionBean().getQuestionName()));
        questionDomain.setCreateDate(DateUtil.getCurrentCalendarDate());
        getQuestionDao().saveOrUpdate(questionDomain);
        Assert.notNull(questionDomain);

        poll.setPollCompleted(pollBean.getCompletedPoll());
        poll.setShowResults(ShowResultsOptions.getShowResults(pollBean.getShowResults()));

        poll.setShowComments(CommentOptions.getCommentOption(pollBean
                .getShowComments()));
        poll.setPublish(pollBean.getPublishPoll());
        poll.setNotifications(pollBean.getCloseNotification());
        poll.getHashTags().addAll(retrieveListOfHashTags(pollBean.getHashTags()));
        return poll;
    }
View Full Code Here


      * @throws EnMeNoResultsFoundException
      */

    public void removePoll(final Long pollId)
            throws EnMeNoResultsFoundException {
        final Poll pollDomain = this.getPollbyUserAndId(pollId, getUserAccount(getUserPrincipalUsername()));

        final List<PollResult> pollResults;
        final List<QuestionAnswer> qAnswer;
        Question question = new Question();
        if (pollDomain != null) {
            // Retrieve Poll results, answers and question.
            pollResults = getPollDao().retrievePollResults(pollDomain);
            if (pollResults.size() > 0) {
                // Delete poll results.
                for (PollResult pollResult : pollResults) {
                    getPollDao().delete(pollResult);
                }
            }
            question = pollDomain.getQuestion();
            if (question != null) {
                // Retrieve answers by Question id.
                qAnswer = this.getQuestionAnswersbyQuestionId(question.getQid());
                if (qAnswer.size() > 0) {
                    for (QuestionAnswer questionAnswer : qAnswer) {
View Full Code Here

     * (non-Javadoc)
     * @see org.encuestame.core.service.imp.IPollService#updateQuestionPoll(java.lang.Long, org.encuestame.persistence.domain.question.Question)
     */
    public PollBean updateQuestionPoll(final Long pollId, final Question question)
            throws EnMeExpcetion {
          final Poll poll = this.getPollById(pollId, getUserAccount(getUserPrincipalUsername()));
          if (poll == null) {
              throw new EnMeNoResultsFoundException("poll not found");
          }
          else{
              poll.setQuestion(question) ;
              getPollDao().saveOrUpdate(poll);
          }
           return ConvertDomainBean.convertPollDomainToBean(poll);
    }
View Full Code Here

    public void addPollToFolder(final Long folderId, final Long pollId)
                                throws EnMeNoResultsFoundException{
        final PollFolder pfolder = this.getPollFolderByFolderIdandUser(folderId, getUserAccount(getUserPrincipalUsername()));
        if (pfolder != null) {
            final Poll poll = getPollDao().getPollById(pollId, getUserAccount(getUserPrincipalUsername()));
            if (poll == null){
                throw new EnMeNoResultsFoundException("TweetPoll not found");
             }
            poll.setPollFolder(pfolder);
            getPollDao().saveOrUpdate(poll);
        } else {
            throw new EnMeNoResultsFoundException("TweetPoll folder not found");
    }
}
View Full Code Here

     * @param account
     * @return
     * @throws EnMeNoResultsFoundException
     */
     public Poll getPollById(final Long pollId, final UserAccount account) throws EnMeNoResultsFoundException{
        final Poll poll = getPollDao().getPollById(pollId, account);
        if (poll == null) {
            log.error("poll invalid with this id "+pollId+ " and username:{"+account);
            throw new EnMePollNotFoundException("poll invalid with this id "+pollId+ " and username:{"+account);
        }
        return poll;
View Full Code Here

     * .Long, java.lang.Long,
     * org.encuestame.persistence.domain.security.UserAccount)
     */
    public Poll getPollByAnswerId(final Long pollId, final Long answerId,
            final UserAccount account) throws EnMeNoResultsFoundException {
        final Poll poll = this.getPollById(pollId);
        QuestionAnswer qA = getQuestionDao().retrieveAnswersByQuestionId(
                poll.getQuestion(), answerId);
        if (qA == null) {
            throw new EnMeNoResultsFoundException("Answer not found");
        }
        return poll;
    }
View Full Code Here

     * @throws EnMeNoResultsFoundException
     */
    public Poll getPollById(final Long pollId, final String account) throws EnMeNoResultsFoundException {
         log.debug("getPollById pollId: "+pollId);
         log.debug("getPollById account: "+account);
         final Poll poll = this.getPollById(pollId, getUserAccount(account));
         if (poll == null) {
             log.error("poll invalid with this id "+pollId+ " and username:{"+account);
             throw new EnMePollNotFoundException("poll invalid with this id "+pollId+ " and username:{"+account);
         }
         return poll;
View Full Code Here

    /*
     * (non-Javadoc)
     * @see org.encuestame.core.service.imp.IPollService#getPollSlugById(java.lang.Long, java.lang.String)
     */
    public Poll getPollSlugById(final Long pollId, final String slug) throws EnMeNoResultsFoundException{
        final Poll poll = this.getPollDao().getPollById(pollId, slug, true);
        if (poll == null) {
            log.error("poll invalid with this id "+pollId+ " and slug:{"+slug);
            throw new EnMePollNotFoundException("poll invalid with this id "+pollId+ " and slug:{"+slug);
        }
        return poll;
View Full Code Here

     * (non-Javadoc)
     * @see org.encuestame.core.service.imp.IPollService#changeStatusPoll(java.lang.Long, java.lang.String)
     */
    public void changeStatusPoll(final Long pollId, final String username)
            throws EnMeNoResultsFoundException, EnmeFailOperation {
        final Poll poll = getPollById(pollId, username);
        if (poll != null) {
            poll.setCloseAfterDate(!(poll.getCloseAfterDate() == null ? false
                    : poll.getCloseAfterDate()));
            getPollDao().saveOrUpdate(poll);
        } else {
            throw new EnmeFailOperation("Fail Change Status Operation");
        }
    }
View Full Code Here

     * (non-Javadoc)
     * @see org.encuestame.core.service.imp.IPollService#closeAfterQuotaPoll(java.lang.Long, java.lang.String)
     */
    public void closeAfterQuotaPoll(final Long pollId, final String username)
            throws EnMeNoResultsFoundException, EnmeFailOperation {
        final Poll poll = getPollById(pollId, username);
        if (poll != null) {
            poll.setCloseAfterquota(!(poll.getCloseAfterquota() == null ? false
                    : poll.getCloseAfterquota()));
            getPollDao().saveOrUpdate(poll);
        } else {
            throw new EnmeFailOperation("Fail Change Status Operation");
        }
    }
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.survey.Poll

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.