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