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