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.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.ProxyUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.model.CacheModel;
023    import com.liferay.portal.model.impl.BaseModelImpl;
024    import com.liferay.portal.service.ServiceContext;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import com.liferay.portlet.blogs.model.BlogsStatsUser;
028    import com.liferay.portlet.blogs.model.BlogsStatsUserModel;
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.Date;
037    import java.util.HashMap;
038    import java.util.Map;
039    
040    /**
041     * 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.
042     *
043     * <p>
044     * 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}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see BlogsStatsUserImpl
049     * @see com.liferay.portlet.blogs.model.BlogsStatsUser
050     * @see com.liferay.portlet.blogs.model.BlogsStatsUserModel
051     * @generated
052     */
053    public class BlogsStatsUserModelImpl extends BaseModelImpl<BlogsStatsUser>
054            implements BlogsStatsUserModel {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * 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.
059             */
060            public static final String TABLE_NAME = "BlogsStatsUser";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "statsUserId", Types.BIGINT },
063                            { "groupId", Types.BIGINT },
064                            { "companyId", Types.BIGINT },
065                            { "userId", Types.BIGINT },
066                            { "entryCount", Types.INTEGER },
067                            { "lastPostDate", Types.TIMESTAMP },
068                            { "ratingsTotalEntries", Types.INTEGER },
069                            { "ratingsTotalScore", Types.DOUBLE },
070                            { "ratingsAverageScore", Types.DOUBLE }
071                    };
072            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)";
073            public static final String TABLE_SQL_DROP = "drop table BlogsStatsUser";
074            public static final String ORDER_BY_JPQL = " ORDER BY blogsStatsUser.entryCount DESC";
075            public static final String ORDER_BY_SQL = " ORDER BY BlogsStatsUser.entryCount DESC";
076            public static final String DATA_SOURCE = "liferayDataSource";
077            public static final String SESSION_FACTORY = "liferaySessionFactory";
078            public static final String TX_MANAGER = "liferayTransactionManager";
079            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.entity.cache.enabled.com.liferay.portlet.blogs.model.BlogsStatsUser"),
081                            true);
082            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.finder.cache.enabled.com.liferay.portlet.blogs.model.BlogsStatsUser"),
084                            true);
085            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.column.bitmask.enabled.com.liferay.portlet.blogs.model.BlogsStatsUser"),
087                            true);
088            public static long COMPANYID_COLUMN_BITMASK = 1L;
089            public static long ENTRYCOUNT_COLUMN_BITMASK = 2L;
090            public static long GROUPID_COLUMN_BITMASK = 4L;
091            public static long LASTPOSTDATE_COLUMN_BITMASK = 8L;
092            public static long USERID_COLUMN_BITMASK = 16L;
093            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
094                                    "lock.expiration.time.com.liferay.portlet.blogs.model.BlogsStatsUser"));
095    
096            public BlogsStatsUserModelImpl() {
097            }
098    
099            public long getPrimaryKey() {
100                    return _statsUserId;
101            }
102    
103            public void setPrimaryKey(long primaryKey) {
104                    setStatsUserId(primaryKey);
105            }
106    
107            public Serializable getPrimaryKeyObj() {
108                    return new Long(_statsUserId);
109            }
110    
111            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
112                    setPrimaryKey(((Long)primaryKeyObj).longValue());
113            }
114    
115            public Class<?> getModelClass() {
116                    return BlogsStatsUser.class;
117            }
118    
119            public String getModelClassName() {
120                    return BlogsStatsUser.class.getName();
121            }
122    
123            @Override
124            public Map<String, Object> getModelAttributes() {
125                    Map<String, Object> attributes = new HashMap<String, Object>();
126    
127                    attributes.put("statsUserId", getStatsUserId());
128                    attributes.put("groupId", getGroupId());
129                    attributes.put("companyId", getCompanyId());
130                    attributes.put("userId", getUserId());
131                    attributes.put("entryCount", getEntryCount());
132                    attributes.put("lastPostDate", getLastPostDate());
133                    attributes.put("ratingsTotalEntries", getRatingsTotalEntries());
134                    attributes.put("ratingsTotalScore", getRatingsTotalScore());
135                    attributes.put("ratingsAverageScore", getRatingsAverageScore());
136    
137                    return attributes;
138            }
139    
140            @Override
141            public void setModelAttributes(Map<String, Object> attributes) {
142                    Long statsUserId = (Long)attributes.get("statsUserId");
143    
144                    if (statsUserId != null) {
145                            setStatsUserId(statsUserId);
146                    }
147    
148                    Long groupId = (Long)attributes.get("groupId");
149    
150                    if (groupId != null) {
151                            setGroupId(groupId);
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                    Integer entryCount = (Integer)attributes.get("entryCount");
167    
168                    if (entryCount != null) {
169                            setEntryCount(entryCount);
170                    }
171    
172                    Date lastPostDate = (Date)attributes.get("lastPostDate");
173    
174                    if (lastPostDate != null) {
175                            setLastPostDate(lastPostDate);
176                    }
177    
178                    Integer ratingsTotalEntries = (Integer)attributes.get(
179                                    "ratingsTotalEntries");
180    
181                    if (ratingsTotalEntries != null) {
182                            setRatingsTotalEntries(ratingsTotalEntries);
183                    }
184    
185                    Double ratingsTotalScore = (Double)attributes.get("ratingsTotalScore");
186    
187                    if (ratingsTotalScore != null) {
188                            setRatingsTotalScore(ratingsTotalScore);
189                    }
190    
191                    Double ratingsAverageScore = (Double)attributes.get(
192                                    "ratingsAverageScore");
193    
194                    if (ratingsAverageScore != null) {
195                            setRatingsAverageScore(ratingsAverageScore);
196                    }
197            }
198    
199            public long getStatsUserId() {
200                    return _statsUserId;
201            }
202    
203            public void setStatsUserId(long statsUserId) {
204                    _statsUserId = statsUserId;
205            }
206    
207            public String getStatsUserUuid() throws SystemException {
208                    return PortalUtil.getUserValue(getStatsUserId(), "uuid", _statsUserUuid);
209            }
210    
211            public void setStatsUserUuid(String statsUserUuid) {
212                    _statsUserUuid = statsUserUuid;
213            }
214    
215            public long getGroupId() {
216                    return _groupId;
217            }
218    
219            public void setGroupId(long groupId) {
220                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
221    
222                    if (!_setOriginalGroupId) {
223                            _setOriginalGroupId = true;
224    
225                            _originalGroupId = _groupId;
226                    }
227    
228                    _groupId = groupId;
229            }
230    
231            public long getOriginalGroupId() {
232                    return _originalGroupId;
233            }
234    
235            public long getCompanyId() {
236                    return _companyId;
237            }
238    
239            public void setCompanyId(long companyId) {
240                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
241    
242                    if (!_setOriginalCompanyId) {
243                            _setOriginalCompanyId = true;
244    
245                            _originalCompanyId = _companyId;
246                    }
247    
248                    _companyId = companyId;
249            }
250    
251            public long getOriginalCompanyId() {
252                    return _originalCompanyId;
253            }
254    
255            public long getUserId() {
256                    return _userId;
257            }
258    
259            public void setUserId(long userId) {
260                    _columnBitmask |= USERID_COLUMN_BITMASK;
261    
262                    if (!_setOriginalUserId) {
263                            _setOriginalUserId = true;
264    
265                            _originalUserId = _userId;
266                    }
267    
268                    _userId = userId;
269            }
270    
271            public String getUserUuid() throws SystemException {
272                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
273            }
274    
275            public void setUserUuid(String userUuid) {
276                    _userUuid = userUuid;
277            }
278    
279            public long getOriginalUserId() {
280                    return _originalUserId;
281            }
282    
283            public int getEntryCount() {
284                    return _entryCount;
285            }
286    
287            public void setEntryCount(int entryCount) {
288                    _columnBitmask = -1L;
289    
290                    if (!_setOriginalEntryCount) {
291                            _setOriginalEntryCount = true;
292    
293                            _originalEntryCount = _entryCount;
294                    }
295    
296                    _entryCount = entryCount;
297            }
298    
299            public int getOriginalEntryCount() {
300                    return _originalEntryCount;
301            }
302    
303            public Date getLastPostDate() {
304                    return _lastPostDate;
305            }
306    
307            public void setLastPostDate(Date lastPostDate) {
308                    _columnBitmask |= LASTPOSTDATE_COLUMN_BITMASK;
309    
310                    if (_originalLastPostDate == null) {
311                            _originalLastPostDate = _lastPostDate;
312                    }
313    
314                    _lastPostDate = lastPostDate;
315            }
316    
317            public Date getOriginalLastPostDate() {
318                    return _originalLastPostDate;
319            }
320    
321            public int getRatingsTotalEntries() {
322                    return _ratingsTotalEntries;
323            }
324    
325            public void setRatingsTotalEntries(int ratingsTotalEntries) {
326                    _ratingsTotalEntries = ratingsTotalEntries;
327            }
328    
329            public double getRatingsTotalScore() {
330                    return _ratingsTotalScore;
331            }
332    
333            public void setRatingsTotalScore(double ratingsTotalScore) {
334                    _ratingsTotalScore = ratingsTotalScore;
335            }
336    
337            public double getRatingsAverageScore() {
338                    return _ratingsAverageScore;
339            }
340    
341            public void setRatingsAverageScore(double ratingsAverageScore) {
342                    _ratingsAverageScore = ratingsAverageScore;
343            }
344    
345            public long getColumnBitmask() {
346                    return _columnBitmask;
347            }
348    
349            @Override
350            public ExpandoBridge getExpandoBridge() {
351                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
352                            BlogsStatsUser.class.getName(), getPrimaryKey());
353            }
354    
355            @Override
356            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
357                    ExpandoBridge expandoBridge = getExpandoBridge();
358    
359                    expandoBridge.setAttributes(serviceContext);
360            }
361    
362            @Override
363            public BlogsStatsUser toEscapedModel() {
364                    if (_escapedModel == null) {
365                            _escapedModel = (BlogsStatsUser)ProxyUtil.newProxyInstance(_classLoader,
366                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
367                    }
368    
369                    return _escapedModel;
370            }
371    
372            public BlogsStatsUser toUnescapedModel() {
373                    return (BlogsStatsUser)this;
374            }
375    
376            @Override
377            public Object clone() {
378                    BlogsStatsUserImpl blogsStatsUserImpl = new BlogsStatsUserImpl();
379    
380                    blogsStatsUserImpl.setStatsUserId(getStatsUserId());
381                    blogsStatsUserImpl.setGroupId(getGroupId());
382                    blogsStatsUserImpl.setCompanyId(getCompanyId());
383                    blogsStatsUserImpl.setUserId(getUserId());
384                    blogsStatsUserImpl.setEntryCount(getEntryCount());
385                    blogsStatsUserImpl.setLastPostDate(getLastPostDate());
386                    blogsStatsUserImpl.setRatingsTotalEntries(getRatingsTotalEntries());
387                    blogsStatsUserImpl.setRatingsTotalScore(getRatingsTotalScore());
388                    blogsStatsUserImpl.setRatingsAverageScore(getRatingsAverageScore());
389    
390                    blogsStatsUserImpl.resetOriginalValues();
391    
392                    return blogsStatsUserImpl;
393            }
394    
395            public int compareTo(BlogsStatsUser blogsStatsUser) {
396                    int value = 0;
397    
398                    if (getEntryCount() < blogsStatsUser.getEntryCount()) {
399                            value = -1;
400                    }
401                    else if (getEntryCount() > blogsStatsUser.getEntryCount()) {
402                            value = 1;
403                    }
404                    else {
405                            value = 0;
406                    }
407    
408                    value = value * -1;
409    
410                    if (value != 0) {
411                            return value;
412                    }
413    
414                    return 0;
415            }
416    
417            @Override
418            public boolean equals(Object obj) {
419                    if (this == obj) {
420                            return true;
421                    }
422    
423                    if (!(obj instanceof BlogsStatsUser)) {
424                            return false;
425                    }
426    
427                    BlogsStatsUser blogsStatsUser = (BlogsStatsUser)obj;
428    
429                    long primaryKey = blogsStatsUser.getPrimaryKey();
430    
431                    if (getPrimaryKey() == primaryKey) {
432                            return true;
433                    }
434                    else {
435                            return false;
436                    }
437            }
438    
439            @Override
440            public int hashCode() {
441                    return (int)getPrimaryKey();
442            }
443    
444            @Override
445            public void resetOriginalValues() {
446                    BlogsStatsUserModelImpl blogsStatsUserModelImpl = this;
447    
448                    blogsStatsUserModelImpl._originalGroupId = blogsStatsUserModelImpl._groupId;
449    
450                    blogsStatsUserModelImpl._setOriginalGroupId = false;
451    
452                    blogsStatsUserModelImpl._originalCompanyId = blogsStatsUserModelImpl._companyId;
453    
454                    blogsStatsUserModelImpl._setOriginalCompanyId = false;
455    
456                    blogsStatsUserModelImpl._originalUserId = blogsStatsUserModelImpl._userId;
457    
458                    blogsStatsUserModelImpl._setOriginalUserId = false;
459    
460                    blogsStatsUserModelImpl._originalEntryCount = blogsStatsUserModelImpl._entryCount;
461    
462                    blogsStatsUserModelImpl._setOriginalEntryCount = false;
463    
464                    blogsStatsUserModelImpl._originalLastPostDate = blogsStatsUserModelImpl._lastPostDate;
465    
466                    blogsStatsUserModelImpl._columnBitmask = 0;
467            }
468    
469            @Override
470            public CacheModel<BlogsStatsUser> toCacheModel() {
471                    BlogsStatsUserCacheModel blogsStatsUserCacheModel = new BlogsStatsUserCacheModel();
472    
473                    blogsStatsUserCacheModel.statsUserId = getStatsUserId();
474    
475                    blogsStatsUserCacheModel.groupId = getGroupId();
476    
477                    blogsStatsUserCacheModel.companyId = getCompanyId();
478    
479                    blogsStatsUserCacheModel.userId = getUserId();
480    
481                    blogsStatsUserCacheModel.entryCount = getEntryCount();
482    
483                    Date lastPostDate = getLastPostDate();
484    
485                    if (lastPostDate != null) {
486                            blogsStatsUserCacheModel.lastPostDate = lastPostDate.getTime();
487                    }
488                    else {
489                            blogsStatsUserCacheModel.lastPostDate = Long.MIN_VALUE;
490                    }
491    
492                    blogsStatsUserCacheModel.ratingsTotalEntries = getRatingsTotalEntries();
493    
494                    blogsStatsUserCacheModel.ratingsTotalScore = getRatingsTotalScore();
495    
496                    blogsStatsUserCacheModel.ratingsAverageScore = getRatingsAverageScore();
497    
498                    return blogsStatsUserCacheModel;
499            }
500    
501            @Override
502            public String toString() {
503                    StringBundler sb = new StringBundler(19);
504    
505                    sb.append("{statsUserId=");
506                    sb.append(getStatsUserId());
507                    sb.append(", groupId=");
508                    sb.append(getGroupId());
509                    sb.append(", companyId=");
510                    sb.append(getCompanyId());
511                    sb.append(", userId=");
512                    sb.append(getUserId());
513                    sb.append(", entryCount=");
514                    sb.append(getEntryCount());
515                    sb.append(", lastPostDate=");
516                    sb.append(getLastPostDate());
517                    sb.append(", ratingsTotalEntries=");
518                    sb.append(getRatingsTotalEntries());
519                    sb.append(", ratingsTotalScore=");
520                    sb.append(getRatingsTotalScore());
521                    sb.append(", ratingsAverageScore=");
522                    sb.append(getRatingsAverageScore());
523                    sb.append("}");
524    
525                    return sb.toString();
526            }
527    
528            public String toXmlString() {
529                    StringBundler sb = new StringBundler(31);
530    
531                    sb.append("<model><model-name>");
532                    sb.append("com.liferay.portlet.blogs.model.BlogsStatsUser");
533                    sb.append("</model-name>");
534    
535                    sb.append(
536                            "<column><column-name>statsUserId</column-name><column-value><![CDATA[");
537                    sb.append(getStatsUserId());
538                    sb.append("]]></column-value></column>");
539                    sb.append(
540                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
541                    sb.append(getGroupId());
542                    sb.append("]]></column-value></column>");
543                    sb.append(
544                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
545                    sb.append(getCompanyId());
546                    sb.append("]]></column-value></column>");
547                    sb.append(
548                            "<column><column-name>userId</column-name><column-value><![CDATA[");
549                    sb.append(getUserId());
550                    sb.append("]]></column-value></column>");
551                    sb.append(
552                            "<column><column-name>entryCount</column-name><column-value><![CDATA[");
553                    sb.append(getEntryCount());
554                    sb.append("]]></column-value></column>");
555                    sb.append(
556                            "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
557                    sb.append(getLastPostDate());
558                    sb.append("]]></column-value></column>");
559                    sb.append(
560                            "<column><column-name>ratingsTotalEntries</column-name><column-value><![CDATA[");
561                    sb.append(getRatingsTotalEntries());
562                    sb.append("]]></column-value></column>");
563                    sb.append(
564                            "<column><column-name>ratingsTotalScore</column-name><column-value><![CDATA[");
565                    sb.append(getRatingsTotalScore());
566                    sb.append("]]></column-value></column>");
567                    sb.append(
568                            "<column><column-name>ratingsAverageScore</column-name><column-value><![CDATA[");
569                    sb.append(getRatingsAverageScore());
570                    sb.append("]]></column-value></column>");
571    
572                    sb.append("</model>");
573    
574                    return sb.toString();
575            }
576    
577            private static ClassLoader _classLoader = BlogsStatsUser.class.getClassLoader();
578            private static Class<?>[] _escapedModelInterfaces = new Class[] {
579                            BlogsStatsUser.class
580                    };
581            private long _statsUserId;
582            private String _statsUserUuid;
583            private long _groupId;
584            private long _originalGroupId;
585            private boolean _setOriginalGroupId;
586            private long _companyId;
587            private long _originalCompanyId;
588            private boolean _setOriginalCompanyId;
589            private long _userId;
590            private String _userUuid;
591            private long _originalUserId;
592            private boolean _setOriginalUserId;
593            private int _entryCount;
594            private int _originalEntryCount;
595            private boolean _setOriginalEntryCount;
596            private Date _lastPostDate;
597            private Date _originalLastPostDate;
598            private int _ratingsTotalEntries;
599            private double _ratingsTotalScore;
600            private double _ratingsAverageScore;
601            private long _columnBitmask;
602            private BlogsStatsUser _escapedModel;
603    }