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