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 {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
110                 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
111             true);
112 
113     public static PollsQuestion toModel(PollsQuestionSoap soapModel) {
114         PollsQuestion model = new PollsQuestionImpl();
115 
116         model.setUuid(soapModel.getUuid());
117         model.setQuestionId(soapModel.getQuestionId());
118         model.setGroupId(soapModel.getGroupId());
119         model.setCompanyId(soapModel.getCompanyId());
120         model.setUserId(soapModel.getUserId());
121         model.setUserName(soapModel.getUserName());
122         model.setCreateDate(soapModel.getCreateDate());
123         model.setModifiedDate(soapModel.getModifiedDate());
124         model.setTitle(soapModel.getTitle());
125         model.setDescription(soapModel.getDescription());
126         model.setExpirationDate(soapModel.getExpirationDate());
127         model.setLastVoteDate(soapModel.getLastVoteDate());
128 
129         return model;
130     }
131 
132     public static List<PollsQuestion> toModels(PollsQuestionSoap[] soapModels) {
133         List<PollsQuestion> models = new ArrayList<PollsQuestion>(soapModels.length);
134 
135         for (PollsQuestionSoap soapModel : soapModels) {
136             models.add(toModel(soapModel));
137         }
138 
139         return models;
140     }
141 
142     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
143                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsQuestion"));
144 
145     public PollsQuestionModelImpl() {
146     }
147 
148     public long getPrimaryKey() {
149         return _questionId;
150     }
151 
152     public void setPrimaryKey(long pk) {
153         setQuestionId(pk);
154     }
155 
156     public Serializable getPrimaryKeyObj() {
157         return new Long(_questionId);
158     }
159 
160     public String getUuid() {
161         return GetterUtil.getString(_uuid);
162     }
163 
164     public void setUuid(String uuid) {
165         if ((uuid != null) && (uuid != _uuid)) {
166             _uuid = uuid;
167         }
168     }
169 
170     public long getQuestionId() {
171         return _questionId;
172     }
173 
174     public void setQuestionId(long questionId) {
175         if (questionId != _questionId) {
176             _questionId = questionId;
177         }
178     }
179 
180     public long getGroupId() {
181         return _groupId;
182     }
183 
184     public void setGroupId(long groupId) {
185         if (groupId != _groupId) {
186             _groupId = groupId;
187         }
188     }
189 
190     public long getCompanyId() {
191         return _companyId;
192     }
193 
194     public void setCompanyId(long companyId) {
195         if (companyId != _companyId) {
196             _companyId = companyId;
197         }
198     }
199 
200     public long getUserId() {
201         return _userId;
202     }
203 
204     public void setUserId(long userId) {
205         if (userId != _userId) {
206             _userId = userId;
207         }
208     }
209 
210     public String getUserName() {
211         return GetterUtil.getString(_userName);
212     }
213 
214     public void setUserName(String userName) {
215         if (((userName == null) && (_userName != null)) ||
216                 ((userName != null) && (_userName == null)) ||
217                 ((userName != null) && (_userName != null) &&
218                 !userName.equals(_userName))) {
219             _userName = userName;
220         }
221     }
222 
223     public Date getCreateDate() {
224         return _createDate;
225     }
226 
227     public void setCreateDate(Date createDate) {
228         if (((createDate == null) && (_createDate != null)) ||
229                 ((createDate != null) && (_createDate == null)) ||
230                 ((createDate != null) && (_createDate != null) &&
231                 !createDate.equals(_createDate))) {
232             _createDate = createDate;
233         }
234     }
235 
236     public Date getModifiedDate() {
237         return _modifiedDate;
238     }
239 
240     public void setModifiedDate(Date modifiedDate) {
241         if (((modifiedDate == null) && (_modifiedDate != null)) ||
242                 ((modifiedDate != null) && (_modifiedDate == null)) ||
243                 ((modifiedDate != null) && (_modifiedDate != null) &&
244                 !modifiedDate.equals(_modifiedDate))) {
245             _modifiedDate = modifiedDate;
246         }
247     }
248 
249     public String getTitle() {
250         return GetterUtil.getString(_title);
251     }
252 
253     public void setTitle(String title) {
254         if (((title == null) && (_title != null)) ||
255                 ((title != null) && (_title == null)) ||
256                 ((title != null) && (_title != null) && !title.equals(_title))) {
257             _title = title;
258         }
259     }
260 
261     public String getDescription() {
262         return GetterUtil.getString(_description);
263     }
264 
265     public void setDescription(String description) {
266         if (((description == null) && (_description != null)) ||
267                 ((description != null) && (_description == null)) ||
268                 ((description != null) && (_description != null) &&
269                 !description.equals(_description))) {
270             _description = description;
271         }
272     }
273 
274     public Date getExpirationDate() {
275         return _expirationDate;
276     }
277 
278     public void setExpirationDate(Date expirationDate) {
279         if (((expirationDate == null) && (_expirationDate != null)) ||
280                 ((expirationDate != null) && (_expirationDate == null)) ||
281                 ((expirationDate != null) && (_expirationDate != null) &&
282                 !expirationDate.equals(_expirationDate))) {
283             _expirationDate = expirationDate;
284         }
285     }
286 
287     public Date getLastVoteDate() {
288         return _lastVoteDate;
289     }
290 
291     public void setLastVoteDate(Date lastVoteDate) {
292         if (((lastVoteDate == null) && (_lastVoteDate != null)) ||
293                 ((lastVoteDate != null) && (_lastVoteDate == null)) ||
294                 ((lastVoteDate != null) && (_lastVoteDate != null) &&
295                 !lastVoteDate.equals(_lastVoteDate))) {
296             _lastVoteDate = lastVoteDate;
297         }
298     }
299 
300     public PollsQuestion toEscapedModel() {
301         if (isEscapedModel()) {
302             return (PollsQuestion)this;
303         }
304         else {
305             PollsQuestion model = new PollsQuestionImpl();
306 
307             model.setNew(isNew());
308             model.setEscapedModel(true);
309 
310             model.setUuid(HtmlUtil.escape(getUuid()));
311             model.setQuestionId(getQuestionId());
312             model.setGroupId(getGroupId());
313             model.setCompanyId(getCompanyId());
314             model.setUserId(getUserId());
315             model.setUserName(HtmlUtil.escape(getUserName()));
316             model.setCreateDate(getCreateDate());
317             model.setModifiedDate(getModifiedDate());
318             model.setTitle(HtmlUtil.escape(getTitle()));
319             model.setDescription(HtmlUtil.escape(getDescription()));
320             model.setExpirationDate(getExpirationDate());
321             model.setLastVoteDate(getLastVoteDate());
322 
323             model = (PollsQuestion)Proxy.newProxyInstance(PollsQuestion.class.getClassLoader(),
324                     new Class[] { PollsQuestion.class },
325                     new ReadOnlyBeanHandler(model));
326 
327             return model;
328         }
329     }
330 
331     public ExpandoBridge getExpandoBridge() {
332         if (_expandoBridge == null) {
333             _expandoBridge = new ExpandoBridgeImpl(PollsQuestion.class.getName(),
334                     getPrimaryKey());
335         }
336 
337         return _expandoBridge;
338     }
339 
340     public Object clone() {
341         PollsQuestionImpl clone = new PollsQuestionImpl();
342 
343         clone.setUuid(getUuid());
344         clone.setQuestionId(getQuestionId());
345         clone.setGroupId(getGroupId());
346         clone.setCompanyId(getCompanyId());
347         clone.setUserId(getUserId());
348         clone.setUserName(getUserName());
349         clone.setCreateDate(getCreateDate());
350         clone.setModifiedDate(getModifiedDate());
351         clone.setTitle(getTitle());
352         clone.setDescription(getDescription());
353         clone.setExpirationDate(getExpirationDate());
354         clone.setLastVoteDate(getLastVoteDate());
355 
356         return clone;
357     }
358 
359     public int compareTo(Object obj) {
360         if (obj == null) {
361             return -1;
362         }
363 
364         PollsQuestionImpl pollsQuestion = (PollsQuestionImpl)obj;
365 
366         int value = 0;
367 
368         value = DateUtil.compareTo(getCreateDate(),
369                 pollsQuestion.getCreateDate());
370 
371         value = value * -1;
372 
373         if (value != 0) {
374             return value;
375         }
376 
377         return 0;
378     }
379 
380     public boolean equals(Object obj) {
381         if (obj == null) {
382             return false;
383         }
384 
385         PollsQuestionImpl pollsQuestion = null;
386 
387         try {
388             pollsQuestion = (PollsQuestionImpl)obj;
389         }
390         catch (ClassCastException cce) {
391             return false;
392         }
393 
394         long pk = pollsQuestion.getPrimaryKey();
395 
396         if (getPrimaryKey() == pk) {
397             return true;
398         }
399         else {
400             return false;
401         }
402     }
403 
404     public int hashCode() {
405         return (int)getPrimaryKey();
406     }
407 
408     private String _uuid;
409     private long _questionId;
410     private long _groupId;
411     private long _companyId;
412     private long _userId;
413     private String _userName;
414     private Date _createDate;
415     private Date _modifiedDate;
416     private String _title;
417     private String _description;
418     private Date _expirationDate;
419     private Date _lastVoteDate;
420     private transient ExpandoBridge _expandoBridge;
421 }