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