Package org.encuestame.utils.web

Examples of org.encuestame.utils.web.HashTagBean


                final List<HomeBean> lastPublications = getFrontService()
                        .searchLastPublicationsbyHashTag(tag, null, this.INIT_RESULTS,
                                LIMIT_HASHTAG, "hashtag", request);
                log.debug("tagController tweetPollbyTags =>"+lastPublications.size());
                log.debug("tagController tag =>"+tag);
                final HashTagBean bean =  ConvertDomainBean.convertHashTagDomain(tag);
                model.addAttribute("tagName", bean);
                model.addAttribute("tweetPolls", lastPublications);
            }
        } catch (Exception e) {
            e.printStackTrace();
View Full Code Here


    /**
     * Test {@link HashTagBean}.
     */
    @Test
    public void testUnitHashTag(){
        final HashTagBean hashTag = new HashTagBean();
        hashTag.setHashTagName("nicaragua");
        hashTag.setId(1L);
        hashTag.setHits(100L);
        hashTag.setSize(15);
        assertNotNull(hashTag.getHashTagName());
        assertNotNull(hashTag.getId());
        assertNotNull(hashTag.getHits());
        assertNotNull(hashTag.getSize());
    }
View Full Code Here

        QuestionBean qBean = createUnitQuestionBean(1L, "First question", "1",
                qAnswerBean);
        assertNotNull(qBean);

        // HashTagBeans
        HashTagBean tagBean1 = createUnitHashTag("Education", 1L);
        HashTagBean tagBean2 = createUnitHashTag("Health", 2L);
        HashTagBean tagBean3 = createUnitHashTag("Jobs", 3L);

        // Add HashtagBean
        final List<HashTagBean> hashTags = new ArrayList<HashTagBean>();
        hashTags.add(tagBean1);
        hashTags.add(tagBean2);
View Full Code Here

    public List<HashTagBean> fillListOfHashTagsBean(String[] hashtags) {
        final List<HashTagBean> hashtagsList = new ArrayList<HashTagBean>();
        hashtags = hashtags == null ? new String[0] : hashtags;
        log.debug("HashTag size:{" + hashtags.length);
        for (int row = 0; row < hashtags.length; row++) {
            final HashTagBean hashTag = new HashTagBean();
            final String hashtagE = hashtags[row];
            if (hashtagE != null && !hashtagE.isEmpty()) {
                log.debug("HashTag:{" + hashTag);
                hashTag.setHashTagName(hashtags[row].toLowerCase().trim());
                hashtagsList.add(hashTag);
            } else {
                log.warn("Trying to save empty or null hashtag?");
            }
        }
View Full Code Here

      * @return unitHashTag
      */
     public HashTagBean createUnitHashTag(
             final String hashTagName,
             final Long hashId){
         final HashTagBean unitHashTag = new HashTagBean();
         unitHashTag.setId(hashId);
         unitHashTag.setHashTagName(hashTagName);
        return unitHashTag;
     }
View Full Code Here

                if ("remove".equals(action)) {
                    setSuccesResponse();
                    getTweetPollService().removeHashtagFromTweetPoll(null, null);
                } else if ("add".equals(action)) {
                     final Map<String, Object> jsonResponse = new HashMap<String, Object>();
                    final HashTagBean bean = ConvertDomainBean
                            .convertHashTagDomain(getTweetPollService()
                                    .addHashtagToTweetPoll(
                                            getTweetPollService()
                                                    .getTweetPollById(id),
                                            new HashTagBean(hashtag)));
                    log.debug("New TweetPoll HT Bean: "+bean);
                    if (bean.getHashTagName().isEmpty()) {
                        setFailedResponse();
                    } else {
                        jsonResponse.put("hashtag", bean);
                        setItemResponse(jsonResponse);
                    }
                }
            } else if (typeItem.equals(TypeSearchResult.POLL)) {
                if ("remove".equals(action)) {
                    log.debug("Remove option has been disabled");
                    setSuccesResponse();
                } else if ("add".equals(action)) {
                    final Map<String, Object> jsonResponse = new HashMap<String, Object>();
                    final HashTagBean bean = ConvertDomainBean
                            .convertHashTagDomain(getPollService()
                                    .addHashTagToPoll(
                                            getPollService().getPollById(id),
                                            new HashTagBean(hashtag)));
                    log.debug("New TweetPoll HT Bean: " + bean);
                    if (bean.getHashTagName().isEmpty()) {
                        setFailedResponse();
                    } else {
                        jsonResponse.put("hashtag", bean);
                        setItemResponse(jsonResponse);
                    }
View Full Code Here

    private List<HashTagBean> getHashtags() throws IOException {
        CSVReader csv = readCSVFile("hashtag.csv");
        String[] nextLine;
        final List<HashTagBean> list = new ArrayList<HashTagBean>();
        while ((nextLine = csv.readNext()) != null) {
            final HashTagBean bean = new HashTagBean();
            bean.setHashTagName(nextLine[0]);
            list.add(bean);
        }
        return list;
    }
View Full Code Here

                log.debug("Add hashtag to tweetpoll ");
                for (int i = 0; i < EnMePlaceHolderConfigurer
                        .getIntegerProperty("demo.hashtab.by.item"); i++) {
                    double htx = getRandomNumberRange(0, totalhashtagss) - 1;
                    final HashTagBean b = hashtags.get(Double.valueOf(htx).intValue());
                        log.debug("Adding Hashtag "+b.getHashTagName()+ " to tp "+tweetPollDomain.getTweetPollId());
                        final HashTag h = getTweetPollService().addHashtagToTweetPoll(tweetPollDomain, b);
                        h.setUpdatedDate(createRandomDate());
                        getTweetPollDao().saveOrUpdate(h);
                }

                List<QuestionAnswerBean> listOfAnswers = question.getListAnswers();
                log.debug("Ansswers in this questions  "+listOfAnswers.size());

                for (QuestionAnswerBean questionAnswerBean : listOfAnswers) {
                    final QuestionAnswerBean answerBean = new QuestionAnswerBean(questionAnswerBean.getAnswers());
                    answerBean.setShortUrlType(ShortUrlProvider.NONE);
                    //create tweetpoll swithch
                    final TweetPollSwitch tweetPollSwitch = getTweetPollService().createTweetPollQuestionAnswer(answerBean, tweetPollDomain, null);
                    double totalVotes = getRandomNumberRange(0, EnMePlaceHolderConfigurer.getIntegerProperty("demo.votes.by.tppoll")) - 1;
                    log.debug(totalVotes+" Votes for this tweetpolls switch id "+tweetPollSwitch.getSwitchId());
                    for (int i = 0; i < totalVotes; i++) {
                        getTweetPollService().tweetPollVote(tweetPollSwitch, EnMeUtils.ipGenerator(), createRandomDate());
                    }
                    //social links.
                    //final List<SocialAccountBean> eeeee = getSecurity().getValidSocialAccounts(SocialProvider.TWITTER, true);
                   final List<SocialAccount>eeee =  getAccountDao().getSocialVerifiedAccountByUserAccount(u.getAccount(), SocialProvider.TWITTER);
                   for (SocialAccount socialAccountBean : eeee) {
                       for (int i = 0; i < EnMePlaceHolderConfigurer
                                .getIntegerProperty("demo.max.tweetpoll.social.network.published"); i++) {
                        String tweetId = RandomStringUtils.random(6);
                        final TweetPollSavedPublishedStatus publishedStatus = new TweetPollSavedPublishedStatus();
                        //social provider.
                        publishedStatus.setApiType(SocialProvider.TWITTER);
                        publishedStatus.setSocialAccount(socialAccountBean);
                        //adding tweetpoll
                        publishedStatus.setTweetPoll(tweetPollDomain);
                        //store original tweet id.
                         publishedStatus.setTweetId(tweetId);
                         //store original publication date.
                         publishedStatus.setPublicationDateTweet(createRandomDate());
                         //success publish state..
                         publishedStatus.setStatus(Status.SUCCESS);
                         //store original tweet content.
                         publishedStatus.setTweetContent(question.getQuestionName());
                         getTweetPollDao().saveOrUpdate(publishedStatus);
                         //create notification
                         //createNotification(NotificationEnum.TWEETPOLL_PUBLISHED, "tweet published", socialAccount.getAccount());
                         createNotification(NotificationEnum.SOCIAL_MESSAGE_PUBLISHED, question.getQuestionName(), SocialUtils.getSocialTweetPublishedUrl(
                                 tweetId, u.getUsername(), socialAccountBean.getAccounType()), Boolean.TRUE);
                       }
                    }
                }

            } catch (EnMeExpcetion e) {
                e.printStackTrace();
            }
        }

        /*
         * POLL
         */
        log.trace("Creating Polls...");
        for (QuestionBean question : listQuestions) {
            try {
                List<String> s = new ArrayList<String>();
                for (QuestionAnswerBean commentBean : question.getListAnswers()) {
                    s.add(commentBean.getAnswers());
                }
                //answer array
                String[] arrayAnswers = new String[s.size()];
                String[] arrayHashtag = new String[EnMePlaceHolderConfigurer.getIntegerProperty("demo.hashtab.by.item")];
                arrayAnswers = s.toArray(arrayAnswers);
                log.trace("Qu Answers x ."+arrayAnswers);
                //hashtag array
                for (int i = 0; i < EnMePlaceHolderConfigurer.getIntegerProperty("demo.hashtab.by.item"); i++) {
                    double htx = getRandomNumberRange(0, totalhashtagss) - 1;
                    final HashTagBean b = hashtags.get(Double.valueOf(htx).intValue());
                    arrayHashtag[i] = b.getHashTagName();
                }
                //List<HashTagBean> hashtagList = Arrays.asList(arrayHashtag);
                final CreatePollBean createPollBean = new CreatePollBean();
                //question.getQuestionName(),arrayAnswers, "ALL", "MODERATE", true, hashtagList);
                //poll.setCreateDate(createRandomDate()
View Full Code Here

   * @throws EnMeNoResultsFoundException
   */
  @Test
  public void testAddHashtagToTweetPoll() throws EnMeNoResultsFoundException {
    final HashTag ht = createHashTag("xx");
    final HashTagBean tagBean = this.createHashTagBean("Hashtag bean", 20L,
        ht.getSize().intValue());
    final Question question1 = createQuestion("Why the sea is salad?",
        "html");
    final TweetPoll tp = createTweetPollPublicated(true, true, new Date(),
        this.userAccount, question1);
    final HashTag ht2 = getTweetPollService().addHashtagToTweetPoll(tp,
        tagBean);
    assertEquals("Should be equals", tagBean.getHashTagName(),
        ht2.getHashTag());
  }
View Full Code Here

   * @param size
   * @return
   */
  private HashTagBean createHashTagBean(final String tagName,
      final Long hits, final Integer size) {
    final HashTagBean hashTagBean = new HashTagBean();
    hashTagBean.setHashTagName(tagName);
    hashTagBean.setHits(hits);
    hashTagBean.setSize(size);
    return hashTagBean;
  }
View Full Code Here

TOP

Related Classes of org.encuestame.utils.web.HashTagBean

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.