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