1
22
23 package com.liferay.portlet.polls.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.model.impl.BaseModelImpl;
28
29 import com.liferay.portlet.polls.model.PollsVote;
30 import com.liferay.portlet.polls.model.PollsVoteSoap;
31
32 import java.io.Serializable;
33
34 import java.lang.reflect.Proxy;
35
36 import java.sql.Types;
37
38 import java.util.ArrayList;
39 import java.util.Date;
40 import java.util.List;
41
42
62 public class PollsVoteModelImpl extends BaseModelImpl {
63 public static final String TABLE_NAME = "PollsVote";
64 public static final Object[][] TABLE_COLUMNS = {
65 { "voteId", new Integer(Types.BIGINT) },
66
67
68 { "userId", new Integer(Types.BIGINT) },
69
70
71 { "questionId", new Integer(Types.BIGINT) },
72
73
74 { "choiceId", new Integer(Types.BIGINT) },
75
76
77 { "voteDate", new Integer(Types.TIMESTAMP) }
78 };
79 public static final String TABLE_SQL_CREATE = "create table PollsVote (voteId LONG not null primary key,userId LONG,questionId LONG,choiceId LONG,voteDate DATE null)";
80 public static final String TABLE_SQL_DROP = "drop table PollsVote";
81 public static final String DATA_SOURCE = "liferayDataSource";
82 public static final String SESSION_FACTORY = "liferaySessionFactory";
83 public static final String TX_MANAGER = "liferayTransactionManager";
84 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
86 true);
87
88 public static PollsVote toModel(PollsVoteSoap soapModel) {
89 PollsVote model = new PollsVoteImpl();
90
91 model.setVoteId(soapModel.getVoteId());
92 model.setUserId(soapModel.getUserId());
93 model.setQuestionId(soapModel.getQuestionId());
94 model.setChoiceId(soapModel.getChoiceId());
95 model.setVoteDate(soapModel.getVoteDate());
96
97 return model;
98 }
99
100 public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
101 List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
102
103 for (PollsVoteSoap soapModel : soapModels) {
104 models.add(toModel(soapModel));
105 }
106
107 return models;
108 }
109
110 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111 "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
112
113 public PollsVoteModelImpl() {
114 }
115
116 public long getPrimaryKey() {
117 return _voteId;
118 }
119
120 public void setPrimaryKey(long pk) {
121 setVoteId(pk);
122 }
123
124 public Serializable getPrimaryKeyObj() {
125 return new Long(_voteId);
126 }
127
128 public long getVoteId() {
129 return _voteId;
130 }
131
132 public void setVoteId(long voteId) {
133 if (voteId != _voteId) {
134 _voteId = voteId;
135 }
136 }
137
138 public long getUserId() {
139 return _userId;
140 }
141
142 public void setUserId(long userId) {
143 if (userId != _userId) {
144 _userId = userId;
145 }
146 }
147
148 public long getQuestionId() {
149 return _questionId;
150 }
151
152 public void setQuestionId(long questionId) {
153 if (questionId != _questionId) {
154 _questionId = questionId;
155 }
156 }
157
158 public long getChoiceId() {
159 return _choiceId;
160 }
161
162 public void setChoiceId(long choiceId) {
163 if (choiceId != _choiceId) {
164 _choiceId = choiceId;
165 }
166 }
167
168 public Date getVoteDate() {
169 return _voteDate;
170 }
171
172 public void setVoteDate(Date voteDate) {
173 if (((voteDate == null) && (_voteDate != null)) ||
174 ((voteDate != null) && (_voteDate == null)) ||
175 ((voteDate != null) && (_voteDate != null) &&
176 !voteDate.equals(_voteDate))) {
177 _voteDate = voteDate;
178 }
179 }
180
181 public PollsVote toEscapedModel() {
182 if (isEscapedModel()) {
183 return (PollsVote)this;
184 }
185 else {
186 PollsVote model = new PollsVoteImpl();
187
188 model.setNew(isNew());
189 model.setEscapedModel(true);
190
191 model.setVoteId(getVoteId());
192 model.setUserId(getUserId());
193 model.setQuestionId(getQuestionId());
194 model.setChoiceId(getChoiceId());
195 model.setVoteDate(getVoteDate());
196
197 model = (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
198 new Class[] { PollsVote.class },
199 new ReadOnlyBeanHandler(model));
200
201 return model;
202 }
203 }
204
205 public Object clone() {
206 PollsVoteImpl clone = new PollsVoteImpl();
207
208 clone.setVoteId(getVoteId());
209 clone.setUserId(getUserId());
210 clone.setQuestionId(getQuestionId());
211 clone.setChoiceId(getChoiceId());
212 clone.setVoteDate(getVoteDate());
213
214 return clone;
215 }
216
217 public int compareTo(Object obj) {
218 if (obj == null) {
219 return -1;
220 }
221
222 PollsVoteImpl pollsVote = (PollsVoteImpl)obj;
223
224 long pk = pollsVote.getPrimaryKey();
225
226 if (getPrimaryKey() < pk) {
227 return -1;
228 }
229 else if (getPrimaryKey() > pk) {
230 return 1;
231 }
232 else {
233 return 0;
234 }
235 }
236
237 public boolean equals(Object obj) {
238 if (obj == null) {
239 return false;
240 }
241
242 PollsVoteImpl pollsVote = null;
243
244 try {
245 pollsVote = (PollsVoteImpl)obj;
246 }
247 catch (ClassCastException cce) {
248 return false;
249 }
250
251 long pk = pollsVote.getPrimaryKey();
252
253 if (getPrimaryKey() == pk) {
254 return true;
255 }
256 else {
257 return false;
258 }
259 }
260
261 public int hashCode() {
262 return (int)getPrimaryKey();
263 }
264
265 private long _voteId;
266 private long _userId;
267 private long _questionId;
268 private long _choiceId;
269 private Date _voteDate;
270 }