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