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