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