001    /**
002     * Copyright (c) 2000-2010 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.portlet.messageboards.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.StringBundler;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    import com.liferay.portal.util.PortalUtil;
024    
025    import com.liferay.portlet.expando.model.ExpandoBridge;
026    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027    import com.liferay.portlet.messageboards.model.MBStatsUser;
028    import com.liferay.portlet.messageboards.model.MBStatsUserModel;
029    
030    import java.io.Serializable;
031    
032    import java.lang.reflect.Proxy;
033    
034    import java.sql.Types;
035    
036    import java.util.Date;
037    
038    /**
039     * <p>
040     * This interface is a model that represents the MBStatsUser table in the
041     * database.
042     * </p>
043     *
044     * @author    Brian Wing Shun Chan
045     * @see       MBStatsUserImpl
046     * @see       com.liferay.portlet.messageboards.model.MBStatsUser
047     * @see       com.liferay.portlet.messageboards.model.MBStatsUserModel
048     * @generated
049     */
050    public class MBStatsUserModelImpl extends BaseModelImpl<MBStatsUser>
051            implements MBStatsUserModel {
052            public static final String TABLE_NAME = "MBStatsUser";
053            public static final Object[][] TABLE_COLUMNS = {
054                            { "statsUserId", new Integer(Types.BIGINT) },
055                            { "groupId", new Integer(Types.BIGINT) },
056                            { "userId", new Integer(Types.BIGINT) },
057                            { "messageCount", new Integer(Types.INTEGER) },
058                            { "lastPostDate", new Integer(Types.TIMESTAMP) }
059                    };
060            public static final String TABLE_SQL_CREATE = "create table MBStatsUser (statsUserId LONG not null primary key,groupId LONG,userId LONG,messageCount INTEGER,lastPostDate DATE null)";
061            public static final String TABLE_SQL_DROP = "drop table MBStatsUser";
062            public static final String ORDER_BY_JPQL = " ORDER BY mbStatsUser.messageCount DESC";
063            public static final String ORDER_BY_SQL = " ORDER BY MBStatsUser.messageCount DESC";
064            public static final String DATA_SOURCE = "liferayDataSource";
065            public static final String SESSION_FACTORY = "liferaySessionFactory";
066            public static final String TX_MANAGER = "liferayTransactionManager";
067            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
068                                    "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBStatsUser"),
069                            true);
070            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
071                                    "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBStatsUser"),
072                            true);
073            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
074                                    "lock.expiration.time.com.liferay.portlet.messageboards.model.MBStatsUser"));
075    
076            public MBStatsUserModelImpl() {
077            }
078    
079            public long getPrimaryKey() {
080                    return _statsUserId;
081            }
082    
083            public void setPrimaryKey(long pk) {
084                    setStatsUserId(pk);
085            }
086    
087            public Serializable getPrimaryKeyObj() {
088                    return new Long(_statsUserId);
089            }
090    
091            public long getStatsUserId() {
092                    return _statsUserId;
093            }
094    
095            public void setStatsUserId(long statsUserId) {
096                    _statsUserId = statsUserId;
097            }
098    
099            public String getStatsUserUuid() throws SystemException {
100                    return PortalUtil.getUserValue(getStatsUserId(), "uuid", _statsUserUuid);
101            }
102    
103            public void setStatsUserUuid(String statsUserUuid) {
104                    _statsUserUuid = statsUserUuid;
105            }
106    
107            public long getGroupId() {
108                    return _groupId;
109            }
110    
111            public void setGroupId(long groupId) {
112                    _groupId = groupId;
113    
114                    if (!_setOriginalGroupId) {
115                            _setOriginalGroupId = true;
116    
117                            _originalGroupId = groupId;
118                    }
119            }
120    
121            public long getOriginalGroupId() {
122                    return _originalGroupId;
123            }
124    
125            public long getUserId() {
126                    return _userId;
127            }
128    
129            public void setUserId(long userId) {
130                    _userId = userId;
131    
132                    if (!_setOriginalUserId) {
133                            _setOriginalUserId = true;
134    
135                            _originalUserId = userId;
136                    }
137            }
138    
139            public String getUserUuid() throws SystemException {
140                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
141            }
142    
143            public void setUserUuid(String userUuid) {
144                    _userUuid = userUuid;
145            }
146    
147            public long getOriginalUserId() {
148                    return _originalUserId;
149            }
150    
151            public int getMessageCount() {
152                    return _messageCount;
153            }
154    
155            public void setMessageCount(int messageCount) {
156                    _messageCount = messageCount;
157            }
158    
159            public Date getLastPostDate() {
160                    return _lastPostDate;
161            }
162    
163            public void setLastPostDate(Date lastPostDate) {
164                    _lastPostDate = lastPostDate;
165            }
166    
167            public MBStatsUser toEscapedModel() {
168                    if (isEscapedModel()) {
169                            return (MBStatsUser)this;
170                    }
171                    else {
172                            return (MBStatsUser)Proxy.newProxyInstance(MBStatsUser.class.getClassLoader(),
173                                    new Class[] { MBStatsUser.class },
174                                    new AutoEscapeBeanHandler(this));
175                    }
176            }
177    
178            public ExpandoBridge getExpandoBridge() {
179                    if (_expandoBridge == null) {
180                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
181                                            MBStatsUser.class.getName(), getPrimaryKey());
182                    }
183    
184                    return _expandoBridge;
185            }
186    
187            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
188                    getExpandoBridge().setAttributes(serviceContext);
189            }
190    
191            public Object clone() {
192                    MBStatsUserImpl clone = new MBStatsUserImpl();
193    
194                    clone.setStatsUserId(getStatsUserId());
195                    clone.setGroupId(getGroupId());
196                    clone.setUserId(getUserId());
197                    clone.setMessageCount(getMessageCount());
198                    clone.setLastPostDate(getLastPostDate());
199    
200                    return clone;
201            }
202    
203            public int compareTo(MBStatsUser mbStatsUser) {
204                    int value = 0;
205    
206                    if (getMessageCount() < mbStatsUser.getMessageCount()) {
207                            value = -1;
208                    }
209                    else if (getMessageCount() > mbStatsUser.getMessageCount()) {
210                            value = 1;
211                    }
212                    else {
213                            value = 0;
214                    }
215    
216                    value = value * -1;
217    
218                    if (value != 0) {
219                            return value;
220                    }
221    
222                    return 0;
223            }
224    
225            public boolean equals(Object obj) {
226                    if (obj == null) {
227                            return false;
228                    }
229    
230                    MBStatsUser mbStatsUser = null;
231    
232                    try {
233                            mbStatsUser = (MBStatsUser)obj;
234                    }
235                    catch (ClassCastException cce) {
236                            return false;
237                    }
238    
239                    long pk = mbStatsUser.getPrimaryKey();
240    
241                    if (getPrimaryKey() == pk) {
242                            return true;
243                    }
244                    else {
245                            return false;
246                    }
247            }
248    
249            public int hashCode() {
250                    return (int)getPrimaryKey();
251            }
252    
253            public String toString() {
254                    StringBundler sb = new StringBundler(11);
255    
256                    sb.append("{statsUserId=");
257                    sb.append(getStatsUserId());
258                    sb.append(", groupId=");
259                    sb.append(getGroupId());
260                    sb.append(", userId=");
261                    sb.append(getUserId());
262                    sb.append(", messageCount=");
263                    sb.append(getMessageCount());
264                    sb.append(", lastPostDate=");
265                    sb.append(getLastPostDate());
266                    sb.append("}");
267    
268                    return sb.toString();
269            }
270    
271            public String toXmlString() {
272                    StringBundler sb = new StringBundler(19);
273    
274                    sb.append("<model><model-name>");
275                    sb.append("com.liferay.portlet.messageboards.model.MBStatsUser");
276                    sb.append("</model-name>");
277    
278                    sb.append(
279                            "<column><column-name>statsUserId</column-name><column-value><![CDATA[");
280                    sb.append(getStatsUserId());
281                    sb.append("]]></column-value></column>");
282                    sb.append(
283                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
284                    sb.append(getGroupId());
285                    sb.append("]]></column-value></column>");
286                    sb.append(
287                            "<column><column-name>userId</column-name><column-value><![CDATA[");
288                    sb.append(getUserId());
289                    sb.append("]]></column-value></column>");
290                    sb.append(
291                            "<column><column-name>messageCount</column-name><column-value><![CDATA[");
292                    sb.append(getMessageCount());
293                    sb.append("]]></column-value></column>");
294                    sb.append(
295                            "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
296                    sb.append(getLastPostDate());
297                    sb.append("]]></column-value></column>");
298    
299                    sb.append("</model>");
300    
301                    return sb.toString();
302            }
303    
304            private long _statsUserId;
305            private String _statsUserUuid;
306            private long _groupId;
307            private long _originalGroupId;
308            private boolean _setOriginalGroupId;
309            private long _userId;
310            private String _userUuid;
311            private long _originalUserId;
312            private boolean _setOriginalUserId;
313            private int _messageCount;
314            private Date _lastPostDate;
315            private transient ExpandoBridge _expandoBridge;
316    }