1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.blogs.model.impl;
24  
25  import com.liferay.portal.kernel.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import java.io.Serializable;
30  
31  import java.sql.Types;
32  
33  import java.util.Date;
34  
35  /**
36   * <a href="BlogsStatsUserModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>BlogsStatsUser</code> table in
45   * the database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portlet.blogs.service.model.BlogsStatsUser
51   * @see com.liferay.portlet.blogs.service.model.BlogsStatsUserModel
52   * @see com.liferay.portlet.blogs.service.model.impl.BlogsStatsUserImpl
53   *
54   */
55  public class BlogsStatsUserModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "BlogsStatsUser";
57      public static Object[][] TABLE_COLUMNS = {
58              { "statsUserId", new Integer(Types.BIGINT) },
59              { "groupId", new Integer(Types.BIGINT) },
60              { "companyId", new Integer(Types.BIGINT) },
61              { "userId", new Integer(Types.BIGINT) },
62              { "entryCount", new Integer(Types.INTEGER) },
63              { "lastPostDate", new Integer(Types.TIMESTAMP) },
64              { "ratingsTotalEntries", new Integer(Types.INTEGER) },
65              { "ratingsTotalScore", new Integer(Types.DOUBLE) },
66              { "ratingsAverageScore", new Integer(Types.DOUBLE) }
67          };
68      public static 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)";
69      public static String TABLE_SQL_DROP = "drop table BlogsStatsUser";
70      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
71                  "xss.allow.com.liferay.portlet.blogs.model.BlogsStatsUser"),
72              XSS_ALLOW);
73      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
74                  "lock.expiration.time.com.liferay.portlet.blogs.model.BlogsStatsUserModel"));
75  
76      public BlogsStatsUserModelImpl() {
77      }
78  
79      public long getPrimaryKey() {
80          return _statsUserId;
81      }
82  
83      public void setPrimaryKey(long pk) {
84          setStatsUserId(pk);
85      }
86  
87      public Serializable getPrimaryKeyObj() {
88          return new Long(_statsUserId);
89      }
90  
91      public long getStatsUserId() {
92          return _statsUserId;
93      }
94  
95      public void setStatsUserId(long statsUserId) {
96          if (statsUserId != _statsUserId) {
97              _statsUserId = statsUserId;
98          }
99      }
100 
101     public long getGroupId() {
102         return _groupId;
103     }
104 
105     public void setGroupId(long groupId) {
106         if (groupId != _groupId) {
107             _groupId = groupId;
108         }
109     }
110 
111     public long getCompanyId() {
112         return _companyId;
113     }
114 
115     public void setCompanyId(long companyId) {
116         if (companyId != _companyId) {
117             _companyId = companyId;
118         }
119     }
120 
121     public long getUserId() {
122         return _userId;
123     }
124 
125     public void setUserId(long userId) {
126         if (userId != _userId) {
127             _userId = userId;
128         }
129     }
130 
131     public int getEntryCount() {
132         return _entryCount;
133     }
134 
135     public void setEntryCount(int entryCount) {
136         if (entryCount != _entryCount) {
137             _entryCount = entryCount;
138         }
139     }
140 
141     public Date getLastPostDate() {
142         return _lastPostDate;
143     }
144 
145     public void setLastPostDate(Date lastPostDate) {
146         if (((lastPostDate == null) && (_lastPostDate != null)) ||
147                 ((lastPostDate != null) && (_lastPostDate == null)) ||
148                 ((lastPostDate != null) && (_lastPostDate != null) &&
149                 !lastPostDate.equals(_lastPostDate))) {
150             _lastPostDate = lastPostDate;
151         }
152     }
153 
154     public int getRatingsTotalEntries() {
155         return _ratingsTotalEntries;
156     }
157 
158     public void setRatingsTotalEntries(int ratingsTotalEntries) {
159         if (ratingsTotalEntries != _ratingsTotalEntries) {
160             _ratingsTotalEntries = ratingsTotalEntries;
161         }
162     }
163 
164     public double getRatingsTotalScore() {
165         return _ratingsTotalScore;
166     }
167 
168     public void setRatingsTotalScore(double ratingsTotalScore) {
169         if (ratingsTotalScore != _ratingsTotalScore) {
170             _ratingsTotalScore = ratingsTotalScore;
171         }
172     }
173 
174     public double getRatingsAverageScore() {
175         return _ratingsAverageScore;
176     }
177 
178     public void setRatingsAverageScore(double ratingsAverageScore) {
179         if (ratingsAverageScore != _ratingsAverageScore) {
180             _ratingsAverageScore = ratingsAverageScore;
181         }
182     }
183 
184     public Object clone() {
185         BlogsStatsUserImpl clone = new BlogsStatsUserImpl();
186         clone.setStatsUserId(getStatsUserId());
187         clone.setGroupId(getGroupId());
188         clone.setCompanyId(getCompanyId());
189         clone.setUserId(getUserId());
190         clone.setEntryCount(getEntryCount());
191         clone.setLastPostDate(getLastPostDate());
192         clone.setRatingsTotalEntries(getRatingsTotalEntries());
193         clone.setRatingsTotalScore(getRatingsTotalScore());
194         clone.setRatingsAverageScore(getRatingsAverageScore());
195 
196         return clone;
197     }
198 
199     public int compareTo(Object obj) {
200         if (obj == null) {
201             return -1;
202         }
203 
204         BlogsStatsUserImpl blogsStatsUser = (BlogsStatsUserImpl)obj;
205         int value = 0;
206 
207         if (getEntryCount() < blogsStatsUser.getEntryCount()) {
208             value = -1;
209         }
210         else if (getEntryCount() > blogsStatsUser.getEntryCount()) {
211             value = 1;
212         }
213         else {
214             value = 0;
215         }
216 
217         value = value * -1;
218 
219         if (value != 0) {
220             return value;
221         }
222 
223         return 0;
224     }
225 
226     public boolean equals(Object obj) {
227         if (obj == null) {
228             return false;
229         }
230 
231         BlogsStatsUserImpl blogsStatsUser = null;
232 
233         try {
234             blogsStatsUser = (BlogsStatsUserImpl)obj;
235         }
236         catch (ClassCastException cce) {
237             return false;
238         }
239 
240         long pk = blogsStatsUser.getPrimaryKey();
241 
242         if (getPrimaryKey() == pk) {
243             return true;
244         }
245         else {
246             return false;
247         }
248     }
249 
250     public int hashCode() {
251         return (int)getPrimaryKey();
252     }
253 
254     private long _statsUserId;
255     private long _groupId;
256     private long _companyId;
257     private long _userId;
258     private int _entryCount;
259     private Date _lastPostDate;
260     private int _ratingsTotalEntries;
261     private double _ratingsTotalScore;
262     private double _ratingsAverageScore;
263 }