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