Package org.encuestame.persistence.domain.survey

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


     */
    @Test
    public void testGetFrontendItems() throws ServletException, IOException{
        final Question question = createQuestion("abcdefg", "pattern");
        final TweetPoll tp = createTweetPollPublicated(Boolean.TRUE, Boolean.TRUE, new Date(), getSpringSecurityLoggedUserAccount(), question);
        final Poll poll = createPoll(new Date(), question, getSpringSecurityLoggedUserAccount(), Boolean.TRUE, Boolean.TRUE);
        tp.setRelevance(50L);
        poll.setRelevance(30L);
        getTweetPoll().saveOrUpdate(tp);
        getPollDao().saveOrUpdate(poll);
        initService("/api/common/frontend/stream.json", MethodJson.GET);
        setParameter("period", "all");
        setParameter("maxResults", "10");
View Full Code Here


                jsonResponse.put("links", getTweetPollService()
                        .getTweetPollLinks(tweetPoll, null, null, TypeSearchResult.getTypeSearchResult(type)));

            // by poll
            } else if (TypeSearchResult.POLL.equals(searchResult) && !id.isEmpty()) {
                final Poll poll = getPollService().getPollById(Long.valueOf(id));
                jsonResponse.put(
                        "links",
                        getTweetPollService().getTweetPollLinks(null, poll,
                                null,
                                TypeSearchResult.getTypeSearchResult(type)));
View Full Code Here

             @RequestParam(value = "id", required = true) final Long pollId,
            HttpServletRequest request, HttpServletResponse response)
            throws JsonGenerationException, JsonMappingException, IOException {
        final Map<String, Object> jsonResponse = new HashMap<String, Object>();
        try{
             final Poll poll = getPollService().getPollById(pollId, getUserPrincipalUsername());
             final List<SocialAccountBean> accountBeans = new ArrayList<SocialAccountBean>();
             //convert accounts id to real social accounts objects.
             for (int row = 0; row < twitterAccountsId.length; row++) {
                 final SocialAccountBean socialAccount = new SocialAccountBean();
                 socialAccount.setAccountId(twitterAccountsId[row]);
                 accountBeans.add(socialAccount);
             }
             //log.trace("Accounts:{" + accountBeans.size());
             String tweetText = poll.getQuestion().getQuestion();
             final String url = WidgetUtil.createShortUrl(ShortUrlProvider.TINYURL, this.buildPollURL(poll, request));
             if (tweetText.length() > this.POLL_PUBLISH_STRING_LIMIT) {
                 tweetText = tweetText.substring(0, this.POLL_PUBLISH_STRING_LIMIT) + " " + url;
             } else {
                 tweetText = tweetText + " " + url;
View Full Code Here

            model.put("domain_config", WidgetUtil.getDomain(request, true));
            if (TypeSearchResult.TWEETPOLL.equals(typeItem)) {
                final TweetPoll tp = getTweetPollService().getTweetPollById(itemId);
                model.put("url", EnMeUtils.createTweetPollUrlAccess(domain, tp));
            } else if (TypeSearchResult.POLL.equals(typeItem)) {
                final Poll poll = getPollService().getPollById(itemId);
                model.put("url", EnMeUtils.createUrlPollAccess(domain, poll));
            } else if (TypeSearchResult.TWEETPOLLRESULT.equals(typeItem)) {
                final TweetPoll tp = getTweetPollService().getTweetPollById(itemId);
                model.put("url", EnMeUtils.createTweetPollUrlAccess(domain, tp));
            } else if (TypeSearchResult.POLLRESULT.equals(typeItem)) {
                final Poll poll = getPollService().getPollById(itemId);
                model.put("url", EnMeUtils.createUrlPollAccess(domain, poll));
            } else if (TypeSearchResult.HASHTAG.equals(typeItem)) {
                //FUTURE:
                model.put("url", "");
            } else if (TypeSearchResult.PROFILE.equals(typeItem)) {
View Full Code Here

                text = VelocityEngineUtils.mergeTemplateIntoString(
                        velocityEngine, HTML_TEMPLATES + "/tweetpoll_votes.vm", "utf-8", model);
                embebedBody.setAditionalInfo(tpollDetail.getResults());
            } else if (TypeSearchResult.POLL.equals(typeItem)) {
                // generate poll body
                final Poll poll = getPollService().getPollById(pollId);
                final PollDetailBean detailBean = getPollService().getPollDetailInfo(poll.getPollId());
                model.put("owner_picture", domain + "/picture/profile/" + poll.getEditorOwner().getUsername() + "/thumbnail");
                model.put("editorOwner", poll.getEditorOwner());
                model.put("title", poll.getQuestion().getQuestion());
                model.put("date_published", EnMeUtils.formatDate(poll.getCreateDate(), "HH:mm - d MMMM yyyy"));
                model.put("poll", poll);
                model.put("action", WidgetUtil.getDomain(request) + "/poll/vote/post");
                model.put("detailBean", detailBean);
                model.put("vote_title", "Vote");
                text = VelocityEngineUtils.mergeTemplateIntoString(
                        velocityEngine, HTML_TEMPLATES + "/poll_form.vm", "utf-8", model);
            else if (TypeSearchResult.POLLRESULT.equals(typeItem)) {
                // generate poll body
                final Poll poll = getPollService().getPollById(pollId);
                final PollDetailBean detailBean = getPollService().getPollDetailInfo(poll.getPollId());
                model.put("owner_picture", domain + "/picture/profile/" + poll.getEditorOwner().getUsername() + "/thumbnail");
                model.put("editorOwner", poll.getEditorOwner());
                model.put("question", poll.getQuestion());
                model.put("url", EnMeUtils.createUrlPollAccess(domain, poll));
                model.put("answersList", detailBean.getResults());
                model.put("date_published", EnMeUtils.formatDate(poll.getCreateDate(), "HH:mm - d MMMM yyyy"));
                text = VelocityEngineUtils.mergeTemplateIntoString(
                        velocityEngine, HTML_TEMPLATES + "/tweetpoll_votes.vm", "utf-8", model);
                embebedBody.setAditionalInfo(detailBean.getResults());
            } else if (TypeSearchResult.HASHTAG.equals(typeItem)) {
                // generate hashtag body
View Full Code Here

        //this.getTweetPollVotesStore(pollId, response);
        try {
            final Map<String, Object> jsonResult = new HashMap<String, Object>();
            //results by tweetpoll id.
            log.debug("poll =============================== ");
            final Poll poll = getPollService().getPollById(pollId, username);
            log.debug("poll ================= " + poll);
            final List<PollBeanResult> results = getPollService().getResultVotes(poll);
            log.debug("poll PollBeanResult results " + results.size());
            jsonResult.put("votesResult", results);
            log.debug("Poll results " + results.size());
View Full Code Here

    //@Test
    public void retrieveItemsbyDate() throws ServletException, IOException{
        // Search poll published today.
        final Date todayDate = new Date();
        final Question question = createQuestion("What is your favourite movie", "pattern");
        final Poll poll = createPoll(todayDate, question,
                          getSpringSecurityLoggedUserAccount(), Boolean.TRUE,
                          Boolean.TRUE);
        Assert.assertNotNull(poll);
        initService("/api/survey/poll/search.json", MethodJson.GET);
        setParameter("typeSearch", "BYOWNER");
View Full Code Here

     */
    private void changePropertyPoll(final String property) throws ServletException, IOException{
         // Search poll published today.
        final Date todayDate = new Date();
        final Question question = createQuestion("What is your favourite movie", "pattern");
        final Poll poll = createPoll(todayDate, question,
                          getSpringSecurityLoggedUserAccount(), Boolean.TRUE,
                          Boolean.TRUE);
        Assert.assertNotNull(poll);
        //change-open-status
        initService("/api/survey/poll/"+property+"-poll.json", MethodJson.POST);
        setParameter("pollId", poll.getPollId().toString());
        final JSONObject response = callJsonService();
        final JSONObject success = getSucess(response);
        final Long polls = (Long) success.get("r");
        Assert.assertEquals("Should be equals ", polls.toString(), "0");
    }
View Full Code Here

    @Test
    public void changeWrongPropertyPoll() throws ServletException, IOException{
        // Search poll published today.
       final Date todayDate = new Date();
       final Question question = createQuestion("What is your favourite movie", "pattern");
       final Poll poll = createPoll(todayDate, question,
                         getSpringSecurityLoggedUserAccount(), Boolean.TRUE,
                         Boolean.TRUE);
       Assert.assertNotNull(poll);
       //change-open-status
       initService("/api/survey/poll/xxx-poll.json", MethodJson.POST);
       setParameter("pollId", poll.getPollId().toString());
       final JSONObject response = callJsonService();
       final JSONObject error = getErrors(response);
       //System.out.println(error);
       final String message = (String) error.get("message");
       Assert.assertEquals("Should be equals ",message, "type not valid");
View Full Code Here

     */
    //@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);
        final PollFolder pfolder = createPollFolder("My Polls folder",
                getSpringSecurityLoggedUserAccount());
        poll.setPollFolder(pfolder);
        Assert.assertNotNull(pfolder);

        // Search Poll by folder.
        Assert.assertNotNull(this.searchPollByFolder(poll.getPollFolder()
                .getId()));
        Assert.assertEquals("Should be equals ",
                this.searchPollByFolder(poll.getPollFolder().getId()).size(), 1);

        // Search Poll by keyword.
        flushIndexes();
        Assert.assertNotNull(this.searchPollByKeyword("What", this.MAX_RESULTS, this.START_ON));
        Assert.assertEquals("Should be equals ",
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.