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