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.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PortalUtil;
30  
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 String getStatsUserUuid() throws SystemException {
142         return PortalUtil.getUserValue(getStatsUserId(), "uuid", _statsUserUuid);
143     }
144 
145     public void setStatsUserUuid(String statsUserUuid) {
146         _statsUserUuid = statsUserUuid;
147     }
148 
149     public long getGroupId() {
150         return _groupId;
151     }
152 
153     public void setGroupId(long groupId) {
154         _groupId = groupId;
155 
156         if (!_setOriginalGroupId) {
157             _setOriginalGroupId = true;
158 
159             _originalGroupId = groupId;
160         }
161     }
162 
163     public long getOriginalGroupId() {
164         return _originalGroupId;
165     }
166 
167     public long getUserId() {
168         return _userId;
169     }
170 
171     public void setUserId(long userId) {
172         _userId = userId;
173 
174         if (!_setOriginalUserId) {
175             _setOriginalUserId = true;
176 
177             _originalUserId = userId;
178         }
179     }
180 
181     public String getUserUuid() throws SystemException {
182         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
183     }
184 
185     public void setUserUuid(String userUuid) {
186         _userUuid = userUuid;
187     }
188 
189     public long getOriginalUserId() {
190         return _originalUserId;
191     }
192 
193     public int getMessageCount() {
194         return _messageCount;
195     }
196 
197     public void setMessageCount(int messageCount) {
198         _messageCount = messageCount;
199     }
200 
201     public Date getLastPostDate() {
202         return _lastPostDate;
203     }
204 
205     public void setLastPostDate(Date lastPostDate) {
206         _lastPostDate = lastPostDate;
207     }
208 
209     public MBStatsUser toEscapedModel() {
210         if (isEscapedModel()) {
211             return (MBStatsUser)this;
212         }
213         else {
214             MBStatsUser model = new MBStatsUserImpl();
215 
216             model.setNew(isNew());
217             model.setEscapedModel(true);
218 
219             model.setStatsUserId(getStatsUserId());
220             model.setGroupId(getGroupId());
221             model.setUserId(getUserId());
222             model.setMessageCount(getMessageCount());
223             model.setLastPostDate(getLastPostDate());
224 
225             model = (MBStatsUser)Proxy.newProxyInstance(MBStatsUser.class.getClassLoader(),
226                     new Class[] { MBStatsUser.class },
227                     new ReadOnlyBeanHandler(model));
228 
229             return model;
230         }
231     }
232 
233     public Object clone() {
234         MBStatsUserImpl clone = new MBStatsUserImpl();
235 
236         clone.setStatsUserId(getStatsUserId());
237         clone.setGroupId(getGroupId());
238         clone.setUserId(getUserId());
239         clone.setMessageCount(getMessageCount());
240         clone.setLastPostDate(getLastPostDate());
241 
242         return clone;
243     }
244 
245     public int compareTo(MBStatsUser mbStatsUser) {
246         int value = 0;
247 
248         if (getMessageCount() < mbStatsUser.getMessageCount()) {
249             value = -1;
250         }
251         else if (getMessageCount() > mbStatsUser.getMessageCount()) {
252             value = 1;
253         }
254         else {
255             value = 0;
256         }
257 
258         value = value * -1;
259 
260         if (value != 0) {
261             return value;
262         }
263 
264         return 0;
265     }
266 
267     public boolean equals(Object obj) {
268         if (obj == null) {
269             return false;
270         }
271 
272         MBStatsUser mbStatsUser = null;
273 
274         try {
275             mbStatsUser = (MBStatsUser)obj;
276         }
277         catch (ClassCastException cce) {
278             return false;
279         }
280 
281         long pk = mbStatsUser.getPrimaryKey();
282 
283         if (getPrimaryKey() == pk) {
284             return true;
285         }
286         else {
287             return false;
288         }
289     }
290 
291     public int hashCode() {
292         return (int)getPrimaryKey();
293     }
294 
295     public String toString() {
296         StringBuilder sb = new StringBuilder();
297 
298         sb.append("{statsUserId=");
299         sb.append(getStatsUserId());
300         sb.append(", groupId=");
301         sb.append(getGroupId());
302         sb.append(", userId=");
303         sb.append(getUserId());
304         sb.append(", messageCount=");
305         sb.append(getMessageCount());
306         sb.append(", lastPostDate=");
307         sb.append(getLastPostDate());
308         sb.append("}");
309 
310         return sb.toString();
311     }
312 
313     public String toXmlString() {
314         StringBuilder sb = new StringBuilder();
315 
316         sb.append("<model><model-name>");
317         sb.append("com.liferay.portlet.messageboards.model.MBStatsUser");
318         sb.append("</model-name>");
319 
320         sb.append(
321             "<column><column-name>statsUserId</column-name><column-value><![CDATA[");
322         sb.append(getStatsUserId());
323         sb.append("]]></column-value></column>");
324         sb.append(
325             "<column><column-name>groupId</column-name><column-value><![CDATA[");
326         sb.append(getGroupId());
327         sb.append("]]></column-value></column>");
328         sb.append(
329             "<column><column-name>userId</column-name><column-value><![CDATA[");
330         sb.append(getUserId());
331         sb.append("]]></column-value></column>");
332         sb.append(
333             "<column><column-name>messageCount</column-name><column-value><![CDATA[");
334         sb.append(getMessageCount());
335         sb.append("]]></column-value></column>");
336         sb.append(
337             "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
338         sb.append(getLastPostDate());
339         sb.append("]]></column-value></column>");
340 
341         sb.append("</model>");
342 
343         return sb.toString();
344     }
345 
346     private long _statsUserId;
347     private String _statsUserUuid;
348     private long _groupId;
349     private long _originalGroupId;
350     private boolean _setOriginalGroupId;
351     private long _userId;
352     private long _originalUserId;
353     private boolean _setOriginalUserId;
354     private String _userUuid;
355     private int _messageCount;
356     private Date _lastPostDate;
357 }