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