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