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.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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 getUserName() {
222         return GetterUtil.getString(_userName);
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         return GetterUtil.getString(_title);
247     }
248 
249     public void setTitle(String title) {
250         _title = title;
251     }
252 
253     public String getDescription() {
254         return GetterUtil.getString(_description);
255     }
256 
257     public void setDescription(String description) {
258         _description = description;
259     }
260 
261     public Date getExpirationDate() {
262         return _expirationDate;
263     }
264 
265     public void setExpirationDate(Date expirationDate) {
266         _expirationDate = expirationDate;
267     }
268 
269     public Date getLastVoteDate() {
270         return _lastVoteDate;
271     }
272 
273     public void setLastVoteDate(Date lastVoteDate) {
274         _lastVoteDate = lastVoteDate;
275     }
276 
277     public PollsQuestion toEscapedModel() {
278         if (isEscapedModel()) {
279             return (PollsQuestion)this;
280         }
281         else {
282             PollsQuestion model = new PollsQuestionImpl();
283 
284             model.setNew(isNew());
285             model.setEscapedModel(true);
286 
287             model.setUuid(HtmlUtil.escape(getUuid()));
288             model.setQuestionId(getQuestionId());
289             model.setGroupId(getGroupId());
290             model.setCompanyId(getCompanyId());
291             model.setUserId(getUserId());
292             model.setUserName(HtmlUtil.escape(getUserName()));
293             model.setCreateDate(getCreateDate());
294             model.setModifiedDate(getModifiedDate());
295             model.setTitle(HtmlUtil.escape(getTitle()));
296             model.setDescription(HtmlUtil.escape(getDescription()));
297             model.setExpirationDate(getExpirationDate());
298             model.setLastVoteDate(getLastVoteDate());
299 
300             model = (PollsQuestion)Proxy.newProxyInstance(PollsQuestion.class.getClassLoader(),
301                     new Class[] { PollsQuestion.class },
302                     new ReadOnlyBeanHandler(model));
303 
304             return model;
305         }
306     }
307 
308     public ExpandoBridge getExpandoBridge() {
309         if (_expandoBridge == null) {
310             _expandoBridge = new ExpandoBridgeImpl(PollsQuestion.class.getName(),
311                     getPrimaryKey());
312         }
313 
314         return _expandoBridge;
315     }
316 
317     public Object clone() {
318         PollsQuestionImpl clone = new PollsQuestionImpl();
319 
320         clone.setUuid(getUuid());
321         clone.setQuestionId(getQuestionId());
322         clone.setGroupId(getGroupId());
323         clone.setCompanyId(getCompanyId());
324         clone.setUserId(getUserId());
325         clone.setUserName(getUserName());
326         clone.setCreateDate(getCreateDate());
327         clone.setModifiedDate(getModifiedDate());
328         clone.setTitle(getTitle());
329         clone.setDescription(getDescription());
330         clone.setExpirationDate(getExpirationDate());
331         clone.setLastVoteDate(getLastVoteDate());
332 
333         return clone;
334     }
335 
336     public int compareTo(PollsQuestion pollsQuestion) {
337         int value = 0;
338 
339         value = DateUtil.compareTo(getCreateDate(),
340                 pollsQuestion.getCreateDate());
341 
342         value = value * -1;
343 
344         if (value != 0) {
345             return value;
346         }
347 
348         return 0;
349     }
350 
351     public boolean equals(Object obj) {
352         if (obj == null) {
353             return false;
354         }
355 
356         PollsQuestion pollsQuestion = null;
357 
358         try {
359             pollsQuestion = (PollsQuestion)obj;
360         }
361         catch (ClassCastException cce) {
362             return false;
363         }
364 
365         long pk = pollsQuestion.getPrimaryKey();
366 
367         if (getPrimaryKey() == pk) {
368             return true;
369         }
370         else {
371             return false;
372         }
373     }
374 
375     public int hashCode() {
376         return (int)getPrimaryKey();
377     }
378 
379     public String toString() {
380         StringBuilder sb = new StringBuilder();
381 
382         sb.append("{uuid=");
383         sb.append(getUuid());
384         sb.append(", questionId=");
385         sb.append(getQuestionId());
386         sb.append(", groupId=");
387         sb.append(getGroupId());
388         sb.append(", companyId=");
389         sb.append(getCompanyId());
390         sb.append(", userId=");
391         sb.append(getUserId());
392         sb.append(", userName=");
393         sb.append(getUserName());
394         sb.append(", createDate=");
395         sb.append(getCreateDate());
396         sb.append(", modifiedDate=");
397         sb.append(getModifiedDate());
398         sb.append(", title=");
399         sb.append(getTitle());
400         sb.append(", description=");
401         sb.append(getDescription());
402         sb.append(", expirationDate=");
403         sb.append(getExpirationDate());
404         sb.append(", lastVoteDate=");
405         sb.append(getLastVoteDate());
406         sb.append("}");
407 
408         return sb.toString();
409     }
410 
411     public String toXmlString() {
412         StringBuilder sb = new StringBuilder();
413 
414         sb.append("<model><model-name>");
415         sb.append("com.liferay.portlet.polls.model.PollsQuestion");
416         sb.append("</model-name>");
417 
418         sb.append(
419             "<column><column-name>uuid</column-name><column-value><![CDATA[");
420         sb.append(getUuid());
421         sb.append("]]></column-value></column>");
422         sb.append(
423             "<column><column-name>questionId</column-name><column-value><![CDATA[");
424         sb.append(getQuestionId());
425         sb.append("]]></column-value></column>");
426         sb.append(
427             "<column><column-name>groupId</column-name><column-value><![CDATA[");
428         sb.append(getGroupId());
429         sb.append("]]></column-value></column>");
430         sb.append(
431             "<column><column-name>companyId</column-name><column-value><![CDATA[");
432         sb.append(getCompanyId());
433         sb.append("]]></column-value></column>");
434         sb.append(
435             "<column><column-name>userId</column-name><column-value><![CDATA[");
436         sb.append(getUserId());
437         sb.append("]]></column-value></column>");
438         sb.append(
439             "<column><column-name>userName</column-name><column-value><![CDATA[");
440         sb.append(getUserName());
441         sb.append("]]></column-value></column>");
442         sb.append(
443             "<column><column-name>createDate</column-name><column-value><![CDATA[");
444         sb.append(getCreateDate());
445         sb.append("]]></column-value></column>");
446         sb.append(
447             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
448         sb.append(getModifiedDate());
449         sb.append("]]></column-value></column>");
450         sb.append(
451             "<column><column-name>title</column-name><column-value><![CDATA[");
452         sb.append(getTitle());
453         sb.append("]]></column-value></column>");
454         sb.append(
455             "<column><column-name>description</column-name><column-value><![CDATA[");
456         sb.append(getDescription());
457         sb.append("]]></column-value></column>");
458         sb.append(
459             "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
460         sb.append(getExpirationDate());
461         sb.append("]]></column-value></column>");
462         sb.append(
463             "<column><column-name>lastVoteDate</column-name><column-value><![CDATA[");
464         sb.append(getLastVoteDate());
465         sb.append("]]></column-value></column>");
466 
467         sb.append("</model>");
468 
469         return sb.toString();
470     }
471 
472     private String _uuid;
473     private String _originalUuid;
474     private long _questionId;
475     private long _groupId;
476     private long _originalGroupId;
477     private boolean _setOriginalGroupId;
478     private long _companyId;
479     private long _userId;
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     private transient ExpandoBridge _expandoBridge;
488 }