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.util.StringBundler;
018    import com.liferay.portal.model.CacheModel;
019    
020    import com.liferay.portlet.blogs.model.BlogsStatsUser;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    import java.util.Date;
028    
029    /**
030     * The cache model class for representing BlogsStatsUser in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see BlogsStatsUser
034     * @generated
035     */
036    public class BlogsStatsUserCacheModel implements CacheModel<BlogsStatsUser>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(19);
041    
042                    sb.append("{statsUserId=");
043                    sb.append(statsUserId);
044                    sb.append(", groupId=");
045                    sb.append(groupId);
046                    sb.append(", companyId=");
047                    sb.append(companyId);
048                    sb.append(", userId=");
049                    sb.append(userId);
050                    sb.append(", entryCount=");
051                    sb.append(entryCount);
052                    sb.append(", lastPostDate=");
053                    sb.append(lastPostDate);
054                    sb.append(", ratingsTotalEntries=");
055                    sb.append(ratingsTotalEntries);
056                    sb.append(", ratingsTotalScore=");
057                    sb.append(ratingsTotalScore);
058                    sb.append(", ratingsAverageScore=");
059                    sb.append(ratingsAverageScore);
060                    sb.append("}");
061    
062                    return sb.toString();
063            }
064    
065            public BlogsStatsUser toEntityModel() {
066                    BlogsStatsUserImpl blogsStatsUserImpl = new BlogsStatsUserImpl();
067    
068                    blogsStatsUserImpl.setStatsUserId(statsUserId);
069                    blogsStatsUserImpl.setGroupId(groupId);
070                    blogsStatsUserImpl.setCompanyId(companyId);
071                    blogsStatsUserImpl.setUserId(userId);
072                    blogsStatsUserImpl.setEntryCount(entryCount);
073    
074                    if (lastPostDate == Long.MIN_VALUE) {
075                            blogsStatsUserImpl.setLastPostDate(null);
076                    }
077                    else {
078                            blogsStatsUserImpl.setLastPostDate(new Date(lastPostDate));
079                    }
080    
081                    blogsStatsUserImpl.setRatingsTotalEntries(ratingsTotalEntries);
082                    blogsStatsUserImpl.setRatingsTotalScore(ratingsTotalScore);
083                    blogsStatsUserImpl.setRatingsAverageScore(ratingsAverageScore);
084    
085                    blogsStatsUserImpl.resetOriginalValues();
086    
087                    return blogsStatsUserImpl;
088            }
089    
090            public void readExternal(ObjectInput objectInput) throws IOException {
091                    statsUserId = objectInput.readLong();
092                    groupId = objectInput.readLong();
093                    companyId = objectInput.readLong();
094                    userId = objectInput.readLong();
095                    entryCount = objectInput.readInt();
096                    lastPostDate = objectInput.readLong();
097                    ratingsTotalEntries = objectInput.readInt();
098                    ratingsTotalScore = objectInput.readDouble();
099                    ratingsAverageScore = objectInput.readDouble();
100            }
101    
102            public void writeExternal(ObjectOutput objectOutput)
103                    throws IOException {
104                    objectOutput.writeLong(statsUserId);
105                    objectOutput.writeLong(groupId);
106                    objectOutput.writeLong(companyId);
107                    objectOutput.writeLong(userId);
108                    objectOutput.writeInt(entryCount);
109                    objectOutput.writeLong(lastPostDate);
110                    objectOutput.writeInt(ratingsTotalEntries);
111                    objectOutput.writeDouble(ratingsTotalScore);
112                    objectOutput.writeDouble(ratingsAverageScore);
113            }
114    
115            public long statsUserId;
116            public long groupId;
117            public long companyId;
118            public long userId;
119            public int entryCount;
120            public long lastPostDate;
121            public int ratingsTotalEntries;
122            public double ratingsTotalScore;
123            public double ratingsAverageScore;
124    }