*
* @param poll
* @return unitPoll unitPoll
*/
public static final PollBean convertPollDomainToBean(final Poll poll) {
final PollBean unitPoll = new PollBean();
unitPoll.setId(poll.getPollId());
unitPoll.setCompletedPoll(poll.getPollCompleted() == null ? false
: poll.getPollCompleted());
unitPoll.setCreationDate(poll.getCreateDate() == null ? null
: DateUtil.SIMPLE_DATE_FORMAT.format(poll.getCreateDate()));
unitPoll.setCreateDateComparable(poll.getCreateDate());
unitPoll.setQuestionBean(ConvertDomainBean.convertQuestionsToBean(poll
.getQuestion()));
unitPoll.setPublishPoll(poll.getPublish() == null ? false : poll
.getPublish());
if (poll.getUpdatedDate() != null) {
unitPoll.setUpdatedDate(poll.getUpdatedDate());
}
unitPoll.setTotalVotes(poll.getNumbervotes() == null ? EnMeUtils.VOTE_MIN
: Long.valueOf(poll.getNumbervotes()));
unitPoll.setShowResultsPoll(Boolean.TRUE);
//poll.getShowResults() == null ? false : poll.getShowResults()
unitPoll.setLikeVote(poll.getLikeVote() == null ? EnMeUtils.LIKE_DEFAULT
: Long.valueOf(poll.getLikeVote()));
unitPoll.setDislikeVote(poll.getDislikeVote() == null ? EnMeUtils.DISLIKE_DEFAULT
: Long.valueOf(poll.getDislikeVote()));
unitPoll.setOwnerUsername(poll.getEditorOwner() == null ? null : poll
.getEditorOwner().getUsername());
unitPoll.setRelevance(poll.getRelevance() == null ? EnMeUtils.RATE_DEFAULT
: poll.getRelevance());
unitPoll.setHits(poll.getHits() == null ? EnMeUtils.VOTE_MIN : poll
.getHits());
unitPoll.setFavorite(poll.getFavourites() == null ? false : poll
.getFavourites());
unitPoll.setHashTags(ConvertDomainBean
.convertListHashTagsToBean(new ArrayList<HashTag>(poll
.getHashTags())));
unitPoll.setLatitude(poll.getLocationLatitude() == null ? 0 : poll
.getLocationLatitude());
unitPoll.setLongitude(poll.getLocationLongitude() == null ? 0 : poll
.getLocationLongitude());
unitPoll.setIsShowAdditionalInfo(poll.getShowAdditionalInfo() == null ? false
: poll.getShowAdditionalInfo());
unitPoll.setAdditionalInfo(poll.getAdditionalInfo() == null ? "" : poll
.getAdditionalInfo());
unitPoll.setCloseNotification(poll.getNotifications() == null ? false
: poll.getNotifications());
unitPoll.setItemType(TypeSearchResult.POLL.toString().toLowerCase());
unitPoll.setIsPasswordRestriction(poll.getPasswordRestrictions() == null ? false
: poll.getPasswordRestrictions());
if (poll.getShowComments() != null) {
unitPoll.setShowComments(poll.getShowComments().toString());
}
unitPoll.setFolderId(poll.getPollFolder() == null ? null : poll
.getPollFolder().getId());
unitPoll.setIsCloseAfterDate(poll.getCloseAfterDate() == null ? false
: poll.getCloseAfterDate());
unitPoll.setClosedDate(poll.getClosedDate() == null ? null
: DateUtil.DOJO_DATE_FORMAT.format(poll.getClosedDate()));
unitPoll.setIsCloseAfterQuota(poll.getCloseAfterquota() == null ? false
: poll.getCloseAfterquota());
unitPoll.setClosedQuota(poll.getClosedQuota() == null ? null : poll
.getClosedQuota());
unitPoll.setIsIpRestricted(poll.getIpRestriction());
unitPoll.setIpRestricted(poll.getIpProtection() == null ? "" : poll
.getIpProtection());
return unitPoll;
}