1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.polls.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
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.LocalizationUtil;
25  import com.liferay.portal.kernel.util.StringBundler;
26  import com.liferay.portal.kernel.util.StringPool;
27  import com.liferay.portal.kernel.util.Validator;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.service.ServiceContext;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
34  import com.liferay.portlet.polls.model.PollsQuestion;
35  import com.liferay.portlet.polls.model.PollsQuestionSoap;
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  /**
50   * <a href="PollsQuestionModelImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * <p>
53   * ServiceBuilder generated this class. Modifications in this class will be
54   * overwritten the next time is generated.
55   * </p>
56   *
57   * <p>
58   * This interface is a model that represents the PollsQuestion table in the
59   * database.
60   * </p>
61   *
62   * @author    Brian Wing Shun Chan
63   * @see       PollsQuestionImpl
64   * @see       com.liferay.portlet.polls.model.PollsQuestion
65   * @see       com.liferay.portlet.polls.model.PollsQuestionModel
66   * @generated
67   */
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         if (_uuid == null) {
147             return StringPool.BLANK;
148         }
149         else {
150             return _uuid;
151         }
152     }
153 
154     public void setUuid(String uuid) {
155         _uuid = uuid;
156 
157         if (_originalUuid == null) {
158             _originalUuid = uuid;
159         }
160     }
161 
162     public String getOriginalUuid() {
163         return GetterUtil.getString(_originalUuid);
164     }
165 
166     public long getQuestionId() {
167         return _questionId;
168     }
169 
170     public void setQuestionId(long questionId) {
171         _questionId = questionId;
172     }
173 
174     public long getGroupId() {
175         return _groupId;
176     }
177 
178     public void setGroupId(long groupId) {
179         _groupId = groupId;
180 
181         if (!_setOriginalGroupId) {
182             _setOriginalGroupId = true;
183 
184             _originalGroupId = groupId;
185         }
186     }
187 
188     public long getOriginalGroupId() {
189         return _originalGroupId;
190     }
191 
192     public long getCompanyId() {
193         return _companyId;
194     }
195 
196     public void setCompanyId(long companyId) {
197         _companyId = companyId;
198     }
199 
200     public long getUserId() {
201         return _userId;
202     }
203 
204     public void setUserId(long userId) {
205         _userId = userId;
206     }
207 
208     public String getUserUuid() throws SystemException {
209         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
210     }
211 
212     public void setUserUuid(String userUuid) {
213         _userUuid = userUuid;
214     }
215 
216     public String getUserName() {
217         if (_userName == null) {
218             return StringPool.BLANK;
219         }
220         else {
221             return _userName;
222         }
223     }
224 
225     public void setUserName(String userName) {
226         _userName = userName;
227     }
228 
229     public Date getCreateDate() {
230         return _createDate;
231     }
232 
233     public void setCreateDate(Date createDate) {
234         _createDate = createDate;
235     }
236 
237     public Date getModifiedDate() {
238         return _modifiedDate;
239     }
240 
241     public void setModifiedDate(Date modifiedDate) {
242         _modifiedDate = modifiedDate;
243     }
244 
245     public String getTitle() {
246         if (_title == null) {
247             return StringPool.BLANK;
248         }
249         else {
250             return _title;
251         }
252     }
253 
254     public String getTitle(Locale locale) {
255         String languageId = LocaleUtil.toLanguageId(locale);
256 
257         return getTitle(languageId);
258     }
259 
260     public String getTitle(Locale locale, boolean useDefault) {
261         String languageId = LocaleUtil.toLanguageId(locale);
262 
263         return getTitle(languageId, useDefault);
264     }
265 
266     public String getTitle(String languageId) {
267         String value = LocalizationUtil.getLocalization(getTitle(), languageId);
268 
269         if (isEscapedModel()) {
270             return HtmlUtil.escape(value);
271         }
272         else {
273             return value;
274         }
275     }
276 
277     public String getTitle(String languageId, boolean useDefault) {
278         String value = LocalizationUtil.getLocalization(getTitle(), languageId,
279                 useDefault);
280 
281         if (isEscapedModel()) {
282             return HtmlUtil.escape(value);
283         }
284         else {
285             return value;
286         }
287     }
288 
289     public Map<Locale, String> getTitleMap() {
290         return LocalizationUtil.getLocalizationMap(getTitle());
291     }
292 
293     public void setTitle(String title) {
294         _title = title;
295     }
296 
297     public void setTitle(Locale locale, String title) {
298         String languageId = LocaleUtil.toLanguageId(locale);
299 
300         if (Validator.isNotNull(title)) {
301             setTitle(LocalizationUtil.updateLocalization(getTitle(), "Title",
302                     title, languageId));
303         }
304         else {
305             setTitle(LocalizationUtil.removeLocalization(getTitle(), "Title",
306                     languageId));
307         }
308     }
309 
310     public void setTitleMap(Map<Locale, String> titleMap) {
311         if (titleMap == null) {
312             return;
313         }
314 
315         Locale[] locales = LanguageUtil.getAvailableLocales();
316 
317         for (Locale locale : locales) {
318             String title = titleMap.get(locale);
319 
320             setTitle(locale, title);
321         }
322     }
323 
324     public String getDescription() {
325         if (_description == null) {
326             return StringPool.BLANK;
327         }
328         else {
329             return _description;
330         }
331     }
332 
333     public String getDescription(Locale locale) {
334         String languageId = LocaleUtil.toLanguageId(locale);
335 
336         return getDescription(languageId);
337     }
338 
339     public String getDescription(Locale locale, boolean useDefault) {
340         String languageId = LocaleUtil.toLanguageId(locale);
341 
342         return getDescription(languageId, useDefault);
343     }
344 
345     public String getDescription(String languageId) {
346         String value = LocalizationUtil.getLocalization(getDescription(),
347                 languageId);
348 
349         if (isEscapedModel()) {
350             return HtmlUtil.escape(value);
351         }
352         else {
353             return value;
354         }
355     }
356 
357     public String getDescription(String languageId, boolean useDefault) {
358         String value = LocalizationUtil.getLocalization(getDescription(),
359                 languageId, useDefault);
360 
361         if (isEscapedModel()) {
362             return HtmlUtil.escape(value);
363         }
364         else {
365             return value;
366         }
367     }
368 
369     public Map<Locale, String> getDescriptionMap() {
370         return LocalizationUtil.getLocalizationMap(getDescription());
371     }
372 
373     public void setDescription(String description) {
374         _description = description;
375     }
376 
377     public void setDescription(Locale locale, String description) {
378         String languageId = LocaleUtil.toLanguageId(locale);
379 
380         if (Validator.isNotNull(description)) {
381             setDescription(LocalizationUtil.updateLocalization(
382                     getDescription(), "Description", description, languageId));
383         }
384         else {
385             setDescription(LocalizationUtil.removeLocalization(
386                     getDescription(), "Description", languageId));
387         }
388     }
389 
390     public void setDescriptionMap(Map<Locale, String> descriptionMap) {
391         if (descriptionMap == null) {
392             return;
393         }
394 
395         Locale[] locales = LanguageUtil.getAvailableLocales();
396 
397         for (Locale locale : locales) {
398             String description = descriptionMap.get(locale);
399 
400             setDescription(locale, description);
401         }
402     }
403 
404     public Date getExpirationDate() {
405         return _expirationDate;
406     }
407 
408     public void setExpirationDate(Date expirationDate) {
409         _expirationDate = expirationDate;
410     }
411 
412     public Date getLastVoteDate() {
413         return _lastVoteDate;
414     }
415 
416     public void setLastVoteDate(Date lastVoteDate) {
417         _lastVoteDate = lastVoteDate;
418     }
419 
420     public PollsQuestion toEscapedModel() {
421         if (isEscapedModel()) {
422             return (PollsQuestion)this;
423         }
424         else {
425             return (PollsQuestion)Proxy.newProxyInstance(PollsQuestion.class.getClassLoader(),
426                 new Class[] { PollsQuestion.class },
427                 new AutoEscapeBeanHandler(this));
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 }