1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.polls.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
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             return (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
194                 new Class[] { PollsVote.class }, new AutoEscapeBeanHandler(this));
195         }
196     }
197 
198     public ExpandoBridge getExpandoBridge() {
199         if (_expandoBridge == null) {
200             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(PollsVote.class.getName(),
201                     getPrimaryKey());
202         }
203 
204         return _expandoBridge;
205     }
206 
207     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
208         getExpandoBridge().setAttributes(serviceContext);
209     }
210 
211     public Object clone() {
212         PollsVoteImpl clone = new PollsVoteImpl();
213 
214         clone.setVoteId(getVoteId());
215         clone.setUserId(getUserId());
216         clone.setQuestionId(getQuestionId());
217         clone.setChoiceId(getChoiceId());
218         clone.setVoteDate(getVoteDate());
219 
220         return clone;
221     }
222 
223     public int compareTo(PollsVote pollsVote) {
224         long pk = pollsVote.getPrimaryKey();
225 
226         if (getPrimaryKey() < pk) {
227             return -1;
228         }
229         else if (getPrimaryKey() > pk) {
230             return 1;
231         }
232         else {
233             return 0;
234         }
235     }
236 
237     public boolean equals(Object obj) {
238         if (obj == null) {
239             return false;
240         }
241 
242         PollsVote pollsVote = null;
243 
244         try {
245             pollsVote = (PollsVote)obj;
246         }
247         catch (ClassCastException cce) {
248             return false;
249         }
250 
251         long pk = pollsVote.getPrimaryKey();
252 
253         if (getPrimaryKey() == pk) {
254             return true;
255         }
256         else {
257             return false;
258         }
259     }
260 
261     public int hashCode() {
262         return (int)getPrimaryKey();
263     }
264 
265     public String toString() {
266         StringBundler sb = new StringBundler(11);
267 
268         sb.append("{voteId=");
269         sb.append(getVoteId());
270         sb.append(", userId=");
271         sb.append(getUserId());
272         sb.append(", questionId=");
273         sb.append(getQuestionId());
274         sb.append(", choiceId=");
275         sb.append(getChoiceId());
276         sb.append(", voteDate=");
277         sb.append(getVoteDate());
278         sb.append("}");
279 
280         return sb.toString();
281     }
282 
283     public String toXmlString() {
284         StringBundler sb = new StringBundler(19);
285 
286         sb.append("<model><model-name>");
287         sb.append("com.liferay.portlet.polls.model.PollsVote");
288         sb.append("</model-name>");
289 
290         sb.append(
291             "<column><column-name>voteId</column-name><column-value><![CDATA[");
292         sb.append(getVoteId());
293         sb.append("]]></column-value></column>");
294         sb.append(
295             "<column><column-name>userId</column-name><column-value><![CDATA[");
296         sb.append(getUserId());
297         sb.append("]]></column-value></column>");
298         sb.append(
299             "<column><column-name>questionId</column-name><column-value><![CDATA[");
300         sb.append(getQuestionId());
301         sb.append("]]></column-value></column>");
302         sb.append(
303             "<column><column-name>choiceId</column-name><column-value><![CDATA[");
304         sb.append(getChoiceId());
305         sb.append("]]></column-value></column>");
306         sb.append(
307             "<column><column-name>voteDate</column-name><column-value><![CDATA[");
308         sb.append(getVoteDate());
309         sb.append("]]></column-value></column>");
310 
311         sb.append("</model>");
312 
313         return sb.toString();
314     }
315 
316     private long _voteId;
317     private long _userId;
318     private String _userUuid;
319     private long _originalUserId;
320     private boolean _setOriginalUserId;
321     private long _questionId;
322     private long _originalQuestionId;
323     private boolean _setOriginalQuestionId;
324     private long _choiceId;
325     private Date _voteDate;
326     private transient ExpandoBridge _expandoBridge;
327 }