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.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PortalUtil;
30  
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 interface is a model that represents the PollsVote table in the
54   * database.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       PollsVoteImpl
59   * @see       com.liferay.portlet.polls.model.PollsVote
60   * @see       com.liferay.portlet.polls.model.PollsVoteModel
61   * @generated
62   */
63  public class PollsVoteModelImpl extends BaseModelImpl<PollsVote> {
64      public static final String TABLE_NAME = "PollsVote";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "voteId", new Integer(Types.BIGINT) },
67              { "userId", new Integer(Types.BIGINT) },
68              { "questionId", new Integer(Types.BIGINT) },
69              { "choiceId", new Integer(Types.BIGINT) },
70              { "voteDate", new Integer(Types.TIMESTAMP) }
71          };
72      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)";
73      public static final String TABLE_SQL_DROP = "drop table PollsVote";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
79              true);
80      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
82              true);
83  
84      public static PollsVote toModel(PollsVoteSoap soapModel) {
85          PollsVote model = new PollsVoteImpl();
86  
87          model.setVoteId(soapModel.getVoteId());
88          model.setUserId(soapModel.getUserId());
89          model.setQuestionId(soapModel.getQuestionId());
90          model.setChoiceId(soapModel.getChoiceId());
91          model.setVoteDate(soapModel.getVoteDate());
92  
93          return model;
94      }
95  
96      public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
97          List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
98  
99          for (PollsVoteSoap soapModel : soapModels) {
100             models.add(toModel(soapModel));
101         }
102 
103         return models;
104     }
105 
106     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
107                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
108 
109     public PollsVoteModelImpl() {
110     }
111 
112     public long getPrimaryKey() {
113         return _voteId;
114     }
115 
116     public void setPrimaryKey(long pk) {
117         setVoteId(pk);
118     }
119 
120     public Serializable getPrimaryKeyObj() {
121         return new Long(_voteId);
122     }
123 
124     public long getVoteId() {
125         return _voteId;
126     }
127 
128     public void setVoteId(long voteId) {
129         _voteId = voteId;
130     }
131 
132     public long getUserId() {
133         return _userId;
134     }
135 
136     public void setUserId(long userId) {
137         _userId = userId;
138 
139         if (!_setOriginalUserId) {
140             _setOriginalUserId = true;
141 
142             _originalUserId = userId;
143         }
144     }
145 
146     public String getUserUuid() throws SystemException {
147         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
148     }
149 
150     public void setUserUuid(String userUuid) {
151         _userUuid = userUuid;
152     }
153 
154     public long getOriginalUserId() {
155         return _originalUserId;
156     }
157 
158     public long getQuestionId() {
159         return _questionId;
160     }
161 
162     public void setQuestionId(long questionId) {
163         _questionId = questionId;
164 
165         if (!_setOriginalQuestionId) {
166             _setOriginalQuestionId = true;
167 
168             _originalQuestionId = questionId;
169         }
170     }
171 
172     public long getOriginalQuestionId() {
173         return _originalQuestionId;
174     }
175 
176     public long getChoiceId() {
177         return _choiceId;
178     }
179 
180     public void setChoiceId(long choiceId) {
181         _choiceId = choiceId;
182     }
183 
184     public Date getVoteDate() {
185         return _voteDate;
186     }
187 
188     public void setVoteDate(Date voteDate) {
189         _voteDate = voteDate;
190     }
191 
192     public PollsVote toEscapedModel() {
193         if (isEscapedModel()) {
194             return (PollsVote)this;
195         }
196         else {
197             PollsVote model = new PollsVoteImpl();
198 
199             model.setNew(isNew());
200             model.setEscapedModel(true);
201 
202             model.setVoteId(getVoteId());
203             model.setUserId(getUserId());
204             model.setQuestionId(getQuestionId());
205             model.setChoiceId(getChoiceId());
206             model.setVoteDate(getVoteDate());
207 
208             model = (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
209                     new Class[] { PollsVote.class },
210                     new ReadOnlyBeanHandler(model));
211 
212             return model;
213         }
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(PollsVote pollsVote) {
229         long pk = pollsVote.getPrimaryKey();
230 
231         if (getPrimaryKey() < pk) {
232             return -1;
233         }
234         else if (getPrimaryKey() > pk) {
235             return 1;
236         }
237         else {
238             return 0;
239         }
240     }
241 
242     public boolean equals(Object obj) {
243         if (obj == null) {
244             return false;
245         }
246 
247         PollsVote pollsVote = null;
248 
249         try {
250             pollsVote = (PollsVote)obj;
251         }
252         catch (ClassCastException cce) {
253             return false;
254         }
255 
256         long pk = pollsVote.getPrimaryKey();
257 
258         if (getPrimaryKey() == pk) {
259             return true;
260         }
261         else {
262             return false;
263         }
264     }
265 
266     public int hashCode() {
267         return (int)getPrimaryKey();
268     }
269 
270     public String toString() {
271         StringBuilder sb = new StringBuilder();
272 
273         sb.append("{voteId=");
274         sb.append(getVoteId());
275         sb.append(", userId=");
276         sb.append(getUserId());
277         sb.append(", questionId=");
278         sb.append(getQuestionId());
279         sb.append(", choiceId=");
280         sb.append(getChoiceId());
281         sb.append(", voteDate=");
282         sb.append(getVoteDate());
283         sb.append("}");
284 
285         return sb.toString();
286     }
287 
288     public String toXmlString() {
289         StringBuilder sb = new StringBuilder();
290 
291         sb.append("<model><model-name>");
292         sb.append("com.liferay.portlet.polls.model.PollsVote");
293         sb.append("</model-name>");
294 
295         sb.append(
296             "<column><column-name>voteId</column-name><column-value><![CDATA[");
297         sb.append(getVoteId());
298         sb.append("]]></column-value></column>");
299         sb.append(
300             "<column><column-name>userId</column-name><column-value><![CDATA[");
301         sb.append(getUserId());
302         sb.append("]]></column-value></column>");
303         sb.append(
304             "<column><column-name>questionId</column-name><column-value><![CDATA[");
305         sb.append(getQuestionId());
306         sb.append("]]></column-value></column>");
307         sb.append(
308             "<column><column-name>choiceId</column-name><column-value><![CDATA[");
309         sb.append(getChoiceId());
310         sb.append("]]></column-value></column>");
311         sb.append(
312             "<column><column-name>voteDate</column-name><column-value><![CDATA[");
313         sb.append(getVoteDate());
314         sb.append("]]></column-value></column>");
315 
316         sb.append("</model>");
317 
318         return sb.toString();
319     }
320 
321     private long _voteId;
322     private long _userId;
323     private String _userUuid;
324     private long _originalUserId;
325     private boolean _setOriginalUserId;
326     private long _questionId;
327     private long _originalQuestionId;
328     private boolean _setOriginalQuestionId;
329     private long _choiceId;
330     private Date _voteDate;
331 }