001
014
015 package com.liferay.portlet.ratings.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.json.JSON;
020 import com.liferay.portal.kernel.util.GetterUtil;
021 import com.liferay.portal.kernel.util.ProxyUtil;
022 import com.liferay.portal.kernel.util.StringBundler;
023 import com.liferay.portal.kernel.util.StringPool;
024 import com.liferay.portal.kernel.util.Validator;
025 import com.liferay.portal.model.CacheModel;
026 import com.liferay.portal.model.impl.BaseModelImpl;
027 import com.liferay.portal.service.ServiceContext;
028 import com.liferay.portal.util.PortalUtil;
029
030 import com.liferay.portlet.expando.model.ExpandoBridge;
031 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
032 import com.liferay.portlet.ratings.model.RatingsEntry;
033 import com.liferay.portlet.ratings.model.RatingsEntryModel;
034 import com.liferay.portlet.ratings.model.RatingsEntrySoap;
035
036 import java.io.Serializable;
037
038 import java.sql.Types;
039
040 import java.util.ArrayList;
041 import java.util.Date;
042 import java.util.HashMap;
043 import java.util.List;
044 import java.util.Map;
045
046
059 @JSON(strict = true)
060 public class RatingsEntryModelImpl extends BaseModelImpl<RatingsEntry>
061 implements RatingsEntryModel {
062
067 public static final String TABLE_NAME = "RatingsEntry";
068 public static final Object[][] TABLE_COLUMNS = {
069 { "entryId", Types.BIGINT },
070 { "companyId", Types.BIGINT },
071 { "userId", Types.BIGINT },
072 { "userName", Types.VARCHAR },
073 { "createDate", Types.TIMESTAMP },
074 { "modifiedDate", Types.TIMESTAMP },
075 { "classNameId", Types.BIGINT },
076 { "classPK", Types.BIGINT },
077 { "score", Types.DOUBLE }
078 };
079 public static final String TABLE_SQL_CREATE = "create table RatingsEntry (entryId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,score DOUBLE)";
080 public static final String TABLE_SQL_DROP = "drop table RatingsEntry";
081 public static final String ORDER_BY_JPQL = " ORDER BY ratingsEntry.entryId ASC";
082 public static final String ORDER_BY_SQL = " ORDER BY RatingsEntry.entryId ASC";
083 public static final String DATA_SOURCE = "liferayDataSource";
084 public static final String SESSION_FACTORY = "liferaySessionFactory";
085 public static final String TX_MANAGER = "liferayTransactionManager";
086 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087 "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
088 true);
089 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090 "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
091 true);
092 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
093 "value.object.column.bitmask.enabled.com.liferay.portlet.ratings.model.RatingsEntry"),
094 true);
095 public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
096 public static long CLASSPK_COLUMN_BITMASK = 2L;
097 public static long SCORE_COLUMN_BITMASK = 4L;
098 public static long USERID_COLUMN_BITMASK = 8L;
099 public static long ENTRYID_COLUMN_BITMASK = 16L;
100
101
107 public static RatingsEntry toModel(RatingsEntrySoap soapModel) {
108 if (soapModel == null) {
109 return null;
110 }
111
112 RatingsEntry model = new RatingsEntryImpl();
113
114 model.setEntryId(soapModel.getEntryId());
115 model.setCompanyId(soapModel.getCompanyId());
116 model.setUserId(soapModel.getUserId());
117 model.setUserName(soapModel.getUserName());
118 model.setCreateDate(soapModel.getCreateDate());
119 model.setModifiedDate(soapModel.getModifiedDate());
120 model.setClassNameId(soapModel.getClassNameId());
121 model.setClassPK(soapModel.getClassPK());
122 model.setScore(soapModel.getScore());
123
124 return model;
125 }
126
127
133 public static List<RatingsEntry> toModels(RatingsEntrySoap[] soapModels) {
134 if (soapModels == null) {
135 return null;
136 }
137
138 List<RatingsEntry> models = new ArrayList<RatingsEntry>(soapModels.length);
139
140 for (RatingsEntrySoap 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.ratings.model.RatingsEntry"));
149
150 public RatingsEntryModelImpl() {
151 }
152
153 @Override
154 public long getPrimaryKey() {
155 return _entryId;
156 }
157
158 @Override
159 public void setPrimaryKey(long primaryKey) {
160 setEntryId(primaryKey);
161 }
162
163 @Override
164 public Serializable getPrimaryKeyObj() {
165 return _entryId;
166 }
167
168 @Override
169 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
170 setPrimaryKey(((Long)primaryKeyObj).longValue());
171 }
172
173 @Override
174 public Class<?> getModelClass() {
175 return RatingsEntry.class;
176 }
177
178 @Override
179 public String getModelClassName() {
180 return RatingsEntry.class.getName();
181 }
182
183 @Override
184 public Map<String, Object> getModelAttributes() {
185 Map<String, Object> attributes = new HashMap<String, Object>();
186
187 attributes.put("entryId", getEntryId());
188 attributes.put("companyId", getCompanyId());
189 attributes.put("userId", getUserId());
190 attributes.put("userName", getUserName());
191 attributes.put("createDate", getCreateDate());
192 attributes.put("modifiedDate", getModifiedDate());
193 attributes.put("classNameId", getClassNameId());
194 attributes.put("classPK", getClassPK());
195 attributes.put("score", getScore());
196
197 return attributes;
198 }
199
200 @Override
201 public void setModelAttributes(Map<String, Object> attributes) {
202 Long entryId = (Long)attributes.get("entryId");
203
204 if (entryId != null) {
205 setEntryId(entryId);
206 }
207
208 Long companyId = (Long)attributes.get("companyId");
209
210 if (companyId != null) {
211 setCompanyId(companyId);
212 }
213
214 Long userId = (Long)attributes.get("userId");
215
216 if (userId != null) {
217 setUserId(userId);
218 }
219
220 String userName = (String)attributes.get("userName");
221
222 if (userName != null) {
223 setUserName(userName);
224 }
225
226 Date createDate = (Date)attributes.get("createDate");
227
228 if (createDate != null) {
229 setCreateDate(createDate);
230 }
231
232 Date modifiedDate = (Date)attributes.get("modifiedDate");
233
234 if (modifiedDate != null) {
235 setModifiedDate(modifiedDate);
236 }
237
238 Long classNameId = (Long)attributes.get("classNameId");
239
240 if (classNameId != null) {
241 setClassNameId(classNameId);
242 }
243
244 Long classPK = (Long)attributes.get("classPK");
245
246 if (classPK != null) {
247 setClassPK(classPK);
248 }
249
250 Double score = (Double)attributes.get("score");
251
252 if (score != null) {
253 setScore(score);
254 }
255 }
256
257 @JSON
258 @Override
259 public long getEntryId() {
260 return _entryId;
261 }
262
263 @Override
264 public void setEntryId(long entryId) {
265 _entryId = entryId;
266 }
267
268 @JSON
269 @Override
270 public long getCompanyId() {
271 return _companyId;
272 }
273
274 @Override
275 public void setCompanyId(long companyId) {
276 _companyId = companyId;
277 }
278
279 @JSON
280 @Override
281 public long getUserId() {
282 return _userId;
283 }
284
285 @Override
286 public void setUserId(long userId) {
287 _columnBitmask |= USERID_COLUMN_BITMASK;
288
289 if (!_setOriginalUserId) {
290 _setOriginalUserId = true;
291
292 _originalUserId = _userId;
293 }
294
295 _userId = userId;
296 }
297
298 @Override
299 public String getUserUuid() throws SystemException {
300 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
301 }
302
303 @Override
304 public void setUserUuid(String userUuid) {
305 _userUuid = userUuid;
306 }
307
308 public long getOriginalUserId() {
309 return _originalUserId;
310 }
311
312 @JSON
313 @Override
314 public String getUserName() {
315 if (_userName == null) {
316 return StringPool.BLANK;
317 }
318 else {
319 return _userName;
320 }
321 }
322
323 @Override
324 public void setUserName(String userName) {
325 _userName = userName;
326 }
327
328 @JSON
329 @Override
330 public Date getCreateDate() {
331 return _createDate;
332 }
333
334 @Override
335 public void setCreateDate(Date createDate) {
336 _createDate = createDate;
337 }
338
339 @JSON
340 @Override
341 public Date getModifiedDate() {
342 return _modifiedDate;
343 }
344
345 @Override
346 public void setModifiedDate(Date modifiedDate) {
347 _modifiedDate = modifiedDate;
348 }
349
350 @Override
351 public String getClassName() {
352 if (getClassNameId() <= 0) {
353 return StringPool.BLANK;
354 }
355
356 return PortalUtil.getClassName(getClassNameId());
357 }
358
359 @Override
360 public void setClassName(String className) {
361 long classNameId = 0;
362
363 if (Validator.isNotNull(className)) {
364 classNameId = PortalUtil.getClassNameId(className);
365 }
366
367 setClassNameId(classNameId);
368 }
369
370 @JSON
371 @Override
372 public long getClassNameId() {
373 return _classNameId;
374 }
375
376 @Override
377 public void setClassNameId(long classNameId) {
378 _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
379
380 if (!_setOriginalClassNameId) {
381 _setOriginalClassNameId = true;
382
383 _originalClassNameId = _classNameId;
384 }
385
386 _classNameId = classNameId;
387 }
388
389 public long getOriginalClassNameId() {
390 return _originalClassNameId;
391 }
392
393 @JSON
394 @Override
395 public long getClassPK() {
396 return _classPK;
397 }
398
399 @Override
400 public void setClassPK(long classPK) {
401 _columnBitmask |= CLASSPK_COLUMN_BITMASK;
402
403 if (!_setOriginalClassPK) {
404 _setOriginalClassPK = true;
405
406 _originalClassPK = _classPK;
407 }
408
409 _classPK = classPK;
410 }
411
412 public long getOriginalClassPK() {
413 return _originalClassPK;
414 }
415
416 @JSON
417 @Override
418 public double getScore() {
419 return _score;
420 }
421
422 @Override
423 public void setScore(double score) {
424 _columnBitmask |= SCORE_COLUMN_BITMASK;
425
426 if (!_setOriginalScore) {
427 _setOriginalScore = true;
428
429 _originalScore = _score;
430 }
431
432 _score = score;
433 }
434
435 public double getOriginalScore() {
436 return _originalScore;
437 }
438
439 public long getColumnBitmask() {
440 return _columnBitmask;
441 }
442
443 @Override
444 public ExpandoBridge getExpandoBridge() {
445 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
446 RatingsEntry.class.getName(), getPrimaryKey());
447 }
448
449 @Override
450 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
451 ExpandoBridge expandoBridge = getExpandoBridge();
452
453 expandoBridge.setAttributes(serviceContext);
454 }
455
456 @Override
457 public RatingsEntry toEscapedModel() {
458 if (_escapedModel == null) {
459 _escapedModel = (RatingsEntry)ProxyUtil.newProxyInstance(_classLoader,
460 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
461 }
462
463 return _escapedModel;
464 }
465
466 @Override
467 public Object clone() {
468 RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl();
469
470 ratingsEntryImpl.setEntryId(getEntryId());
471 ratingsEntryImpl.setCompanyId(getCompanyId());
472 ratingsEntryImpl.setUserId(getUserId());
473 ratingsEntryImpl.setUserName(getUserName());
474 ratingsEntryImpl.setCreateDate(getCreateDate());
475 ratingsEntryImpl.setModifiedDate(getModifiedDate());
476 ratingsEntryImpl.setClassNameId(getClassNameId());
477 ratingsEntryImpl.setClassPK(getClassPK());
478 ratingsEntryImpl.setScore(getScore());
479
480 ratingsEntryImpl.resetOriginalValues();
481
482 return ratingsEntryImpl;
483 }
484
485 @Override
486 public int compareTo(RatingsEntry ratingsEntry) {
487 long primaryKey = ratingsEntry.getPrimaryKey();
488
489 if (getPrimaryKey() < primaryKey) {
490 return -1;
491 }
492 else if (getPrimaryKey() > primaryKey) {
493 return 1;
494 }
495 else {
496 return 0;
497 }
498 }
499
500 @Override
501 public boolean equals(Object obj) {
502 if (this == obj) {
503 return true;
504 }
505
506 if (!(obj instanceof RatingsEntry)) {
507 return false;
508 }
509
510 RatingsEntry ratingsEntry = (RatingsEntry)obj;
511
512 long primaryKey = ratingsEntry.getPrimaryKey();
513
514 if (getPrimaryKey() == primaryKey) {
515 return true;
516 }
517 else {
518 return false;
519 }
520 }
521
522 @Override
523 public int hashCode() {
524 return (int)getPrimaryKey();
525 }
526
527 @Override
528 public void resetOriginalValues() {
529 RatingsEntryModelImpl ratingsEntryModelImpl = this;
530
531 ratingsEntryModelImpl._originalUserId = ratingsEntryModelImpl._userId;
532
533 ratingsEntryModelImpl._setOriginalUserId = false;
534
535 ratingsEntryModelImpl._originalClassNameId = ratingsEntryModelImpl._classNameId;
536
537 ratingsEntryModelImpl._setOriginalClassNameId = false;
538
539 ratingsEntryModelImpl._originalClassPK = ratingsEntryModelImpl._classPK;
540
541 ratingsEntryModelImpl._setOriginalClassPK = false;
542
543 ratingsEntryModelImpl._originalScore = ratingsEntryModelImpl._score;
544
545 ratingsEntryModelImpl._setOriginalScore = false;
546
547 ratingsEntryModelImpl._columnBitmask = 0;
548 }
549
550 @Override
551 public CacheModel<RatingsEntry> toCacheModel() {
552 RatingsEntryCacheModel ratingsEntryCacheModel = new RatingsEntryCacheModel();
553
554 ratingsEntryCacheModel.entryId = getEntryId();
555
556 ratingsEntryCacheModel.companyId = getCompanyId();
557
558 ratingsEntryCacheModel.userId = getUserId();
559
560 ratingsEntryCacheModel.userName = getUserName();
561
562 String userName = ratingsEntryCacheModel.userName;
563
564 if ((userName != null) && (userName.length() == 0)) {
565 ratingsEntryCacheModel.userName = null;
566 }
567
568 Date createDate = getCreateDate();
569
570 if (createDate != null) {
571 ratingsEntryCacheModel.createDate = createDate.getTime();
572 }
573 else {
574 ratingsEntryCacheModel.createDate = Long.MIN_VALUE;
575 }
576
577 Date modifiedDate = getModifiedDate();
578
579 if (modifiedDate != null) {
580 ratingsEntryCacheModel.modifiedDate = modifiedDate.getTime();
581 }
582 else {
583 ratingsEntryCacheModel.modifiedDate = Long.MIN_VALUE;
584 }
585
586 ratingsEntryCacheModel.classNameId = getClassNameId();
587
588 ratingsEntryCacheModel.classPK = getClassPK();
589
590 ratingsEntryCacheModel.score = getScore();
591
592 return ratingsEntryCacheModel;
593 }
594
595 @Override
596 public String toString() {
597 StringBundler sb = new StringBundler(19);
598
599 sb.append("{entryId=");
600 sb.append(getEntryId());
601 sb.append(", companyId=");
602 sb.append(getCompanyId());
603 sb.append(", userId=");
604 sb.append(getUserId());
605 sb.append(", userName=");
606 sb.append(getUserName());
607 sb.append(", createDate=");
608 sb.append(getCreateDate());
609 sb.append(", modifiedDate=");
610 sb.append(getModifiedDate());
611 sb.append(", classNameId=");
612 sb.append(getClassNameId());
613 sb.append(", classPK=");
614 sb.append(getClassPK());
615 sb.append(", score=");
616 sb.append(getScore());
617 sb.append("}");
618
619 return sb.toString();
620 }
621
622 @Override
623 public String toXmlString() {
624 StringBundler sb = new StringBundler(31);
625
626 sb.append("<model><model-name>");
627 sb.append("com.liferay.portlet.ratings.model.RatingsEntry");
628 sb.append("</model-name>");
629
630 sb.append(
631 "<column><column-name>entryId</column-name><column-value><![CDATA[");
632 sb.append(getEntryId());
633 sb.append("]]></column-value></column>");
634 sb.append(
635 "<column><column-name>companyId</column-name><column-value><![CDATA[");
636 sb.append(getCompanyId());
637 sb.append("]]></column-value></column>");
638 sb.append(
639 "<column><column-name>userId</column-name><column-value><![CDATA[");
640 sb.append(getUserId());
641 sb.append("]]></column-value></column>");
642 sb.append(
643 "<column><column-name>userName</column-name><column-value><![CDATA[");
644 sb.append(getUserName());
645 sb.append("]]></column-value></column>");
646 sb.append(
647 "<column><column-name>createDate</column-name><column-value><![CDATA[");
648 sb.append(getCreateDate());
649 sb.append("]]></column-value></column>");
650 sb.append(
651 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
652 sb.append(getModifiedDate());
653 sb.append("]]></column-value></column>");
654 sb.append(
655 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
656 sb.append(getClassNameId());
657 sb.append("]]></column-value></column>");
658 sb.append(
659 "<column><column-name>classPK</column-name><column-value><![CDATA[");
660 sb.append(getClassPK());
661 sb.append("]]></column-value></column>");
662 sb.append(
663 "<column><column-name>score</column-name><column-value><![CDATA[");
664 sb.append(getScore());
665 sb.append("]]></column-value></column>");
666
667 sb.append("</model>");
668
669 return sb.toString();
670 }
671
672 private static ClassLoader _classLoader = RatingsEntry.class.getClassLoader();
673 private static Class<?>[] _escapedModelInterfaces = new Class[] {
674 RatingsEntry.class
675 };
676 private long _entryId;
677 private long _companyId;
678 private long _userId;
679 private String _userUuid;
680 private long _originalUserId;
681 private boolean _setOriginalUserId;
682 private String _userName;
683 private Date _createDate;
684 private Date _modifiedDate;
685 private long _classNameId;
686 private long _originalClassNameId;
687 private boolean _setOriginalClassNameId;
688 private long _classPK;
689 private long _originalClassPK;
690 private boolean _setOriginalClassPK;
691 private double _score;
692 private double _originalScore;
693 private boolean _setOriginalScore;
694 private long _columnBitmask;
695 private RatingsEntry _escapedModel;
696 }