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