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.blogs.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.blogs.model.BlogsStatsUser;
026    import com.liferay.portlet.blogs.model.BlogsStatsUserModel;
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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 BlogsStatsUser table in the
041     * database.
042     * </p>
043     *
044     * @author    Brian Wing Shun Chan
045     * @see       BlogsStatsUserImpl
046     * @see       com.liferay.portlet.blogs.model.BlogsStatsUser
047     * @see       com.liferay.portlet.blogs.model.BlogsStatsUserModel
048     * @generated
049     */
050    public class BlogsStatsUserModelImpl extends BaseModelImpl<BlogsStatsUser>
051            implements BlogsStatsUserModel {
052            public static final String TABLE_NAME = "BlogsStatsUser";
053            public static final Object[][] TABLE_COLUMNS = {
054                            { "statsUserId", new Integer(Types.BIGINT) },
055                            { "groupId", new Integer(Types.BIGINT) },
056                            { "companyId", new Integer(Types.BIGINT) },
057                            { "userId", new Integer(Types.BIGINT) },
058                            { "entryCount", new Integer(Types.INTEGER) },
059                            { "lastPostDate", new Integer(Types.TIMESTAMP) },
060                            { "ratingsTotalEntries", new Integer(Types.INTEGER) },
061                            { "ratingsTotalScore", new Integer(Types.DOUBLE) },
062                            { "ratingsAverageScore", new Integer(Types.DOUBLE) }
063                    };
064            public static final String TABLE_SQL_CREATE = "create table BlogsStatsUser (statsUserId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,entryCount INTEGER,lastPostDate DATE null,ratingsTotalEntries INTEGER,ratingsTotalScore DOUBLE,ratingsAverageScore DOUBLE)";
065            public static final String TABLE_SQL_DROP = "drop table BlogsStatsUser";
066            public static final String ORDER_BY_JPQL = " ORDER BY blogsStatsUser.entryCount DESC";
067            public static final String ORDER_BY_SQL = " ORDER BY BlogsStatsUser.entryCount DESC";
068            public static final String DATA_SOURCE = "liferayDataSource";
069            public static final String SESSION_FACTORY = "liferaySessionFactory";
070            public static final String TX_MANAGER = "liferayTransactionManager";
071            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072                                    "value.object.entity.cache.enabled.com.liferay.portlet.blogs.model.BlogsStatsUser"),
073                            true);
074            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075                                    "value.object.finder.cache.enabled.com.liferay.portlet.blogs.model.BlogsStatsUser"),
076                            true);
077            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
078                                    "lock.expiration.time.com.liferay.portlet.blogs.model.BlogsStatsUser"));
079    
080            public BlogsStatsUserModelImpl() {
081            }
082    
083            public long getPrimaryKey() {
084                    return _statsUserId;
085            }
086    
087            public void setPrimaryKey(long pk) {
088                    setStatsUserId(pk);
089            }
090    
091            public Serializable getPrimaryKeyObj() {
092                    return new Long(_statsUserId);
093            }
094    
095            public long getStatsUserId() {
096                    return _statsUserId;
097            }
098    
099            public void setStatsUserId(long statsUserId) {
100                    _statsUserId = statsUserId;
101            }
102    
103            public String getStatsUserUuid() throws SystemException {
104                    return PortalUtil.getUserValue(getStatsUserId(), "uuid", _statsUserUuid);
105            }
106    
107            public void setStatsUserUuid(String statsUserUuid) {
108                    _statsUserUuid = statsUserUuid;
109            }
110    
111            public long getGroupId() {
112                    return _groupId;
113            }
114    
115            public void setGroupId(long groupId) {
116                    _groupId = groupId;
117    
118                    if (!_setOriginalGroupId) {
119                            _setOriginalGroupId = true;
120    
121                            _originalGroupId = groupId;
122                    }
123            }
124    
125            public long getOriginalGroupId() {
126                    return _originalGroupId;
127            }
128    
129            public long getCompanyId() {
130                    return _companyId;
131            }
132    
133            public void setCompanyId(long companyId) {
134                    _companyId = companyId;
135            }
136    
137            public long getUserId() {
138                    return _userId;
139            }
140    
141            public void setUserId(long userId) {
142                    _userId = userId;
143    
144                    if (!_setOriginalUserId) {
145                            _setOriginalUserId = true;
146    
147                            _originalUserId = userId;
148                    }
149            }
150    
151            public String getUserUuid() throws SystemException {
152                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
153            }
154    
155            public void setUserUuid(String userUuid) {
156                    _userUuid = userUuid;
157            }
158    
159            public long getOriginalUserId() {
160                    return _originalUserId;
161            }
162    
163            public int getEntryCount() {
164                    return _entryCount;
165            }
166    
167            public void setEntryCount(int entryCount) {
168                    _entryCount = entryCount;
169            }
170    
171            public Date getLastPostDate() {
172                    return _lastPostDate;
173            }
174    
175            public void setLastPostDate(Date lastPostDate) {
176                    _lastPostDate = lastPostDate;
177            }
178    
179            public int getRatingsTotalEntries() {
180                    return _ratingsTotalEntries;
181            }
182    
183            public void setRatingsTotalEntries(int ratingsTotalEntries) {
184                    _ratingsTotalEntries = ratingsTotalEntries;
185            }
186    
187            public double getRatingsTotalScore() {
188                    return _ratingsTotalScore;
189            }
190    
191            public void setRatingsTotalScore(double ratingsTotalScore) {
192                    _ratingsTotalScore = ratingsTotalScore;
193            }
194    
195            public double getRatingsAverageScore() {
196                    return _ratingsAverageScore;
197            }
198    
199            public void setRatingsAverageScore(double ratingsAverageScore) {
200                    _ratingsAverageScore = ratingsAverageScore;
201            }
202    
203            public BlogsStatsUser toEscapedModel() {
204                    if (isEscapedModel()) {
205                            return (BlogsStatsUser)this;
206                    }
207                    else {
208                            return (BlogsStatsUser)Proxy.newProxyInstance(BlogsStatsUser.class.getClassLoader(),
209                                    new Class[] { BlogsStatsUser.class },
210                                    new AutoEscapeBeanHandler(this));
211                    }
212            }
213    
214            public ExpandoBridge getExpandoBridge() {
215                    if (_expandoBridge == null) {
216                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
217                                            BlogsStatsUser.class.getName(), getPrimaryKey());
218                    }
219    
220                    return _expandoBridge;
221            }
222    
223            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
224                    getExpandoBridge().setAttributes(serviceContext);
225            }
226    
227            public Object clone() {
228                    BlogsStatsUserImpl clone = new BlogsStatsUserImpl();
229    
230                    clone.setStatsUserId(getStatsUserId());
231                    clone.setGroupId(getGroupId());
232                    clone.setCompanyId(getCompanyId());
233                    clone.setUserId(getUserId());
234                    clone.setEntryCount(getEntryCount());
235                    clone.setLastPostDate(getLastPostDate());
236                    clone.setRatingsTotalEntries(getRatingsTotalEntries());
237                    clone.setRatingsTotalScore(getRatingsTotalScore());
238                    clone.setRatingsAverageScore(getRatingsAverageScore());
239    
240                    return clone;
241            }
242    
243            public int compareTo(BlogsStatsUser blogsStatsUser) {
244                    int value = 0;
245    
246                    if (getEntryCount() < blogsStatsUser.getEntryCount()) {
247                            value = -1;
248                    }
249                    else if (getEntryCount() > blogsStatsUser.getEntryCount()) {
250                            value = 1;
251                    }
252                    else {
253                            value = 0;
254                    }
255    
256                    value = value * -1;
257    
258                    if (value != 0) {
259                            return value;
260                    }
261    
262                    return 0;
263            }
264    
265            public boolean equals(Object obj) {
266                    if (obj == null) {
267                            return false;
268                    }
269    
270                    BlogsStatsUser blogsStatsUser = null;
271    
272                    try {
273                            blogsStatsUser = (BlogsStatsUser)obj;
274                    }
275                    catch (ClassCastException cce) {
276                            return false;
277                    }
278    
279                    long pk = blogsStatsUser.getPrimaryKey();
280    
281                    if (getPrimaryKey() == pk) {
282                            return true;
283                    }
284                    else {
285                            return false;
286                    }
287            }
288    
289            public int hashCode() {
290                    return (int)getPrimaryKey();
291            }
292    
293            public String toString() {
294                    StringBundler sb = new StringBundler(19);
295    
296                    sb.append("{statsUserId=");
297                    sb.append(getStatsUserId());
298                    sb.append(", groupId=");
299                    sb.append(getGroupId());
300                    sb.append(", companyId=");
301                    sb.append(getCompanyId());
302                    sb.append(", userId=");
303                    sb.append(getUserId());
304                    sb.append(", entryCount=");
305                    sb.append(getEntryCount());
306                    sb.append(", lastPostDate=");
307                    sb.append(getLastPostDate());
308                    sb.append(", ratingsTotalEntries=");
309                    sb.append(getRatingsTotalEntries());
310                    sb.append(", ratingsTotalScore=");
311                    sb.append(getRatingsTotalScore());
312                    sb.append(", ratingsAverageScore=");
313                    sb.append(getRatingsAverageScore());
314                    sb.append("}");
315    
316                    return sb.toString();
317            }
318    
319            public String toXmlString() {
320                    StringBundler sb = new StringBundler(31);
321    
322                    sb.append("<model><model-name>");
323                    sb.append("com.liferay.portlet.blogs.model.BlogsStatsUser");
324                    sb.append("</model-name>");
325    
326                    sb.append(
327                            "<column><column-name>statsUserId</column-name><column-value><![CDATA[");
328                    sb.append(getStatsUserId());
329                    sb.append("]]></column-value></column>");
330                    sb.append(
331                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
332                    sb.append(getGroupId());
333                    sb.append("]]></column-value></column>");
334                    sb.append(
335                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
336                    sb.append(getCompanyId());
337                    sb.append("]]></column-value></column>");
338                    sb.append(
339                            "<column><column-name>userId</column-name><column-value><![CDATA[");
340                    sb.append(getUserId());
341                    sb.append("]]></column-value></column>");
342                    sb.append(
343                            "<column><column-name>entryCount</column-name><column-value><![CDATA[");
344                    sb.append(getEntryCount());
345                    sb.append("]]></column-value></column>");
346                    sb.append(
347                            "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
348                    sb.append(getLastPostDate());
349                    sb.append("]]></column-value></column>");
350                    sb.append(
351                            "<column><column-name>ratingsTotalEntries</column-name><column-value><![CDATA[");
352                    sb.append(getRatingsTotalEntries());
353                    sb.append("]]></column-value></column>");
354                    sb.append(
355                            "<column><column-name>ratingsTotalScore</column-name><column-value><![CDATA[");
356                    sb.append(getRatingsTotalScore());
357                    sb.append("]]></column-value></column>");
358                    sb.append(
359                            "<column><column-name>ratingsAverageScore</column-name><column-value><![CDATA[");
360                    sb.append(getRatingsAverageScore());
361                    sb.append("]]></column-value></column>");
362    
363                    sb.append("</model>");
364    
365                    return sb.toString();
366            }
367    
368            private long _statsUserId;
369            private String _statsUserUuid;
370            private long _groupId;
371            private long _originalGroupId;
372            private boolean _setOriginalGroupId;
373            private long _companyId;
374            private long _userId;
375            private String _userUuid;
376            private long _originalUserId;
377            private boolean _setOriginalUserId;
378            private int _entryCount;
379            private Date _lastPostDate;
380            private int _ratingsTotalEntries;
381            private double _ratingsTotalScore;
382            private double _ratingsAverageScore;
383            private transient ExpandoBridge _expandoBridge;
384    }