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 _createDate = createDate;
275 }
276
277 @JSON
278 public Date getModifiedDate() {
279 return _modifiedDate;
280 }
281
282 public void setModifiedDate(Date modifiedDate) {
283 _modifiedDate = modifiedDate;
284 }
285
286 @JSON
287 public String getTitle() {
288 if (_title == null) {
289 return StringPool.BLANK;
290 }
291 else {
292 return _title;
293 }
294 }
295
296 public String getTitle(Locale locale) {
297 String languageId = LocaleUtil.toLanguageId(locale);
298
299 return getTitle(languageId);
300 }
301
302 public String getTitle(Locale locale, boolean useDefault) {
303 String languageId = LocaleUtil.toLanguageId(locale);
304
305 return getTitle(languageId, useDefault);
306 }
307
308 public String getTitle(String languageId) {
309 return LocalizationUtil.getLocalization(getTitle(), languageId);
310 }
311
312 public String getTitle(String languageId, boolean useDefault) {
313 return LocalizationUtil.getLocalization(getTitle(), languageId,
314 useDefault);
315 }
316
317 public String getTitleCurrentLanguageId() {
318 return _titleCurrentLanguageId;
319 }
320
321 @JSON
322 public String getTitleCurrentValue() {
323 Locale locale = getLocale(_titleCurrentLanguageId);
324
325 return getTitle(locale);
326 }
327
328 public Map<Locale, String> getTitleMap() {
329 return LocalizationUtil.getLocalizationMap(getTitle());
330 }
331
332 public void setTitle(String title) {
333 _title = title;
334 }
335
336 public void setTitle(String title, Locale locale) {
337 setTitle(title, locale, LocaleUtil.getDefault());
338 }
339
340 public void setTitle(String title, Locale locale, Locale defaultLocale) {
341 String languageId = LocaleUtil.toLanguageId(locale);
342 String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
343
344 if (Validator.isNotNull(title)) {
345 setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
346 title, languageId, defaultLanguageId));
347 }
348 else {
349 setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
350 languageId));
351 }
352 }
353
354 public void setTitleCurrentLanguageId(String languageId) {
355 _titleCurrentLanguageId = languageId;
356 }
357
358 public void setTitleMap(Map<Locale, String> titleMap) {
359 setTitleMap(titleMap, LocaleUtil.getDefault());
360 }
361
362 public void setTitleMap(Map<Locale, String> titleMap, Locale defaultLocale) {
363 if (titleMap == null) {
364 return;
365 }
366
367 Locale[] locales = LanguageUtil.getAvailableLocales();
368
369 for (Locale locale : locales) {
370 String title = titleMap.get(locale);
371
372 setTitle(title, locale, defaultLocale);
373 }
374 }
375
376 @JSON
377 public String getDescription() {
378 if (_description == null) {
379 return StringPool.BLANK;
380 }
381 else {
382 return _description;
383 }
384 }
385
386 public String getDescription(Locale locale) {
387 String languageId = LocaleUtil.toLanguageId(locale);
388
389 return getDescription(languageId);
390 }
391
392 public String getDescription(Locale locale, boolean useDefault) {
393 String languageId = LocaleUtil.toLanguageId(locale);
394
395 return getDescription(languageId, useDefault);
396 }
397
398 public String getDescription(String languageId) {
399 return LocalizationUtil.getLocalization(getDescription(), languageId);
400 }
401
402 public String getDescription(String languageId, boolean useDefault) {
403 return LocalizationUtil.getLocalization(getDescription(), languageId,
404 useDefault);
405 }
406
407 public String getDescriptionCurrentLanguageId() {
408 return _descriptionCurrentLanguageId;
409 }
410
411 @JSON
412 public String getDescriptionCurrentValue() {
413 Locale locale = getLocale(_descriptionCurrentLanguageId);
414
415 return getDescription(locale);
416 }
417
418 public Map<Locale, String> getDescriptionMap() {
419 return LocalizationUtil.getLocalizationMap(getDescription());
420 }
421
422 public void setDescription(String description) {
423 _description = description;
424 }
425
426 public void setDescription(String description, Locale locale) {
427 setDescription(description, locale, LocaleUtil.getDefault());
428 }
429
430 public void setDescription(String description, Locale locale,
431 Locale defaultLocale) {
432 String languageId = LocaleUtil.toLanguageId(locale);
433 String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
434
435 if (Validator.isNotNull(description)) {
436 setDescription(LocalizationUtil.updateLocalization(
437 getDescription(), "Description", description, languageId,
438 defaultLanguageId));
439 }
440 else {
441 setDescription(LocalizationUtil.removeLocalization(
442 getDescription(), "Description", languageId));
443 }
444 }
445
446 public void setDescriptionCurrentLanguageId(String languageId) {
447 _descriptionCurrentLanguageId = languageId;
448 }
449
450 public void setDescriptionMap(Map<Locale, String> descriptionMap) {
451 setDescriptionMap(descriptionMap, LocaleUtil.getDefault());
452 }
453
454 public void setDescriptionMap(Map<Locale, String> descriptionMap,
455 Locale defaultLocale) {
456 if (descriptionMap == null) {
457 return;
458 }
459
460 Locale[] locales = LanguageUtil.getAvailableLocales();
461
462 for (Locale locale : locales) {
463 String description = descriptionMap.get(locale);
464
465 setDescription(description, locale, defaultLocale);
466 }
467 }
468
469 @JSON
470 public Date getExpirationDate() {
471 return _expirationDate;
472 }
473
474 public void setExpirationDate(Date expirationDate) {
475 _expirationDate = expirationDate;
476 }
477
478 @JSON
479 public Date getLastVoteDate() {
480 return _lastVoteDate;
481 }
482
483 public void setLastVoteDate(Date lastVoteDate) {
484 _lastVoteDate = lastVoteDate;
485 }
486
487 public long getColumnBitmask() {
488 return _columnBitmask;
489 }
490
491 @Override
492 public PollsQuestion toEscapedModel() {
493 if (_escapedModelProxy == null) {
494 _escapedModelProxy = (PollsQuestion)ProxyUtil.newProxyInstance(_classLoader,
495 _escapedModelProxyInterfaces,
496 new AutoEscapeBeanHandler(this));
497 }
498
499 return _escapedModelProxy;
500 }
501
502 @Override
503 public ExpandoBridge getExpandoBridge() {
504 if (_expandoBridge == null) {
505 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
506 PollsQuestion.class.getName(), getPrimaryKey());
507 }
508
509 return _expandoBridge;
510 }
511
512 @Override
513 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
514 getExpandoBridge().setAttributes(serviceContext);
515 }
516
517 @Override
518 public Object clone() {
519 PollsQuestionImpl pollsQuestionImpl = new PollsQuestionImpl();
520
521 pollsQuestionImpl.setUuid(getUuid());
522 pollsQuestionImpl.setQuestionId(getQuestionId());
523 pollsQuestionImpl.setGroupId(getGroupId());
524 pollsQuestionImpl.setCompanyId(getCompanyId());
525 pollsQuestionImpl.setUserId(getUserId());
526 pollsQuestionImpl.setUserName(getUserName());
527 pollsQuestionImpl.setCreateDate(getCreateDate());
528 pollsQuestionImpl.setModifiedDate(getModifiedDate());
529 pollsQuestionImpl.setTitle(getTitle());
530 pollsQuestionImpl.setDescription(getDescription());
531 pollsQuestionImpl.setExpirationDate(getExpirationDate());
532 pollsQuestionImpl.setLastVoteDate(getLastVoteDate());
533
534 pollsQuestionImpl.resetOriginalValues();
535
536 return pollsQuestionImpl;
537 }
538
539 public int compareTo(PollsQuestion pollsQuestion) {
540 int value = 0;
541
542 value = DateUtil.compareTo(getCreateDate(),
543 pollsQuestion.getCreateDate());
544
545 value = value * -1;
546
547 if (value != 0) {
548 return value;
549 }
550
551 return 0;
552 }
553
554 @Override
555 public boolean equals(Object obj) {
556 if (obj == null) {
557 return false;
558 }
559
560 PollsQuestion pollsQuestion = null;
561
562 try {
563 pollsQuestion = (PollsQuestion)obj;
564 }
565 catch (ClassCastException cce) {
566 return false;
567 }
568
569 long primaryKey = pollsQuestion.getPrimaryKey();
570
571 if (getPrimaryKey() == primaryKey) {
572 return true;
573 }
574 else {
575 return false;
576 }
577 }
578
579 @Override
580 public int hashCode() {
581 return (int)getPrimaryKey();
582 }
583
584 @Override
585 public void resetOriginalValues() {
586 PollsQuestionModelImpl pollsQuestionModelImpl = this;
587
588 pollsQuestionModelImpl._originalUuid = pollsQuestionModelImpl._uuid;
589
590 pollsQuestionModelImpl._originalGroupId = pollsQuestionModelImpl._groupId;
591
592 pollsQuestionModelImpl._setOriginalGroupId = false;
593
594 pollsQuestionModelImpl._columnBitmask = 0;
595 }
596
597 @Override
598 public CacheModel<PollsQuestion> toCacheModel() {
599 PollsQuestionCacheModel pollsQuestionCacheModel = new PollsQuestionCacheModel();
600
601 pollsQuestionCacheModel.uuid = getUuid();
602
603 String uuid = pollsQuestionCacheModel.uuid;
604
605 if ((uuid != null) && (uuid.length() == 0)) {
606 pollsQuestionCacheModel.uuid = null;
607 }
608
609 pollsQuestionCacheModel.questionId = getQuestionId();
610
611 pollsQuestionCacheModel.groupId = getGroupId();
612
613 pollsQuestionCacheModel.companyId = getCompanyId();
614
615 pollsQuestionCacheModel.userId = getUserId();
616
617 pollsQuestionCacheModel.userName = getUserName();
618
619 String userName = pollsQuestionCacheModel.userName;
620
621 if ((userName != null) && (userName.length() == 0)) {
622 pollsQuestionCacheModel.userName = null;
623 }
624
625 Date createDate = getCreateDate();
626
627 if (createDate != null) {
628 pollsQuestionCacheModel.createDate = createDate.getTime();
629 }
630 else {
631 pollsQuestionCacheModel.createDate = Long.MIN_VALUE;
632 }
633
634 Date modifiedDate = getModifiedDate();
635
636 if (modifiedDate != null) {
637 pollsQuestionCacheModel.modifiedDate = modifiedDate.getTime();
638 }
639 else {
640 pollsQuestionCacheModel.modifiedDate = Long.MIN_VALUE;
641 }
642
643 pollsQuestionCacheModel.title = getTitle();
644
645 String title = pollsQuestionCacheModel.title;
646
647 if ((title != null) && (title.length() == 0)) {
648 pollsQuestionCacheModel.title = null;
649 }
650
651 pollsQuestionCacheModel.description = getDescription();
652
653 String description = pollsQuestionCacheModel.description;
654
655 if ((description != null) && (description.length() == 0)) {
656 pollsQuestionCacheModel.description = null;
657 }
658
659 Date expirationDate = getExpirationDate();
660
661 if (expirationDate != null) {
662 pollsQuestionCacheModel.expirationDate = expirationDate.getTime();
663 }
664 else {
665 pollsQuestionCacheModel.expirationDate = Long.MIN_VALUE;
666 }
667
668 Date lastVoteDate = getLastVoteDate();
669
670 if (lastVoteDate != null) {
671 pollsQuestionCacheModel.lastVoteDate = lastVoteDate.getTime();
672 }
673 else {
674 pollsQuestionCacheModel.lastVoteDate = Long.MIN_VALUE;
675 }
676
677 return pollsQuestionCacheModel;
678 }
679
680 @Override
681 public String toString() {
682 StringBundler sb = new StringBundler(25);
683
684 sb.append("{uuid=");
685 sb.append(getUuid());
686 sb.append(", questionId=");
687 sb.append(getQuestionId());
688 sb.append(", groupId=");
689 sb.append(getGroupId());
690 sb.append(", companyId=");
691 sb.append(getCompanyId());
692 sb.append(", userId=");
693 sb.append(getUserId());
694 sb.append(", userName=");
695 sb.append(getUserName());
696 sb.append(", createDate=");
697 sb.append(getCreateDate());
698 sb.append(", modifiedDate=");
699 sb.append(getModifiedDate());
700 sb.append(", title=");
701 sb.append(getTitle());
702 sb.append(", description=");
703 sb.append(getDescription());
704 sb.append(", expirationDate=");
705 sb.append(getExpirationDate());
706 sb.append(", lastVoteDate=");
707 sb.append(getLastVoteDate());
708 sb.append("}");
709
710 return sb.toString();
711 }
712
713 public String toXmlString() {
714 StringBundler sb = new StringBundler(40);
715
716 sb.append("<model><model-name>");
717 sb.append("com.liferay.portlet.polls.model.PollsQuestion");
718 sb.append("</model-name>");
719
720 sb.append(
721 "<column><column-name>uuid</column-name><column-value><![CDATA[");
722 sb.append(getUuid());
723 sb.append("]]></column-value></column>");
724 sb.append(
725 "<column><column-name>questionId</column-name><column-value><![CDATA[");
726 sb.append(getQuestionId());
727 sb.append("]]></column-value></column>");
728 sb.append(
729 "<column><column-name>groupId</column-name><column-value><![CDATA[");
730 sb.append(getGroupId());
731 sb.append("]]></column-value></column>");
732 sb.append(
733 "<column><column-name>companyId</column-name><column-value><![CDATA[");
734 sb.append(getCompanyId());
735 sb.append("]]></column-value></column>");
736 sb.append(
737 "<column><column-name>userId</column-name><column-value><![CDATA[");
738 sb.append(getUserId());
739 sb.append("]]></column-value></column>");
740 sb.append(
741 "<column><column-name>userName</column-name><column-value><![CDATA[");
742 sb.append(getUserName());
743 sb.append("]]></column-value></column>");
744 sb.append(
745 "<column><column-name>createDate</column-name><column-value><![CDATA[");
746 sb.append(getCreateDate());
747 sb.append("]]></column-value></column>");
748 sb.append(
749 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
750 sb.append(getModifiedDate());
751 sb.append("]]></column-value></column>");
752 sb.append(
753 "<column><column-name>title</column-name><column-value><![CDATA[");
754 sb.append(getTitle());
755 sb.append("]]></column-value></column>");
756 sb.append(
757 "<column><column-name>description</column-name><column-value><![CDATA[");
758 sb.append(getDescription());
759 sb.append("]]></column-value></column>");
760 sb.append(
761 "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
762 sb.append(getExpirationDate());
763 sb.append("]]></column-value></column>");
764 sb.append(
765 "<column><column-name>lastVoteDate</column-name><column-value><![CDATA[");
766 sb.append(getLastVoteDate());
767 sb.append("]]></column-value></column>");
768
769 sb.append("</model>");
770
771 return sb.toString();
772 }
773
774 private static ClassLoader _classLoader = PollsQuestion.class.getClassLoader();
775 private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
776 PollsQuestion.class
777 };
778 private String _uuid;
779 private String _originalUuid;
780 private long _questionId;
781 private long _groupId;
782 private long _originalGroupId;
783 private boolean _setOriginalGroupId;
784 private long _companyId;
785 private long _userId;
786 private String _userUuid;
787 private String _userName;
788 private Date _createDate;
789 private Date _modifiedDate;
790 private String _title;
791 private String _titleCurrentLanguageId;
792 private String _description;
793 private String _descriptionCurrentLanguageId;
794 private Date _expirationDate;
795 private Date _lastVoteDate;
796 private transient ExpandoBridge _expandoBridge;
797 private long _columnBitmask;
798 private PollsQuestion _escapedModelProxy;
799 }