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