001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
045     * The base model implementation for the UserNotificationDelivery service. Represents a row in the "UserNotificationDelivery" database table, with each column mapped to a property of this class.
046     *
047     * <p>
048     * This implementation and its corresponding interface {@link UserNotificationDeliveryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link UserNotificationDeliveryImpl}.
049     * </p>
050     *
051     * @author Brian Wing Shun Chan
052     * @see UserNotificationDeliveryImpl
053     * @see UserNotificationDelivery
054     * @see UserNotificationDeliveryModel
055     * @generated
056     */
057    @ProviderType
058    public class UserNotificationDeliveryModelImpl extends BaseModelImpl<UserNotificationDelivery>
059            implements UserNotificationDeliveryModel {
060            /*
061             * NOTE FOR DEVELOPERS:
062             *
063             * Never modify or reference this class directly. All methods that expect a user notification delivery model instance should use the {@link UserNotificationDelivery} interface instead.
064             */
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 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)";
078            public static final String TABLE_SQL_DROP = "drop table UserNotificationDelivery";
079            public static final String ORDER_BY_JPQL = " ORDER BY userNotificationDelivery.userNotificationDeliveryId ASC";
080            public static final String ORDER_BY_SQL = " ORDER BY UserNotificationDelivery.userNotificationDeliveryId ASC";
081            public static final String DATA_SOURCE = "liferayDataSource";
082            public static final String SESSION_FACTORY = "liferaySessionFactory";
083            public static final String TX_MANAGER = "liferayTransactionManager";
084            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085                                    "value.object.entity.cache.enabled.com.liferay.portal.model.UserNotificationDelivery"),
086                            true);
087            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
088                                    "value.object.finder.cache.enabled.com.liferay.portal.model.UserNotificationDelivery"),
089                            true);
090            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.UserNotificationDelivery"),
092                            true);
093            public static final long CLASSNAMEID_COLUMN_BITMASK = 1L;
094            public static final long DELIVERYTYPE_COLUMN_BITMASK = 2L;
095            public static final long NOTIFICATIONTYPE_COLUMN_BITMASK = 4L;
096            public static final long PORTLETID_COLUMN_BITMASK = 8L;
097            public static final long USERID_COLUMN_BITMASK = 16L;
098            public static final long USERNOTIFICATIONDELIVERYID_COLUMN_BITMASK = 32L;
099            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
100                                    "lock.expiration.time.com.liferay.portal.model.UserNotificationDelivery"));
101    
102            public UserNotificationDeliveryModelImpl() {
103            }
104    
105            @Override
106            public long getPrimaryKey() {
107                    return _userNotificationDeliveryId;
108            }
109    
110            @Override
111            public void setPrimaryKey(long primaryKey) {
112                    setUserNotificationDeliveryId(primaryKey);
113            }
114    
115            @Override
116            public Serializable getPrimaryKeyObj() {
117                    return _userNotificationDeliveryId;
118            }
119    
120            @Override
121            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
122                    setPrimaryKey(((Long)primaryKeyObj).longValue());
123            }
124    
125            @Override
126            public Class<?> getModelClass() {
127                    return UserNotificationDelivery.class;
128            }
129    
130            @Override
131            public String getModelClassName() {
132                    return UserNotificationDelivery.class.getName();
133            }
134    
135            @Override
136            public Map<String, Object> getModelAttributes() {
137                    Map<String, Object> attributes = new HashMap<String, Object>();
138    
139                    attributes.put("mvccVersion", getMvccVersion());
140                    attributes.put("userNotificationDeliveryId",
141                            getUserNotificationDeliveryId());
142                    attributes.put("companyId", getCompanyId());
143                    attributes.put("userId", getUserId());
144                    attributes.put("portletId", getPortletId());
145                    attributes.put("classNameId", getClassNameId());
146                    attributes.put("notificationType", getNotificationType());
147                    attributes.put("deliveryType", getDeliveryType());
148                    attributes.put("deliver", getDeliver());
149    
150                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
151                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
152    
153                    return attributes;
154            }
155    
156            @Override
157            public void setModelAttributes(Map<String, Object> attributes) {
158                    Long mvccVersion = (Long)attributes.get("mvccVersion");
159    
160                    if (mvccVersion != null) {
161                            setMvccVersion(mvccVersion);
162                    }
163    
164                    Long userNotificationDeliveryId = (Long)attributes.get(
165                                    "userNotificationDeliveryId");
166    
167                    if (userNotificationDeliveryId != null) {
168                            setUserNotificationDeliveryId(userNotificationDeliveryId);
169                    }
170    
171                    Long companyId = (Long)attributes.get("companyId");
172    
173                    if (companyId != null) {
174                            setCompanyId(companyId);
175                    }
176    
177                    Long userId = (Long)attributes.get("userId");
178    
179                    if (userId != null) {
180                            setUserId(userId);
181                    }
182    
183                    String portletId = (String)attributes.get("portletId");
184    
185                    if (portletId != null) {
186                            setPortletId(portletId);
187                    }
188    
189                    Long classNameId = (Long)attributes.get("classNameId");
190    
191                    if (classNameId != null) {
192                            setClassNameId(classNameId);
193                    }
194    
195                    Integer notificationType = (Integer)attributes.get("notificationType");
196    
197                    if (notificationType != null) {
198                            setNotificationType(notificationType);
199                    }
200    
201                    Integer deliveryType = (Integer)attributes.get("deliveryType");
202    
203                    if (deliveryType != null) {
204                            setDeliveryType(deliveryType);
205                    }
206    
207                    Boolean deliver = (Boolean)attributes.get("deliver");
208    
209                    if (deliver != null) {
210                            setDeliver(deliver);
211                    }
212            }
213    
214            @Override
215            public long getMvccVersion() {
216                    return _mvccVersion;
217            }
218    
219            @Override
220            public void setMvccVersion(long mvccVersion) {
221                    _mvccVersion = mvccVersion;
222            }
223    
224            @Override
225            public long getUserNotificationDeliveryId() {
226                    return _userNotificationDeliveryId;
227            }
228    
229            @Override
230            public void setUserNotificationDeliveryId(long userNotificationDeliveryId) {
231                    _userNotificationDeliveryId = userNotificationDeliveryId;
232            }
233    
234            @Override
235            public long getCompanyId() {
236                    return _companyId;
237            }
238    
239            @Override
240            public void setCompanyId(long companyId) {
241                    _companyId = companyId;
242            }
243    
244            @Override
245            public long getUserId() {
246                    return _userId;
247            }
248    
249            @Override
250            public void setUserId(long userId) {
251                    _columnBitmask |= USERID_COLUMN_BITMASK;
252    
253                    if (!_setOriginalUserId) {
254                            _setOriginalUserId = true;
255    
256                            _originalUserId = _userId;
257                    }
258    
259                    _userId = userId;
260            }
261    
262            @Override
263            public String getUserUuid() {
264                    try {
265                            User user = UserLocalServiceUtil.getUserById(getUserId());
266    
267                            return user.getUuid();
268                    }
269                    catch (PortalException pe) {
270                            return StringPool.BLANK;
271                    }
272            }
273    
274            @Override
275            public void setUserUuid(String userUuid) {
276            }
277    
278            public long getOriginalUserId() {
279                    return _originalUserId;
280            }
281    
282            @Override
283            public String getPortletId() {
284                    if (_portletId == null) {
285                            return StringPool.BLANK;
286                    }
287                    else {
288                            return _portletId;
289                    }
290            }
291    
292            @Override
293            public void setPortletId(String portletId) {
294                    _columnBitmask |= PORTLETID_COLUMN_BITMASK;
295    
296                    if (_originalPortletId == null) {
297                            _originalPortletId = _portletId;
298                    }
299    
300                    _portletId = portletId;
301            }
302    
303            public String getOriginalPortletId() {
304                    return GetterUtil.getString(_originalPortletId);
305            }
306    
307            @Override
308            public String getClassName() {
309                    if (getClassNameId() <= 0) {
310                            return StringPool.BLANK;
311                    }
312    
313                    return PortalUtil.getClassName(getClassNameId());
314            }
315    
316            @Override
317            public void setClassName(String className) {
318                    long classNameId = 0;
319    
320                    if (Validator.isNotNull(className)) {
321                            classNameId = PortalUtil.getClassNameId(className);
322                    }
323    
324                    setClassNameId(classNameId);
325            }
326    
327            @Override
328            public long getClassNameId() {
329                    return _classNameId;
330            }
331    
332            @Override
333            public void setClassNameId(long classNameId) {
334                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
335    
336                    if (!_setOriginalClassNameId) {
337                            _setOriginalClassNameId = true;
338    
339                            _originalClassNameId = _classNameId;
340                    }
341    
342                    _classNameId = classNameId;
343            }
344    
345            public long getOriginalClassNameId() {
346                    return _originalClassNameId;
347            }
348    
349            @Override
350            public int getNotificationType() {
351                    return _notificationType;
352            }
353    
354            @Override
355            public void setNotificationType(int notificationType) {
356                    _columnBitmask |= NOTIFICATIONTYPE_COLUMN_BITMASK;
357    
358                    if (!_setOriginalNotificationType) {
359                            _setOriginalNotificationType = true;
360    
361                            _originalNotificationType = _notificationType;
362                    }
363    
364                    _notificationType = notificationType;
365            }
366    
367            public int getOriginalNotificationType() {
368                    return _originalNotificationType;
369            }
370    
371            @Override
372            public int getDeliveryType() {
373                    return _deliveryType;
374            }
375    
376            @Override
377            public void setDeliveryType(int deliveryType) {
378                    _columnBitmask |= DELIVERYTYPE_COLUMN_BITMASK;
379    
380                    if (!_setOriginalDeliveryType) {
381                            _setOriginalDeliveryType = true;
382    
383                            _originalDeliveryType = _deliveryType;
384                    }
385    
386                    _deliveryType = deliveryType;
387            }
388    
389            public int getOriginalDeliveryType() {
390                    return _originalDeliveryType;
391            }
392    
393            @Override
394            public boolean getDeliver() {
395                    return _deliver;
396            }
397    
398            @Override
399            public boolean isDeliver() {
400                    return _deliver;
401            }
402    
403            @Override
404            public void setDeliver(boolean deliver) {
405                    _deliver = deliver;
406            }
407    
408            public long getColumnBitmask() {
409                    return _columnBitmask;
410            }
411    
412            @Override
413            public ExpandoBridge getExpandoBridge() {
414                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
415                            UserNotificationDelivery.class.getName(), getPrimaryKey());
416            }
417    
418            @Override
419            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
420                    ExpandoBridge expandoBridge = getExpandoBridge();
421    
422                    expandoBridge.setAttributes(serviceContext);
423            }
424    
425            @Override
426            public UserNotificationDelivery toEscapedModel() {
427                    if (_escapedModel == null) {
428                            _escapedModel = (UserNotificationDelivery)ProxyUtil.newProxyInstance(_classLoader,
429                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
430                    }
431    
432                    return _escapedModel;
433            }
434    
435            @Override
436            public Object clone() {
437                    UserNotificationDeliveryImpl userNotificationDeliveryImpl = new UserNotificationDeliveryImpl();
438    
439                    userNotificationDeliveryImpl.setMvccVersion(getMvccVersion());
440                    userNotificationDeliveryImpl.setUserNotificationDeliveryId(getUserNotificationDeliveryId());
441                    userNotificationDeliveryImpl.setCompanyId(getCompanyId());
442                    userNotificationDeliveryImpl.setUserId(getUserId());
443                    userNotificationDeliveryImpl.setPortletId(getPortletId());
444                    userNotificationDeliveryImpl.setClassNameId(getClassNameId());
445                    userNotificationDeliveryImpl.setNotificationType(getNotificationType());
446                    userNotificationDeliveryImpl.setDeliveryType(getDeliveryType());
447                    userNotificationDeliveryImpl.setDeliver(getDeliver());
448    
449                    userNotificationDeliveryImpl.resetOriginalValues();
450    
451                    return userNotificationDeliveryImpl;
452            }
453    
454            @Override
455            public int compareTo(UserNotificationDelivery userNotificationDelivery) {
456                    long primaryKey = userNotificationDelivery.getPrimaryKey();
457    
458                    if (getPrimaryKey() < primaryKey) {
459                            return -1;
460                    }
461                    else if (getPrimaryKey() > primaryKey) {
462                            return 1;
463                    }
464                    else {
465                            return 0;
466                    }
467            }
468    
469            @Override
470            public boolean equals(Object obj) {
471                    if (this == obj) {
472                            return true;
473                    }
474    
475                    if (!(obj instanceof UserNotificationDelivery)) {
476                            return false;
477                    }
478    
479                    UserNotificationDelivery userNotificationDelivery = (UserNotificationDelivery)obj;
480    
481                    long primaryKey = userNotificationDelivery.getPrimaryKey();
482    
483                    if (getPrimaryKey() == primaryKey) {
484                            return true;
485                    }
486                    else {
487                            return false;
488                    }
489            }
490    
491            @Override
492            public int hashCode() {
493                    return (int)getPrimaryKey();
494            }
495    
496            @Override
497            public boolean isEntityCacheEnabled() {
498                    return ENTITY_CACHE_ENABLED;
499            }
500    
501            @Override
502            public boolean isFinderCacheEnabled() {
503                    return FINDER_CACHE_ENABLED;
504            }
505    
506            @Override
507            public void resetOriginalValues() {
508                    UserNotificationDeliveryModelImpl userNotificationDeliveryModelImpl = this;
509    
510                    userNotificationDeliveryModelImpl._originalUserId = userNotificationDeliveryModelImpl._userId;
511    
512                    userNotificationDeliveryModelImpl._setOriginalUserId = false;
513    
514                    userNotificationDeliveryModelImpl._originalPortletId = userNotificationDeliveryModelImpl._portletId;
515    
516                    userNotificationDeliveryModelImpl._originalClassNameId = userNotificationDeliveryModelImpl._classNameId;
517    
518                    userNotificationDeliveryModelImpl._setOriginalClassNameId = false;
519    
520                    userNotificationDeliveryModelImpl._originalNotificationType = userNotificationDeliveryModelImpl._notificationType;
521    
522                    userNotificationDeliveryModelImpl._setOriginalNotificationType = false;
523    
524                    userNotificationDeliveryModelImpl._originalDeliveryType = userNotificationDeliveryModelImpl._deliveryType;
525    
526                    userNotificationDeliveryModelImpl._setOriginalDeliveryType = false;
527    
528                    userNotificationDeliveryModelImpl._columnBitmask = 0;
529            }
530    
531            @Override
532            public CacheModel<UserNotificationDelivery> toCacheModel() {
533                    UserNotificationDeliveryCacheModel userNotificationDeliveryCacheModel = new UserNotificationDeliveryCacheModel();
534    
535                    userNotificationDeliveryCacheModel.mvccVersion = getMvccVersion();
536    
537                    userNotificationDeliveryCacheModel.userNotificationDeliveryId = getUserNotificationDeliveryId();
538    
539                    userNotificationDeliveryCacheModel.companyId = getCompanyId();
540    
541                    userNotificationDeliveryCacheModel.userId = getUserId();
542    
543                    userNotificationDeliveryCacheModel.portletId = getPortletId();
544    
545                    String portletId = userNotificationDeliveryCacheModel.portletId;
546    
547                    if ((portletId != null) && (portletId.length() == 0)) {
548                            userNotificationDeliveryCacheModel.portletId = null;
549                    }
550    
551                    userNotificationDeliveryCacheModel.classNameId = getClassNameId();
552    
553                    userNotificationDeliveryCacheModel.notificationType = getNotificationType();
554    
555                    userNotificationDeliveryCacheModel.deliveryType = getDeliveryType();
556    
557                    userNotificationDeliveryCacheModel.deliver = getDeliver();
558    
559                    return userNotificationDeliveryCacheModel;
560            }
561    
562            @Override
563            public String toString() {
564                    StringBundler sb = new StringBundler(19);
565    
566                    sb.append("{mvccVersion=");
567                    sb.append(getMvccVersion());
568                    sb.append(", userNotificationDeliveryId=");
569                    sb.append(getUserNotificationDeliveryId());
570                    sb.append(", companyId=");
571                    sb.append(getCompanyId());
572                    sb.append(", userId=");
573                    sb.append(getUserId());
574                    sb.append(", portletId=");
575                    sb.append(getPortletId());
576                    sb.append(", classNameId=");
577                    sb.append(getClassNameId());
578                    sb.append(", notificationType=");
579                    sb.append(getNotificationType());
580                    sb.append(", deliveryType=");
581                    sb.append(getDeliveryType());
582                    sb.append(", deliver=");
583                    sb.append(getDeliver());
584                    sb.append("}");
585    
586                    return sb.toString();
587            }
588    
589            @Override
590            public String toXmlString() {
591                    StringBundler sb = new StringBundler(31);
592    
593                    sb.append("<model><model-name>");
594                    sb.append("com.liferay.portal.model.UserNotificationDelivery");
595                    sb.append("</model-name>");
596    
597                    sb.append(
598                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
599                    sb.append(getMvccVersion());
600                    sb.append("]]></column-value></column>");
601                    sb.append(
602                            "<column><column-name>userNotificationDeliveryId</column-name><column-value><![CDATA[");
603                    sb.append(getUserNotificationDeliveryId());
604                    sb.append("]]></column-value></column>");
605                    sb.append(
606                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
607                    sb.append(getCompanyId());
608                    sb.append("]]></column-value></column>");
609                    sb.append(
610                            "<column><column-name>userId</column-name><column-value><![CDATA[");
611                    sb.append(getUserId());
612                    sb.append("]]></column-value></column>");
613                    sb.append(
614                            "<column><column-name>portletId</column-name><column-value><![CDATA[");
615                    sb.append(getPortletId());
616                    sb.append("]]></column-value></column>");
617                    sb.append(
618                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
619                    sb.append(getClassNameId());
620                    sb.append("]]></column-value></column>");
621                    sb.append(
622                            "<column><column-name>notificationType</column-name><column-value><![CDATA[");
623                    sb.append(getNotificationType());
624                    sb.append("]]></column-value></column>");
625                    sb.append(
626                            "<column><column-name>deliveryType</column-name><column-value><![CDATA[");
627                    sb.append(getDeliveryType());
628                    sb.append("]]></column-value></column>");
629                    sb.append(
630                            "<column><column-name>deliver</column-name><column-value><![CDATA[");
631                    sb.append(getDeliver());
632                    sb.append("]]></column-value></column>");
633    
634                    sb.append("</model>");
635    
636                    return sb.toString();
637            }
638    
639            private static final ClassLoader _classLoader = UserNotificationDelivery.class.getClassLoader();
640            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
641                            UserNotificationDelivery.class
642                    };
643            private long _mvccVersion;
644            private long _userNotificationDeliveryId;
645            private long _companyId;
646            private long _userId;
647            private long _originalUserId;
648            private boolean _setOriginalUserId;
649            private String _portletId;
650            private String _originalPortletId;
651            private long _classNameId;
652            private long _originalClassNameId;
653            private boolean _setOriginalClassNameId;
654            private int _notificationType;
655            private int _originalNotificationType;
656            private boolean _setOriginalNotificationType;
657            private int _deliveryType;
658            private int _originalDeliveryType;
659            private boolean _setOriginalDeliveryType;
660            private boolean _deliver;
661            private long _columnBitmask;
662            private UserNotificationDelivery _escapedModel;
663    }