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