1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portlet.polls.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
19  import com.liferay.portal.kernel.util.DateUtil;
20  import com.liferay.portal.kernel.util.GetterUtil;
21  import com.liferay.portal.kernel.util.HtmlUtil;
22  import com.liferay.portal.kernel.util.StringBundler;
23  import com.liferay.portal.model.impl.BaseModelImpl;
24  import com.liferay.portal.util.PortalUtil;
25  
26  import com.liferay.portlet.polls.model.PollsQuestion;
27  import com.liferay.portlet.polls.model.PollsQuestionSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.Date;
37  import java.util.List;
38  
39  /**
40   * <a href="PollsQuestionModelImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * <p>
43   * ServiceBuilder generated this class. Modifications in this class will be
44   * overwritten the next time is generated.
45   * </p>
46   *
47   * <p>
48   * This interface is a model that represents the PollsQuestion table in the
49   * database.
50   * </p>
51   *
52   * @author    Brian Wing Shun Chan
53   * @see       PollsQuestionImpl
54   * @see       com.liferay.portlet.polls.model.PollsQuestion
55   * @see       com.liferay.portlet.polls.model.PollsQuestionModel
56   * @generated
57   */
58  public class PollsQuestionModelImpl extends BaseModelImpl<PollsQuestion> {
59      public static final String TABLE_NAME = "PollsQuestion";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "uuid_", new Integer(Types.VARCHAR) },
62              { "questionId", new Integer(Types.BIGINT) },
63              { "groupId", new Integer(Types.BIGINT) },
64              { "companyId", new Integer(Types.BIGINT) },
65              { "userId", new Integer(Types.BIGINT) },
66              { "userName", new Integer(Types.VARCHAR) },
67              { "createDate", new Integer(Types.TIMESTAMP) },
68              { "modifiedDate", new Integer(Types.TIMESTAMP) },
69              { "title", new Integer(Types.VARCHAR) },
70              { "description", new Integer(Types.VARCHAR) },
71              { "expirationDate", new Integer(Types.TIMESTAMP) },
72              { "lastVoteDate", new Integer(Types.TIMESTAMP) }
73          };
74      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 VARCHAR(500) null,description STRING null,expirationDate DATE null,lastVoteDate DATE null)";
75      public static final String TABLE_SQL_DROP = "drop table PollsQuestion";
76      public static final String ORDER_BY_JPQL = " ORDER BY pollsQuestion.createDate DESC";
77      public static final String ORDER_BY_SQL = " ORDER BY PollsQuestion.createDate DESC";
78      public static final String DATA_SOURCE = "liferayDataSource";
79      public static final String SESSION_FACTORY = "liferaySessionFactory";
80      public static final String TX_MANAGER = "liferayTransactionManager";
81      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82                  "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
83              true);
84      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85                  "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
86              true);
87  
88      public static PollsQuestion toModel(PollsQuestionSoap soapModel) {
89          PollsQuestion model = new PollsQuestionImpl();
90  
91          model.setUuid(soapModel.getUuid());
92          model.setQuestionId(soapModel.getQuestionId());
93          model.setGroupId(soapModel.getGroupId());
94          model.setCompanyId(soapModel.getCompanyId());
95          model.setUserId(soapModel.getUserId());
96          model.setUserName(soapModel.getUserName());
97          model.setCreateDate(soapModel.getCreateDate());
98          model.setModifiedDate(soapModel.getModifiedDate());
99          model.setTitle(soapModel.getTitle());
100         model.setDescription(soapModel.getDescription());
101         model.setExpirationDate(soapModel.getExpirationDate());
102         model.setLastVoteDate(soapModel.getLastVoteDate());
103 
104         return model;
105     }
106 
107     public static List<PollsQuestion> toModels(PollsQuestionSoap[] soapModels) {
108         List<PollsQuestion> models = new ArrayList<PollsQuestion>(soapModels.length);
109 
110         for (PollsQuestionSoap soapModel : soapModels) {
111             models.add(toModel(soapModel));
112         }
113 
114         return models;
115     }
116 
117     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
118                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsQuestion"));
119 
120     public PollsQuestionModelImpl() {
121     }
122 
123     public long getPrimaryKey() {
124         return _questionId;
125     }
126 
127     public void setPrimaryKey(long pk) {
128         setQuestionId(pk);
129     }
130 
131     public Serializable getPrimaryKeyObj() {
132         return new Long(_questionId);
133     }
134 
135     public String getUuid() {
136         return GetterUtil.getString(_uuid);
137     }
138 
139     public void setUuid(String uuid) {
140         _uuid = uuid;
141 
142         if (_originalUuid == null) {
143             _originalUuid = uuid;
144         }
145     }
146 
147     public String getOriginalUuid() {
148         return GetterUtil.getString(_originalUuid);
149     }
150 
151     public long getQuestionId() {
152         return _questionId;
153     }
154 
155     public void setQuestionId(long questionId) {
156         _questionId = questionId;
157     }
158 
159     public long getGroupId() {
160         return _groupId;
161     }
162 
163     public void setGroupId(long groupId) {
164         _groupId = groupId;
165 
166         if (!_setOriginalGroupId) {
167             _setOriginalGroupId = true;
168 
169             _originalGroupId = groupId;
170         }
171     }
172 
173     public long getOriginalGroupId() {
174         return _originalGroupId;
175     }
176 
177     public long getCompanyId() {
178         return _companyId;
179     }
180 
181     public void setCompanyId(long companyId) {
182         _companyId = companyId;
183     }
184 
185     public long getUserId() {
186         return _userId;
187     }
188 
189     public void setUserId(long userId) {
190         _userId = userId;
191     }
192 
193     public String getUserUuid() throws SystemException {
194         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
195     }
196 
197     public void setUserUuid(String userUuid) {
198         _userUuid = userUuid;
199     }
200 
201     public String getUserName() {
202         return GetterUtil.getString(_userName);
203     }
204 
205     public void setUserName(String userName) {
206         _userName = userName;
207     }
208 
209     public Date getCreateDate() {
210         return _createDate;
211     }
212 
213     public void setCreateDate(Date createDate) {
214         _createDate = createDate;
215     }
216 
217     public Date getModifiedDate() {
218         return _modifiedDate;
219     }
220 
221     public void setModifiedDate(Date modifiedDate) {
222         _modifiedDate = modifiedDate;
223     }
224 
225     public String getTitle() {
226         return GetterUtil.getString(_title);
227     }
228 
229     public void setTitle(String title) {
230         _title = title;
231     }
232 
233     public String getDescription() {
234         return GetterUtil.getString(_description);
235     }
236 
237     public void setDescription(String description) {
238         _description = description;
239     }
240 
241     public Date getExpirationDate() {
242         return _expirationDate;
243     }
244 
245     public void setExpirationDate(Date expirationDate) {
246         _expirationDate = expirationDate;
247     }
248 
249     public Date getLastVoteDate() {
250         return _lastVoteDate;
251     }
252 
253     public void setLastVoteDate(Date lastVoteDate) {
254         _lastVoteDate = lastVoteDate;
255     }
256 
257     public PollsQuestion toEscapedModel() {
258         if (isEscapedModel()) {
259             return (PollsQuestion)this;
260         }
261         else {
262             PollsQuestion model = new PollsQuestionImpl();
263 
264             model.setNew(isNew());
265             model.setEscapedModel(true);
266 
267             model.setUuid(HtmlUtil.escape(getUuid()));
268             model.setQuestionId(getQuestionId());
269             model.setGroupId(getGroupId());
270             model.setCompanyId(getCompanyId());
271             model.setUserId(getUserId());
272             model.setUserName(HtmlUtil.escape(getUserName()));
273             model.setCreateDate(getCreateDate());
274             model.setModifiedDate(getModifiedDate());
275             model.setTitle(HtmlUtil.escape(getTitle()));
276             model.setDescription(HtmlUtil.escape(getDescription()));
277             model.setExpirationDate(getExpirationDate());
278             model.setLastVoteDate(getLastVoteDate());
279 
280             model = (PollsQuestion)Proxy.newProxyInstance(PollsQuestion.class.getClassLoader(),
281                     new Class[] { PollsQuestion.class },
282                     new ReadOnlyBeanHandler(model));
283 
284             return model;
285         }
286     }
287 
288     public Object clone() {
289         PollsQuestionImpl clone = new PollsQuestionImpl();
290 
291         clone.setUuid(getUuid());
292         clone.setQuestionId(getQuestionId());
293         clone.setGroupId(getGroupId());
294         clone.setCompanyId(getCompanyId());
295         clone.setUserId(getUserId());
296         clone.setUserName(getUserName());
297         clone.setCreateDate(getCreateDate());
298         clone.setModifiedDate(getModifiedDate());
299         clone.setTitle(getTitle());
300         clone.setDescription(getDescription());
301         clone.setExpirationDate(getExpirationDate());
302         clone.setLastVoteDate(getLastVoteDate());
303 
304         return clone;
305     }
306 
307     public int compareTo(PollsQuestion pollsQuestion) {
308         int value = 0;
309 
310         value = DateUtil.compareTo(getCreateDate(),
311                 pollsQuestion.getCreateDate());
312 
313         value = value * -1;
314 
315         if (value != 0) {
316             return value;
317         }
318 
319         return 0;
320     }
321 
322     public boolean equals(Object obj) {
323         if (obj == null) {
324             return false;
325         }
326 
327         PollsQuestion pollsQuestion = null;
328 
329         try {
330             pollsQuestion = (PollsQuestion)obj;
331         }
332         catch (ClassCastException cce) {
333             return false;
334         }
335 
336         long pk = pollsQuestion.getPrimaryKey();
337 
338         if (getPrimaryKey() == pk) {
339             return true;
340         }
341         else {
342             return false;
343         }
344     }
345 
346     public int hashCode() {
347         return (int)getPrimaryKey();
348     }
349 
350     public String toString() {
351         StringBundler sb = new StringBundler(25);
352 
353         sb.append("{uuid=");
354         sb.append(getUuid());
355         sb.append(", questionId=");
356         sb.append(getQuestionId());
357         sb.append(", groupId=");
358         sb.append(getGroupId());
359         sb.append(", companyId=");
360         sb.append(getCompanyId());
361         sb.append(", userId=");
362         sb.append(getUserId());
363         sb.append(", userName=");
364         sb.append(getUserName());
365         sb.append(", createDate=");
366         sb.append(getCreateDate());
367         sb.append(", modifiedDate=");
368         sb.append(getModifiedDate());
369         sb.append(", title=");
370         sb.append(getTitle());
371         sb.append(", description=");
372         sb.append(getDescription());
373         sb.append(", expirationDate=");
374         sb.append(getExpirationDate());
375         sb.append(", lastVoteDate=");
376         sb.append(getLastVoteDate());
377         sb.append("}");
378 
379         return sb.toString();
380     }
381 
382     public String toXmlString() {
383         StringBundler sb = new StringBundler(40);
384 
385         sb.append("<model><model-name>");
386         sb.append("com.liferay.portlet.polls.model.PollsQuestion");
387         sb.append("</model-name>");
388 
389         sb.append(
390             "<column><column-name>uuid</column-name><column-value><![CDATA[");
391         sb.append(getUuid());
392         sb.append("]]></column-value></column>");
393         sb.append(
394             "<column><column-name>questionId</column-name><column-value><![CDATA[");
395         sb.append(getQuestionId());
396         sb.append("]]></column-value></column>");
397         sb.append(
398             "<column><column-name>groupId</column-name><column-value><![CDATA[");
399         sb.append(getGroupId());
400         sb.append("]]></column-value></column>");
401         sb.append(
402             "<column><column-name>companyId</column-name><column-value><![CDATA[");
403         sb.append(getCompanyId());
404         sb.append("]]></column-value></column>");
405         sb.append(
406             "<column><column-name>userId</column-name><column-value><![CDATA[");
407         sb.append(getUserId());
408         sb.append("]]></column-value></column>");
409         sb.append(
410             "<column><column-name>userName</column-name><column-value><![CDATA[");
411         sb.append(getUserName());
412         sb.append("]]></column-value></column>");
413         sb.append(
414             "<column><column-name>createDate</column-name><column-value><![CDATA[");
415         sb.append(getCreateDate());
416         sb.append("]]></column-value></column>");
417         sb.append(
418             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
419         sb.append(getModifiedDate());
420         sb.append("]]></column-value></column>");
421         sb.append(
422             "<column><column-name>title</column-name><column-value><![CDATA[");
423         sb.append(getTitle());
424         sb.append("]]></column-value></column>");
425         sb.append(
426             "<column><column-name>description</column-name><column-value><![CDATA[");
427         sb.append(getDescription());
428         sb.append("]]></column-value></column>");
429         sb.append(
430             "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
431         sb.append(getExpirationDate());
432         sb.append("]]></column-value></column>");
433         sb.append(
434             "<column><column-name>lastVoteDate</column-name><column-value><![CDATA[");
435         sb.append(getLastVoteDate());
436         sb.append("]]></column-value></column>");
437 
438         sb.append("</model>");
439 
440         return sb.toString();
441     }
442 
443     private String _uuid;
444     private String _originalUuid;
445     private long _questionId;
446     private long _groupId;
447     private long _originalGroupId;
448     private boolean _setOriginalGroupId;
449     private long _companyId;
450     private long _userId;
451     private String _userUuid;
452     private String _userName;
453     private Date _createDate;
454     private Date _modifiedDate;
455     private String _title;
456     private String _description;
457     private Date _expirationDate;
458     private Date _lastVoteDate;
459 }