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