001
014
015 package com.liferay.portlet.polls.model.impl;
016
017 import com.liferay.portal.kernel.exception.SystemException;
018 import com.liferay.portal.service.ServiceContext;
019 import com.liferay.portlet.polls.model.PollsChoice;
020 import com.liferay.portlet.polls.service.PollsChoiceLocalServiceUtil;
021 import com.liferay.portlet.polls.service.PollsVoteLocalServiceUtil;
022
023 import java.util.Date;
024 import java.util.List;
025
026
029 public class PollsQuestionImpl extends PollsQuestionBaseImpl {
030
031 public PollsQuestionImpl() {
032 }
033
034 @Override
035 public List<PollsChoice> getChoices() throws SystemException {
036 return PollsChoiceLocalServiceUtil.getChoices(getQuestionId());
037 }
038
039 @Override
040 public int getVotesCount() throws SystemException {
041 return PollsVoteLocalServiceUtil.getQuestionVotesCount(getQuestionId());
042 }
043
044 @Override
045 public boolean isExpired() {
046 Date expirationDate = getExpirationDate();
047
048 if ((expirationDate != null) && expirationDate.before(new Date())) {
049 return true;
050 }
051 else {
052 return false;
053 }
054 }
055
056 @Override
057 public boolean isExpired(
058 ServiceContext serviceContext, Date defaultCreateDate) {
059
060 Date expirationDate = getExpirationDate();
061
062 if (expirationDate == null) {
063 return false;
064 }
065
066 Date createDate = serviceContext.getCreateDate(defaultCreateDate);
067
068 if (createDate.after(expirationDate)) {
069 return true;
070 }
071 else {
072 return false;
073 }
074 }
075
076 }