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