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