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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PortalUtil;
30  
31  import com.liferay.portlet.polls.model.PollsVote;
32  import com.liferay.portlet.polls.model.PollsVoteSoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="PollsVoteModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>PollsVote</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.polls.model.PollsVote
60   * @see com.liferay.portlet.polls.model.PollsVoteModel
61   * @see com.liferay.portlet.polls.model.impl.PollsVoteImpl
62   *
63   */
64  public class PollsVoteModelImpl extends BaseModelImpl<PollsVote> {
65      public static final String TABLE_NAME = "PollsVote";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "voteId", new Integer(Types.BIGINT) },
68              
69  
70              { "userId", new Integer(Types.BIGINT) },
71              
72  
73              { "questionId", new Integer(Types.BIGINT) },
74              
75  
76              { "choiceId", new Integer(Types.BIGINT) },
77              
78  
79              { "voteDate", new Integer(Types.TIMESTAMP) }
80          };
81      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)";
82      public static final String TABLE_SQL_DROP = "drop table PollsVote";
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.PollsVote"),
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.PollsVote"),
91              true);
92  
93      public static PollsVote toModel(PollsVoteSoap soapModel) {
94          PollsVote model = new PollsVoteImpl();
95  
96          model.setVoteId(soapModel.getVoteId());
97          model.setUserId(soapModel.getUserId());
98          model.setQuestionId(soapModel.getQuestionId());
99          model.setChoiceId(soapModel.getChoiceId());
100         model.setVoteDate(soapModel.getVoteDate());
101 
102         return model;
103     }
104 
105     public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
106         List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
107 
108         for (PollsVoteSoap soapModel : soapModels) {
109             models.add(toModel(soapModel));
110         }
111 
112         return models;
113     }
114 
115     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
116                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
117 
118     public PollsVoteModelImpl() {
119     }
120 
121     public long getPrimaryKey() {
122         return _voteId;
123     }
124 
125     public void setPrimaryKey(long pk) {
126         setVoteId(pk);
127     }
128 
129     public Serializable getPrimaryKeyObj() {
130         return new Long(_voteId);
131     }
132 
133     public long getVoteId() {
134         return _voteId;
135     }
136 
137     public void setVoteId(long voteId) {
138         _voteId = voteId;
139     }
140 
141     public long getUserId() {
142         return _userId;
143     }
144 
145     public void setUserId(long userId) {
146         _userId = userId;
147 
148         if (!_setOriginalUserId) {
149             _setOriginalUserId = true;
150 
151             _originalUserId = userId;
152         }
153     }
154 
155     public String getUserUuid() throws SystemException {
156         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
157     }
158 
159     public void setUserUuid(String userUuid) {
160         _userUuid = userUuid;
161     }
162 
163     public long getOriginalUserId() {
164         return _originalUserId;
165     }
166 
167     public long getQuestionId() {
168         return _questionId;
169     }
170 
171     public void setQuestionId(long questionId) {
172         _questionId = questionId;
173 
174         if (!_setOriginalQuestionId) {
175             _setOriginalQuestionId = true;
176 
177             _originalQuestionId = questionId;
178         }
179     }
180 
181     public long getOriginalQuestionId() {
182         return _originalQuestionId;
183     }
184 
185     public long getChoiceId() {
186         return _choiceId;
187     }
188 
189     public void setChoiceId(long choiceId) {
190         _choiceId = choiceId;
191     }
192 
193     public Date getVoteDate() {
194         return _voteDate;
195     }
196 
197     public void setVoteDate(Date voteDate) {
198         _voteDate = voteDate;
199     }
200 
201     public PollsVote toEscapedModel() {
202         if (isEscapedModel()) {
203             return (PollsVote)this;
204         }
205         else {
206             PollsVote model = new PollsVoteImpl();
207 
208             model.setNew(isNew());
209             model.setEscapedModel(true);
210 
211             model.setVoteId(getVoteId());
212             model.setUserId(getUserId());
213             model.setQuestionId(getQuestionId());
214             model.setChoiceId(getChoiceId());
215             model.setVoteDate(getVoteDate());
216 
217             model = (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
218                     new Class[] { PollsVote.class },
219                     new ReadOnlyBeanHandler(model));
220 
221             return model;
222         }
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         StringBuilder sb = new StringBuilder();
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         StringBuilder sb = new StringBuilder();
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 long _originalUserId;
333     private boolean _setOriginalUserId;
334     private String _userUuid;
335     private long _questionId;
336     private long _originalQuestionId;
337     private boolean _setOriginalQuestionId;
338     private long _choiceId;
339     private Date _voteDate;
340 }