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()