1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.DateUtil;
28  import com.liferay.portal.kernel.util.GetterUtil;
29  import com.liferay.portal.kernel.util.HtmlUtil;
30  import com.liferay.portal.model.impl.BaseModelImpl;
31  import com.liferay.portal.util.PortalUtil;
32  
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 interface is a model that represents the PollsQuestion table in the
56   * database.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       PollsQuestionImpl
61   * @see       com.liferay.portlet.polls.model.PollsQuestion
62   * @see       com.liferay.portlet.polls.model.PollsQuestionModel
63   * @generated
64   */
65  public class PollsQuestionModelImpl extends BaseModelImpl<PollsQuestion> {
66      public static final String TABLE_NAME = "PollsQuestion";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "uuid_", new Integer(Types.VARCHAR) },
69              { "questionId", new Integer(Types.BIGINT) },
70              { "groupId", new Integer(Types.BIGINT) },
71              { "companyId", new Integer(Types.BIGINT) },
72              { "userId", new Integer(Types.BIGINT) },
73              { "userName", new Integer(Types.VARCHAR) },
74              { "createDate", new Integer(Types.TIMESTAMP) },
75              { "modifiedDate", new Integer(Types.TIMESTAMP) },
76              { "title", new Integer(Types.VARCHAR) },
77              { "description", new Integer(Types.VARCHAR) },
78              { "expirationDate", new Integer(Types.TIMESTAMP) },
79              { "lastVoteDate", new Integer(Types.TIMESTAMP) }
80          };
81      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)";
82      public static final String TABLE_SQL_DROP = "drop table PollsQuestion";
83      public static final String DATA_SOURCE = "liferayDataSource";
84      public static final String SESSION_FACTORY = "liferaySessionFactory";
85      public static final String TX_MANAGER = "liferayTransactionManager";
86      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87                  "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
88              true);
89      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
91              true);
92  
93      public static PollsQuestion toModel(PollsQuestionSoap soapModel) {
94          PollsQuestion model = new PollsQuestionImpl();
95  
96          model.setUuid(soapModel.getUuid());
97          model.setQuestionId(soapModel.getQuestionId());
98          model.setGroupId(soapModel.getGroupId());
99          model.setCompanyId(soapModel.getCompanyId());
100         model.setUserId(soapModel.getUserId());
101         model.setUserName(soapModel.getUserName());
102         model.setCreateDate(soapModel.getCreateDate());
103         model.setModifiedDate(soapModel.getModifiedDate());
104         model.setTitle(soapModel.getTitle());
105         model.setDescription(soapModel.getDescription());
106         model.setExpirationDate(soapModel.getExpirationDate());
107         model.setLastVoteDate(soapModel.getLastVoteDate());
108 
109         return model;
110     }
111 
112     public static List<PollsQuestion> toModels(PollsQuestionSoap[] soapModels) {
113         List<PollsQuestion> models = new ArrayList<PollsQuestion>(soapModels.length);
114 
115         for (PollsQuestionSoap soapModel : soapModels) {
116             models.add(toModel(soapModel));
117         }
118 
119         return models;
120     }
121 
122     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
123                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsQuestion"));
124 
125     public PollsQuestionModelImpl() {
126     }
127 
128     public long getPrimaryKey() {
129         return _questionId;
130     }
131 
132     public void setPrimaryKey(long pk) {
133         setQuestionId(pk);
134     }
135 
136     public Serializable getPrimaryKeyObj() {
137         return new Long(_questionId);
138     }
139 
140     public String getUuid() {
141         return GetterUtil.getString(_uuid);
142     }
143 
144     public void setUuid(String uuid) {
145         _uuid = uuid;
146 
147         if (_originalUuid == null) {
148             _originalUuid = uuid;
149         }
150     }
151 
152     public String getOriginalUuid() {
153         return GetterUtil.getString(_originalUuid);
154     }
155 
156     public long getQuestionId() {
157         return _questionId;
158     }
159 
160     public void setQuestionId(long questionId) {
161         _questionId = questionId;
162     }
163 
164     public long getGroupId() {
165         return _groupId;
166     }
167 
168     public void setGroupId(long groupId) {
169         _groupId = groupId;
170 
171         if (!_setOriginalGroupId) {
172             _setOriginalGroupId = true;
173 
174             _originalGroupId = groupId;
175         }
176     }
177 
178     public long getOriginalGroupId() {
179         return _originalGroupId;
180     }
181 
182     public long getCompanyId() {
183         return _companyId;
184     }
185 
186     public void setCompanyId(long companyId) {
187         _companyId = companyId;
188     }
189 
190     public long getUserId() {
191         return _userId;
192     }
193 
194     public void setUserId(long userId) {
195         _userId = userId;
196     }
197 
198     public String getUserUuid() throws SystemException {
199         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
200     }
201 
202     public void setUserUuid(String userUuid) {
203         _userUuid = userUuid;
204     }
205 
206     public String getUserName() {
207         return GetterUtil.getString(_userName);
208     }
209 
210     public void setUserName(String userName) {
211         _userName = userName;
212     }
213 
214     public Date getCreateDate() {
215         return _createDate;
216     }
217 
218     public void setCreateDate(Date createDate) {
219         _createDate = createDate;
220     }
221 
222     public Date getModifiedDate() {
223         return _modifiedDate;
224     }
225 
226     public void setModifiedDate(Date modifiedDate) {
227         _modifiedDate = modifiedDate;
228     }
229 
230     public String getTitle() {
231         return GetterUtil.getString(_title);
232     }
233 
234     public void setTitle(String title) {
235         _title = title;
236     }
237 
238     public String getDescription() {
239         return GetterUtil.getString(_description);
240     }
241 
242     public void setDescription(String description) {
243         _description = description;
244     }
245 
246     public Date getExpirationDate() {
247         return _expirationDate;
248     }
249 
250     public void setExpirationDate(Date expirationDate) {
251         _expirationDate = expirationDate;
252     }
253 
254     public Date getLastVoteDate() {
255         return _lastVoteDate;
256     }
257 
258     public void setLastVoteDate(Date lastVoteDate) {
259         _lastVoteDate = lastVoteDate;
260     }
261 
262     public PollsQuestion toEscapedModel() {
263         if (isEscapedModel()) {
264             return (PollsQuestion)this;
265         }
266         else {
267             PollsQuestion model = new PollsQuestionImpl();
268 
269             model.setNew(isNew());
270             model.setEscapedModel(true);
271 
272             model.setUuid(HtmlUtil.escape(getUuid()));
273             model.setQuestionId(getQuestionId());
274             model.setGroupId(getGroupId());
275             model.setCompanyId(getCompanyId());
276             model.setUserId(getUserId());
277             model.setUserName(HtmlUtil.escape(getUserName()));
278             model.setCreateDate(getCreateDate());
279             model.setModifiedDate(getModifiedDate());
280             model.setTitle(HtmlUtil.escape(getTitle()));
281             model.setDescription(HtmlUtil.escape(getDescription()));
282             model.setExpirationDate(getExpirationDate());
283             model.setLastVoteDate(getLastVoteDate());
284 
285             model = (PollsQuestion)Proxy.newProxyInstance(PollsQuestion.class.getClassLoader(),
286                     new Class[] { PollsQuestion.class },
287                     new ReadOnlyBeanHandler(model));
288 
289             return model;
290         }
291     }
292 
293     public Object clone() {
294         PollsQuestionImpl clone = new PollsQuestionImpl();
295 
296         clone.setUuid(getUuid());
297         clone.setQuestionId(getQuestionId());
298         clone.setGroupId(getGroupId());
299         clone.setCompanyId(getCompanyId());
300         clone.setUserId(getUserId());
301         clone.setUserName(getUserName());
302         clone.setCreateDate(getCreateDate());
303         clone.setModifiedDate(getModifiedDate());
304         clone.setTitle(getTitle());
305         clone.setDescription(getDescription());
306         clone.setExpirationDate(getExpirationDate());
307         clone.setLastVoteDate(getLastVoteDate());
308 
309         return clone;
310     }
311 
312     public int compareTo(PollsQuestion pollsQuestion) {
313         int value = 0;
314 
315         value = DateUtil.compareTo(getCreateDate(),
316                 pollsQuestion.getCreateDate());
317 
318         value = value * -1;
319 
320         if (value != 0) {
321             return value;
322         }
323 
324         return 0;
325     }
326 
327     public boolean equals(Object obj) {
328         if (obj == null) {
329             return false;
330         }
331 
332         PollsQuestion pollsQuestion = null;
333 
334         try {
335             pollsQuestion = (PollsQuestion)obj;
336         }
337         catch (ClassCastException cce) {
338             return false;
339         }
340 
341         long pk = pollsQuestion.getPrimaryKey();
342 
343         if (getPrimaryKey() == pk) {
344             return true;
345         }
346         else {
347             return false;
348         }
349     }
350 
351     public int hashCode() {
352         return (int)getPrimaryKey();
353     }
354 
355     public String toString() {
356         StringBuilder sb = new StringBuilder();
357 
358         sb.append("{uuid=");
359         sb.append(getUuid());
360         sb.append(", questionId=");
361         sb.append(getQuestionId());
362         sb.append(", groupId=");
363         sb.append(getGroupId());
364         sb.append(", companyId=");
365         sb.append(getCompanyId());
366         sb.append(", userId=");
367         sb.append(getUserId());
368         sb.append(", userName=");
369         sb.append(getUserName());
370         sb.append(", createDate=");
371         sb.append(getCreateDate());
372         sb.append(", modifiedDate=");
373         sb.append(getModifiedDate());
374         sb.append(", title=");
375         sb.append(getTitle());
376         sb.append(", description=");
377         sb.append(getDescription());
378         sb.append(", expirationDate=");
379         sb.append(getExpirationDate());
380         sb.append(", lastVoteDate=");
381         sb.append(getLastVoteDate());
382         sb.append("}");
383 
384         return sb.toString();
385     }
386 
387     public String toXmlString() {
388         StringBuilder sb = new StringBuilder();
389 
390         sb.append("<model><model-name>");
391         sb.append("com.liferay.portlet.polls.model.PollsQuestion");
392         sb.append("</model-name>");
393 
394         sb.append(
395             "<column><column-name>uuid</column-name><column-value><![CDATA[");
396         sb.append(getUuid());
397         sb.append("]]></column-value></column>");
398         sb.append(
399             "<column><column-name>questionId</column-name><column-value><![CDATA[");
400         sb.append(getQuestionId());
401         sb.append("]]></column-value></column>");
402         sb.append(
403             "<column><column-name>groupId</column-name><column-value><![CDATA[");
404         sb.append(getGroupId());
405         sb.append("]]></column-value></column>");
406         sb.append(
407             "<column><column-name>companyId</column-name><column-value><![CDATA[");
408         sb.append(getCompanyId());
409         sb.append("]]></column-value></column>");
410         sb.append(
411             "<column><column-name>userId</column-name><column-value><![CDATA[");
412         sb.append(getUserId());
413         sb.append("]]></column-value></column>");
414         sb.append(
415             "<column><column-name>userName</column-name><column-value><![CDATA[");
416         sb.append(getUserName());
417         sb.append("]]></column-value></column>");
418         sb.append(
419             "<column><column-name>createDate</column-name><column-value><![CDATA[");
420         sb.append(getCreateDate());
421         sb.append("]]></column-value></column>");
422         sb.append(
423             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
424         sb.append(getModifiedDate());
425         sb.append("]]></column-value></column>");
426         sb.append(
427             "<column><column-name>title</column-name><column-value><![CDATA[");
428         sb.append(getTitle());
429         sb.append("]]></column-value></column>");
430         sb.append(
431             "<column><column-name>description</column-name><column-value><![CDATA[");
432         sb.append(getDescription());
433         sb.append("]]></column-value></column>");
434         sb.append(
435             "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
436         sb.append(getExpirationDate());
437         sb.append("]]></column-value></column>");
438         sb.append(
439             "<column><column-name>lastVoteDate</column-name><column-value><![CDATA[");
440         sb.append(getLastVoteDate());
441         sb.append("]]></column-value></column>");
442 
443         sb.append("</model>");
444 
445         return sb.toString();
446     }
447 
448     private String _uuid;
449     private String _originalUuid;
450     private long _questionId;
451     private long _groupId;
452     private long _originalGroupId;
453     private boolean _setOriginalGroupId;
454     private long _companyId;
455     private long _userId;
456     private String _userUuid;
457     private String _userName;
458     private Date _createDate;
459     private Date _modifiedDate;
460     private String _title;
461     private String _description;
462     private Date _expirationDate;
463     private Date _lastVoteDate;
464 }