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.messageboards.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  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.messageboards.model.MBStatsUser;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.Date;
39  
40  /**
41   * <a href="MBStatsUserModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>MBStatsUser</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.messageboards.service.model.MBStatsUser
56   * @see com.liferay.portlet.messageboards.service.model.MBStatsUserModel
57   * @see com.liferay.portlet.messageboards.service.model.impl.MBStatsUserImpl
58   *
59   */
60  public class MBStatsUserModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "MBStatsUser";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "statsUserId", new Integer(Types.BIGINT) },
64              
65  
66              { "groupId", new Integer(Types.BIGINT) },
67              
68  
69              { "userId", new Integer(Types.BIGINT) },
70              
71  
72              { "messageCount", new Integer(Types.INTEGER) },
73              
74  
75              { "lastPostDate", new Integer(Types.TIMESTAMP) }
76          };
77      public static final String TABLE_SQL_CREATE = "create table MBStatsUser (statsUserId LONG not null primary key,groupId LONG,userId LONG,messageCount INTEGER,lastPostDate DATE null)";
78      public static final String TABLE_SQL_DROP = "drop table MBStatsUser";
79      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBStatsUser"),
81              true);
82      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
83                  "lock.expiration.time.com.liferay.portlet.messageboards.model.MBStatsUser"));
84  
85      public MBStatsUserModelImpl() {
86      }
87  
88      public long getPrimaryKey() {
89          return _statsUserId;
90      }
91  
92      public void setPrimaryKey(long pk) {
93          setStatsUserId(pk);
94      }
95  
96      public Serializable getPrimaryKeyObj() {
97          return new Long(_statsUserId);
98      }
99  
100     public long getStatsUserId() {
101         return _statsUserId;
102     }
103 
104     public void setStatsUserId(long statsUserId) {
105         if (statsUserId != _statsUserId) {
106             _statsUserId = statsUserId;
107         }
108     }
109 
110     public long getGroupId() {
111         return _groupId;
112     }
113 
114     public void setGroupId(long groupId) {
115         if (groupId != _groupId) {
116             _groupId = groupId;
117         }
118     }
119 
120     public long getUserId() {
121         return _userId;
122     }
123 
124     public void setUserId(long userId) {
125         if (userId != _userId) {
126             _userId = userId;
127         }
128     }
129 
130     public int getMessageCount() {
131         return _messageCount;
132     }
133 
134     public void setMessageCount(int messageCount) {
135         if (messageCount != _messageCount) {
136             _messageCount = messageCount;
137         }
138     }
139 
140     public Date getLastPostDate() {
141         return _lastPostDate;
142     }
143 
144     public void setLastPostDate(Date lastPostDate) {
145         if (((lastPostDate == null) && (_lastPostDate != null)) ||
146                 ((lastPostDate != null) && (_lastPostDate == null)) ||
147                 ((lastPostDate != null) && (_lastPostDate != null) &&
148                 !lastPostDate.equals(_lastPostDate))) {
149             _lastPostDate = lastPostDate;
150         }
151     }
152 
153     public MBStatsUser toEscapedModel() {
154         if (isEscapedModel()) {
155             return (MBStatsUser)this;
156         }
157         else {
158             MBStatsUser model = new MBStatsUserImpl();
159 
160             model.setEscapedModel(true);
161 
162             model.setStatsUserId(getStatsUserId());
163             model.setGroupId(getGroupId());
164             model.setUserId(getUserId());
165             model.setMessageCount(getMessageCount());
166             model.setLastPostDate(getLastPostDate());
167 
168             model = (MBStatsUser)Proxy.newProxyInstance(MBStatsUser.class.getClassLoader(),
169                     new Class[] { MBStatsUser.class },
170                     new ReadOnlyBeanHandler(model));
171 
172             return model;
173         }
174     }
175 
176     public Object clone() {
177         MBStatsUserImpl clone = new MBStatsUserImpl();
178 
179         clone.setStatsUserId(getStatsUserId());
180         clone.setGroupId(getGroupId());
181         clone.setUserId(getUserId());
182         clone.setMessageCount(getMessageCount());
183         clone.setLastPostDate(getLastPostDate());
184 
185         return clone;
186     }
187 
188     public int compareTo(Object obj) {
189         if (obj == null) {
190             return -1;
191         }
192 
193         MBStatsUserImpl mbStatsUser = (MBStatsUserImpl)obj;
194 
195         int value = 0;
196 
197         if (getMessageCount() < mbStatsUser.getMessageCount()) {
198             value = -1;
199         }
200         else if (getMessageCount() > mbStatsUser.getMessageCount()) {
201             value = 1;
202         }
203         else {
204             value = 0;
205         }
206 
207         value = value * -1;
208 
209         if (value != 0) {
210             return value;
211         }
212 
213         return 0;
214     }
215 
216     public boolean equals(Object obj) {
217         if (obj == null) {
218             return false;
219         }
220 
221         MBStatsUserImpl mbStatsUser = null;
222 
223         try {
224             mbStatsUser = (MBStatsUserImpl)obj;
225         }
226         catch (ClassCastException cce) {
227             return false;
228         }
229 
230         long pk = mbStatsUser.getPrimaryKey();
231 
232         if (getPrimaryKey() == pk) {
233             return true;
234         }
235         else {
236             return false;
237         }
238     }
239 
240     public int hashCode() {
241         return (int)getPrimaryKey();
242     }
243 
244     private long _statsUserId;
245     private long _groupId;
246     private long _userId;
247     private int _messageCount;
248     private Date _lastPostDate;
249 }