001
014
015 package com.liferay.portlet.polls.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.model.impl.BaseModelImpl;
022 import com.liferay.portal.service.ServiceContext;
023 import com.liferay.portal.util.PortalUtil;
024
025 import com.liferay.portlet.expando.model.ExpandoBridge;
026 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027 import com.liferay.portlet.polls.model.PollsVote;
028 import com.liferay.portlet.polls.model.PollsVoteModel;
029 import com.liferay.portlet.polls.model.PollsVoteSoap;
030
031 import java.io.Serializable;
032
033 import java.lang.reflect.Proxy;
034
035 import java.sql.Types;
036
037 import java.util.ArrayList;
038 import java.util.Date;
039 import java.util.List;
040
041
058 public class PollsVoteModelImpl extends BaseModelImpl<PollsVote>
059 implements PollsVoteModel {
060 public static final String TABLE_NAME = "PollsVote";
061 public static final Object[][] TABLE_COLUMNS = {
062 { "voteId", new Integer(Types.BIGINT) },
063 { "userId", new Integer(Types.BIGINT) },
064 { "questionId", new Integer(Types.BIGINT) },
065 { "choiceId", new Integer(Types.BIGINT) },
066 { "voteDate", new Integer(Types.TIMESTAMP) }
067 };
068 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)";
069 public static final String TABLE_SQL_DROP = "drop table PollsVote";
070 public static final String DATA_SOURCE = "liferayDataSource";
071 public static final String SESSION_FACTORY = "liferaySessionFactory";
072 public static final String TX_MANAGER = "liferayTransactionManager";
073 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
075 true);
076 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsVote"),
078 true);
079
080
086 public static PollsVote toModel(PollsVoteSoap soapModel) {
087 PollsVote model = new PollsVoteImpl();
088
089 model.setVoteId(soapModel.getVoteId());
090 model.setUserId(soapModel.getUserId());
091 model.setQuestionId(soapModel.getQuestionId());
092 model.setChoiceId(soapModel.getChoiceId());
093 model.setVoteDate(soapModel.getVoteDate());
094
095 return model;
096 }
097
098
104 public static List<PollsVote> toModels(PollsVoteSoap[] soapModels) {
105 List<PollsVote> models = new ArrayList<PollsVote>(soapModels.length);
106
107 for (PollsVoteSoap soapModel : soapModels) {
108 models.add(toModel(soapModel));
109 }
110
111 return models;
112 }
113
114 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
115 "lock.expiration.time.com.liferay.portlet.polls.model.PollsVote"));
116
117 public PollsVoteModelImpl() {
118 }
119
120 public long getPrimaryKey() {
121 return _voteId;
122 }
123
124 public void setPrimaryKey(long pk) {
125 setVoteId(pk);
126 }
127
128 public Serializable getPrimaryKeyObj() {
129 return new Long(_voteId);
130 }
131
132 public long getVoteId() {
133 return _voteId;
134 }
135
136 public void setVoteId(long voteId) {
137 _voteId = voteId;
138 }
139
140 public long getUserId() {
141 return _userId;
142 }
143
144 public void setUserId(long userId) {
145 _userId = userId;
146
147 if (!_setOriginalUserId) {
148 _setOriginalUserId = true;
149
150 _originalUserId = userId;
151 }
152 }
153
154 public String getUserUuid() throws SystemException {
155 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
156 }
157
158 public void setUserUuid(String userUuid) {
159 _userUuid = userUuid;
160 }
161
162 public long getOriginalUserId() {
163 return _originalUserId;
164 }
165
166 public long getQuestionId() {
167 return _questionId;
168 }
169
170 public void setQuestionId(long questionId) {
171 _questionId = questionId;
172
173 if (!_setOriginalQuestionId) {
174 _setOriginalQuestionId = true;
175
176 _originalQuestionId = questionId;
177 }
178 }
179
180 public long getOriginalQuestionId() {
181 return _originalQuestionId;
182 }
183
184 public long getChoiceId() {
185 return _choiceId;
186 }
187
188 public void setChoiceId(long choiceId) {
189 _choiceId = choiceId;
190 }
191
192 public Date getVoteDate() {
193 return _voteDate;
194 }
195
196 public void setVoteDate(Date voteDate) {
197 _voteDate = voteDate;
198 }
199
200 public PollsVote toEscapedModel() {
201 if (isEscapedModel()) {
202 return (PollsVote)this;
203 }
204 else {
205 return (PollsVote)Proxy.newProxyInstance(PollsVote.class.getClassLoader(),
206 new Class[] { PollsVote.class }, new AutoEscapeBeanHandler(this));
207 }
208 }
209
210 public ExpandoBridge getExpandoBridge() {
211 if (_expandoBridge == null) {
212 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
213 PollsVote.class.getName(), getPrimaryKey());
214 }
215
216 return _expandoBridge;
217 }
218
219 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
220 getExpandoBridge().setAttributes(serviceContext);
221 }
222
223 public Object clone() {
224 PollsVoteImpl clone = new PollsVoteImpl();
225
226 clone.setVoteId(getVoteId());
227 clone.setUserId(getUserId());
228 clone.setQuestionId(getQuestionId());
229 clone.setChoiceId(getChoiceId());
230 clone.setVoteDate(getVoteDate());
231
232 return clone;
233 }
234
235 public int compareTo(PollsVote pollsVote) {
236 long pk = pollsVote.getPrimaryKey();
237
238 if (getPrimaryKey() < pk) {
239 return -1;
240 }
241 else if (getPrimaryKey() > pk) {
242 return 1;
243 }
244 else {
245 return 0;
246 }
247 }
248
249 public boolean equals(Object obj) {
250 if (obj == null) {
251 return false;
252 }
253
254 PollsVote pollsVote = null;
255
256 try {
257 pollsVote = (PollsVote)obj;
258 }
259 catch (ClassCastException cce) {
260 return false;
261 }
262
263 long pk = pollsVote.getPrimaryKey();
264
265 if (getPrimaryKey() == pk) {
266 return true;
267 }
268 else {
269 return false;
270 }
271 }
272
273 public int hashCode() {
274 return (int)getPrimaryKey();
275 }
276
277 public String toString() {
278 StringBundler sb = new StringBundler(11);
279
280 sb.append("{voteId=");
281 sb.append(getVoteId());
282 sb.append(", userId=");
283 sb.append(getUserId());
284 sb.append(", questionId=");
285 sb.append(getQuestionId());
286 sb.append(", choiceId=");
287 sb.append(getChoiceId());
288 sb.append(", voteDate=");
289 sb.append(getVoteDate());
290 sb.append("}");
291
292 return sb.toString();
293 }
294
295 public String toXmlString() {
296 StringBundler sb = new StringBundler(19);
297
298 sb.append("<model><model-name>");
299 sb.append("com.liferay.portlet.polls.model.PollsVote");
300 sb.append("</model-name>");
301
302 sb.append(
303 "<column><column-name>voteId</column-name><column-value><![CDATA[");
304 sb.append(getVoteId());
305 sb.append("]]></column-value></column>");
306 sb.append(
307 "<column><column-name>userId</column-name><column-value><![CDATA[");
308 sb.append(getUserId());
309 sb.append("]]></column-value></column>");
310 sb.append(
311 "<column><column-name>questionId</column-name><column-value><![CDATA[");
312 sb.append(getQuestionId());
313 sb.append("]]></column-value></column>");
314 sb.append(
315 "<column><column-name>choiceId</column-name><column-value><![CDATA[");
316 sb.append(getChoiceId());
317 sb.append("]]></column-value></column>");
318 sb.append(
319 "<column><column-name>voteDate</column-name><column-value><![CDATA[");
320 sb.append(getVoteDate());
321 sb.append("]]></column-value></column>");
322
323 sb.append("</model>");
324
325 return sb.toString();
326 }
327
328 private long _voteId;
329 private long _userId;
330 private String _userUuid;
331 private long _originalUserId;
332 private boolean _setOriginalUserId;
333 private long _questionId;
334 private long _originalQuestionId;
335 private boolean _setOriginalQuestionId;
336 private long _choiceId;
337 private Date _voteDate;
338 private transient ExpandoBridge _expandoBridge;
339 }