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