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.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 long TIMESTAMP_COLUMN_BITMASK = 16L;
092            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
093                                    "lock.expiration.time.com.liferay.portal.model.UserNotificationEvent"));
094    
095            public UserNotificationEventModelImpl() {
096            }
097    
098            public long getPrimaryKey() {
099                    return _userNotificationEventId;
100            }
101    
102            public void setPrimaryKey(long primaryKey) {
103                    setUserNotificationEventId(primaryKey);
104            }
105    
106            public Serializable getPrimaryKeyObj() {
107                    return _userNotificationEventId;
108            }
109    
110            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
111                    setPrimaryKey(((Long)primaryKeyObj).longValue());
112            }
113    
114            public Class<?> getModelClass() {
115                    return UserNotificationEvent.class;
116            }
117    
118            public String getModelClassName() {
119                    return UserNotificationEvent.class.getName();
120            }
121    
122            @Override
123            public Map<String, Object> getModelAttributes() {
124                    Map<String, Object> attributes = new HashMap<String, Object>();
125    
126                    attributes.put("uuid", getUuid());
127                    attributes.put("userNotificationEventId", getUserNotificationEventId());
128                    attributes.put("companyId", getCompanyId());
129                    attributes.put("userId", getUserId());
130                    attributes.put("type", getType());
131                    attributes.put("timestamp", getTimestamp());
132                    attributes.put("deliverBy", getDeliverBy());
133                    attributes.put("payload", getPayload());
134                    attributes.put("archived", getArchived());
135    
136                    return attributes;
137            }
138    
139            @Override
140            public void setModelAttributes(Map<String, Object> attributes) {
141                    String uuid = (String)attributes.get("uuid");
142    
143                    if (uuid != null) {
144                            setUuid(uuid);
145                    }
146    
147                    Long userNotificationEventId = (Long)attributes.get(
148                                    "userNotificationEventId");
149    
150                    if (userNotificationEventId != null) {
151                            setUserNotificationEventId(userNotificationEventId);
152                    }
153    
154                    Long companyId = (Long)attributes.get("companyId");
155    
156                    if (companyId != null) {
157                            setCompanyId(companyId);
158                    }
159    
160                    Long userId = (Long)attributes.get("userId");
161    
162                    if (userId != null) {
163                            setUserId(userId);
164                    }
165    
166                    String type = (String)attributes.get("type");
167    
168                    if (type != null) {
169                            setType(type);
170                    }
171    
172                    Long timestamp = (Long)attributes.get("timestamp");
173    
174                    if (timestamp != null) {
175                            setTimestamp(timestamp);
176                    }
177    
178                    Long deliverBy = (Long)attributes.get("deliverBy");
179    
180                    if (deliverBy != null) {
181                            setDeliverBy(deliverBy);
182                    }
183    
184                    String payload = (String)attributes.get("payload");
185    
186                    if (payload != null) {
187                            setPayload(payload);
188                    }
189    
190                    Boolean archived = (Boolean)attributes.get("archived");
191    
192                    if (archived != null) {
193                            setArchived(archived);
194                    }
195            }
196    
197            public String getUuid() {
198                    if (_uuid == null) {
199                            return StringPool.BLANK;
200                    }
201                    else {
202                            return _uuid;
203                    }
204            }
205    
206            public void setUuid(String uuid) {
207                    if (_originalUuid == null) {
208                            _originalUuid = _uuid;
209                    }
210    
211                    _uuid = uuid;
212            }
213    
214            public String getOriginalUuid() {
215                    return GetterUtil.getString(_originalUuid);
216            }
217    
218            public long getUserNotificationEventId() {
219                    return _userNotificationEventId;
220            }
221    
222            public void setUserNotificationEventId(long userNotificationEventId) {
223                    _userNotificationEventId = userNotificationEventId;
224            }
225    
226            public long getCompanyId() {
227                    return _companyId;
228            }
229    
230            public void setCompanyId(long companyId) {
231                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
232    
233                    if (!_setOriginalCompanyId) {
234                            _setOriginalCompanyId = true;
235    
236                            _originalCompanyId = _companyId;
237                    }
238    
239                    _companyId = companyId;
240            }
241    
242            public long getOriginalCompanyId() {
243                    return _originalCompanyId;
244            }
245    
246            public long getUserId() {
247                    return _userId;
248            }
249    
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            public String getUserUuid() throws SystemException {
263                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
264            }
265    
266            public void setUserUuid(String userUuid) {
267                    _userUuid = userUuid;
268            }
269    
270            public long getOriginalUserId() {
271                    return _originalUserId;
272            }
273    
274            public String getType() {
275                    if (_type == null) {
276                            return StringPool.BLANK;
277                    }
278                    else {
279                            return _type;
280                    }
281            }
282    
283            public void setType(String type) {
284                    _type = type;
285            }
286    
287            public long getTimestamp() {
288                    return _timestamp;
289            }
290    
291            public void setTimestamp(long timestamp) {
292                    _columnBitmask = -1L;
293    
294                    _timestamp = timestamp;
295            }
296    
297            public long getDeliverBy() {
298                    return _deliverBy;
299            }
300    
301            public void setDeliverBy(long deliverBy) {
302                    _deliverBy = deliverBy;
303            }
304    
305            public String getPayload() {
306                    if (_payload == null) {
307                            return StringPool.BLANK;
308                    }
309                    else {
310                            return _payload;
311                    }
312            }
313    
314            public void setPayload(String payload) {
315                    _payload = payload;
316            }
317    
318            public boolean getArchived() {
319                    return _archived;
320            }
321    
322            public boolean isArchived() {
323                    return _archived;
324            }
325    
326            public void setArchived(boolean archived) {
327                    _columnBitmask |= ARCHIVED_COLUMN_BITMASK;
328    
329                    if (!_setOriginalArchived) {
330                            _setOriginalArchived = true;
331    
332                            _originalArchived = _archived;
333                    }
334    
335                    _archived = archived;
336            }
337    
338            public boolean getOriginalArchived() {
339                    return _originalArchived;
340            }
341    
342            public long getColumnBitmask() {
343                    return _columnBitmask;
344            }
345    
346            @Override
347            public ExpandoBridge getExpandoBridge() {
348                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
349                            UserNotificationEvent.class.getName(), getPrimaryKey());
350            }
351    
352            @Override
353            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
354                    ExpandoBridge expandoBridge = getExpandoBridge();
355    
356                    expandoBridge.setAttributes(serviceContext);
357            }
358    
359            @Override
360            public UserNotificationEvent toEscapedModel() {
361                    if (_escapedModel == null) {
362                            _escapedModel = (UserNotificationEvent)ProxyUtil.newProxyInstance(_classLoader,
363                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
364                    }
365    
366                    return _escapedModel;
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<?>[] _escapedModelInterfaces = 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 _escapedModel;
603    }