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