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