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