1   /**
2    * Copyright (c) 2000-2008 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.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  
29  import com.liferay.portlet.blogs.model.BlogsStatsUser;
30  import com.liferay.portlet.blogs.model.BlogsStatsUserSoap;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.Date;
40  import java.util.List;
41  
42  /**
43   * <a href="BlogsStatsUserModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>BlogsStatsUser</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.blogs.service.model.BlogsStatsUser
58   * @see com.liferay.portlet.blogs.service.model.BlogsStatsUserModel
59   * @see com.liferay.portlet.blogs.service.model.impl.BlogsStatsUserImpl
60   *
61   */
62  public class BlogsStatsUserModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "BlogsStatsUser";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "statsUserId", new Integer(Types.BIGINT) },
66              
67  
68              { "groupId", new Integer(Types.BIGINT) },
69              
70  
71              { "companyId", new Integer(Types.BIGINT) },
72              
73  
74              { "userId", new Integer(Types.BIGINT) },
75              
76  
77              { "entryCount", new Integer(Types.INTEGER) },
78              
79  
80              { "lastPostDate", new Integer(Types.TIMESTAMP) },
81              
82  
83              { "ratingsTotalEntries", new Integer(Types.INTEGER) },
84              
85  
86              { "ratingsTotalScore", new Integer(Types.DOUBLE) },
87              
88  
89              { "ratingsAverageScore", new Integer(Types.DOUBLE) }
90          };
91      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)";
92      public static final String TABLE_SQL_DROP = "drop table BlogsStatsUser";
93      public static final String DATA_SOURCE = "liferayDataSource";
94      public static final String SESSION_FACTORY = "liferaySessionFactory";
95      public static final String TX_MANAGER = "liferayTransactionManager";
96      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
97                  "value.object.finder.cache.enabled.com.liferay.portlet.blogs.model.BlogsStatsUser"),
98              true);
99  
100     public static BlogsStatsUser toModel(BlogsStatsUserSoap soapModel) {
101         BlogsStatsUser model = new BlogsStatsUserImpl();
102 
103         model.setStatsUserId(soapModel.getStatsUserId());
104         model.setGroupId(soapModel.getGroupId());
105         model.setCompanyId(soapModel.getCompanyId());
106         model.setUserId(soapModel.getUserId());
107         model.setEntryCount(soapModel.getEntryCount());
108         model.setLastPostDate(soapModel.getLastPostDate());
109         model.setRatingsTotalEntries(soapModel.getRatingsTotalEntries());
110         model.setRatingsTotalScore(soapModel.getRatingsTotalScore());
111         model.setRatingsAverageScore(soapModel.getRatingsAverageScore());
112 
113         return model;
114     }
115 
116     public static List<BlogsStatsUser> toModels(BlogsStatsUserSoap[] soapModels) {
117         List<BlogsStatsUser> models = new ArrayList<BlogsStatsUser>(soapModels.length);
118 
119         for (BlogsStatsUserSoap soapModel : soapModels) {
120             models.add(toModel(soapModel));
121         }
122 
123         return models;
124     }
125 
126     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
127                 "lock.expiration.time.com.liferay.portlet.blogs.model.BlogsStatsUser"));
128 
129     public BlogsStatsUserModelImpl() {
130     }
131 
132     public long getPrimaryKey() {
133         return _statsUserId;
134     }
135 
136     public void setPrimaryKey(long pk) {
137         setStatsUserId(pk);
138     }
139 
140     public Serializable getPrimaryKeyObj() {
141         return new Long(_statsUserId);
142     }
143 
144     public long getStatsUserId() {
145         return _statsUserId;
146     }
147 
148     public void setStatsUserId(long statsUserId) {
149         if (statsUserId != _statsUserId) {
150             _statsUserId = statsUserId;
151         }
152     }
153 
154     public long getGroupId() {
155         return _groupId;
156     }
157 
158     public void setGroupId(long groupId) {
159         if (groupId != _groupId) {
160             _groupId = groupId;
161         }
162     }
163 
164     public long getCompanyId() {
165         return _companyId;
166     }
167 
168     public void setCompanyId(long companyId) {
169         if (companyId != _companyId) {
170             _companyId = companyId;
171         }
172     }
173 
174     public long getUserId() {
175         return _userId;
176     }
177 
178     public void setUserId(long userId) {
179         if (userId != _userId) {
180             _userId = userId;
181         }
182     }
183 
184     public int getEntryCount() {
185         return _entryCount;
186     }
187 
188     public void setEntryCount(int entryCount) {
189         if (entryCount != _entryCount) {
190             _entryCount = entryCount;
191         }
192     }
193 
194     public Date getLastPostDate() {
195         return _lastPostDate;
196     }
197 
198     public void setLastPostDate(Date lastPostDate) {
199         if (((lastPostDate == null) && (_lastPostDate != null)) ||
200                 ((lastPostDate != null) && (_lastPostDate == null)) ||
201                 ((lastPostDate != null) && (_lastPostDate != null) &&
202                 !lastPostDate.equals(_lastPostDate))) {
203             _lastPostDate = lastPostDate;
204         }
205     }
206 
207     public int getRatingsTotalEntries() {
208         return _ratingsTotalEntries;
209     }
210 
211     public void setRatingsTotalEntries(int ratingsTotalEntries) {
212         if (ratingsTotalEntries != _ratingsTotalEntries) {
213             _ratingsTotalEntries = ratingsTotalEntries;
214         }
215     }
216 
217     public double getRatingsTotalScore() {
218         return _ratingsTotalScore;
219     }
220 
221     public void setRatingsTotalScore(double ratingsTotalScore) {
222         if (ratingsTotalScore != _ratingsTotalScore) {
223             _ratingsTotalScore = ratingsTotalScore;
224         }
225     }
226 
227     public double getRatingsAverageScore() {
228         return _ratingsAverageScore;
229     }
230 
231     public void setRatingsAverageScore(double ratingsAverageScore) {
232         if (ratingsAverageScore != _ratingsAverageScore) {
233             _ratingsAverageScore = ratingsAverageScore;
234         }
235     }
236 
237     public BlogsStatsUser toEscapedModel() {
238         if (isEscapedModel()) {
239             return (BlogsStatsUser)this;
240         }
241         else {
242             BlogsStatsUser model = new BlogsStatsUserImpl();
243 
244             model.setEscapedModel(true);
245 
246             model.setStatsUserId(getStatsUserId());
247             model.setGroupId(getGroupId());
248             model.setCompanyId(getCompanyId());
249             model.setUserId(getUserId());
250             model.setEntryCount(getEntryCount());
251             model.setLastPostDate(getLastPostDate());
252             model.setRatingsTotalEntries(getRatingsTotalEntries());
253             model.setRatingsTotalScore(getRatingsTotalScore());
254             model.setRatingsAverageScore(getRatingsAverageScore());
255 
256             model = (BlogsStatsUser)Proxy.newProxyInstance(BlogsStatsUser.class.getClassLoader(),
257                     new Class[] { BlogsStatsUser.class },
258                     new ReadOnlyBeanHandler(model));
259 
260             return model;
261         }
262     }
263 
264     public Object clone() {
265         BlogsStatsUserImpl clone = new BlogsStatsUserImpl();
266 
267         clone.setStatsUserId(getStatsUserId());
268         clone.setGroupId(getGroupId());
269         clone.setCompanyId(getCompanyId());
270         clone.setUserId(getUserId());
271         clone.setEntryCount(getEntryCount());
272         clone.setLastPostDate(getLastPostDate());
273         clone.setRatingsTotalEntries(getRatingsTotalEntries());
274         clone.setRatingsTotalScore(getRatingsTotalScore());
275         clone.setRatingsAverageScore(getRatingsAverageScore());
276 
277         return clone;
278     }
279 
280     public int compareTo(Object obj) {
281         if (obj == null) {
282             return -1;
283         }
284 
285         BlogsStatsUserImpl blogsStatsUser = (BlogsStatsUserImpl)obj;
286 
287         int value = 0;
288 
289         if (getEntryCount() < blogsStatsUser.getEntryCount()) {
290             value = -1;
291         }
292         else if (getEntryCount() > blogsStatsUser.getEntryCount()) {
293             value = 1;
294         }
295         else {
296             value = 0;
297         }
298 
299         value = value * -1;
300 
301         if (value != 0) {
302             return value;
303         }
304 
305         return 0;
306     }
307 
308     public boolean equals(Object obj) {
309         if (obj == null) {
310             return false;
311         }
312 
313         BlogsStatsUserImpl blogsStatsUser = null;
314 
315         try {
316             blogsStatsUser = (BlogsStatsUserImpl)obj;
317         }
318         catch (ClassCastException cce) {
319             return false;
320         }
321 
322         long pk = blogsStatsUser.getPrimaryKey();
323 
324         if (getPrimaryKey() == pk) {
325             return true;
326         }
327         else {
328             return false;
329         }
330     }
331 
332     public int hashCode() {
333         return (int)getPrimaryKey();
334     }
335 
336     private long _statsUserId;
337     private long _groupId;
338     private long _companyId;
339     private long _userId;
340     private int _entryCount;
341     private Date _lastPostDate;
342     private int _ratingsTotalEntries;
343     private double _ratingsTotalScore;
344     private double _ratingsAverageScore;
345 }