1
14
15 package com.liferay.portlet.polls.model.impl;
16
17 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18 import com.liferay.portal.kernel.exception.SystemException;
19 import com.liferay.portal.kernel.language.LanguageUtil;
20 import com.liferay.portal.kernel.util.DateUtil;
21 import com.liferay.portal.kernel.util.GetterUtil;
22 import com.liferay.portal.kernel.util.HtmlUtil;
23 import com.liferay.portal.kernel.util.LocaleUtil;
24 import com.liferay.portal.kernel.util.StringBundler;
25 import com.liferay.portal.kernel.util.Validator;
26 import com.liferay.portal.model.impl.BaseModelImpl;
27 import com.liferay.portal.service.ServiceContext;
28 import com.liferay.portal.util.PortalUtil;
29
30 import com.liferay.portlet.expando.model.ExpandoBridge;
31 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
32 import com.liferay.portlet.polls.model.PollsQuestion;
33 import com.liferay.portlet.polls.model.PollsQuestionSoap;
34
35 import com.liferay.util.LocalizationUtil;
36
37 import java.io.Serializable;
38
39 import java.lang.reflect.Proxy;
40
41 import java.sql.Types;
42
43 import java.util.ArrayList;
44 import java.util.Date;
45 import java.util.List;
46 import java.util.Locale;
47 import java.util.Map;
48
49
68 public class PollsQuestionModelImpl extends BaseModelImpl<PollsQuestion> {
69 public static final String TABLE_NAME = "PollsQuestion";
70 public static final Object[][] TABLE_COLUMNS = {
71 { "uuid_", new Integer(Types.VARCHAR) },
72 { "questionId", new Integer(Types.BIGINT) },
73 { "groupId", new Integer(Types.BIGINT) },
74 { "companyId", new Integer(Types.BIGINT) },
75 { "userId", new Integer(Types.BIGINT) },
76 { "userName", new Integer(Types.VARCHAR) },
77 { "createDate", new Integer(Types.TIMESTAMP) },
78 { "modifiedDate", new Integer(Types.TIMESTAMP) },
79 { "title", new Integer(Types.VARCHAR) },
80 { "description", new Integer(Types.VARCHAR) },
81 { "expirationDate", new Integer(Types.TIMESTAMP) },
82 { "lastVoteDate", new Integer(Types.TIMESTAMP) }
83 };
84 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)";
85 public static final String TABLE_SQL_DROP = "drop table PollsQuestion";
86 public static final String ORDER_BY_JPQL = " ORDER BY pollsQuestion.createDate DESC";
87 public static final String ORDER_BY_SQL = " ORDER BY PollsQuestion.createDate DESC";
88 public static final String DATA_SOURCE = "liferayDataSource";
89 public static final String SESSION_FACTORY = "liferaySessionFactory";
90 public static final String TX_MANAGER = "liferayTransactionManager";
91 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
92 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
93 true);
94 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
96 true);
97
98 public static PollsQuestion toModel(PollsQuestionSoap soapModel) {
99 PollsQuestion model = new PollsQuestionImpl();
100
101 model.setUuid(soapModel.getUuid());
102 model.setQuestionId(soapModel.getQuestionId());
103 model.setGroupId(soapModel.getGroupId());
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.setTitle(soapModel.getTitle());
110 model.setDescription(soapModel.getDescription());
111 model.setExpirationDate(soapModel.getExpirationDate());
112 model.setLastVoteDate(soapModel.getLastVoteDate());
113
114 return model;
115 }
116
117 public static List<PollsQuestion> toModels(PollsQuestionSoap[] soapModels) {
118 List<PollsQuestion> models = new ArrayList<PollsQuestion>(soapModels.length);
119
120 for (PollsQuestionSoap soapModel : soapModels) {
121 models.add(toModel(soapModel));
122 }
123
124 return models;
125 }
126
127 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128 "lock.expiration.time.com.liferay.portlet.polls.model.PollsQuestion"));
129
130 public PollsQuestionModelImpl() {
131 }
132
133 public long getPrimaryKey() {
134 return _questionId;
135 }
136
137 public void setPrimaryKey(long pk) {
138 setQuestionId(pk);
139 }
140
141 public Serializable getPrimaryKeyObj() {
142 return new Long(_questionId);
143 }
144
145 public String getUuid() {
146 return GetterUtil.getString(_uuid);
147 }
148
149 public void setUuid(String uuid) {
150 _uuid = uuid;
151
152 if (_originalUuid == null) {
153 _originalUuid = uuid;
154 }
155 }
156
157 public String getOriginalUuid() {
158 return GetterUtil.getString(_originalUuid);
159 }
160
161 public long getQuestionId() {
162 return _questionId;
163 }
164
165 public void setQuestionId(long questionId) {
166 _questionId = questionId;
167 }
168
169 public long getGroupId() {
170 return _groupId;
171 }
172
173 public void setGroupId(long groupId) {
174 _groupId = groupId;
175
176 if (!_setOriginalGroupId) {
177 _setOriginalGroupId = true;
178
179 _originalGroupId = groupId;
180 }
181 }
182
183 public long getOriginalGroupId() {
184 return _originalGroupId;
185 }
186
187 public long getCompanyId() {
188 return _companyId;
189 }
190
191 public void setCompanyId(long companyId) {
192 _companyId = companyId;
193 }
194
195 public long getUserId() {
196 return _userId;
197 }
198
199 public void setUserId(long userId) {
200 _userId = userId;
201 }
202
203 public String getUserUuid() throws SystemException {
204 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
205 }
206
207 public void setUserUuid(String userUuid) {
208 _userUuid = userUuid;
209 }
210
211 public String getUserName() {
212 return GetterUtil.getString(_userName);
213 }
214
215 public void setUserName(String userName) {
216 _userName = userName;
217 }
218
219 public Date getCreateDate() {
220 return _createDate;
221 }
222
223 public void setCreateDate(Date createDate) {
224 _createDate = createDate;
225 }
226
227 public Date getModifiedDate() {
228 return _modifiedDate;
229 }
230
231 public void setModifiedDate(Date modifiedDate) {
232 _modifiedDate = modifiedDate;
233 }
234
235 public String getTitle() {
236 return GetterUtil.getString(_title);
237 }
238
239 public String getTitle(Locale locale) {
240 String languageId = LocaleUtil.toLanguageId(locale);
241
242 return getTitle(languageId);
243 }
244
245 public String getTitle(Locale locale, boolean useDefault) {
246 String languageId = LocaleUtil.toLanguageId(locale);
247
248 return getTitle(languageId, useDefault);
249 }
250
251 public String getTitle(String languageId) {
252 String value = LocalizationUtil.getLocalization(getTitle(), languageId);
253
254 if (isEscapedModel()) {
255 return HtmlUtil.escape(value);
256 }
257 else {
258 return value;
259 }
260 }
261
262 public String getTitle(String languageId, boolean useDefault) {
263 String value = LocalizationUtil.getLocalization(getTitle(), languageId,
264 useDefault);
265
266 if (isEscapedModel()) {
267 return HtmlUtil.escape(value);
268 }
269 else {
270 return value;
271 }
272 }
273
274 public Map<Locale, String> getTitleMap() {
275 return LocalizationUtil.getLocalizationMap(getTitle());
276 }
277
278 public void setTitle(String title) {
279 _title = title;
280 }
281
282 public void setTitle(Locale locale, String title) {
283 String languageId = LocaleUtil.toLanguageId(locale);
284
285 if (Validator.isNotNull(title)) {
286 setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
287 title, languageId));
288 }
289 else {
290 setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
291 languageId));
292 }
293 }
294
295 public void setTitleMap(Map<Locale, String> titleMap) {
296 if (titleMap == null) {
297 return;
298 }
299
300 Locale[] locales = LanguageUtil.getAvailableLocales();
301
302 for (Locale locale : locales) {
303 String title = titleMap.get(locale);
304
305 setTitle(locale, title);
306 }
307 }
308
309 public String getDescription() {
310 return GetterUtil.getString(_description);
311 }
312
313 public String getDescription(Locale locale) {
314 String languageId = LocaleUtil.toLanguageId(locale);
315
316 return getDescription(languageId);
317 }
318
319 public String getDescription(Locale locale, boolean useDefault) {
320 String languageId = LocaleUtil.toLanguageId(locale);
321
322 return getDescription(languageId, useDefault);
323 }
324
325 public String getDescription(String languageId) {
326 String value = LocalizationUtil.getLocalization(getDescription(),
327 languageId);
328
329 if (isEscapedModel()) {
330 return HtmlUtil.escape(value);
331 }
332 else {
333 return value;
334 }
335 }
336
337 public String getDescription(String languageId, boolean useDefault) {
338 String value = LocalizationUtil.getLocalization(getDescription(),
339 languageId, useDefault);
340
341 if (isEscapedModel()) {
342 return HtmlUtil.escape(value);
343 }
344 else {
345 return value;
346 }
347 }
348
349 public Map<Locale, String> getDescriptionMap() {
350 return LocalizationUtil.getLocalizationMap(getDescription());
351 }
352
353 public void setDescription(String description) {
354 _description = description;
355 }
356
357 public void setDescription(Locale locale, String description) {
358 String languageId = LocaleUtil.toLanguageId(locale);
359
360 if (Validator.isNotNull(description)) {
361 setDescription(LocalizationUtil.updateLocalization(
362 getDescription(), "Description", description, languageId));
363 }
364 else {
365 setDescription(LocalizationUtil.removeLocalization(
366 getDescription(), "Description", languageId));
367 }
368 }
369
370 public void setDescriptionMap(Map<Locale, String> descriptionMap) {
371 if (descriptionMap == null) {
372 return;
373 }
374
375 Locale[] locales = LanguageUtil.getAvailableLocales();
376
377 for (Locale locale : locales) {
378 String description = descriptionMap.get(locale);
379
380 setDescription(locale, description);
381 }
382 }
383
384 public Date getExpirationDate() {
385 return _expirationDate;
386 }
387
388 public void setExpirationDate(Date expirationDate) {
389 _expirationDate = expirationDate;
390 }
391
392 public Date getLastVoteDate() {
393 return _lastVoteDate;
394 }
395
396 public void setLastVoteDate(Date lastVoteDate) {
397 _lastVoteDate = lastVoteDate;
398 }
399
400 public PollsQuestion toEscapedModel() {
401 if (isEscapedModel()) {
402 return (PollsQuestion)this;
403 }
404 else {
405 PollsQuestion model = new PollsQuestionImpl();
406
407 model.setNew(isNew());
408 model.setEscapedModel(true);
409
410 model.setUuid(HtmlUtil.escape(getUuid()));
411 model.setQuestionId(getQuestionId());
412 model.setGroupId(getGroupId());
413 model.setCompanyId(getCompanyId());
414 model.setUserId(getUserId());
415 model.setUserName(HtmlUtil.escape(getUserName()));
416 model.setCreateDate(getCreateDate());
417 model.setModifiedDate(getModifiedDate());
418 model.setTitle(getTitle());
419 model.setDescription(getDescription());
420 model.setExpirationDate(getExpirationDate());
421 model.setLastVoteDate(getLastVoteDate());
422
423 model = (PollsQuestion)Proxy.newProxyInstance(PollsQuestion.class.getClassLoader(),
424 new Class[] { PollsQuestion.class },
425 new ReadOnlyBeanHandler(model));
426
427 return model;
428 }
429 }
430
431 public ExpandoBridge getExpandoBridge() {
432 if (_expandoBridge == null) {
433 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
434 PollsQuestion.class.getName(), getPrimaryKey());
435 }
436
437 return _expandoBridge;
438 }
439
440 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
441 getExpandoBridge().setAttributes(serviceContext);
442 }
443
444 public Object clone() {
445 PollsQuestionImpl clone = new PollsQuestionImpl();
446
447 clone.setUuid(getUuid());
448 clone.setQuestionId(getQuestionId());
449 clone.setGroupId(getGroupId());
450 clone.setCompanyId(getCompanyId());
451 clone.setUserId(getUserId());
452 clone.setUserName(getUserName());
453 clone.setCreateDate(getCreateDate());
454 clone.setModifiedDate(getModifiedDate());
455 clone.setTitle(getTitle());
456 clone.setDescription(getDescription());
457 clone.setExpirationDate(getExpirationDate());
458 clone.setLastVoteDate(getLastVoteDate());
459
460 return clone;
461 }
462
463 public int compareTo(PollsQuestion pollsQuestion) {
464 int value = 0;
465
466 value = DateUtil.compareTo(getCreateDate(),
467 pollsQuestion.getCreateDate());
468
469 value = value * -1;
470
471 if (value != 0) {
472 return value;
473 }
474
475 return 0;
476 }
477
478 public boolean equals(Object obj) {
479 if (obj == null) {
480 return false;
481 }
482
483 PollsQuestion pollsQuestion = null;
484
485 try {
486 pollsQuestion = (PollsQuestion)obj;
487 }
488 catch (ClassCastException cce) {
489 return false;
490 }
491
492 long pk = pollsQuestion.getPrimaryKey();
493
494 if (getPrimaryKey() == pk) {
495 return true;
496 }
497 else {
498 return false;
499 }
500 }
501
502 public int hashCode() {
503 return (int)getPrimaryKey();
504 }
505
506 public String toString() {
507 StringBundler sb = new StringBundler(25);
508
509 sb.append("{uuid=");
510 sb.append(getUuid());
511 sb.append(", questionId=");
512 sb.append(getQuestionId());
513 sb.append(", groupId=");
514 sb.append(getGroupId());
515 sb.append(", companyId=");
516 sb.append(getCompanyId());
517 sb.append(", userId=");
518 sb.append(getUserId());
519 sb.append(", userName=");
520 sb.append(getUserName());
521 sb.append(", createDate=");
522 sb.append(getCreateDate());
523 sb.append(", modifiedDate=");
524 sb.append(getModifiedDate());
525 sb.append(", title=");
526 sb.append(getTitle());
527 sb.append(", description=");
528 sb.append(getDescription());
529 sb.append(", expirationDate=");
530 sb.append(getExpirationDate());
531 sb.append(", lastVoteDate=");
532 sb.append(getLastVoteDate());
533 sb.append("}");
534
535 return sb.toString();
536 }
537
538 public String toXmlString() {
539 StringBundler sb = new StringBundler(40);
540
541 sb.append("<model><model-name>");
542 sb.append("com.liferay.portlet.polls.model.PollsQuestion");
543 sb.append("</model-name>");
544
545 sb.append(
546 "<column><column-name>uuid</column-name><column-value><![CDATA[");
547 sb.append(getUuid());
548 sb.append("]]></column-value></column>");
549 sb.append(
550 "<column><column-name>questionId</column-name><column-value><![CDATA[");
551 sb.append(getQuestionId());
552 sb.append("]]></column-value></column>");
553 sb.append(
554 "<column><column-name>groupId</column-name><column-value><![CDATA[");
555 sb.append(getGroupId());
556 sb.append("]]></column-value></column>");
557 sb.append(
558 "<column><column-name>companyId</column-name><column-value><![CDATA[");
559 sb.append(getCompanyId());
560 sb.append("]]></column-value></column>");
561 sb.append(
562 "<column><column-name>userId</column-name><column-value><![CDATA[");
563 sb.append(getUserId());
564 sb.append("]]></column-value></column>");
565 sb.append(
566 "<column><column-name>userName</column-name><column-value><![CDATA[");
567 sb.append(getUserName());
568 sb.append("]]></column-value></column>");
569 sb.append(
570 "<column><column-name>createDate</column-name><column-value><![CDATA[");
571 sb.append(getCreateDate());
572 sb.append("]]></column-value></column>");
573 sb.append(
574 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
575 sb.append(getModifiedDate());
576 sb.append("]]></column-value></column>");
577 sb.append(
578 "<column><column-name>title</column-name><column-value><![CDATA[");
579 sb.append(getTitle());
580 sb.append("]]></column-value></column>");
581 sb.append(
582 "<column><column-name>description</column-name><column-value><![CDATA[");
583 sb.append(getDescription());
584 sb.append("]]></column-value></column>");
585 sb.append(
586 "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
587 sb.append(getExpirationDate());
588 sb.append("]]></column-value></column>");
589 sb.append(
590 "<column><column-name>lastVoteDate</column-name><column-value><![CDATA[");
591 sb.append(getLastVoteDate());
592 sb.append("]]></column-value></column>");
593
594 sb.append("</model>");
595
596 return sb.toString();
597 }
598
599 private String _uuid;
600 private String _originalUuid;
601 private long _questionId;
602 private long _groupId;
603 private long _originalGroupId;
604 private boolean _setOriginalGroupId;
605 private long _companyId;
606 private long _userId;
607 private String _userUuid;
608 private String _userName;
609 private Date _createDate;
610 private Date _modifiedDate;
611 private String _title;
612 private String _description;
613 private Date _expirationDate;
614 private Date _lastVoteDate;
615 private transient ExpandoBridge _expandoBridge;
616 }