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 {
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 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         if (voteId != _voteId) {
136             _voteId = voteId;
137         }
138     }
139 
140     public long getUserId() {
141         return _userId;
142     }
143 
144     public void setUserId(long userId) {
145         if (userId != _userId) {
146             _userId = userId;
147         }
148     }
149 
150     public long getQuestionId() {
151         return _questionId;
152     }
153 
154     public void setQuestionId(long questionId) {
155         if (questionId != _questionId) {
156             _questionId = questionId;
157         }
158     }
159 
160     public long getChoiceId() {
161         return _choiceId;
162     }
163 
164     public void setChoiceId(long choiceId) {
165         if (choiceId != _choiceId) {
166             _choiceId = choiceId;
167         }
168     }
169 
170     public Date getVoteDate() {
171         return _voteDate;
172     }
173 
174     public void setVoteDate(Date voteDate) {
175         if (((voteDate == null) && (_voteDate != null)) ||
176                 ((voteDate != null) && (_voteDate == null)) ||
177                 ((voteDate != null) && (_voteDate != null) &&
178                 !voteDate.equals(_voteDate))) {
179             _voteDate = voteDate;
180         }
181     }
182 
183     public PollsVote toEscapedModel() {
184         if (isEscapedModel()) {
185             return (PollsVote)this;
186         }
187         else {
188             PollsVote model = new PollsVoteImpl();
189 
190             model.setNew(isNew());
191             model.setEscapedModel(true);
192 
193             model.setVoteId(getVoteId());
194             model.setUserId(getUserId());
195             model.setQuestionId(getQuestionId());
196             model.setChoiceId(getChoiceId());
197             model.setVoteDate(getVoteDate());
198 
199             model = (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
200                     new Class[] { PollsVote.class },
201                     new ReadOnlyBeanHandler(model));
202 
203             return model;
204         }
205     }
206 
207     public ExpandoBridge getExpandoBridge() {
208         if (_expandoBridge == null) {
209             _expandoBridge = new ExpandoBridgeImpl(PollsVote.class.getName(),
210                     getPrimaryKey());
211         }
212 
213         return _expandoBridge;
214     }
215 
216     public Object clone() {
217         PollsVoteImpl clone = new PollsVoteImpl();
218 
219         clone.setVoteId(getVoteId());
220         clone.setUserId(getUserId());
221         clone.setQuestionId(getQuestionId());
222         clone.setChoiceId(getChoiceId());
223         clone.setVoteDate(getVoteDate());
224 
225         return clone;
226     }
227 
228     public int compareTo(Object obj) {
229         if (obj == null) {
230             return -1;
231         }
232 
233         PollsVoteImpl pollsVote = (PollsVoteImpl)obj;
234 
235         long pk = pollsVote.getPrimaryKey();
236 
237         if (getPrimaryKey() < pk) {
238             return -1;
239         }
240         else if (getPrimaryKey() > pk) {
241             return 1;
242         }
243         else {
244             return 0;
245         }
246     }
247 
248     public boolean equals(Object obj) {
249         if (obj == null) {
250             return false;
251         }
252 
253         PollsVoteImpl pollsVote = null;
254 
255         try {
256             pollsVote = (PollsVoteImpl)obj;
257         }
258         catch (ClassCastException cce) {
259             return false;
260         }
261 
262         long pk = pollsVote.getPrimaryKey();
263 
264         if (getPrimaryKey() == pk) {
265             return true;
266         }
267         else {
268             return false;
269         }
270     }
271 
272     public int hashCode() {
273         return (int)getPrimaryKey();
274     }
275 
276     private long _voteId;
277     private long _userId;
278     private long _questionId;
279     private long _choiceId;
280     private Date _voteDate;
281     private transient ExpandoBridge _expandoBridge;
282 }