Status status = Status.SUCCESS;
final Long INCREASE_VOTES = 1L;
final String userVote = getUserPrincipalUsername();
log.debug("registerVote: "+userVote);
final Hit hit = new Hit();
hit.setHitCategory(HitCategory.VOTE);
hit.setIpAddress(ipAddress);
try {
//vote process
if (searchResult.equals(TypeSearchResult.TWEETPOLL)) {
final TweetPoll tp = getTweetPollService().getTweetPollPublishedById(itemId);
final Long votes = tp.getNumbervotes() + INCREASE_VOTES;
tp.setNumbervotes(votes);
hit.setTweetPoll(tp);
getTweetPollDao().saveOrUpdate(tp);
} else if (searchResult.equals(TypeSearchResult.POLL)) {
final Poll poll = getPollService().getPollById(itemId);
final Long votes = poll.getNumbervotes() + INCREASE_VOTES;
poll.setNumbervotes(votes);
getPollDao().saveOrUpdate(poll);
hit.setPoll(poll);
} else if (searchResult.equals(TypeSearchResult.SURVEY)) {
//TODO: Vote a Survey.
}
//register the vote.
if (!EnMeUtils.ANONYMOUS_USER.equals(userVote)) {
UserAccount userAccount = getUserAccount(userVote);
hit.setUserAccount(userAccount);
log.debug("registerVote by userAccount: "+userAccount.getUsername());
}
hit.setHitDate(Calendar.getInstance().getTime());
getAccountDao().saveOrUpdate(hit);
} catch (EnMeNoResultsFoundException e) {
log.error(e);
status = Status.FAILED;
}