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