// }
// no scheduled tp in the demo data
tweetPollBean.setSchedule(Boolean.FALSE);
try {
//final Question qm = createQuestion(question, u, QuestionPattern.CUSTOMIZABLE_SELECTION);
final TweetPoll tweetPollDomain = getTweetPollService().createTweetPoll(tweetPollBean, question.getQuestionName(), u, null);
//force to be published
tweetPollDomain.setPublishTweetPoll(true);
getTweetPollDao().saveOrUpdate(tweetPollDomain);
double hits = getRandomNumberRange(2, EnMePlaceHolderConfigurer
.getIntegerProperty("demo.max.tweetpoll.hits"));
for (int i = 0; i < hits; i++) {
getFrontEndService().registerHit(tweetPollDomain, null, null, null, EnMeUtils.ipGenerator(), HitCategory.VISIT);
}
double votes = getRandomNumberRange(10, EnMePlaceHolderConfigurer
.getIntegerProperty("demo.max.tweetpoll.votes"));
for (int i = 0; i < votes; i++) {
getFrontEndService().registerVote(tweetPollDomain.getTweetPollId(), TypeSearchResult.TWEETPOLL, EnMeUtils.ipGenerator());
}
//TODO: make sense?
//tpx.setHits(Long.valueOf(getRandomNumberRange(6, 5000)));
//tpx.setNumbervotes(Long.valueOf(getRandomNumberRange(40, 10000)));
tweetPollDomain.setPublishTweetPoll(true);
Date tweetPollRandomDate = createRandomDate();
tweetPollDomain.setCreateDate(tweetPollRandomDate);
tweetPollDomain.setUpdatedDate(tweetPollRandomDate);
getTweetPollDao().saveOrUpdate(tweetPollDomain);
for (int i = 0; i < EnMePlaceHolderConfigurer
.getIntegerProperty("demo.max.tweetpoll.folder"); i++) {
log.debug("Creating folder name ....");
getTweetPollService().createTweetPollFolder(this.DEFAULT_FOLDER_NAME+"_"+i+"_", u.getUsername());
}
log.debug("New tweetpoll "+tweetPollDomain.getTweetPollId());
for (CommentBean commentBean2 : comments) {
log.debug("New COMMENT tweetpoll ");
final Comment comment = new Comment();
comment.setTweetPoll(tweetPollDomain);
comment.setCreatedAt(createRandomDate());
comment.setComment(commentBean2.getComment());
comment.setDislikeVote(Long.valueOf(getRandomNumberRange(EnMePlaceHolderConfigurer
.getIntegerProperty("demo.min.comments.unlikes"), EnMePlaceHolderConfigurer
.getIntegerProperty("demo.max.comments.unlikes"))));
comment.setLikeVote(Long.valueOf(getRandomNumberRange(EnMePlaceHolderConfigurer
.getIntegerProperty("demo.min.comments.likes"), EnMePlaceHolderConfigurer
.getIntegerProperty("demo.max.comments.likes"))));
comment.setUser(userAccount.get(Double.valueOf(getRandomNumberRange(0, totalUsers) - 1).intValue()));
getTweetPollDao().saveOrUpdate(comment);
log.debug("Saved COMMENT tweetpoll ");
}
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);
}