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