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