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.language.LanguageUtil;
021 import com.liferay.portal.kernel.util.DateUtil;
022 import com.liferay.portal.kernel.util.GetterUtil;
023 import com.liferay.portal.kernel.util.LocaleUtil;
024 import com.liferay.portal.kernel.util.LocalizationUtil;
025 import com.liferay.portal.kernel.util.ProxyUtil;
026 import com.liferay.portal.kernel.util.StringBundler;
027 import com.liferay.portal.kernel.util.StringPool;
028 import com.liferay.portal.kernel.util.Validator;
029 import com.liferay.portal.model.CacheModel;
030 import com.liferay.portal.model.impl.BaseModelImpl;
031 import com.liferay.portal.service.ServiceContext;
032 import com.liferay.portal.util.PortalUtil;
033
034 import com.liferay.portlet.expando.model.ExpandoBridge;
035 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
036 import com.liferay.portlet.polls.model.PollsQuestion;
037 import com.liferay.portlet.polls.model.PollsQuestionModel;
038 import com.liferay.portlet.polls.model.PollsQuestionSoap;
039
040 import java.io.Serializable;
041
042 import java.sql.Types;
043
044 import java.util.ArrayList;
045 import java.util.Date;
046 import java.util.List;
047 import java.util.Locale;
048 import java.util.Map;
049
050
063 @JSON(strict = true)
064 public class PollsQuestionModelImpl extends BaseModelImpl<PollsQuestion>
065 implements PollsQuestionModel {
066
071 public static final String TABLE_NAME = "PollsQuestion";
072 public static final Object[][] TABLE_COLUMNS = {
073 { "uuid_", Types.VARCHAR },
074 { "questionId", Types.BIGINT },
075 { "groupId", Types.BIGINT },
076 { "companyId", Types.BIGINT },
077 { "userId", Types.BIGINT },
078 { "userName", Types.VARCHAR },
079 { "createDate", Types.TIMESTAMP },
080 { "modifiedDate", Types.TIMESTAMP },
081 { "title", Types.VARCHAR },
082 { "description", Types.VARCHAR },
083 { "expirationDate", Types.TIMESTAMP },
084 { "lastVoteDate", Types.TIMESTAMP }
085 };
086 public static final String TABLE_SQL_CREATE = "create table PollsQuestion (uuid_ VARCHAR(75) null,questionId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,title STRING null,description STRING null,expirationDate DATE null,lastVoteDate DATE null)";
087 public static final String TABLE_SQL_DROP = "drop table PollsQuestion";
088 public static final String ORDER_BY_JPQL = " ORDER BY pollsQuestion.createDate DESC";
089 public static final String ORDER_BY_SQL = " ORDER BY PollsQuestion.createDate DESC";
090 public static final String DATA_SOURCE = "liferayDataSource";
091 public static final String SESSION_FACTORY = "liferaySessionFactory";
092 public static final String TX_MANAGER = "liferayTransactionManager";
093 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
094 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
095 true);
096 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
097 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
098 true);
099 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
100 "value.object.column.bitmask.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
101 true);
102 public static long GROUPID_COLUMN_BITMASK = 1L;
103 public static long UUID_COLUMN_BITMASK = 2L;
104
105
111 public static PollsQuestion toModel(PollsQuestionSoap soapModel) {
112 PollsQuestion model = new PollsQuestionImpl();
113
114 model.setUuid(soapModel.getUuid());
115 model.setQuestionId(soapModel.getQuestionId());
116 model.setGroupId(soapModel.getGroupId());
117 model.setCompanyId(soapModel.getCompanyId());
118 model.setUserId(soapModel.getUserId());
119 model.setUserName(soapModel.getUserName());
120 model.setCreateDate(soapModel.getCreateDate());
121 model.setModifiedDate(soapModel.getModifiedDate());
122 model.setTitle(soapModel.getTitle());
123 model.setDescription(soapModel.getDescription());
124 model.setExpirationDate(soapModel.getExpirationDate());
125 model.setLastVoteDate(soapModel.getLastVoteDate());
126
127 return model;
128 }
129
130
136 public static List<PollsQuestion> toModels(PollsQuestionSoap[] soapModels) {
137 List<PollsQuestion> models = new ArrayList<PollsQuestion>(soapModels.length);
138
139 for (PollsQuestionSoap soapModel : soapModels) {
140 models.add(toModel(soapModel));
141 }
142
143 return models;
144 }
145
146 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
147 "lock.expiration.time.com.liferay.portlet.polls.model.PollsQuestion"));
148
149 public PollsQuestionModelImpl() {
150 }
151
152 public long getPrimaryKey() {
153 return _questionId;
154 }
155
156 public void setPrimaryKey(long primaryKey) {
157 setQuestionId(primaryKey);
158 }
159
160 public Serializable getPrimaryKeyObj() {
161 return new Long(_questionId);
162 }
163
164 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
165 setPrimaryKey(((Long)primaryKeyObj).longValue());
166 }
167
168 public Class<?> getModelClass() {
169 return PollsQuestion.class;
170 }
171
172 public String getModelClassName() {
173 return PollsQuestion.class.getName();
174 }
175
176 @JSON
177 public String getUuid() {
178 if (_uuid == null) {
179 return StringPool.BLANK;
180 }
181 else {
182 return _uuid;
183 }
184 }
185
186 public void setUuid(String uuid) {
187 if (_originalUuid == null) {
188 _originalUuid = _uuid;
189 }
190
191 _uuid = uuid;
192 }
193
194 public String getOriginalUuid() {
195 return GetterUtil.getString(_originalUuid);
196 }
197
198 @JSON
199 public long getQuestionId() {
200 return _questionId;
201 }
202
203 public void setQuestionId(long questionId) {
204 _questionId = questionId;
205 }
206
207 @JSON
208 public long getGroupId() {
209 return _groupId;
210 }
211
212 public void setGroupId(long groupId) {
213 _columnBitmask |= GROUPID_COLUMN_BITMASK;
214
215 if (!_setOriginalGroupId) {
216 _setOriginalGroupId = true;
217
218 _originalGroupId = _groupId;
219 }
220
221 _groupId = groupId;
222 }
223
224 public long getOriginalGroupId() {
225 return _originalGroupId;
226 }
227
228 @JSON
229 public long getCompanyId() {
230 return _companyId;
231 }
232
233 public void setCompanyId(long companyId) {
234 _companyId = companyId;
235 }
236
237 @JSON
238 public long getUserId() {
239 return _userId;
240 }
241
242 public void setUserId(long userId) {
243 _userId = userId;
244 }
245
246 public String getUserUuid() throws SystemException {
247 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
248 }
249
250 public void setUserUuid(String userUuid) {
251 _userUuid = userUuid;
252 }
253
254 @JSON
255 public String getUserName() {
256 if (_userName == null) {
257 return StringPool.BLANK;
258 }
259 else {
260 return _userName;
261 }
262 }
263
264 public void setUserName(String userName) {
265 _userName = userName;
266 }
267
268 @JSON
269 public Date getCreateDate() {
270 return _createDate;
271 }
272
273 public void setCreateDate(Date createDate) {
274 _columnBitmask = -1L;
275
276 _createDate = createDate;
277 }
278
279 @JSON
280 public Date getModifiedDate() {
281 return _modifiedDate;
282 }
283
284 public void setModifiedDate(Date modifiedDate) {
285 _modifiedDate = modifiedDate;
286 }
287
288 @JSON
289 public String getTitle() {
290 if (_title == null) {
291 return StringPool.BLANK;
292 }
293 else {
294 return _title;
295 }
296 }
297
298 public String getTitle(Locale locale) {
299 String languageId = LocaleUtil.toLanguageId(locale);
300
301 return getTitle(languageId);
302 }
303
304 public String getTitle(Locale locale, boolean useDefault) {
305 String languageId = LocaleUtil.toLanguageId(locale);
306
307 return getTitle(languageId, useDefault);
308 }
309
310 public String getTitle(String languageId) {
311 return LocalizationUtil.getLocalization(getTitle(), languageId);
312 }
313
314 public String getTitle(String languageId, boolean useDefault) {
315 return LocalizationUtil.getLocalization(getTitle(), languageId,
316 useDefault);
317 }
318
319 public String getTitleCurrentLanguageId() {
320 return _titleCurrentLanguageId;
321 }
322
323 @JSON
324 public String getTitleCurrentValue() {
325 Locale locale = getLocale(_titleCurrentLanguageId);
326
327 return getTitle(locale);
328 }
329
330 public Map<Locale, String> getTitleMap() {
331 return LocalizationUtil.getLocalizationMap(getTitle());
332 }
333
334 public void setTitle(String title) {
335 _title = title;
336 }
337
338 public void setTitle(String title, Locale locale) {
339 setTitle(title, locale, LocaleUtil.getDefault());
340 }
341
342 public void setTitle(String title, Locale locale, Locale defaultLocale) {
343 String languageId = LocaleUtil.toLanguageId(locale);
344 String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
345
346 if (Validator.isNotNull(title)) {
347 setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
348 title, languageId, defaultLanguageId));
349 }
350 else {
351 setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
352 languageId));
353 }
354 }
355
356 public void setTitleCurrentLanguageId(String languageId) {
357 _titleCurrentLanguageId = languageId;
358 }
359
360 public void setTitleMap(Map<Locale, String> titleMap) {
361 setTitleMap(titleMap, LocaleUtil.getDefault());
362 }
363
364 public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
365 if (titleMap == null) {
366 return;
367 }
368
369 Locale[] locales = LanguageUtil.getAvailableLocales();
370
371 for (Locale locale : locales) {
372 String title = titleMap.get(locale);
373
374 setTitle(title, locale, defaultLocale);
375 }
376 }
377
378 @JSON
379 public String getDescription() {
380 if (_description == null) {
381 return StringPool.BLANK;
382 }
383 else {
384 return _description;
385 }
386 }
387
388 public String getDescription(Locale locale) {
389 String languageId = LocaleUtil.toLanguageId(locale);
390
391 return getDescription(languageId);
392 }
393
394 public String getDescription(Locale locale, boolean useDefault) {
395 String languageId = LocaleUtil.toLanguageId(locale);
396
397 return getDescription(languageId, useDefault);
398 }
399
400 public String getDescription(String languageId) {
401 return LocalizationUtil.getLocalization(getDescription(), languageId);
402 }
403
404 public String getDescription(String languageId, boolean useDefault) {
405 return LocalizationUtil.getLocalization(getDescription(), languageId,
406 useDefault);
407 }
408
409 public String getDescriptionCurrentLanguageId() {
410 return _descriptionCurrentLanguageId;
411 }
412
413 @JSON
414 public String getDescriptionCurrentValue() {
415 Locale locale = getLocale(_descriptionCurrentLanguageId);
416
417 return getDescription(locale);
418 }
419
420 public Map<Locale, String> getDescriptionMap() {
421 return LocalizationUtil.getLocalizationMap(getDescription());
422 }
423
424 public void setDescription(String description) {
425 _description = description;
426 }
427
428 public void setDescription(String description, Locale locale) {
429 setDescription(description, locale, LocaleUtil.getDefault());
430 }
431
432 public void setDescription(String description, Locale locale,
433 Locale defaultLocale) {
434 String languageId = LocaleUtil.toLanguageId(locale);
435 String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
436
437 if (Validator.isNotNull(description)) {
438 setDescription(LocalizationUtil.updateLocalization(
439 getDescription(), "Description", description, languageId,
440 defaultLanguageId));
441 }
442 else {
443 setDescription(LocalizationUtil.removeLocalization(
444 getDescription(), "Description", languageId));
445 }
446 }
447
448 public void setDescriptionCurrentLanguageId(String languageId) {
449 _descriptionCurrentLanguageId = languageId;
450 }
451
452 public void setDescriptionMap(Map<Locale, String> descriptionMap) {
453 setDescriptionMap(descriptionMap, LocaleUtil.getDefault());
454 }
455
456 public void setDescriptionMap(Map<Locale, String> descriptionMap,
457 Locale defaultLocale) {
458 if (descriptionMap == null) {
459 return;
460 }
461
462 Locale[] locales = LanguageUtil.getAvailableLocales();
463
464 for (Locale locale : locales) {
465 String description = descriptionMap.get(locale);
466
467 setDescription(description, locale, defaultLocale);
468 }
469 }
470
471 @JSON
472 public Date getExpirationDate() {
473 return _expirationDate;
474 }
475
476 public void setExpirationDate(Date expirationDate) {
477 _expirationDate = expirationDate;
478 }
479
480 @JSON
481 public Date getLastVoteDate() {
482 return _lastVoteDate;
483 }
484
485 public void setLastVoteDate(Date lastVoteDate) {
486 _lastVoteDate = lastVoteDate;
487 }
488
489 public long getColumnBitmask() {
490 return _columnBitmask;
491 }
492
493 @Override
494 public PollsQuestion toEscapedModel() {
495 if (_escapedModelProxy == null) {
496 _escapedModelProxy = (PollsQuestion)ProxyUtil.newProxyInstance(_classLoader,
497 _escapedModelProxyInterfaces,
498 new AutoEscapeBeanHandler(this));
499 }
500
501 return _escapedModelProxy;
502 }
503
504 @Override
505 public ExpandoBridge getExpandoBridge() {
506 if (_expandoBridge == null) {
507 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
508 PollsQuestion.class.getName(), getPrimaryKey());
509 }
510
511 return _expandoBridge;
512 }
513
514 @Override
515 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
516 getExpandoBridge().setAttributes(serviceContext);
517 }
518
519 @Override
520 public Object clone() {
521 PollsQuestionImpl pollsQuestionImpl = new PollsQuestionImpl();
522
523 pollsQuestionImpl.setUuid(getUuid());
524 pollsQuestionImpl.setQuestionId(getQuestionId());
525 pollsQuestionImpl.setGroupId(getGroupId());
526 pollsQuestionImpl.setCompanyId(getCompanyId());
527 pollsQuestionImpl.setUserId(getUserId());
528 pollsQuestionImpl.setUserName(getUserName());
529 pollsQuestionImpl.setCreateDate(getCreateDate());
530 pollsQuestionImpl.setModifiedDate(getModifiedDate());
531 pollsQuestionImpl.setTitle(getTitle());
532 pollsQuestionImpl.setDescription(getDescription());
533 pollsQuestionImpl.setExpirationDate(getExpirationDate());
534 pollsQuestionImpl.setLastVoteDate(getLastVoteDate());
535
536 pollsQuestionImpl.resetOriginalValues();
537
538 return pollsQuestionImpl;
539 }
540
541 public int compareTo(PollsQuestion pollsQuestion) {
542 int value = 0;
543
544 value = DateUtil.compareTo(getCreateDate(),
545 pollsQuestion.getCreateDate());
546
547 value = value * -1;
548
549 if (value != 0) {
550 return value;
551 }
552
553 return 0;
554 }
555
556 @Override
557 public boolean equals(Object obj) {
558 if (obj == null) {
559 return false;
560 }
561
562 PollsQuestion pollsQuestion = null;
563
564 try {
565 pollsQuestion = (PollsQuestion)obj;
566 }
567 catch (ClassCastException cce) {
568 return false;
569 }
570
571 long primaryKey = pollsQuestion.getPrimaryKey();
572
573 if (getPrimaryKey() == primaryKey) {
574 return true;
575 }
576 else {
577 return false;
578 }
579 }
580
581 @Override
582 public int hashCode() {
583 return (int)getPrimaryKey();
584 }
585
586 @Override
587 public void resetOriginalValues() {
588 PollsQuestionModelImpl pollsQuestionModelImpl = this;
589
590 pollsQuestionModelImpl._originalUuid = pollsQuestionModelImpl._uuid;
591
592 pollsQuestionModelImpl._originalGroupId = pollsQuestionModelImpl._groupId;
593
594 pollsQuestionModelImpl._setOriginalGroupId = false;
595
596 pollsQuestionModelImpl._columnBitmask = 0;
597 }
598
599 @Override
600 public CacheModel<PollsQuestion> toCacheModel() {
601 PollsQuestionCacheModel pollsQuestionCacheModel = new PollsQuestionCacheModel();
602
603 pollsQuestionCacheModel.uuid = getUuid();
604
605 String uuid = pollsQuestionCacheModel.uuid;
606
607 if ((uuid != null) && (uuid.length() == 0)) {
608 pollsQuestionCacheModel.uuid = null;
609 }
610
611 pollsQuestionCacheModel.questionId = getQuestionId();
612
613 pollsQuestionCacheModel.groupId = getGroupId();
614
615 pollsQuestionCacheModel.companyId = getCompanyId();
616
617 pollsQuestionCacheModel.userId = getUserId();
618
619 pollsQuestionCacheModel.userName = getUserName();
620
621 String userName = pollsQuestionCacheModel.userName;
622
623 if ((userName != null) && (userName.length() == 0)) {
624 pollsQuestionCacheModel.userName = null;
625 }
626
627 Date createDate = getCreateDate();
628
629 if (createDate != null) {
630 pollsQuestionCacheModel.createDate = createDate.getTime();
631 }
632 else {
633 pollsQuestionCacheModel.createDate = Long.MIN_VALUE;
634 }
635
636 Date modifiedDate = getModifiedDate();
637
638 if (modifiedDate != null) {
639 pollsQuestionCacheModel.modifiedDate = modifiedDate.getTime();
640 }
641 else {
642 pollsQuestionCacheModel.modifiedDate = Long.MIN_VALUE;
643 }
644
645 pollsQuestionCacheModel.title = getTitle();
646
647 String title = pollsQuestionCacheModel.title;
648
649 if ((title != null) && (title.length() == 0)) {
650 pollsQuestionCacheModel.title = null;
651 }
652
653 pollsQuestionCacheModel.description = getDescription();
654
655 String description = pollsQuestionCacheModel.description;
656
657 if ((description != null) && (description.length() == 0)) {
658 pollsQuestionCacheModel.description = null;
659 }
660
661 Date expirationDate = getExpirationDate();
662
663 if (expirationDate != null) {
664 pollsQuestionCacheModel.expirationDate = expirationDate.getTime();
665 }
666 else {
667 pollsQuestionCacheModel.expirationDate = Long.MIN_VALUE;
668 }
669
670 Date lastVoteDate = getLastVoteDate();
671
672 if (lastVoteDate != null) {
673 pollsQuestionCacheModel.lastVoteDate = lastVoteDate.getTime();
674 }
675 else {
676 pollsQuestionCacheModel.lastVoteDate = Long.MIN_VALUE;
677 }
678
679 return pollsQuestionCacheModel;
680 }
681
682 @Override
683 public String toString() {
684 StringBundler sb = new StringBundler(25);
685
686 sb.append("{uuid=");
687 sb.append(getUuid());
688 sb.append(", questionId=");
689 sb.append(getQuestionId());
690 sb.append(", groupId=");
691 sb.append(getGroupId());
692 sb.append(", companyId=");
693 sb.append(getCompanyId());
694 sb.append(", userId=");
695 sb.append(getUserId());
696 sb.append(", userName=");
697 sb.append(getUserName());
698 sb.append(", createDate=");
699 sb.append(getCreateDate());
700 sb.append(", modifiedDate=");
701 sb.append(getModifiedDate());
702 sb.append(", title=");
703 sb.append(getTitle());
704 sb.append(", description=");
705 sb.append(getDescription());
706 sb.append(", expirationDate=");
707 sb.append(getExpirationDate());
708 sb.append(", lastVoteDate=");
709 sb.append(getLastVoteDate());
710 sb.append("}");
711
712 return sb.toString();
713 }
714
715 public String toXmlString() {
716 StringBundler sb = new StringBundler(40);
717
718 sb.append("<model><model-name>");
719 sb.append("com.liferay.portlet.polls.model.PollsQuestion");
720 sb.append("</model-name>");
721
722 sb.append(
723 "<column><column-name>uuid</column-name><column-value><![CDATA[");
724 sb.append(getUuid());
725 sb.append("]]></column-value></column>");
726 sb.append(
727 "<column><column-name>questionId</column-name><column-value><![CDATA[");
728 sb.append(getQuestionId());
729 sb.append("]]></column-value></column>");
730 sb.append(
731 "<column><column-name>groupId</column-name><column-value><![CDATA[");
732 sb.append(getGroupId());
733 sb.append("]]></column-value></column>");
734 sb.append(
735 "<column><column-name>companyId</column-name><column-value><![CDATA[");
736 sb.append(getCompanyId());
737 sb.append("]]></column-value></column>");
738 sb.append(
739 "<column><column-name>userId</column-name><column-value><![CDATA[");
740 sb.append(getUserId());
741 sb.append("]]></column-value></column>");
742 sb.append(
743 "<column><column-name>userName</column-name><column-value><![CDATA[");
744 sb.append(getUserName());
745 sb.append("]]></column-value></column>");
746 sb.append(
747 "<column><column-name>createDate</column-name><column-value><![CDATA[");
748 sb.append(getCreateDate());
749 sb.append("]]></column-value></column>");
750 sb.append(
751 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
752 sb.append(getModifiedDate());
753 sb.append("]]></column-value></column>");
754 sb.append(
755 "<column><column-name>title</column-name><column-value><![CDATA[");
756 sb.append(getTitle());
757 sb.append("]]></column-value></column>");
758 sb.append(
759 "<column><column-name>description</column-name><column-value><![CDATA[");
760 sb.append(getDescription());
761 sb.append("]]></column-value></column>");
762 sb.append(
763 "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
764 sb.append(getExpirationDate());
765 sb.append("]]></column-value></column>");
766 sb.append(
767 "<column><column-name>lastVoteDate</column-name><column-value><![CDATA[");
768 sb.append(getLastVoteDate());
769 sb.append("]]></column-value></column>");
770
771 sb.append("</model>");
772
773 return sb.toString();
774 }
775
776 private static ClassLoader _classLoader = PollsQuestion.class.getClassLoader();
777 private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
778 PollsQuestion.class
779 };
780 private String _uuid;
781 private String _originalUuid;
782 private long _questionId;
783 private long _groupId;
784 private long _originalGroupId;
785 private boolean _setOriginalGroupId;
786 private long _companyId;
787 private long _userId;
788 private String _userUuid;
789 private String _userName;
790 private Date _createDate;
791 private Date _modifiedDate;
792 private String _title;
793 private String _titleCurrentLanguageId;
794 private String _description;
795 private String _descriptionCurrentLanguageId;
796 private Date _expirationDate;
797 private Date _lastVoteDate;
798 private transient ExpandoBridge _expandoBridge;
799 private long _columnBitmask;
800 private PollsQuestion _escapedModelProxy;
801 }