Package org.encuestame.persistence.domain.question

Examples of org.encuestame.persistence.domain.question.Question


     * @throws ServletException
     * @throws IOException
     */
    //@Test
    public void testSearchPollByType() throws ServletException, IOException {
        final Question question = createQuestion(
                "What is your favourite season", "pattern");
        final Poll poll = createPoll(new Date(), question,
                getSpringSecurityLoggedUserAccount(), Boolean.TRUE,
                Boolean.TRUE);
        Assert.assertNotNull(poll);
View Full Code Here


            final QuestionAnswerBean answer = new QuestionAnswerBean();
            answer.setAnswers(answers[row].trim());
            answer.setAnswerHash(RandomStringUtils.randomAscii(5));
            questionBean.getListAnswers().add(answer);
        }
        final Question questionDomain = getSurveyService().createQuestion(
                questionBean);
        return questionDomain;
    }
View Full Code Here

        /* HashTag **/
        final HashTag hashtag1 = createHashTag("romantic");

        /* Question **/
        final Question question = createQuestion("What is your favorite type of movies?", "");

        /* TweetPoll **/
        final TweetPoll myTweetPoll = createPublishedTweetPoll(question, userAcc);

        /* Poll **/
 
View Full Code Here

     * @throws IOException
     * @throws ServletException
     */
    @Test
    public void testRetrieveGenericStats() throws ServletException, IOException{
        final Question question = createQuestion("Black or White?", "");
        final TweetPoll tweetpoll = createPublishedTweetPoll(5L, question, getSpringSecurityLoggedUserAccount());
        // TWEETPOLL
        initService("/api/common/stats/generic.json", MethodJson.GET);
        setParameter("id", tweetpoll.getTweetPollId().toString());
        setParameter("filter", "TWEETPOLL");
View Full Code Here

     * @throws EnMeNoResultsFoundException
     */
    @Before
    public void init() throws EnMeNoResultsFoundException{
      //question
        final Question question = createQuestion("Real Madrid or Barcelona?", getSpringSecurityLoggedUserAccount().getAccount());
        //tweetpoll
        this.tweetPoll = createTweetPollPublicated(Boolean.TRUE, Boolean.TRUE, new Date(), getSpringSecurityLoggedUserAccount(), question);
        final QuestionAnswer questionsAnswers1 = createQuestionAnswer("Yes", question, "hash1");
        final QuestionAnswer questionsAnswers2 = createQuestionAnswer("No", question, "hash2");
         //answers
        this.answer1 = createTweetPollSwitch(questionsAnswers1, tweetPoll);
        this.answer2 = createTweetPollSwitch(questionsAnswers2, tweetPoll);
        //votes
        getTweetPollService().tweetPollVote(answer1, "80.23.43.23", Calendar.getInstance().getTime());
        getTweetPollService().tweetPollVote(answer2, "80.33.13.23", Calendar.getInstance().getTime());
        getTweetPollService().tweetPollVote(answer2, "80.13.13.43", Calendar.getInstance().getTime());
        getTweetPollService().tweetPollVote(answer2, "30.33.13.23", Calendar.getInstance().getTime());
        getTweetPollService().tweetPollVote(answer1, "80.33.13.13", Calendar.getInstance().getTime());
        //poll
        this.poll = createPoll(new Date(), question,  getSpringSecurityLoggedUserAccount(), true, true);
        getPollService().vote(poll, question.getSlugQuestion(), "80.33.13.23", questionsAnswers1.getQuestionAnswerId());
        getPollService().vote(poll, question.getSlugQuestion(), "80.33.13.25", questionsAnswers2.getQuestionAnswerId());
    }
View Full Code Here

        @Before
        public void initMVc() {
            final UserAccount userAccount = createUserAccount("jota", createAccount());
            createFakesTweetPoll(userAccount);
            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

        final UserAccount user = getUserAccount(getUserPrincipalUsername());
        final Poll pollDomain = new Poll();
        try {
            final QuestionBean questionBean = new QuestionBean();
            questionBean.setQuestionName(createPollBean.getQuestionName());
            final Question question = createQuestion(questionBean, user, QuestionPattern.CUSTOMIZABLE_SELECTION);
            if (question == null) {
                throw new EnMeNoResultsFoundException("Question not valid");
            } else if (createPollBean.getAnswers().length  == 0 ) {
                  throw new EnMeNoResultsFoundException("answers are required to create Poll");
            }
View Full Code Here

    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()));
View Full Code Here

            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) {
                        getQuestionDao().delete(questionAnswer);
                    }
                }
View Full Code Here

     */
    public Question createQuestion(
            final QuestionBean questionBean,
            final UserAccount account,
            final QuestionPattern questionPattern) throws EnMeExpcetion{
            final Question question = new Question();
            try{
                question.setQuestion(questionBean.getQuestionName());
                question.setSlugQuestion(RestFullUtil.slugify(questionBean.getQuestionName()));
                question.setAccountQuestion(account.getAccount());
                question.setQidKey(MD5Utils.md5(RandomStringUtils.randomAlphanumeric(500)));
                question.setSharedQuestion(false);
                getQuestionDao().saveOrUpdate(question);
//                for (final QuestionAnswerBean answerBean : questionBean.getListAnswers()) {
//                    this.createQuestionAnswer(answerBean, question);
//                }
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.question.Question

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.