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    import java.util.HashMap;
037    import java.util.Map;
038    
039    /**
040     * 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.
041     *
042     * <p>
043     * 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}.
044     * </p>
045     *
046     * @author Brian Wing Shun Chan
047     * @see UserNotificationEventImpl
048     * @see com.liferay.portal.model.UserNotificationEvent
049     * @see com.liferay.portal.model.UserNotificationEventModel
050     * @generated
051     */
052    public class UserNotificationEventModelImpl extends BaseModelImpl<UserNotificationEvent>
053            implements UserNotificationEventModel {
054            /*
055             * NOTE FOR DEVELOPERS:
056             *
057             * 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.
058             */
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                            { "payload", Types.CLOB },
069                            { "archived", Types.BOOLEAN }
070                    };
071            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)";
072            public static final String TABLE_SQL_DROP = "drop table UserNotificationEvent";
073            public static final String ORDER_BY_JPQL = " ORDER BY userNotificationEvent.timestamp DESC";
074            public static final String ORDER_BY_SQL = " ORDER BY UserNotificationEvent.timestamp DESC";
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.UserNotificationEvent"),
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.UserNotificationEvent"),
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.UserNotificationEvent"),
086                            true);
087            public static long ARCHIVED_COLUMN_BITMASK = 1L;
088            public static long COMPANYID_COLUMN_BITMASK = 2L;
089            public static long USERID_COLUMN_BITMASK = 4L;
090            public static long UUID_COLUMN_BITMASK = 8L;
091            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
092                                    "lock.expiration.time.com.liferay.portal.model.UserNotificationEvent"));
093    
094            public UserNotificationEventModelImpl() {
095            }
096    
097            public long getPrimaryKey() {
098                    return _userNotificationEventId;
099            }
100    
101            public void setPrimaryKey(long primaryKey) {
102                    setUserNotificationEventId(primaryKey);
103            }
104    
105            public Serializable getPrimaryKeyObj() {
106                    return new Long(_userNotificationEventId);
107            }
108    
109            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
110                    setPrimaryKey(((Long)primaryKeyObj).longValue());
111            }
112    
113            public Class<?> getModelClass() {
114                    return UserNotificationEvent.class;
115            }
116    
117            public String getModelClassName() {
118                    return UserNotificationEvent.class.getName();
119            }
120    
121            @Override
122            public Map<String, Object> getModelAttributes() {
123                    Map<String, Object> attributes = new HashMap<String, Object>();
124    
125                    attributes.put("uuid", getUuid());
126                    attributes.put("userNotificationEventId", getUserNotificationEventId());
127                    attributes.put("companyId", getCompanyId());
128                    attributes.put("userId", getUserId());
129                    attributes.put("type", getType());
130                    attributes.put("timestamp", getTimestamp());
131                    attributes.put("deliverBy", getDeliverBy());
132                    attributes.put("payload", getPayload());
133                    attributes.put("archived", getArchived());
134    
135                    return attributes;
136            }
137    
138            @Override
139            public void setModelAttributes(Map<String, Object> attributes) {
140                    String uuid = (String)attributes.get("uuid");
141    
142                    if (uuid != null) {
143                            setUuid(uuid);
144                    }
145    
146                    Long userNotificationEventId = (Long)attributes.get(
147                                    "userNotificationEventId");
148    
149                    if (userNotificationEventId != null) {
150                            setUserNotificationEventId(userNotificationEventId);
151                    }
152    
153                    Long companyId = (Long)attributes.get("companyId");
154    
155                    if (companyId != null) {
156                            setCompanyId(companyId);
157                    }
158    
159                    Long userId = (Long)attributes.get("userId");
160    
161                    if (userId != null) {
162                            setUserId(userId);
163                    }
164    
165                    String type = (String)attributes.get("type");
166    
167                    if (type != null) {
168                            setType(type);
169                    }
170    
171                    Long timestamp = (Long)attributes.get("timestamp");
172    
173                    if (timestamp != null) {
174                            setTimestamp(timestamp);
175                    }
176    
177                    Long deliverBy = (Long)attributes.get("deliverBy");
178    
179                    if (deliverBy != null) {
180                            setDeliverBy(deliverBy);
181                    }
182    
183                    String payload = (String)attributes.get("payload");
184    
185                    if (payload != null) {
186                            setPayload(payload);
187                    }
188    
189                    Boolean archived = (Boolean)attributes.get("archived");
190    
191                    if (archived != null) {
192                            setArchived(archived);
193                    }
194            }
195    
196            public String getUuid() {
197                    if (_uuid == null) {
198                            return StringPool.BLANK;
199                    }
200                    else {
201                            return _uuid;
202                    }
203            }
204    
205            public void setUuid(String uuid) {
206                    if (_originalUuid == null) {
207                            _originalUuid = _uuid;
208                    }
209    
210                    _uuid = uuid;
211            }
212    
213            public String getOriginalUuid() {
214                    return GetterUtil.getString(_originalUuid);
215            }
216    
217            public long getUserNotificationEventId() {
218                    return _userNotificationEventId;
219            }
220    
221            public void setUserNotificationEventId(long userNotificationEventId) {
222                    _userNotificationEventId = userNotificationEventId;
223            }
224    
225            public long getCompanyId() {
226                    return _companyId;
227            }
228    
229            public void setCompanyId(long companyId) {
230                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
231    
232                    if (!_setOriginalCompanyId) {
233                            _setOriginalCompanyId = true;
234    
235                            _originalCompanyId = _companyId;
236                    }
237    
238                    _companyId = companyId;
239            }
240    
241            public long getOriginalCompanyId() {
242                    return _originalCompanyId;
243            }
244    
245            public long getUserId() {
246                    return _userId;
247            }
248    
249            public void setUserId(long userId) {
250                    _columnBitmask |= USERID_COLUMN_BITMASK;
251    
252                    if (!_setOriginalUserId) {
253                            _setOriginalUserId = true;
254    
255                            _originalUserId = _userId;
256                    }
257    
258                    _userId = userId;
259            }
260    
261            public String getUserUuid() throws SystemException {
262                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
263            }
264    
265            public void setUserUuid(String userUuid) {
266                    _userUuid = userUuid;
267            }
268    
269            public long getOriginalUserId() {
270                    return _originalUserId;
271            }
272    
273            public String getType() {
274                    if (_type == null) {
275                            return StringPool.BLANK;
276                    }
277                    else {
278                            return _type;
279                    }
280            }
281    
282            public void setType(String type) {
283                    _type = type;
284            }
285    
286            public long getTimestamp() {
287                    return _timestamp;
288            }
289    
290            public void setTimestamp(long timestamp) {
291                    _columnBitmask = -1L;
292    
293                    _timestamp = timestamp;
294            }
295    
296            public long getDeliverBy() {
297                    return _deliverBy;
298            }
299    
300            public void setDeliverBy(long deliverBy) {
301                    _deliverBy = deliverBy;
302            }
303    
304            public String getPayload() {
305                    if (_payload == null) {
306                            return StringPool.BLANK;
307                    }
308                    else {
309                            return _payload;
310                    }
311            }
312    
313            public void setPayload(String payload) {
314                    _payload = payload;
315            }
316    
317            public boolean getArchived() {
318                    return _archived;
319            }
320    
321            public boolean isArchived() {
322                    return _archived;
323            }
324    
325            public void setArchived(boolean archived) {
326                    _columnBitmask |= ARCHIVED_COLUMN_BITMASK;
327    
328                    if (!_setOriginalArchived) {
329                            _setOriginalArchived = true;
330    
331                            _originalArchived = _archived;
332                    }
333    
334                    _archived = archived;
335            }
336    
337            public boolean getOriginalArchived() {
338                    return _originalArchived;
339            }
340    
341            public long getColumnBitmask() {
342                    return _columnBitmask;
343            }
344    
345            @Override
346            public ExpandoBridge getExpandoBridge() {
347                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
348                            UserNotificationEvent.class.getName(), getPrimaryKey());
349            }
350    
351            @Override
352            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
353                    ExpandoBridge expandoBridge = getExpandoBridge();
354    
355                    expandoBridge.setAttributes(serviceContext);
356            }
357    
358            @Override
359            public UserNotificationEvent toEscapedModel() {
360                    if (_escapedModelProxy == null) {
361                            _escapedModelProxy = (UserNotificationEvent)ProxyUtil.newProxyInstance(_classLoader,
362                                            _escapedModelProxyInterfaces,
363                                            new AutoEscapeBeanHandler(this));
364                    }
365    
366                    return _escapedModelProxy;
367            }
368    
369            @Override
370            public Object clone() {
371                    UserNotificationEventImpl userNotificationEventImpl = new UserNotificationEventImpl();
372    
373                    userNotificationEventImpl.setUuid(getUuid());
374                    userNotificationEventImpl.setUserNotificationEventId(getUserNotificationEventId());
375                    userNotificationEventImpl.setCompanyId(getCompanyId());
376                    userNotificationEventImpl.setUserId(getUserId());
377                    userNotificationEventImpl.setType(getType());
378                    userNotificationEventImpl.setTimestamp(getTimestamp());
379                    userNotificationEventImpl.setDeliverBy(getDeliverBy());
380                    userNotificationEventImpl.setPayload(getPayload());
381                    userNotificationEventImpl.setArchived(getArchived());
382    
383                    userNotificationEventImpl.resetOriginalValues();
384    
385                    return userNotificationEventImpl;
386            }
387    
388            public int compareTo(UserNotificationEvent userNotificationEvent) {
389                    int value = 0;
390    
391                    if (getTimestamp() < userNotificationEvent.getTimestamp()) {
392                            value = -1;
393                    }
394                    else if (getTimestamp() > userNotificationEvent.getTimestamp()) {
395                            value = 1;
396                    }
397                    else {
398                            value = 0;
399                    }
400    
401                    value = value * -1;
402    
403                    if (value != 0) {
404                            return value;
405                    }
406    
407                    return 0;
408            }
409    
410            @Override
411            public boolean equals(Object obj) {
412                    if (obj == null) {
413                            return false;
414                    }
415    
416                    UserNotificationEvent userNotificationEvent = null;
417    
418                    try {
419                            userNotificationEvent = (UserNotificationEvent)obj;
420                    }
421                    catch (ClassCastException cce) {
422                            return false;
423                    }
424    
425                    long primaryKey = userNotificationEvent.getPrimaryKey();
426    
427                    if (getPrimaryKey() == primaryKey) {
428                            return true;
429                    }
430                    else {
431                            return false;
432                    }
433            }
434    
435            @Override
436            public int hashCode() {
437                    return (int)getPrimaryKey();
438            }
439    
440            @Override
441            public void resetOriginalValues() {
442                    UserNotificationEventModelImpl userNotificationEventModelImpl = this;
443    
444                    userNotificationEventModelImpl._originalUuid = userNotificationEventModelImpl._uuid;
445    
446                    userNotificationEventModelImpl._originalCompanyId = userNotificationEventModelImpl._companyId;
447    
448                    userNotificationEventModelImpl._setOriginalCompanyId = false;
449    
450                    userNotificationEventModelImpl._originalUserId = userNotificationEventModelImpl._userId;
451    
452                    userNotificationEventModelImpl._setOriginalUserId = false;
453    
454                    userNotificationEventModelImpl._originalArchived = userNotificationEventModelImpl._archived;
455    
456                    userNotificationEventModelImpl._setOriginalArchived = false;
457    
458                    userNotificationEventModelImpl._columnBitmask = 0;
459            }
460    
461            @Override
462            public CacheModel<UserNotificationEvent> toCacheModel() {
463                    UserNotificationEventCacheModel userNotificationEventCacheModel = new UserNotificationEventCacheModel();
464    
465                    userNotificationEventCacheModel.uuid = getUuid();
466    
467                    String uuid = userNotificationEventCacheModel.uuid;
468    
469                    if ((uuid != null) && (uuid.length() == 0)) {
470                            userNotificationEventCacheModel.uuid = null;
471                    }
472    
473                    userNotificationEventCacheModel.userNotificationEventId = getUserNotificationEventId();
474    
475                    userNotificationEventCacheModel.companyId = getCompanyId();
476    
477                    userNotificationEventCacheModel.userId = getUserId();
478    
479                    userNotificationEventCacheModel.type = getType();
480    
481                    String type = userNotificationEventCacheModel.type;
482    
483                    if ((type != null) && (type.length() == 0)) {
484                            userNotificationEventCacheModel.type = null;
485                    }
486    
487                    userNotificationEventCacheModel.timestamp = getTimestamp();
488    
489                    userNotificationEventCacheModel.deliverBy = getDeliverBy();
490    
491                    userNotificationEventCacheModel.payload = getPayload();
492    
493                    String payload = userNotificationEventCacheModel.payload;
494    
495                    if ((payload != null) && (payload.length() == 0)) {
496                            userNotificationEventCacheModel.payload = null;
497                    }
498    
499                    userNotificationEventCacheModel.archived = getArchived();
500    
501                    return userNotificationEventCacheModel;
502            }
503    
504            @Override
505            public String toString() {
506                    StringBundler sb = new StringBundler(19);
507    
508                    sb.append("{uuid=");
509                    sb.append(getUuid());
510                    sb.append(", userNotificationEventId=");
511                    sb.append(getUserNotificationEventId());
512                    sb.append(", companyId=");
513                    sb.append(getCompanyId());
514                    sb.append(", userId=");
515                    sb.append(getUserId());
516                    sb.append(", type=");
517                    sb.append(getType());
518                    sb.append(", timestamp=");
519                    sb.append(getTimestamp());
520                    sb.append(", deliverBy=");
521                    sb.append(getDeliverBy());
522                    sb.append(", payload=");
523                    sb.append(getPayload());
524                    sb.append(", archived=");
525                    sb.append(getArchived());
526                    sb.append("}");
527    
528                    return sb.toString();
529            }
530    
531            public String toXmlString() {
532                    StringBundler sb = new StringBundler(31);
533    
534                    sb.append("<model><model-name>");
535                    sb.append("com.liferay.portal.model.UserNotificationEvent");
536                    sb.append("</model-name>");
537    
538                    sb.append(
539                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
540                    sb.append(getUuid());
541                    sb.append("]]></column-value></column>");
542                    sb.append(
543                            "<column><column-name>userNotificationEventId</column-name><column-value><![CDATA[");
544                    sb.append(getUserNotificationEventId());
545                    sb.append("]]></column-value></column>");
546                    sb.append(
547                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
548                    sb.append(getCompanyId());
549                    sb.append("]]></column-value></column>");
550                    sb.append(
551                            "<column><column-name>userId</column-name><column-value><![CDATA[");
552                    sb.append(getUserId());
553                    sb.append("]]></column-value></column>");
554                    sb.append(
555                            "<column><column-name>type</column-name><column-value><![CDATA[");
556                    sb.append(getType());
557                    sb.append("]]></column-value></column>");
558                    sb.append(
559                            "<column><column-name>timestamp</column-name><column-value><![CDATA[");
560                    sb.append(getTimestamp());
561                    sb.append("]]></column-value></column>");
562                    sb.append(
563                            "<column><column-name>deliverBy</column-name><column-value><![CDATA[");
564                    sb.append(getDeliverBy());
565                    sb.append("]]></column-value></column>");
566                    sb.append(
567                            "<column><column-name>payload</column-name><column-value><![CDATA[");
568                    sb.append(getPayload());
569                    sb.append("]]></column-value></column>");
570                    sb.append(
571                            "<column><column-name>archived</column-name><column-value><![CDATA[");
572                    sb.append(getArchived());
573                    sb.append("]]></column-value></column>");
574    
575                    sb.append("</model>");
576    
577                    return sb.toString();
578            }
579    
580            private static ClassLoader _classLoader = UserNotificationEvent.class.getClassLoader();
581            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
582                            UserNotificationEvent.class
583                    };
584            private String _uuid;
585            private String _originalUuid;
586            private long _userNotificationEventId;
587            private long _companyId;
588            private long _originalCompanyId;
589            private boolean _setOriginalCompanyId;
590            private long _userId;
591            private String _userUuid;
592            private long _originalUserId;
593            private boolean _setOriginalUserId;
594            private String _type;
595            private long _timestamp;
596            private long _deliverBy;
597            private String _payload;
598            private boolean _archived;
599            private boolean _originalArchived;
600            private boolean _setOriginalArchived;
601            private long _columnBitmask;
602            private UserNotificationEvent _escapedModelProxy;
603    }