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.json.JSON;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.ProxyUtil;
022 import com.liferay.portal.kernel.util.StringBundler;
023 import com.liferay.portal.kernel.util.StringPool;
024 import com.liferay.portal.model.CacheModel;
025 import com.liferay.portal.model.impl.BaseModelImpl;
026 import com.liferay.portal.service.ServiceContext;
027 import com.liferay.portal.util.PortalUtil;
028
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031 import com.liferay.portlet.polls.model.PollsVote;
032 import com.liferay.portlet.polls.model.PollsVoteModel;
033 import com.liferay.portlet.polls.model.PollsVoteSoap;
034
035 import java.io.Serializable;
036
037 import java.sql.Types;
038
039 import java.util.ArrayList;
040 import java.util.Date;
041 import java.util.List;
042
043
056 @JSON(strict = true)
057 public class PollsVoteModelImpl extends BaseModelImpl<PollsVote>
058 implements PollsVoteModel {
059
064 public static final String TABLE_NAME = "PollsVote";
065 public static final Object[][] TABLE_COLUMNS = {
066 { "voteId", Types.BIGINT },
067 { "companyId", Types.BIGINT },
068 { "userId", Types.BIGINT },
069 { "userName", Types.VARCHAR },
070 { "createDate", Types.TIMESTAMP },
071 { "modifiedDate", Types.TIMESTAMP },
072 { "questionId", Types.BIGINT },
073 { "choiceId", Types.BIGINT },
074 { "voteDate", Types.TIMESTAMP }
075 };
076 public static final String TABLE_SQL_CREATE = "create table PollsVote (voteId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,questionId LONG,choiceId LONG,voteDate DATE null)";
077 public static final String TABLE_SQL_DROP = "drop table PollsVote";
078 public static final String DATA_SOURCE = "liferayDataSource";
079 public static final String SESSION_FACTORY = "liferaySessionFactory";
080 public static final String TX_MANAGER = "liferayTransactionManager";
081 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
083 true);
084 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
086 true);
087 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
088 "value.object.column.bitmask.enabled.com.liferay.portlet.polls.model.PollsVote"),
089 true);
090 public static long CHOICEID_COLUMN_BITMASK = 1L;
091 public static long QUESTIONID_COLUMN_BITMASK = 2L;
092 public static long USERID_COLUMN_BITMASK = 4L;
093
094
100 public static PollsVote toModel(PollsVoteSoap soapModel) {
101 PollsVote model = new PollsVoteImpl();
102
103 model.setVoteId(soapModel.getVoteId());
104 model.setCompanyId(soapModel.getCompanyId());
105 model.setUserId(soapModel.getUserId());
106 model.setUserName(soapModel.getUserName());
107 model.setCreateDate(soapModel.getCreateDate());
108 model.setModifiedDate(soapModel.getModifiedDate());
109 model.setQuestionId(soapModel.getQuestionId());
110 model.setChoiceId(soapModel.getChoiceId());
111 model.setVoteDate(soapModel.getVoteDate());
112
113 return model;
114 }
115
116
122 public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
123 List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
124
125 for (PollsVoteSoap soapModel : soapModels) {
126 models.add(toModel(soapModel));
127 }
128
129 return models;
130 }
131
132 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
133 "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
134
135 public PollsVoteModelImpl() {
136 }
137
138 public long getPrimaryKey() {
139 return _voteId;
140 }
141
142 public void setPrimaryKey(long primaryKey) {
143 setVoteId(primaryKey);
144 }
145
146 public Serializable getPrimaryKeyObj() {
147 return new Long(_voteId);
148 }
149
150 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
151 setPrimaryKey(((Long)primaryKeyObj).longValue());
152 }
153
154 public Class<?> getModelClass() {
155 return PollsVote.class;
156 }
157
158 public String getModelClassName() {
159 return PollsVote.class.getName();
160 }
161
162 @JSON
163 public long getVoteId() {
164 return _voteId;
165 }
166
167 public void setVoteId(long voteId) {
168 _voteId = voteId;
169 }
170
171 @JSON
172 public long getCompanyId() {
173 return _companyId;
174 }
175
176 public void setCompanyId(long companyId) {
177 _companyId = companyId;
178 }
179
180 @JSON
181 public long getUserId() {
182 return _userId;
183 }
184
185 public void setUserId(long userId) {
186 _columnBitmask |= USERID_COLUMN_BITMASK;
187
188 if (!_setOriginalUserId) {
189 _setOriginalUserId = true;
190
191 _originalUserId = _userId;
192 }
193
194 _userId = userId;
195 }
196
197 public String getUserUuid() throws SystemException {
198 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
199 }
200
201 public void setUserUuid(String userUuid) {
202 _userUuid = userUuid;
203 }
204
205 public long getOriginalUserId() {
206 return _originalUserId;
207 }
208
209 @JSON
210 public String getUserName() {
211 if (_userName == null) {
212 return StringPool.BLANK;
213 }
214 else {
215 return _userName;
216 }
217 }
218
219 public void setUserName(String userName) {
220 _userName = userName;
221 }
222
223 @JSON
224 public Date getCreateDate() {
225 return _createDate;
226 }
227
228 public void setCreateDate(Date createDate) {
229 _createDate = createDate;
230 }
231
232 @JSON
233 public Date getModifiedDate() {
234 return _modifiedDate;
235 }
236
237 public void setModifiedDate(Date modifiedDate) {
238 _modifiedDate = modifiedDate;
239 }
240
241 @JSON
242 public long getQuestionId() {
243 return _questionId;
244 }
245
246 public void setQuestionId(long questionId) {
247 _columnBitmask |= QUESTIONID_COLUMN_BITMASK;
248
249 if (!_setOriginalQuestionId) {
250 _setOriginalQuestionId = true;
251
252 _originalQuestionId = _questionId;
253 }
254
255 _questionId = questionId;
256 }
257
258 public long getOriginalQuestionId() {
259 return _originalQuestionId;
260 }
261
262 @JSON
263 public long getChoiceId() {
264 return _choiceId;
265 }
266
267 public void setChoiceId(long choiceId) {
268 _columnBitmask |= CHOICEID_COLUMN_BITMASK;
269
270 if (!_setOriginalChoiceId) {
271 _setOriginalChoiceId = true;
272
273 _originalChoiceId = _choiceId;
274 }
275
276 _choiceId = choiceId;
277 }
278
279 public long getOriginalChoiceId() {
280 return _originalChoiceId;
281 }
282
283 @JSON
284 public Date getVoteDate() {
285 return _voteDate;
286 }
287
288 public void setVoteDate(Date voteDate) {
289 _voteDate = voteDate;
290 }
291
292 public long getColumnBitmask() {
293 return _columnBitmask;
294 }
295
296 @Override
297 public PollsVote toEscapedModel() {
298 if (_escapedModelProxy == null) {
299 _escapedModelProxy = (PollsVote)ProxyUtil.newProxyInstance(_classLoader,
300 _escapedModelProxyInterfaces,
301 new AutoEscapeBeanHandler(this));
302 }
303
304 return _escapedModelProxy;
305 }
306
307 @Override
308 public ExpandoBridge getExpandoBridge() {
309 if (_expandoBridge == null) {
310 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
311 PollsVote.class.getName(), getPrimaryKey());
312 }
313
314 return _expandoBridge;
315 }
316
317 @Override
318 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
319 getExpandoBridge().setAttributes(serviceContext);
320 }
321
322 @Override
323 public Object clone() {
324 PollsVoteImpl pollsVoteImpl = new PollsVoteImpl();
325
326 pollsVoteImpl.setVoteId(getVoteId());
327 pollsVoteImpl.setCompanyId(getCompanyId());
328 pollsVoteImpl.setUserId(getUserId());
329 pollsVoteImpl.setUserName(getUserName());
330 pollsVoteImpl.setCreateDate(getCreateDate());
331 pollsVoteImpl.setModifiedDate(getModifiedDate());
332 pollsVoteImpl.setQuestionId(getQuestionId());
333 pollsVoteImpl.setChoiceId(getChoiceId());
334 pollsVoteImpl.setVoteDate(getVoteDate());
335
336 pollsVoteImpl.resetOriginalValues();
337
338 return pollsVoteImpl;
339 }
340
341 public int compareTo(PollsVote pollsVote) {
342 long primaryKey = pollsVote.getPrimaryKey();
343
344 if (getPrimaryKey() < primaryKey) {
345 return -1;
346 }
347 else if (getPrimaryKey() > primaryKey) {
348 return 1;
349 }
350 else {
351 return 0;
352 }
353 }
354
355 @Override
356 public boolean equals(Object obj) {
357 if (obj == null) {
358 return false;
359 }
360
361 PollsVote pollsVote = null;
362
363 try {
364 pollsVote = (PollsVote)obj;
365 }
366 catch (ClassCastException cce) {
367 return false;
368 }
369
370 long primaryKey = pollsVote.getPrimaryKey();
371
372 if (getPrimaryKey() == primaryKey) {
373 return true;
374 }
375 else {
376 return false;
377 }
378 }
379
380 @Override
381 public int hashCode() {
382 return (int)getPrimaryKey();
383 }
384
385 @Override
386 public void resetOriginalValues() {
387 PollsVoteModelImpl pollsVoteModelImpl = this;
388
389 pollsVoteModelImpl._originalUserId = pollsVoteModelImpl._userId;
390
391 pollsVoteModelImpl._setOriginalUserId = false;
392
393 pollsVoteModelImpl._originalQuestionId = pollsVoteModelImpl._questionId;
394
395 pollsVoteModelImpl._setOriginalQuestionId = false;
396
397 pollsVoteModelImpl._originalChoiceId = pollsVoteModelImpl._choiceId;
398
399 pollsVoteModelImpl._setOriginalChoiceId = false;
400
401 pollsVoteModelImpl._columnBitmask = 0;
402 }
403
404 @Override
405 public CacheModel<PollsVote> toCacheModel() {
406 PollsVoteCacheModel pollsVoteCacheModel = new PollsVoteCacheModel();
407
408 pollsVoteCacheModel.voteId = getVoteId();
409
410 pollsVoteCacheModel.companyId = getCompanyId();
411
412 pollsVoteCacheModel.userId = getUserId();
413
414 pollsVoteCacheModel.userName = getUserName();
415
416 String userName = pollsVoteCacheModel.userName;
417
418 if ((userName != null) && (userName.length() == 0)) {
419 pollsVoteCacheModel.userName = null;
420 }
421
422 Date createDate = getCreateDate();
423
424 if (createDate != null) {
425 pollsVoteCacheModel.createDate = createDate.getTime();
426 }
427 else {
428 pollsVoteCacheModel.createDate = Long.MIN_VALUE;
429 }
430
431 Date modifiedDate = getModifiedDate();
432
433 if (modifiedDate != null) {
434 pollsVoteCacheModel.modifiedDate = modifiedDate.getTime();
435 }
436 else {
437 pollsVoteCacheModel.modifiedDate = Long.MIN_VALUE;
438 }
439
440 pollsVoteCacheModel.questionId = getQuestionId();
441
442 pollsVoteCacheModel.choiceId = getChoiceId();
443
444 Date voteDate = getVoteDate();
445
446 if (voteDate != null) {
447 pollsVoteCacheModel.voteDate = voteDate.getTime();
448 }
449 else {
450 pollsVoteCacheModel.voteDate = Long.MIN_VALUE;
451 }
452
453 return pollsVoteCacheModel;
454 }
455
456 @Override
457 public String toString() {
458 StringBundler sb = new StringBundler(19);
459
460 sb.append("{voteId=");
461 sb.append(getVoteId());
462 sb.append(", companyId=");
463 sb.append(getCompanyId());
464 sb.append(", userId=");
465 sb.append(getUserId());
466 sb.append(", userName=");
467 sb.append(getUserName());
468 sb.append(", createDate=");
469 sb.append(getCreateDate());
470 sb.append(", modifiedDate=");
471 sb.append(getModifiedDate());
472 sb.append(", questionId=");
473 sb.append(getQuestionId());
474 sb.append(", choiceId=");
475 sb.append(getChoiceId());
476 sb.append(", voteDate=");
477 sb.append(getVoteDate());
478 sb.append("}");
479
480 return sb.toString();
481 }
482
483 public String toXmlString() {
484 StringBundler sb = new StringBundler(31);
485
486 sb.append("<model><model-name>");
487 sb.append("com.liferay.portlet.polls.model.PollsVote");
488 sb.append("</model-name>");
489
490 sb.append(
491 "<column><column-name>voteId</column-name><column-value><![CDATA[");
492 sb.append(getVoteId());
493 sb.append("]]></column-value></column>");
494 sb.append(
495 "<column><column-name>companyId</column-name><column-value><![CDATA[");
496 sb.append(getCompanyId());
497 sb.append("]]></column-value></column>");
498 sb.append(
499 "<column><column-name>userId</column-name><column-value><![CDATA[");
500 sb.append(getUserId());
501 sb.append("]]></column-value></column>");
502 sb.append(
503 "<column><column-name>userName</column-name><column-value><![CDATA[");
504 sb.append(getUserName());
505 sb.append("]]></column-value></column>");
506 sb.append(
507 "<column><column-name>createDate</column-name><column-value><![CDATA[");
508 sb.append(getCreateDate());
509 sb.append("]]></column-value></column>");
510 sb.append(
511 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
512 sb.append(getModifiedDate());
513 sb.append("]]></column-value></column>");
514 sb.append(
515 "<column><column-name>questionId</column-name><column-value><![CDATA[");
516 sb.append(getQuestionId());
517 sb.append("]]></column-value></column>");
518 sb.append(
519 "<column><column-name>choiceId</column-name><column-value><![CDATA[");
520 sb.append(getChoiceId());
521 sb.append("]]></column-value></column>");
522 sb.append(
523 "<column><column-name>voteDate</column-name><column-value><![CDATA[");
524 sb.append(getVoteDate());
525 sb.append("]]></column-value></column>");
526
527 sb.append("</model>");
528
529 return sb.toString();
530 }
531
532 private static ClassLoader _classLoader = PollsVote.class.getClassLoader();
533 private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
534 PollsVote.class
535 };
536 private long _voteId;
537 private long _companyId;
538 private long _userId;
539 private String _userUuid;
540 private long _originalUserId;
541 private boolean _setOriginalUserId;
542 private String _userName;
543 private Date _createDate;
544 private Date _modifiedDate;
545 private long _questionId;
546 private long _originalQuestionId;
547 private boolean _setOriginalQuestionId;
548 private long _choiceId;
549 private long _originalChoiceId;
550 private boolean _setOriginalChoiceId;
551 private Date _voteDate;
552 private transient ExpandoBridge _expandoBridge;
553 private long _columnBitmask;
554 private PollsVote _escapedModelProxy;
555 }