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