1   /**
2    * Copyright (c) 2000-2008 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.service.model.PollsVote
58   * @see com.liferay.portlet.polls.service.model.PollsVoteModel
59   * @see com.liferay.portlet.polls.service.model.impl.PollsVoteImpl
60   *
61   */
62  public class PollsVoteModelImpl extends BaseModelImpl {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85                  "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
86              true);
87  
88      public static PollsVote toModel(PollsVoteSoap soapModel) {
89          PollsVote model = new PollsVoteImpl();
90  
91          model.setVoteId(soapModel.getVoteId());
92          model.setUserId(soapModel.getUserId());
93          model.setQuestionId(soapModel.getQuestionId());
94          model.setChoiceId(soapModel.getChoiceId());
95          model.setVoteDate(soapModel.getVoteDate());
96  
97          return model;
98      }
99  
100     public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
101         List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
102 
103         for (PollsVoteSoap soapModel : soapModels) {
104             models.add(toModel(soapModel));
105         }
106 
107         return models;
108     }
109 
110     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
112 
113     public PollsVoteModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _voteId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setVoteId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_voteId);
126     }
127 
128     public long getVoteId() {
129         return _voteId;
130     }
131 
132     public void setVoteId(long voteId) {
133         if (voteId != _voteId) {
134             _voteId = voteId;
135         }
136     }
137 
138     public long getUserId() {
139         return _userId;
140     }
141 
142     public void setUserId(long userId) {
143         if (userId != _userId) {
144             _userId = userId;
145         }
146     }
147 
148     public long getQuestionId() {
149         return _questionId;
150     }
151 
152     public void setQuestionId(long questionId) {
153         if (questionId != _questionId) {
154             _questionId = questionId;
155         }
156     }
157 
158     public long getChoiceId() {
159         return _choiceId;
160     }
161 
162     public void setChoiceId(long choiceId) {
163         if (choiceId != _choiceId) {
164             _choiceId = choiceId;
165         }
166     }
167 
168     public Date getVoteDate() {
169         return _voteDate;
170     }
171 
172     public void setVoteDate(Date voteDate) {
173         if (((voteDate == null) && (_voteDate != null)) ||
174                 ((voteDate != null) && (_voteDate == null)) ||
175                 ((voteDate != null) && (_voteDate != null) &&
176                 !voteDate.equals(_voteDate))) {
177             _voteDate = voteDate;
178         }
179     }
180 
181     public PollsVote toEscapedModel() {
182         if (isEscapedModel()) {
183             return (PollsVote)this;
184         }
185         else {
186             PollsVote model = new PollsVoteImpl();
187 
188             model.setEscapedModel(true);
189 
190             model.setVoteId(getVoteId());
191             model.setUserId(getUserId());
192             model.setQuestionId(getQuestionId());
193             model.setChoiceId(getChoiceId());
194             model.setVoteDate(getVoteDate());
195 
196             model = (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
197                     new Class[] { PollsVote.class },
198                     new ReadOnlyBeanHandler(model));
199 
200             return model;
201         }
202     }
203 
204     public Object clone() {
205         PollsVoteImpl clone = new PollsVoteImpl();
206 
207         clone.setVoteId(getVoteId());
208         clone.setUserId(getUserId());
209         clone.setQuestionId(getQuestionId());
210         clone.setChoiceId(getChoiceId());
211         clone.setVoteDate(getVoteDate());
212 
213         return clone;
214     }
215 
216     public int compareTo(Object obj) {
217         if (obj == null) {
218             return -1;
219         }
220 
221         PollsVoteImpl pollsVote = (PollsVoteImpl)obj;
222 
223         long pk = pollsVote.getPrimaryKey();
224 
225         if (getPrimaryKey() < pk) {
226             return -1;
227         }
228         else if (getPrimaryKey() > pk) {
229             return 1;
230         }
231         else {
232             return 0;
233         }
234     }
235 
236     public boolean equals(Object obj) {
237         if (obj == null) {
238             return false;
239         }
240 
241         PollsVoteImpl pollsVote = null;
242 
243         try {
244             pollsVote = (PollsVoteImpl)obj;
245         }
246         catch (ClassCastException cce) {
247             return false;
248         }
249 
250         long pk = pollsVote.getPrimaryKey();
251 
252         if (getPrimaryKey() == pk) {
253             return true;
254         }
255         else {
256             return false;
257         }
258     }
259 
260     public int hashCode() {
261         return (int)getPrimaryKey();
262     }
263 
264     private long _voteId;
265     private long _userId;
266     private long _questionId;
267     private long _choiceId;
268     private Date _voteDate;
269 }