001    /**
002     * Copyright (c) 2000-2012 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.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    /**
037     * The base model implementation for the UserNotificationEvent service. Represents a row in the "UserNotificationEvent" database table, with each column mapped to a property of this class.
038     *
039     * <p>
040     * This implementation and its corresponding interface {@link com.liferay.portal.model.UserNotificationEventModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link UserNotificationEventImpl}.
041     * </p>
042     *
043     * @author Brian Wing Shun Chan
044     * @see UserNotificationEventImpl
045     * @see com.liferay.portal.model.UserNotificationEvent
046     * @see com.liferay.portal.model.UserNotificationEventModel
047     * @generated
048     */
049    public class UserNotificationEventModelImpl extends BaseModelImpl<UserNotificationEvent>
050            implements UserNotificationEventModel {
051            /*
052             * NOTE FOR DEVELOPERS:
053             *
054             * Never modify or reference this class directly. All methods that expect a user notification event model instance should use the {@link com.liferay.portal.model.UserNotificationEvent} interface instead.
055             */
056            public static final String TABLE_NAME = "UserNotificationEvent";
057            public static final Object[][] TABLE_COLUMNS = {
058                            { "uuid_", Types.VARCHAR },
059                            { "userNotificationEventId", Types.BIGINT },
060                            { "companyId", Types.BIGINT },
061                            { "userId", Types.BIGINT },
062                            { "type_", Types.VARCHAR },
063                            { "timestamp", Types.BIGINT },
064                            { "deliverBy", Types.BIGINT },
065                            { "payload", Types.CLOB },
066                            { "archived", Types.BOOLEAN }
067                    };
068            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,payload TEXT null,archived BOOLEAN)";
069            public static final String TABLE_SQL_DROP = "drop table UserNotificationEvent";
070            public static final String ORDER_BY_JPQL = " ORDER BY userNotificationEvent.timestamp DESC";
071            public static final String ORDER_BY_SQL = " ORDER BY UserNotificationEvent.timestamp DESC";
072            public static final String DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portal.model.UserNotificationEvent"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portal.model.UserNotificationEvent"),
080                            true);
081            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.UserNotificationEvent"),
083                            true);
084            public static long ARCHIVED_COLUMN_BITMASK = 1L;
085            public static long USERID_COLUMN_BITMASK = 2L;
086            public static long UUID_COLUMN_BITMASK = 4L;
087            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
088                                    "lock.expiration.time.com.liferay.portal.model.UserNotificationEvent"));
089    
090            public UserNotificationEventModelImpl() {
091            }
092    
093            public long getPrimaryKey() {
094                    return _userNotificationEventId;
095            }
096    
097            public void setPrimaryKey(long primaryKey) {
098                    setUserNotificationEventId(primaryKey);
099            }
100    
101            public Serializable getPrimaryKeyObj() {
102                    return new Long(_userNotificationEventId);
103            }
104    
105            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
106                    setPrimaryKey(((Long)primaryKeyObj).longValue());
107            }
108    
109            public Class<?> getModelClass() {
110                    return UserNotificationEvent.class;
111            }
112    
113            public String getModelClassName() {
114                    return UserNotificationEvent.class.getName();
115            }
116    
117            public String getUuid() {
118                    if (_uuid == null) {
119                            return StringPool.BLANK;
120                    }
121                    else {
122                            return _uuid;
123                    }
124            }
125    
126            public void setUuid(String uuid) {
127                    if (_originalUuid == null) {
128                            _originalUuid = _uuid;
129                    }
130    
131                    _uuid = uuid;
132            }
133    
134            public String getOriginalUuid() {
135                    return GetterUtil.getString(_originalUuid);
136            }
137    
138            public long getUserNotificationEventId() {
139                    return _userNotificationEventId;
140            }
141    
142            public void setUserNotificationEventId(long userNotificationEventId) {
143                    _userNotificationEventId = userNotificationEventId;
144            }
145    
146            public long getCompanyId() {
147                    return _companyId;
148            }
149    
150            public void setCompanyId(long companyId) {
151                    _companyId = companyId;
152            }
153    
154            public long getUserId() {
155                    return _userId;
156            }
157    
158            public void setUserId(long userId) {
159                    _columnBitmask |= USERID_COLUMN_BITMASK;
160    
161                    if (!_setOriginalUserId) {
162                            _setOriginalUserId = true;
163    
164                            _originalUserId = _userId;
165                    }
166    
167                    _userId = userId;
168            }
169    
170            public String getUserUuid() throws SystemException {
171                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
172            }
173    
174            public void setUserUuid(String userUuid) {
175                    _userUuid = userUuid;
176            }
177    
178            public long getOriginalUserId() {
179                    return _originalUserId;
180            }
181    
182            public String getType() {
183                    if (_type == null) {
184                            return StringPool.BLANK;
185                    }
186                    else {
187                            return _type;
188                    }
189            }
190    
191            public void setType(String type) {
192                    _type = type;
193            }
194    
195            public long getTimestamp() {
196                    return _timestamp;
197            }
198    
199            public void setTimestamp(long timestamp) {
200                    _columnBitmask = -1L;
201    
202                    _timestamp = timestamp;
203            }
204    
205            public long getDeliverBy() {
206                    return _deliverBy;
207            }
208    
209            public void setDeliverBy(long deliverBy) {
210                    _deliverBy = deliverBy;
211            }
212    
213            public String getPayload() {
214                    if (_payload == null) {
215                            return StringPool.BLANK;
216                    }
217                    else {
218                            return _payload;
219                    }
220            }
221    
222            public void setPayload(String payload) {
223                    _payload = payload;
224            }
225    
226            public boolean getArchived() {
227                    return _archived;
228            }
229    
230            public boolean isArchived() {
231                    return _archived;
232            }
233    
234            public void setArchived(boolean archived) {
235                    _columnBitmask |= ARCHIVED_COLUMN_BITMASK;
236    
237                    if (!_setOriginalArchived) {
238                            _setOriginalArchived = true;
239    
240                            _originalArchived = _archived;
241                    }
242    
243                    _archived = archived;
244            }
245    
246            public boolean getOriginalArchived() {
247                    return _originalArchived;
248            }
249    
250            public long getColumnBitmask() {
251                    return _columnBitmask;
252            }
253    
254            @Override
255            public UserNotificationEvent toEscapedModel() {
256                    if (_escapedModelProxy == null) {
257                            _escapedModelProxy = (UserNotificationEvent)ProxyUtil.newProxyInstance(_classLoader,
258                                            _escapedModelProxyInterfaces,
259                                            new AutoEscapeBeanHandler(this));
260                    }
261    
262                    return _escapedModelProxy;
263            }
264    
265            @Override
266            public ExpandoBridge getExpandoBridge() {
267                    if (_expandoBridge == null) {
268                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
269                                            UserNotificationEvent.class.getName(), getPrimaryKey());
270                    }
271    
272                    return _expandoBridge;
273            }
274    
275            @Override
276            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
277                    getExpandoBridge().setAttributes(serviceContext);
278            }
279    
280            @Override
281            public Object clone() {
282                    UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
283    
284                    userNotificationEventImpl.setUuid(getUuid());
285                    userNotificationEventImpl.setUserNotificationEventId(getUserNotificationEventId());
286                    userNotificationEventImpl.setCompanyId(getCompanyId());
287                    userNotificationEventImpl.setUserId(getUserId());
288                    userNotificationEventImpl.setType(getType());
289                    userNotificationEventImpl.setTimestamp(getTimestamp());
290                    userNotificationEventImpl.setDeliverBy(getDeliverBy());
291                    userNotificationEventImpl.setPayload(getPayload());
292                    userNotificationEventImpl.setArchived(getArchived());
293    
294                    userNotificationEventImpl.resetOriginalValues();
295    
296                    return userNotificationEventImpl;
297            }
298    
299            public int compareTo(UserNotificationEvent userNotificationEvent) {
300                    int value = 0;
301    
302                    if (getTimestamp() < userNotificationEvent.getTimestamp()) {
303                            value = -1;
304                    }
305                    else if (getTimestamp() > userNotificationEvent.getTimestamp()) {
306                            value = 1;
307                    }
308                    else {
309                            value = 0;
310                    }
311    
312                    value = value * -1;
313    
314                    if (value != 0) {
315                            return value;
316                    }
317    
318                    return 0;
319            }
320    
321            @Override
322            public boolean equals(Object obj) {
323                    if (obj == null) {
324                            return false;
325                    }
326    
327                    UserNotificationEvent userNotificationEvent = null;
328    
329                    try {
330                            userNotificationEvent = (UserNotificationEvent)obj;
331                    }
332                    catch (ClassCastException cce) {
333                            return false;
334                    }
335    
336                    long primaryKey = userNotificationEvent.getPrimaryKey();
337    
338                    if (getPrimaryKey() == primaryKey) {
339                            return true;
340                    }
341                    else {
342                            return false;
343                    }
344            }
345    
346            @Override
347            public int hashCode() {
348                    return (int)getPrimaryKey();
349            }
350    
351            @Override
352            public void resetOriginalValues() {
353                    UserNotificationEventModelImpl userNotificationEventModelImpl = this;
354    
355                    userNotificationEventModelImpl._originalUuid = userNotificationEventModelImpl._uuid;
356    
357                    userNotificationEventModelImpl._originalUserId = userNotificationEventModelImpl._userId;
358    
359                    userNotificationEventModelImpl._setOriginalUserId = false;
360    
361                    userNotificationEventModelImpl._originalArchived = userNotificationEventModelImpl._archived;
362    
363                    userNotificationEventModelImpl._setOriginalArchived = false;
364    
365                    userNotificationEventModelImpl._columnBitmask = 0;
366            }
367    
368            @Override
369            public CacheModel<UserNotificationEvent> toCacheModel() {
370                    UserNotificationEventCacheModel userNotificationEventCacheModel = new UserNotificationEventCacheModel();
371    
372                    userNotificationEventCacheModel.uuid = getUuid();
373    
374                    String uuid = userNotificationEventCacheModel.uuid;
375    
376                    if ((uuid != null) && (uuid.length() == 0)) {
377                            userNotificationEventCacheModel.uuid = null;
378                    }
379    
380                    userNotificationEventCacheModel.userNotificationEventId = getUserNotificationEventId();
381    
382                    userNotificationEventCacheModel.companyId = getCompanyId();
383    
384                    userNotificationEventCacheModel.userId = getUserId();
385    
386                    userNotificationEventCacheModel.type = getType();
387    
388                    String type = userNotificationEventCacheModel.type;
389    
390                    if ((type != null) && (type.length() == 0)) {
391                            userNotificationEventCacheModel.type = null;
392                    }
393    
394                    userNotificationEventCacheModel.timestamp = getTimestamp();
395    
396                    userNotificationEventCacheModel.deliverBy = getDeliverBy();
397    
398                    userNotificationEventCacheModel.payload = getPayload();
399    
400                    String payload = userNotificationEventCacheModel.payload;
401    
402                    if ((payload != null) && (payload.length() == 0)) {
403                            userNotificationEventCacheModel.payload = null;
404                    }
405    
406                    userNotificationEventCacheModel.archived = getArchived();
407    
408                    return userNotificationEventCacheModel;
409            }
410    
411            @Override
412            public String toString() {
413                    StringBundler sb = new StringBundler(19);
414    
415                    sb.append("{uuid=");
416                    sb.append(getUuid());
417                    sb.append(", userNotificationEventId=");
418                    sb.append(getUserNotificationEventId());
419                    sb.append(", companyId=");
420                    sb.append(getCompanyId());
421                    sb.append(", userId=");
422                    sb.append(getUserId());
423                    sb.append(", type=");
424                    sb.append(getType());
425                    sb.append(", timestamp=");
426                    sb.append(getTimestamp());
427                    sb.append(", deliverBy=");
428                    sb.append(getDeliverBy());
429                    sb.append(", payload=");
430                    sb.append(getPayload());
431                    sb.append(", archived=");
432                    sb.append(getArchived());
433                    sb.append("}");
434    
435                    return sb.toString();
436            }
437    
438            public String toXmlString() {
439                    StringBundler sb = new StringBundler(31);
440    
441                    sb.append("<model><model-name>");
442                    sb.append("com.liferay.portal.model.UserNotificationEvent");
443                    sb.append("</model-name>");
444    
445                    sb.append(
446                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
447                    sb.append(getUuid());
448                    sb.append("]]></column-value></column>");
449                    sb.append(
450                            "<column><column-name>userNotificationEventId</column-name><column-value><![CDATA[");
451                    sb.append(getUserNotificationEventId());
452                    sb.append("]]></column-value></column>");
453                    sb.append(
454                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
455                    sb.append(getCompanyId());
456                    sb.append("]]></column-value></column>");
457                    sb.append(
458                            "<column><column-name>userId</column-name><column-value><![CDATA[");
459                    sb.append(getUserId());
460                    sb.append("]]></column-value></column>");
461                    sb.append(
462                            "<column><column-name>type</column-name><column-value><![CDATA[");
463                    sb.append(getType());
464                    sb.append("]]></column-value></column>");
465                    sb.append(
466                            "<column><column-name>timestamp</column-name><column-value><![CDATA[");
467                    sb.append(getTimestamp());
468                    sb.append("]]></column-value></column>");
469                    sb.append(
470                            "<column><column-name>deliverBy</column-name><column-value><![CDATA[");
471                    sb.append(getDeliverBy());
472                    sb.append("]]></column-value></column>");
473                    sb.append(
474                            "<column><column-name>payload</column-name><column-value><![CDATA[");
475                    sb.append(getPayload());
476                    sb.append("]]></column-value></column>");
477                    sb.append(
478                            "<column><column-name>archived</column-name><column-value><![CDATA[");
479                    sb.append(getArchived());
480                    sb.append("]]></column-value></column>");
481    
482                    sb.append("</model>");
483    
484                    return sb.toString();
485            }
486    
487            private static ClassLoader _classLoader = UserNotificationEvent.class.getClassLoader();
488            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
489                            UserNotificationEvent.class
490                    };
491            private String _uuid;
492            private String _originalUuid;
493            private long _userNotificationEventId;
494            private long _companyId;
495            private long _userId;
496            private String _userUuid;
497            private long _originalUserId;
498            private boolean _setOriginalUserId;
499            private String _type;
500            private long _timestamp;
501            private long _deliverBy;
502            private String _payload;
503            private boolean _archived;
504            private boolean _originalArchived;
505            private boolean _setOriginalArchived;
506            private transient ExpandoBridge _expandoBridge;
507            private long _columnBitmask;
508            private UserNotificationEvent _escapedModelProxy;
509    }