1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.StringBundler;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.service.ServiceContext;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import com.liferay.portlet.expando.model.ExpandoBridge;
34  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
35  import com.liferay.portlet.polls.model.PollsVote;
36  import com.liferay.portlet.polls.model.PollsVoteSoap;
37  
38  import java.io.Serializable;
39  
40  import java.lang.reflect.Proxy;
41  
42  import java.sql.Types;
43  
44  import java.util.ArrayList;
45  import java.util.Date;
46  import java.util.List;
47  
48  /**
49   * <a href="PollsVoteModelImpl.java.html"><b><i>View Source</i></b></a>
50   *
51   * <p>
52   * ServiceBuilder generated this class. Modifications in this class will be
53   * overwritten the next time is generated.
54   * </p>
55   *
56   * <p>
57   * This interface is a model that represents the PollsVote table in the
58   * database.
59   * </p>
60   *
61   * @author    Brian Wing Shun Chan
62   * @see       PollsVoteImpl
63   * @see       com.liferay.portlet.polls.model.PollsVote
64   * @see       com.liferay.portlet.polls.model.PollsVoteModel
65   * @generated
66   */
67  public class PollsVoteModelImpl extends BaseModelImpl<PollsVote> {
68      public static final String TABLE_NAME = "PollsVote";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "voteId", new Integer(Types.BIGINT) },
71              { "userId", new Integer(Types.BIGINT) },
72              { "questionId", new Integer(Types.BIGINT) },
73              { "choiceId", new Integer(Types.BIGINT) },
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 ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82                  "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
83              true);
84      public static final boolean FINDER_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         _voteId = voteId;
134     }
135 
136     public long getUserId() {
137         return _userId;
138     }
139 
140     public void setUserId(long userId) {
141         _userId = userId;
142 
143         if (!_setOriginalUserId) {
144             _setOriginalUserId = true;
145 
146             _originalUserId = userId;
147         }
148     }
149 
150     public String getUserUuid() throws SystemException {
151         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
152     }
153 
154     public void setUserUuid(String userUuid) {
155         _userUuid = userUuid;
156     }
157 
158     public long getOriginalUserId() {
159         return _originalUserId;
160     }
161 
162     public long getQuestionId() {
163         return _questionId;
164     }
165 
166     public void setQuestionId(long questionId) {
167         _questionId = questionId;
168 
169         if (!_setOriginalQuestionId) {
170             _setOriginalQuestionId = true;
171 
172             _originalQuestionId = questionId;
173         }
174     }
175 
176     public long getOriginalQuestionId() {
177         return _originalQuestionId;
178     }
179 
180     public long getChoiceId() {
181         return _choiceId;
182     }
183 
184     public void setChoiceId(long choiceId) {
185         _choiceId = choiceId;
186     }
187 
188     public Date getVoteDate() {
189         return _voteDate;
190     }
191 
192     public void setVoteDate(Date voteDate) {
193         _voteDate = voteDate;
194     }
195 
196     public PollsVote toEscapedModel() {
197         if (isEscapedModel()) {
198             return (PollsVote)this;
199         }
200         else {
201             PollsVote model = new PollsVoteImpl();
202 
203             model.setNew(isNew());
204             model.setEscapedModel(true);
205 
206             model.setVoteId(getVoteId());
207             model.setUserId(getUserId());
208             model.setQuestionId(getQuestionId());
209             model.setChoiceId(getChoiceId());
210             model.setVoteDate(getVoteDate());
211 
212             model = (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
213                     new Class[] { PollsVote.class },
214                     new ReadOnlyBeanHandler(model));
215 
216             return model;
217         }
218     }
219 
220     public ExpandoBridge getExpandoBridge() {
221         if (_expandoBridge == null) {
222             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(PollsVote.class.getName(),
223                     getPrimaryKey());
224         }
225 
226         return _expandoBridge;
227     }
228 
229     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
230         getExpandoBridge().setAttributes(serviceContext);
231     }
232 
233     public Object clone() {
234         PollsVoteImpl clone = new PollsVoteImpl();
235 
236         clone.setVoteId(getVoteId());
237         clone.setUserId(getUserId());
238         clone.setQuestionId(getQuestionId());
239         clone.setChoiceId(getChoiceId());
240         clone.setVoteDate(getVoteDate());
241 
242         return clone;
243     }
244 
245     public int compareTo(PollsVote pollsVote) {
246         long pk = pollsVote.getPrimaryKey();
247 
248         if (getPrimaryKey() < pk) {
249             return -1;
250         }
251         else if (getPrimaryKey() > pk) {
252             return 1;
253         }
254         else {
255             return 0;
256         }
257     }
258 
259     public boolean equals(Object obj) {
260         if (obj == null) {
261             return false;
262         }
263 
264         PollsVote pollsVote = null;
265 
266         try {
267             pollsVote = (PollsVote)obj;
268         }
269         catch (ClassCastException cce) {
270             return false;
271         }
272 
273         long pk = pollsVote.getPrimaryKey();
274 
275         if (getPrimaryKey() == pk) {
276             return true;
277         }
278         else {
279             return false;
280         }
281     }
282 
283     public int hashCode() {
284         return (int)getPrimaryKey();
285     }
286 
287     public String toString() {
288         StringBundler sb = new StringBundler(11);
289 
290         sb.append("{voteId=");
291         sb.append(getVoteId());
292         sb.append(", userId=");
293         sb.append(getUserId());
294         sb.append(", questionId=");
295         sb.append(getQuestionId());
296         sb.append(", choiceId=");
297         sb.append(getChoiceId());
298         sb.append(", voteDate=");
299         sb.append(getVoteDate());
300         sb.append("}");
301 
302         return sb.toString();
303     }
304 
305     public String toXmlString() {
306         StringBundler sb = new StringBundler(19);
307 
308         sb.append("<model><model-name>");
309         sb.append("com.liferay.portlet.polls.model.PollsVote");
310         sb.append("</model-name>");
311 
312         sb.append(
313             "<column><column-name>voteId</column-name><column-value><![CDATA[");
314         sb.append(getVoteId());
315         sb.append("]]></column-value></column>");
316         sb.append(
317             "<column><column-name>userId</column-name><column-value><![CDATA[");
318         sb.append(getUserId());
319         sb.append("]]></column-value></column>");
320         sb.append(
321             "<column><column-name>questionId</column-name><column-value><![CDATA[");
322         sb.append(getQuestionId());
323         sb.append("]]></column-value></column>");
324         sb.append(
325             "<column><column-name>choiceId</column-name><column-value><![CDATA[");
326         sb.append(getChoiceId());
327         sb.append("]]></column-value></column>");
328         sb.append(
329             "<column><column-name>voteDate</column-name><column-value><![CDATA[");
330         sb.append(getVoteDate());
331         sb.append("]]></column-value></column>");
332 
333         sb.append("</model>");
334 
335         return sb.toString();
336     }
337 
338     private long _voteId;
339     private long _userId;
340     private String _userUuid;
341     private long _originalUserId;
342     private boolean _setOriginalUserId;
343     private long _questionId;
344     private long _originalQuestionId;
345     private boolean _setOriginalQuestionId;
346     private long _choiceId;
347     private Date _voteDate;
348     private transient ExpandoBridge _expandoBridge;
349 }