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.expando.model.ExpandoBridge;
30  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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 long getOriginalUserId() {
156         return _originalUserId;
157     }
158 
159     public long getQuestionId() {
160         return _questionId;
161     }
162 
163     public void setQuestionId(long questionId) {
164         _questionId = questionId;
165 
166         if (!_setOriginalQuestionId) {
167             _setOriginalQuestionId = true;
168 
169             _originalQuestionId = questionId;
170         }
171     }
172 
173     public long getOriginalQuestionId() {
174         return _originalQuestionId;
175     }
176 
177     public long getChoiceId() {
178         return _choiceId;
179     }
180 
181     public void setChoiceId(long choiceId) {
182         _choiceId = choiceId;
183     }
184 
185     public Date getVoteDate() {
186         return _voteDate;
187     }
188 
189     public void setVoteDate(Date voteDate) {
190         _voteDate = voteDate;
191     }
192 
193     public PollsVote toEscapedModel() {
194         if (isEscapedModel()) {
195             return (PollsVote)this;
196         }
197         else {
198             PollsVote model = new PollsVoteImpl();
199 
200             model.setNew(isNew());
201             model.setEscapedModel(true);
202 
203             model.setVoteId(getVoteId());
204             model.setUserId(getUserId());
205             model.setQuestionId(getQuestionId());
206             model.setChoiceId(getChoiceId());
207             model.setVoteDate(getVoteDate());
208 
209             model = (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
210                     new Class[] { PollsVote.class },
211                     new ReadOnlyBeanHandler(model));
212 
213             return model;
214         }
215     }
216 
217     public ExpandoBridge getExpandoBridge() {
218         if (_expandoBridge == null) {
219             _expandoBridge = new ExpandoBridgeImpl(PollsVote.class.getName(),
220                     getPrimaryKey());
221         }
222 
223         return _expandoBridge;
224     }
225 
226     public Object clone() {
227         PollsVoteImpl clone = new PollsVoteImpl();
228 
229         clone.setVoteId(getVoteId());
230         clone.setUserId(getUserId());
231         clone.setQuestionId(getQuestionId());
232         clone.setChoiceId(getChoiceId());
233         clone.setVoteDate(getVoteDate());
234 
235         return clone;
236     }
237 
238     public int compareTo(PollsVote pollsVote) {
239         long pk = pollsVote.getPrimaryKey();
240 
241         if (getPrimaryKey() < pk) {
242             return -1;
243         }
244         else if (getPrimaryKey() > pk) {
245             return 1;
246         }
247         else {
248             return 0;
249         }
250     }
251 
252     public boolean equals(Object obj) {
253         if (obj == null) {
254             return false;
255         }
256 
257         PollsVote pollsVote = null;
258 
259         try {
260             pollsVote = (PollsVote)obj;
261         }
262         catch (ClassCastException cce) {
263             return false;
264         }
265 
266         long pk = pollsVote.getPrimaryKey();
267 
268         if (getPrimaryKey() == pk) {
269             return true;
270         }
271         else {
272             return false;
273         }
274     }
275 
276     public int hashCode() {
277         return (int)getPrimaryKey();
278     }
279 
280     public String toString() {
281         StringBuilder sb = new StringBuilder();
282 
283         sb.append("{voteId=");
284         sb.append(getVoteId());
285         sb.append(", userId=");
286         sb.append(getUserId());
287         sb.append(", questionId=");
288         sb.append(getQuestionId());
289         sb.append(", choiceId=");
290         sb.append(getChoiceId());
291         sb.append(", voteDate=");
292         sb.append(getVoteDate());
293         sb.append("}");
294 
295         return sb.toString();
296     }
297 
298     public String toXmlString() {
299         StringBuilder sb = new StringBuilder();
300 
301         sb.append("<model><model-name>");
302         sb.append("com.liferay.portlet.polls.model.PollsVote");
303         sb.append("</model-name>");
304 
305         sb.append(
306             "<column><column-name>voteId</column-name><column-value><![CDATA[");
307         sb.append(getVoteId());
308         sb.append("]]></column-value></column>");
309         sb.append(
310             "<column><column-name>userId</column-name><column-value><![CDATA[");
311         sb.append(getUserId());
312         sb.append("]]></column-value></column>");
313         sb.append(
314             "<column><column-name>questionId</column-name><column-value><![CDATA[");
315         sb.append(getQuestionId());
316         sb.append("]]></column-value></column>");
317         sb.append(
318             "<column><column-name>choiceId</column-name><column-value><![CDATA[");
319         sb.append(getChoiceId());
320         sb.append("]]></column-value></column>");
321         sb.append(
322             "<column><column-name>voteDate</column-name><column-value><![CDATA[");
323         sb.append(getVoteDate());
324         sb.append("]]></column-value></column>");
325 
326         sb.append("</model>");
327 
328         return sb.toString();
329     }
330 
331     private long _voteId;
332     private long _userId;
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 }