1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.polls.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  import com.liferay.portal.service.ServiceContext;
23  import com.liferay.portal.util.PortalUtil;
24  
25  import com.liferay.portlet.expando.model.ExpandoBridge;
26  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
27  import com.liferay.portlet.polls.model.PollsVote;
28  import com.liferay.portlet.polls.model.PollsVoteSoap;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <a href="PollsVoteModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This interface is a model that represents the PollsVote table in the
50   * database.
51   * </p>
52   *
53   * @author    Brian Wing Shun Chan
54   * @see       PollsVoteImpl
55   * @see       com.liferay.portlet.polls.model.PollsVote
56   * @see       com.liferay.portlet.polls.model.PollsVoteModel
57   * @generated
58   */
59  public class PollsVoteModelImpl extends BaseModelImpl<PollsVote> {
60      public static final String TABLE_NAME = "PollsVote";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "voteId", new Integer(Types.BIGINT) },
63              { "userId", new Integer(Types.BIGINT) },
64              { "questionId", new Integer(Types.BIGINT) },
65              { "choiceId", new Integer(Types.BIGINT) },
66              { "voteDate", new Integer(Types.TIMESTAMP) }
67          };
68      public static final String TABLE_SQL_CREATE = "create table PollsVote (voteId LONG not null primary key,userId LONG,questionId LONG,choiceId LONG,voteDate DATE null)";
69      public static final String TABLE_SQL_DROP = "drop table PollsVote";
70      public static final String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
75              true);
76      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
78              true);
79  
80      public static PollsVote toModel(PollsVoteSoap soapModel) {
81          PollsVote model = new PollsVoteImpl();
82  
83          model.setVoteId(soapModel.getVoteId());
84          model.setUserId(soapModel.getUserId());
85          model.setQuestionId(soapModel.getQuestionId());
86          model.setChoiceId(soapModel.getChoiceId());
87          model.setVoteDate(soapModel.getVoteDate());
88  
89          return model;
90      }
91  
92      public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
93          List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
94  
95          for (PollsVoteSoap soapModel : soapModels) {
96              models.add(toModel(soapModel));
97          }
98  
99          return models;
100     }
101 
102     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
103                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
104 
105     public PollsVoteModelImpl() {
106     }
107 
108     public long getPrimaryKey() {
109         return _voteId;
110     }
111 
112     public void setPrimaryKey(long pk) {
113         setVoteId(pk);
114     }
115 
116     public Serializable getPrimaryKeyObj() {
117         return new Long(_voteId);
118     }
119 
120     public long getVoteId() {
121         return _voteId;
122     }
123 
124     public void setVoteId(long voteId) {
125         _voteId = voteId;
126     }
127 
128     public long getUserId() {
129         return _userId;
130     }
131 
132     public void setUserId(long userId) {
133         _userId = userId;
134 
135         if (!_setOriginalUserId) {
136             _setOriginalUserId = true;
137 
138             _originalUserId = userId;
139         }
140     }
141 
142     public String getUserUuid() throws SystemException {
143         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
144     }
145 
146     public void setUserUuid(String userUuid) {
147         _userUuid = userUuid;
148     }
149 
150     public long getOriginalUserId() {
151         return _originalUserId;
152     }
153 
154     public long getQuestionId() {
155         return _questionId;
156     }
157 
158     public void setQuestionId(long questionId) {
159         _questionId = questionId;
160 
161         if (!_setOriginalQuestionId) {
162             _setOriginalQuestionId = true;
163 
164             _originalQuestionId = questionId;
165         }
166     }
167 
168     public long getOriginalQuestionId() {
169         return _originalQuestionId;
170     }
171 
172     public long getChoiceId() {
173         return _choiceId;
174     }
175 
176     public void setChoiceId(long choiceId) {
177         _choiceId = choiceId;
178     }
179 
180     public Date getVoteDate() {
181         return _voteDate;
182     }
183 
184     public void setVoteDate(Date voteDate) {
185         _voteDate = voteDate;
186     }
187 
188     public PollsVote toEscapedModel() {
189         if (isEscapedModel()) {
190             return (PollsVote)this;
191         }
192         else {
193             PollsVote model = new PollsVoteImpl();
194 
195             model.setNew(isNew());
196             model.setEscapedModel(true);
197 
198             model.setVoteId(getVoteId());
199             model.setUserId(getUserId());
200             model.setQuestionId(getQuestionId());
201             model.setChoiceId(getChoiceId());
202             model.setVoteDate(getVoteDate());
203 
204             model = (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
205                     new Class[] { PollsVote.class },
206                     new ReadOnlyBeanHandler(model));
207 
208             return model;
209         }
210     }
211 
212     public ExpandoBridge getExpandoBridge() {
213         if (_expandoBridge == null) {
214             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
215                     PollsVote.class.getName(), getPrimaryKey());
216         }
217 
218         return _expandoBridge;
219     }
220 
221     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
222         getExpandoBridge().setAttributes(serviceContext);
223     }
224 
225     public Object clone() {
226         PollsVoteImpl clone = new PollsVoteImpl();
227 
228         clone.setVoteId(getVoteId());
229         clone.setUserId(getUserId());
230         clone.setQuestionId(getQuestionId());
231         clone.setChoiceId(getChoiceId());
232         clone.setVoteDate(getVoteDate());
233 
234         return clone;
235     }
236 
237     public int compareTo(PollsVote pollsVote) {
238         long pk = pollsVote.getPrimaryKey();
239 
240         if (getPrimaryKey() < pk) {
241             return -1;
242         }
243         else if (getPrimaryKey() > pk) {
244             return 1;
245         }
246         else {
247             return 0;
248         }
249     }
250 
251     public boolean equals(Object obj) {
252         if (obj == null) {
253             return false;
254         }
255 
256         PollsVote pollsVote = null;
257 
258         try {
259             pollsVote = (PollsVote)obj;
260         }
261         catch (ClassCastException cce) {
262             return false;
263         }
264 
265         long pk = pollsVote.getPrimaryKey();
266 
267         if (getPrimaryKey() == pk) {
268             return true;
269         }
270         else {
271             return false;
272         }
273     }
274 
275     public int hashCode() {
276         return (int)getPrimaryKey();
277     }
278 
279     public String toString() {
280         StringBundler sb = new StringBundler(11);
281 
282         sb.append("{voteId=");
283         sb.append(getVoteId());
284         sb.append(", userId=");
285         sb.append(getUserId());
286         sb.append(", questionId=");
287         sb.append(getQuestionId());
288         sb.append(", choiceId=");
289         sb.append(getChoiceId());
290         sb.append(", voteDate=");
291         sb.append(getVoteDate());
292         sb.append("}");
293 
294         return sb.toString();
295     }
296 
297     public String toXmlString() {
298         StringBundler sb = new StringBundler(19);
299 
300         sb.append("<model><model-name>");
301         sb.append("com.liferay.portlet.polls.model.PollsVote");
302         sb.append("</model-name>");
303 
304         sb.append(
305             "<column><column-name>voteId</column-name><column-value><![CDATA[");
306         sb.append(getVoteId());
307         sb.append("]]></column-value></column>");
308         sb.append(
309             "<column><column-name>userId</column-name><column-value><![CDATA[");
310         sb.append(getUserId());
311         sb.append("]]></column-value></column>");
312         sb.append(
313             "<column><column-name>questionId</column-name><column-value><![CDATA[");
314         sb.append(getQuestionId());
315         sb.append("]]></column-value></column>");
316         sb.append(
317             "<column><column-name>choiceId</column-name><column-value><![CDATA[");
318         sb.append(getChoiceId());
319         sb.append("]]></column-value></column>");
320         sb.append(
321             "<column><column-name>voteDate</column-name><column-value><![CDATA[");
322         sb.append(getVoteDate());
323         sb.append("]]></column-value></column>");
324 
325         sb.append("</model>");
326 
327         return sb.toString();
328     }
329 
330     private long _voteId;
331     private long _userId;
332     private String _userUuid;
333     private long _originalUserId;
334     private boolean _setOriginalUserId;
335     private long _questionId;
336     private long _originalQuestionId;
337     private boolean _setOriginalQuestionId;
338     private long _choiceId;
339     private Date _voteDate;
340     private transient ExpandoBridge _expandoBridge;
341 }