1
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.DateUtil;
28 import com.liferay.portal.kernel.util.GetterUtil;
29 import com.liferay.portal.kernel.util.HtmlUtil;
30 import com.liferay.portal.model.impl.BaseModelImpl;
31 import com.liferay.portal.util.PortalUtil;
32
33 import com.liferay.portlet.expando.model.ExpandoBridge;
34 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
35 import com.liferay.portlet.polls.model.PollsQuestion;
36 import com.liferay.portlet.polls.model.PollsQuestionSoap;
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
68 public class PollsQuestionModelImpl extends BaseModelImpl<PollsQuestion> {
69 public static final String TABLE_NAME = "PollsQuestion";
70 public static final Object[][] TABLE_COLUMNS = {
71 { "uuid_", new Integer(Types.VARCHAR) },
72
73
74 { "questionId", new Integer(Types.BIGINT) },
75
76
77 { "groupId", new Integer(Types.BIGINT) },
78
79
80 { "companyId", new Integer(Types.BIGINT) },
81
82
83 { "userId", new Integer(Types.BIGINT) },
84
85
86 { "userName", new Integer(Types.VARCHAR) },
87
88
89 { "createDate", new Integer(Types.TIMESTAMP) },
90
91
92 { "modifiedDate", new Integer(Types.TIMESTAMP) },
93
94
95 { "title", new Integer(Types.VARCHAR) },
96
97
98 { "description", new Integer(Types.VARCHAR) },
99
100
101 { "expirationDate", new Integer(Types.TIMESTAMP) },
102
103
104 { "lastVoteDate", new Integer(Types.TIMESTAMP) }
105 };
106 public static final String TABLE_SQL_CREATE = "create table PollsQuestion (uuid_ VARCHAR(75) null,questionId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,title VARCHAR(500) null,description STRING null,expirationDate DATE null,lastVoteDate DATE null)";
107 public static final String TABLE_SQL_DROP = "drop table PollsQuestion";
108 public static final String DATA_SOURCE = "liferayDataSource";
109 public static final String SESSION_FACTORY = "liferaySessionFactory";
110 public static final String TX_MANAGER = "liferayTransactionManager";
111 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
112 "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
113 true);
114 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
115 "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
116 true);
117
118 public static PollsQuestion toModel(PollsQuestionSoap soapModel) {
119 PollsQuestion model = new PollsQuestionImpl();
120
121 model.setUuid(soapModel.getUuid());
122 model.setQuestionId(soapModel.getQuestionId());
123 model.setGroupId(soapModel.getGroupId());
124 model.setCompanyId(soapModel.getCompanyId());
125 model.setUserId(soapModel.getUserId());
126 model.setUserName(soapModel.getUserName());
127 model.setCreateDate(soapModel.getCreateDate());
128 model.setModifiedDate(soapModel.getModifiedDate());
129 model.setTitle(soapModel.getTitle());
130 model.setDescription(soapModel.getDescription());
131 model.setExpirationDate(soapModel.getExpirationDate());
132 model.setLastVoteDate(soapModel.getLastVoteDate());
133
134 return model;
135 }
136
137 public static List<PollsQuestion> toModels(PollsQuestionSoap[] soapModels) {
138 List<PollsQuestion> models = new ArrayList<PollsQuestion>(soapModels.length);
139
140 for (PollsQuestionSoap soapModel : soapModels) {
141 models.add(toModel(soapModel));
142 }
143
144 return models;
145 }
146
147 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
148 "lock.expiration.time.com.liferay.portlet.polls.model.PollsQuestion"));
149
150 public PollsQuestionModelImpl() {
151 }
152
153 public long getPrimaryKey() {
154 return _questionId;
155 }
156
157 public void setPrimaryKey(long pk) {
158 setQuestionId(pk);
159 }
160
161 public Serializable getPrimaryKeyObj() {
162 return new Long(_questionId);
163 }
164
165 public String getUuid() {
166 return GetterUtil.getString(_uuid);
167 }
168
169 public void setUuid(String uuid) {
170 _uuid = uuid;
171
172 if (_originalUuid == null) {
173 _originalUuid = uuid;
174 }
175 }
176
177 public String getOriginalUuid() {
178 return GetterUtil.getString(_originalUuid);
179 }
180
181 public long getQuestionId() {
182 return _questionId;
183 }
184
185 public void setQuestionId(long questionId) {
186 _questionId = questionId;
187 }
188
189 public long getGroupId() {
190 return _groupId;
191 }
192
193 public void setGroupId(long groupId) {
194 _groupId = groupId;
195
196 if (!_setOriginalGroupId) {
197 _setOriginalGroupId = true;
198
199 _originalGroupId = groupId;
200 }
201 }
202
203 public long getOriginalGroupId() {
204 return _originalGroupId;
205 }
206
207 public long getCompanyId() {
208 return _companyId;
209 }
210
211 public void setCompanyId(long companyId) {
212 _companyId = companyId;
213 }
214
215 public long getUserId() {
216 return _userId;
217 }
218
219 public void setUserId(long userId) {
220 _userId = userId;
221 }
222
223 public String getUserUuid() throws SystemException {
224 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
225 }
226
227 public void setUserUuid(String userUuid) {
228 _userUuid = userUuid;
229 }
230
231 public String getUserName() {
232 return GetterUtil.getString(_userName);
233 }
234
235 public void setUserName(String userName) {
236 _userName = userName;
237 }
238
239 public Date getCreateDate() {
240 return _createDate;
241 }
242
243 public void setCreateDate(Date createDate) {
244 _createDate = createDate;
245 }
246
247 public Date getModifiedDate() {
248 return _modifiedDate;
249 }
250
251 public void setModifiedDate(Date modifiedDate) {
252 _modifiedDate = modifiedDate;
253 }
254
255 public String getTitle() {
256 return GetterUtil.getString(_title);
257 }
258
259 public void setTitle(String title) {
260 _title = title;
261 }
262
263 public String getDescription() {
264 return GetterUtil.getString(_description);
265 }
266
267 public void setDescription(String description) {
268 _description = description;
269 }
270
271 public Date getExpirationDate() {
272 return _expirationDate;
273 }
274
275 public void setExpirationDate(Date expirationDate) {
276 _expirationDate = expirationDate;
277 }
278
279 public Date getLastVoteDate() {
280 return _lastVoteDate;
281 }
282
283 public void setLastVoteDate(Date lastVoteDate) {
284 _lastVoteDate = lastVoteDate;
285 }
286
287 public PollsQuestion toEscapedModel() {
288 if (isEscapedModel()) {
289 return (PollsQuestion)this;
290 }
291 else {
292 PollsQuestion model = new PollsQuestionImpl();
293
294 model.setNew(isNew());
295 model.setEscapedModel(true);
296
297 model.setUuid(HtmlUtil.escape(getUuid()));
298 model.setQuestionId(getQuestionId());
299 model.setGroupId(getGroupId());
300 model.setCompanyId(getCompanyId());
301 model.setUserId(getUserId());
302 model.setUserName(HtmlUtil.escape(getUserName()));
303 model.setCreateDate(getCreateDate());
304 model.setModifiedDate(getModifiedDate());
305 model.setTitle(HtmlUtil.escape(getTitle()));
306 model.setDescription(HtmlUtil.escape(getDescription()));
307 model.setExpirationDate(getExpirationDate());
308 model.setLastVoteDate(getLastVoteDate());
309
310 model = (PollsQuestion)Proxy.newProxyInstance(PollsQuestion.class.getClassLoader(),
311 new Class[] { PollsQuestion.class },
312 new ReadOnlyBeanHandler(model));
313
314 return model;
315 }
316 }
317
318 public ExpandoBridge getExpandoBridge() {
319 if (_expandoBridge == null) {
320 _expandoBridge = new ExpandoBridgeImpl(PollsQuestion.class.getName(),
321 getPrimaryKey());
322 }
323
324 return _expandoBridge;
325 }
326
327 public Object clone() {
328 PollsQuestionImpl clone = new PollsQuestionImpl();
329
330 clone.setUuid(getUuid());
331 clone.setQuestionId(getQuestionId());
332 clone.setGroupId(getGroupId());
333 clone.setCompanyId(getCompanyId());
334 clone.setUserId(getUserId());
335 clone.setUserName(getUserName());
336 clone.setCreateDate(getCreateDate());
337 clone.setModifiedDate(getModifiedDate());
338 clone.setTitle(getTitle());
339 clone.setDescription(getDescription());
340 clone.setExpirationDate(getExpirationDate());
341 clone.setLastVoteDate(getLastVoteDate());
342
343 return clone;
344 }
345
346 public int compareTo(PollsQuestion pollsQuestion) {
347 int value = 0;
348
349 value = DateUtil.compareTo(getCreateDate(),
350 pollsQuestion.getCreateDate());
351
352 value = value * -1;
353
354 if (value != 0) {
355 return value;
356 }
357
358 return 0;
359 }
360
361 public boolean equals(Object obj) {
362 if (obj == null) {
363 return false;
364 }
365
366 PollsQuestion pollsQuestion = null;
367
368 try {
369 pollsQuestion = (PollsQuestion)obj;
370 }
371 catch (ClassCastException cce) {
372 return false;
373 }
374
375 long pk = pollsQuestion.getPrimaryKey();
376
377 if (getPrimaryKey() == pk) {
378 return true;
379 }
380 else {
381 return false;
382 }
383 }
384
385 public int hashCode() {
386 return (int)getPrimaryKey();
387 }
388
389 public String toString() {
390 StringBuilder sb = new StringBuilder();
391
392 sb.append("{uuid=");
393 sb.append(getUuid());
394 sb.append(", questionId=");
395 sb.append(getQuestionId());
396 sb.append(", groupId=");
397 sb.append(getGroupId());
398 sb.append(", companyId=");
399 sb.append(getCompanyId());
400 sb.append(", userId=");
401 sb.append(getUserId());
402 sb.append(", userName=");
403 sb.append(getUserName());
404 sb.append(", createDate=");
405 sb.append(getCreateDate());
406 sb.append(", modifiedDate=");
407 sb.append(getModifiedDate());
408 sb.append(", title=");
409 sb.append(getTitle());
410 sb.append(", description=");
411 sb.append(getDescription());
412 sb.append(", expirationDate=");
413 sb.append(getExpirationDate());
414 sb.append(", lastVoteDate=");
415 sb.append(getLastVoteDate());
416 sb.append("}");
417
418 return sb.toString();
419 }
420
421 public String toXmlString() {
422 StringBuilder sb = new StringBuilder();
423
424 sb.append("<model><model-name>");
425 sb.append("com.liferay.portlet.polls.model.PollsQuestion");
426 sb.append("</model-name>");
427
428 sb.append(
429 "<column><column-name>uuid</column-name><column-value><![CDATA[");
430 sb.append(getUuid());
431 sb.append("]]></column-value></column>");
432 sb.append(
433 "<column><column-name>questionId</column-name><column-value><![CDATA[");
434 sb.append(getQuestionId());
435 sb.append("]]></column-value></column>");
436 sb.append(
437 "<column><column-name>groupId</column-name><column-value><![CDATA[");
438 sb.append(getGroupId());
439 sb.append("]]></column-value></column>");
440 sb.append(
441 "<column><column-name>companyId</column-name><column-value><![CDATA[");
442 sb.append(getCompanyId());
443 sb.append("]]></column-value></column>");
444 sb.append(
445 "<column><column-name>userId</column-name><column-value><![CDATA[");
446 sb.append(getUserId());
447 sb.append("]]></column-value></column>");
448 sb.append(
449 "<column><column-name>userName</column-name><column-value><![CDATA[");
450 sb.append(getUserName());
451 sb.append("]]></column-value></column>");
452 sb.append(
453 "<column><column-name>createDate</column-name><column-value><![CDATA[");
454 sb.append(getCreateDate());
455 sb.append("]]></column-value></column>");
456 sb.append(
457 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
458 sb.append(getModifiedDate());
459 sb.append("]]></column-value></column>");
460 sb.append(
461 "<column><column-name>title</column-name><column-value><![CDATA[");
462 sb.append(getTitle());
463 sb.append("]]></column-value></column>");
464 sb.append(
465 "<column><column-name>description</column-name><column-value><![CDATA[");
466 sb.append(getDescription());
467 sb.append("]]></column-value></column>");
468 sb.append(
469 "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
470 sb.append(getExpirationDate());
471 sb.append("]]></column-value></column>");
472 sb.append(
473 "<column><column-name>lastVoteDate</column-name><column-value><![CDATA[");
474 sb.append(getLastVoteDate());
475 sb.append("]]></column-value></column>");
476
477 sb.append("</model>");
478
479 return sb.toString();
480 }
481
482 private String _uuid;
483 private String _originalUuid;
484 private long _questionId;
485 private long _groupId;
486 private long _originalGroupId;
487 private boolean _setOriginalGroupId;
488 private long _companyId;
489 private long _userId;
490 private String _userUuid;
491 private String _userName;
492 private Date _createDate;
493 private Date _modifiedDate;
494 private String _title;
495 private String _description;
496 private Date _expirationDate;
497 private Date _lastVoteDate;
498 private transient ExpandoBridge _expandoBridge;
499 }