001
014
015 package com.liferay.portlet.polls.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.model.impl.BaseModelImpl;
022 import com.liferay.portal.service.ServiceContext;
023 import com.liferay.portal.util.PortalUtil;
024
025 import com.liferay.portlet.expando.model.ExpandoBridge;
026 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027 import com.liferay.portlet.polls.model.PollsVote;
028 import com.liferay.portlet.polls.model.PollsVoteModel;
029 import com.liferay.portlet.polls.model.PollsVoteSoap;
030
031 import java.io.Serializable;
032
033 import java.lang.reflect.Proxy;
034
035 import java.sql.Types;
036
037 import java.util.ArrayList;
038 import java.util.Date;
039 import java.util.List;
040
041
058 public class PollsVoteModelImpl extends BaseModelImpl<PollsVote>
059 implements PollsVoteModel {
060 public static final String TABLE_NAME = "PollsVote";
061 public static final Object[][] TABLE_COLUMNS = {
062 { "voteId", new Integer(Types.BIGINT) },
063 { "userId", new Integer(Types.BIGINT) },
064 { "questionId", new Integer(Types.BIGINT) },
065 { "choiceId", new Integer(Types.BIGINT) },
066 { "voteDate", new Integer(Types.TIMESTAMP) }
067 };
068 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)";
069 public static final String TABLE_SQL_DROP = "drop table PollsVote";
070 public static final String DATA_SOURCE = "liferayDataSource";
071 public static final String SESSION_FACTORY = "liferaySessionFactory";
072 public static final String TX_MANAGER = "liferayTransactionManager";
073 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
075 true);
076 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
078 true);
079
080
086 public static PollsVote toModel(PollsVoteSoap soapModel) {
087 PollsVote model = new PollsVoteImpl();
088
089 model.setVoteId(soapModel.getVoteId());
090 model.setUserId(soapModel.getUserId());
091 model.setQuestionId(soapModel.getQuestionId());
092 model.setChoiceId(soapModel.getChoiceId());
093 model.setVoteDate(soapModel.getVoteDate());
094
095 return model;
096 }
097
098
104 public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
105 List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
106
107 for (PollsVoteSoap soapModel : soapModels) {
108 models.add(toModel(soapModel));
109 }
110
111 return models;
112 }
113
114 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115 "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
116
117 public PollsVoteModelImpl() {
118 }
119
120 public long getPrimaryKey() {
121 return _voteId;
122 }
123
124 public void setPrimaryKey(long pk) {
125 setVoteId(pk);
126 }
127
128 public Serializable getPrimaryKeyObj() {
129 return new Long(_voteId);
130 }
131
132 public long getVoteId() {
133 return _voteId;
134 }
135
136 public void setVoteId(long voteId) {
137 _voteId = voteId;
138 }
139
140 public long getUserId() {
141 return _userId;
142 }
143
144 public void setUserId(long userId) {
145 if (!_setOriginalUserId) {
146 _setOriginalUserId = true;
147
148 _originalUserId = _userId;
149 }
150
151 _userId = userId;
152 }
153
154 public String getUserUuid() throws SystemException {
155 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
156 }
157
158 public void setUserUuid(String userUuid) {
159 _userUuid = userUuid;
160 }
161
162 public long getOriginalUserId() {
163 return _originalUserId;
164 }
165
166 public long getQuestionId() {
167 return _questionId;
168 }
169
170 public void setQuestionId(long questionId) {
171 if (!_setOriginalQuestionId) {
172 _setOriginalQuestionId = true;
173
174 _originalQuestionId = _questionId;
175 }
176
177 _questionId = questionId;
178 }
179
180 public long getOriginalQuestionId() {
181 return _originalQuestionId;
182 }
183
184 public long getChoiceId() {
185 return _choiceId;
186 }
187
188 public void setChoiceId(long choiceId) {
189 _choiceId = choiceId;
190 }
191
192 public Date getVoteDate() {
193 return _voteDate;
194 }
195
196 public void setVoteDate(Date voteDate) {
197 _voteDate = voteDate;
198 }
199
200 public PollsVote toEscapedModel() {
201 if (isEscapedModel()) {
202 return (PollsVote)this;
203 }
204 else {
205 return (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
206 new Class[] { PollsVote.class }, new AutoEscapeBeanHandler(this));
207 }
208 }
209
210 public ExpandoBridge getExpandoBridge() {
211 if (_expandoBridge == null) {
212 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
213 PollsVote.class.getName(), getPrimaryKey());
214 }
215
216 return _expandoBridge;
217 }
218
219 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
220 getExpandoBridge().setAttributes(serviceContext);
221 }
222
223 public Object clone() {
224 PollsVoteImpl pollsVoteImpl = new PollsVoteImpl();
225
226 pollsVoteImpl.setVoteId(getVoteId());
227
228 pollsVoteImpl.setUserId(getUserId());
229
230 PollsVoteModelImpl pollsVoteModelImpl = pollsVoteImpl;
231
232 pollsVoteModelImpl._originalUserId = pollsVoteModelImpl._userId;
233
234 pollsVoteModelImpl._setOriginalUserId = false;
235 pollsVoteImpl.setQuestionId(getQuestionId());
236
237 pollsVoteModelImpl._originalQuestionId = pollsVoteModelImpl._questionId;
238
239 pollsVoteModelImpl._setOriginalQuestionId = false;
240 pollsVoteImpl.setChoiceId(getChoiceId());
241
242 pollsVoteImpl.setVoteDate(getVoteDate());
243
244 return pollsVoteImpl;
245 }
246
247 public int compareTo(PollsVote pollsVote) {
248 long pk = pollsVote.getPrimaryKey();
249
250 if (getPrimaryKey() < pk) {
251 return -1;
252 }
253 else if (getPrimaryKey() > pk) {
254 return 1;
255 }
256 else {
257 return 0;
258 }
259 }
260
261 public boolean equals(Object obj) {
262 if (obj == null) {
263 return false;
264 }
265
266 PollsVote pollsVote = null;
267
268 try {
269 pollsVote = (PollsVote)obj;
270 }
271 catch (ClassCastException cce) {
272 return false;
273 }
274
275 long pk = pollsVote.getPrimaryKey();
276
277 if (getPrimaryKey() == pk) {
278 return true;
279 }
280 else {
281 return false;
282 }
283 }
284
285 public int hashCode() {
286 return (int)getPrimaryKey();
287 }
288
289 public String toString() {
290 StringBundler sb = new StringBundler(11);
291
292 sb.append("{voteId=");
293 sb.append(getVoteId());
294 sb.append(", userId=");
295 sb.append(getUserId());
296 sb.append(", questionId=");
297 sb.append(getQuestionId());
298 sb.append(", choiceId=");
299 sb.append(getChoiceId());
300 sb.append(", voteDate=");
301 sb.append(getVoteDate());
302 sb.append("}");
303
304 return sb.toString();
305 }
306
307 public String toXmlString() {
308 StringBundler sb = new StringBundler(19);
309
310 sb.append("<model><model-name>");
311 sb.append("com.liferay.portlet.polls.model.PollsVote");
312 sb.append("</model-name>");
313
314 sb.append(
315 "<column><column-name>voteId</column-name><column-value><![CDATA[");
316 sb.append(getVoteId());
317 sb.append("]]></column-value></column>");
318 sb.append(
319 "<column><column-name>userId</column-name><column-value><![CDATA[");
320 sb.append(getUserId());
321 sb.append("]]></column-value></column>");
322 sb.append(
323 "<column><column-name>questionId</column-name><column-value><![CDATA[");
324 sb.append(getQuestionId());
325 sb.append("]]></column-value></column>");
326 sb.append(
327 "<column><column-name>choiceId</column-name><column-value><![CDATA[");
328 sb.append(getChoiceId());
329 sb.append("]]></column-value></column>");
330 sb.append(
331 "<column><column-name>voteDate</column-name><column-value><![CDATA[");
332 sb.append(getVoteDate());
333 sb.append("]]></column-value></column>");
334
335 sb.append("</model>");
336
337 return sb.toString();
338 }
339
340 private long _voteId;
341 private long _userId;
342 private String _userUuid;
343 private long _originalUserId;
344 private boolean _setOriginalUserId;
345 private long _questionId;
346 private long _originalQuestionId;
347 private boolean _setOriginalQuestionId;
348 private long _choiceId;
349 private Date _voteDate;
350 private transient ExpandoBridge _expandoBridge;
351 }