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            @Override
066            public BlogsStatsUser toEntityModel() {
067                    BlogsStatsUserImpl blogsStatsUserImpl = new BlogsStatsUserImpl();
068    
069                    blogsStatsUserImpl.setStatsUserId(statsUserId);
070                    blogsStatsUserImpl.setGroupId(groupId);
071                    blogsStatsUserImpl.setCompanyId(companyId);
072                    blogsStatsUserImpl.setUserId(userId);
073                    blogsStatsUserImpl.setEntryCount(entryCount);
074    
075                    if (lastPostDate == Long.MIN_VALUE) {
076                            blogsStatsUserImpl.setLastPostDate(null);
077                    }
078                    else {
079                            blogsStatsUserImpl.setLastPostDate(new Date(lastPostDate));
080                    }
081    
082                    blogsStatsUserImpl.setRatingsTotalEntries(ratingsTotalEntries);
083                    blogsStatsUserImpl.setRatingsTotalScore(ratingsTotalScore);
084                    blogsStatsUserImpl.setRatingsAverageScore(ratingsAverageScore);
085    
086                    blogsStatsUserImpl.resetOriginalValues();
087    
088                    return blogsStatsUserImpl;
089            }
090    
091            @Override
092            public void readExternal(ObjectInput objectInput) throws IOException {
093                    statsUserId = objectInput.readLong();
094                    groupId = objectInput.readLong();
095                    companyId = objectInput.readLong();
096                    userId = objectInput.readLong();
097                    entryCount = objectInput.readInt();
098                    lastPostDate = objectInput.readLong();
099                    ratingsTotalEntries = objectInput.readInt();
100                    ratingsTotalScore = objectInput.readDouble();
101                    ratingsAverageScore = objectInput.readDouble();
102            }
103    
104            @Override
105            public void writeExternal(ObjectOutput objectOutput)
106                    throws IOException {
107                    objectOutput.writeLong(statsUserId);
108                    objectOutput.writeLong(groupId);
109                    objectOutput.writeLong(companyId);
110                    objectOutput.writeLong(userId);
111                    objectOutput.writeInt(entryCount);
112                    objectOutput.writeLong(lastPostDate);
113                    objectOutput.writeInt(ratingsTotalEntries);
114                    objectOutput.writeDouble(ratingsTotalScore);
115                    objectOutput.writeDouble(ratingsAverageScore);
116            }
117    
118            public long statsUserId;
119            public long groupId;
120            public long companyId;
121            public long userId;
122            public int entryCount;
123            public long lastPostDate;
124            public int ratingsTotalEntries;
125            public double ratingsTotalScore;
126            public double ratingsAverageScore;
127    }