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