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.lar.StagedModelType;
023 import com.liferay.portal.kernel.util.GetterUtil;
024 import com.liferay.portal.kernel.util.ProxyUtil;
025 import com.liferay.portal.kernel.util.StringBundler;
026 import com.liferay.portal.kernel.util.StringPool;
027 import com.liferay.portal.kernel.util.Validator;
028 import com.liferay.portal.model.CacheModel;
029 import com.liferay.portal.model.User;
030 import com.liferay.portal.model.impl.BaseModelImpl;
031 import com.liferay.portal.service.ServiceContext;
032 import com.liferay.portal.service.UserLocalServiceUtil;
033 import com.liferay.portal.util.PortalUtil;
034
035 import com.liferay.portlet.expando.model.ExpandoBridge;
036 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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 @Override
408 public void setModifiedDate(Date modifiedDate) {
409 _modifiedDate = modifiedDate;
410 }
411
412 @Override
413 public String getClassName() {
414 if (getClassNameId() <= 0) {
415 return StringPool.BLANK;
416 }
417
418 return PortalUtil.getClassName(getClassNameId());
419 }
420
421 @Override
422 public void setClassName(String className) {
423 long classNameId = 0;
424
425 if (Validator.isNotNull(className)) {
426 classNameId = PortalUtil.getClassNameId(className);
427 }
428
429 setClassNameId(classNameId);
430 }
431
432 @JSON
433 @Override
434 public long getClassNameId() {
435 return _classNameId;
436 }
437
438 @Override
439 public void setClassNameId(long classNameId) {
440 _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
441
442 if (!_setOriginalClassNameId) {
443 _setOriginalClassNameId = true;
444
445 _originalClassNameId = _classNameId;
446 }
447
448 _classNameId = classNameId;
449 }
450
451 public long getOriginalClassNameId() {
452 return _originalClassNameId;
453 }
454
455 @JSON
456 @Override
457 public long getClassPK() {
458 return _classPK;
459 }
460
461 @Override
462 public void setClassPK(long classPK) {
463 _columnBitmask |= CLASSPK_COLUMN_BITMASK;
464
465 if (!_setOriginalClassPK) {
466 _setOriginalClassPK = true;
467
468 _originalClassPK = _classPK;
469 }
470
471 _classPK = classPK;
472 }
473
474 public long getOriginalClassPK() {
475 return _originalClassPK;
476 }
477
478 @JSON
479 @Override
480 public double getScore() {
481 return _score;
482 }
483
484 @Override
485 public void setScore(double score) {
486 _columnBitmask |= SCORE_COLUMN_BITMASK;
487
488 if (!_setOriginalScore) {
489 _setOriginalScore = true;
490
491 _originalScore = _score;
492 }
493
494 _score = score;
495 }
496
497 public double getOriginalScore() {
498 return _originalScore;
499 }
500
501 @Override
502 public StagedModelType getStagedModelType() {
503 return new StagedModelType(PortalUtil.getClassNameId(
504 RatingsEntry.class.getName()), getClassNameId());
505 }
506
507 public long getColumnBitmask() {
508 return _columnBitmask;
509 }
510
511 @Override
512 public ExpandoBridge getExpandoBridge() {
513 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
514 RatingsEntry.class.getName(), getPrimaryKey());
515 }
516
517 @Override
518 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
519 ExpandoBridge expandoBridge = getExpandoBridge();
520
521 expandoBridge.setAttributes(serviceContext);
522 }
523
524 @Override
525 public RatingsEntry toEscapedModel() {
526 if (_escapedModel == null) {
527 _escapedModel = (RatingsEntry)ProxyUtil.newProxyInstance(_classLoader,
528 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
529 }
530
531 return _escapedModel;
532 }
533
534 @Override
535 public Object clone() {
536 RatingsEntryImpl ratingsEntryImpl = new RatingsEntryImpl();
537
538 ratingsEntryImpl.setUuid(getUuid());
539 ratingsEntryImpl.setEntryId(getEntryId());
540 ratingsEntryImpl.setCompanyId(getCompanyId());
541 ratingsEntryImpl.setUserId(getUserId());
542 ratingsEntryImpl.setUserName(getUserName());
543 ratingsEntryImpl.setCreateDate(getCreateDate());
544 ratingsEntryImpl.setModifiedDate(getModifiedDate());
545 ratingsEntryImpl.setClassNameId(getClassNameId());
546 ratingsEntryImpl.setClassPK(getClassPK());
547 ratingsEntryImpl.setScore(getScore());
548
549 ratingsEntryImpl.resetOriginalValues();
550
551 return ratingsEntryImpl;
552 }
553
554 @Override
555 public int compareTo(RatingsEntry ratingsEntry) {
556 long primaryKey = ratingsEntry.getPrimaryKey();
557
558 if (getPrimaryKey() < primaryKey) {
559 return -1;
560 }
561 else if (getPrimaryKey() > primaryKey) {
562 return 1;
563 }
564 else {
565 return 0;
566 }
567 }
568
569 @Override
570 public boolean equals(Object obj) {
571 if (this == obj) {
572 return true;
573 }
574
575 if (!(obj instanceof RatingsEntry)) {
576 return false;
577 }
578
579 RatingsEntry ratingsEntry = (RatingsEntry)obj;
580
581 long primaryKey = ratingsEntry.getPrimaryKey();
582
583 if (getPrimaryKey() == primaryKey) {
584 return true;
585 }
586 else {
587 return false;
588 }
589 }
590
591 @Override
592 public int hashCode() {
593 return (int)getPrimaryKey();
594 }
595
596 @Override
597 public boolean isEntityCacheEnabled() {
598 return ENTITY_CACHE_ENABLED;
599 }
600
601 @Override
602 public boolean isFinderCacheEnabled() {
603 return FINDER_CACHE_ENABLED;
604 }
605
606 @Override
607 public void resetOriginalValues() {
608 RatingsEntryModelImpl ratingsEntryModelImpl = this;
609
610 ratingsEntryModelImpl._originalUuid = ratingsEntryModelImpl._uuid;
611
612 ratingsEntryModelImpl._originalCompanyId = ratingsEntryModelImpl._companyId;
613
614 ratingsEntryModelImpl._setOriginalCompanyId = false;
615
616 ratingsEntryModelImpl._originalUserId = ratingsEntryModelImpl._userId;
617
618 ratingsEntryModelImpl._setOriginalUserId = false;
619
620 ratingsEntryModelImpl._originalClassNameId = ratingsEntryModelImpl._classNameId;
621
622 ratingsEntryModelImpl._setOriginalClassNameId = false;
623
624 ratingsEntryModelImpl._originalClassPK = ratingsEntryModelImpl._classPK;
625
626 ratingsEntryModelImpl._setOriginalClassPK = false;
627
628 ratingsEntryModelImpl._originalScore = ratingsEntryModelImpl._score;
629
630 ratingsEntryModelImpl._setOriginalScore = false;
631
632 ratingsEntryModelImpl._columnBitmask = 0;
633 }
634
635 @Override
636 public CacheModel<RatingsEntry> toCacheModel() {
637 RatingsEntryCacheModel ratingsEntryCacheModel = new RatingsEntryCacheModel();
638
639 ratingsEntryCacheModel.uuid = getUuid();
640
641 String uuid = ratingsEntryCacheModel.uuid;
642
643 if ((uuid != null) && (uuid.length() == 0)) {
644 ratingsEntryCacheModel.uuid = null;
645 }
646
647 ratingsEntryCacheModel.entryId = getEntryId();
648
649 ratingsEntryCacheModel.companyId = getCompanyId();
650
651 ratingsEntryCacheModel.userId = getUserId();
652
653 ratingsEntryCacheModel.userName = getUserName();
654
655 String userName = ratingsEntryCacheModel.userName;
656
657 if ((userName != null) && (userName.length() == 0)) {
658 ratingsEntryCacheModel.userName = null;
659 }
660
661 Date createDate = getCreateDate();
662
663 if (createDate != null) {
664 ratingsEntryCacheModel.createDate = createDate.getTime();
665 }
666 else {
667 ratingsEntryCacheModel.createDate = Long.MIN_VALUE;
668 }
669
670 Date modifiedDate = getModifiedDate();
671
672 if (modifiedDate != null) {
673 ratingsEntryCacheModel.modifiedDate = modifiedDate.getTime();
674 }
675 else {
676 ratingsEntryCacheModel.modifiedDate = Long.MIN_VALUE;
677 }
678
679 ratingsEntryCacheModel.classNameId = getClassNameId();
680
681 ratingsEntryCacheModel.classPK = getClassPK();
682
683 ratingsEntryCacheModel.score = getScore();
684
685 return ratingsEntryCacheModel;
686 }
687
688 @Override
689 public String toString() {
690 StringBundler sb = new StringBundler(21);
691
692 sb.append("{uuid=");
693 sb.append(getUuid());
694 sb.append(", entryId=");
695 sb.append(getEntryId());
696 sb.append(", companyId=");
697 sb.append(getCompanyId());
698 sb.append(", userId=");
699 sb.append(getUserId());
700 sb.append(", userName=");
701 sb.append(getUserName());
702 sb.append(", createDate=");
703 sb.append(getCreateDate());
704 sb.append(", modifiedDate=");
705 sb.append(getModifiedDate());
706 sb.append(", classNameId=");
707 sb.append(getClassNameId());
708 sb.append(", classPK=");
709 sb.append(getClassPK());
710 sb.append(", score=");
711 sb.append(getScore());
712 sb.append("}");
713
714 return sb.toString();
715 }
716
717 @Override
718 public String toXmlString() {
719 StringBundler sb = new StringBundler(34);
720
721 sb.append("<model><model-name>");
722 sb.append("com.liferay.portlet.ratings.model.RatingsEntry");
723 sb.append("</model-name>");
724
725 sb.append(
726 "<column><column-name>uuid</column-name><column-value><![CDATA[");
727 sb.append(getUuid());
728 sb.append("]]></column-value></column>");
729 sb.append(
730 "<column><column-name>entryId</column-name><column-value><![CDATA[");
731 sb.append(getEntryId());
732 sb.append("]]></column-value></column>");
733 sb.append(
734 "<column><column-name>companyId</column-name><column-value><![CDATA[");
735 sb.append(getCompanyId());
736 sb.append("]]></column-value></column>");
737 sb.append(
738 "<column><column-name>userId</column-name><column-value><![CDATA[");
739 sb.append(getUserId());
740 sb.append("]]></column-value></column>");
741 sb.append(
742 "<column><column-name>userName</column-name><column-value><![CDATA[");
743 sb.append(getUserName());
744 sb.append("]]></column-value></column>");
745 sb.append(
746 "<column><column-name>createDate</column-name><column-value><![CDATA[");
747 sb.append(getCreateDate());
748 sb.append("]]></column-value></column>");
749 sb.append(
750 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
751 sb.append(getModifiedDate());
752 sb.append("]]></column-value></column>");
753 sb.append(
754 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
755 sb.append(getClassNameId());
756 sb.append("]]></column-value></column>");
757 sb.append(
758 "<column><column-name>classPK</column-name><column-value><![CDATA[");
759 sb.append(getClassPK());
760 sb.append("]]></column-value></column>");
761 sb.append(
762 "<column><column-name>score</column-name><column-value><![CDATA[");
763 sb.append(getScore());
764 sb.append("]]></column-value></column>");
765
766 sb.append("</model>");
767
768 return sb.toString();
769 }
770
771 private static final ClassLoader _classLoader = RatingsEntry.class.getClassLoader();
772 private static final Class<?>[] _escapedModelInterfaces = new Class[] {
773 RatingsEntry.class
774 };
775 private String _uuid;
776 private String _originalUuid;
777 private long _entryId;
778 private long _companyId;
779 private long _originalCompanyId;
780 private boolean _setOriginalCompanyId;
781 private long _userId;
782 private long _originalUserId;
783 private boolean _setOriginalUserId;
784 private String _userName;
785 private Date _createDate;
786 private Date _modifiedDate;
787 private long _classNameId;
788 private long _originalClassNameId;
789 private boolean _setOriginalClassNameId;
790 private long _classPK;
791 private long _originalClassPK;
792 private boolean _setOriginalClassPK;
793 private double _score;
794 private double _originalScore;
795 private boolean _setOriginalScore;
796 private long _columnBitmask;
797 private RatingsEntry _escapedModel;
798 }