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 {
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 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         if (statsUserId != _statsUserId) {
136             _statsUserId = statsUserId;
137         }
138     }
139 
140     public long getGroupId() {
141         return _groupId;
142     }
143 
144     public void setGroupId(long groupId) {
145         if (groupId != _groupId) {
146             _groupId = groupId;
147         }
148     }
149 
150     public long getUserId() {
151         return _userId;
152     }
153 
154     public void setUserId(long userId) {
155         if (userId != _userId) {
156             _userId = userId;
157         }
158     }
159 
160     public int getMessageCount() {
161         return _messageCount;
162     }
163 
164     public void setMessageCount(int messageCount) {
165         if (messageCount != _messageCount) {
166             _messageCount = messageCount;
167         }
168     }
169 
170     public Date getLastPostDate() {
171         return _lastPostDate;
172     }
173 
174     public void setLastPostDate(Date lastPostDate) {
175         if (((lastPostDate == null) && (_lastPostDate != null)) ||
176                 ((lastPostDate != null) && (_lastPostDate == null)) ||
177                 ((lastPostDate != null) && (_lastPostDate != null) &&
178                 !lastPostDate.equals(_lastPostDate))) {
179             _lastPostDate = lastPostDate;
180         }
181     }
182 
183     public MBStatsUser toEscapedModel() {
184         if (isEscapedModel()) {
185             return (MBStatsUser)this;
186         }
187         else {
188             MBStatsUser model = new MBStatsUserImpl();
189 
190             model.setNew(isNew());
191             model.setEscapedModel(true);
192 
193             model.setStatsUserId(getStatsUserId());
194             model.setGroupId(getGroupId());
195             model.setUserId(getUserId());
196             model.setMessageCount(getMessageCount());
197             model.setLastPostDate(getLastPostDate());
198 
199             model = (MBStatsUser)Proxy.newProxyInstance(MBStatsUser.class.getClassLoader(),
200                     new Class[] { MBStatsUser.class },
201                     new ReadOnlyBeanHandler(model));
202 
203             return model;
204         }
205     }
206 
207     public ExpandoBridge getExpandoBridge() {
208         if (_expandoBridge == null) {
209             _expandoBridge = new ExpandoBridgeImpl(MBStatsUser.class.getName(),
210                     getPrimaryKey());
211         }
212 
213         return _expandoBridge;
214     }
215 
216     public Object clone() {
217         MBStatsUserImpl clone = new MBStatsUserImpl();
218 
219         clone.setStatsUserId(getStatsUserId());
220         clone.setGroupId(getGroupId());
221         clone.setUserId(getUserId());
222         clone.setMessageCount(getMessageCount());
223         clone.setLastPostDate(getLastPostDate());
224 
225         return clone;
226     }
227 
228     public int compareTo(Object obj) {
229         if (obj == null) {
230             return -1;
231         }
232 
233         MBStatsUserImpl mbStatsUser = (MBStatsUserImpl)obj;
234 
235         int value = 0;
236 
237         if (getMessageCount() < mbStatsUser.getMessageCount()) {
238             value = -1;
239         }
240         else if (getMessageCount() > mbStatsUser.getMessageCount()) {
241             value = 1;
242         }
243         else {
244             value = 0;
245         }
246 
247         value = value * -1;
248 
249         if (value != 0) {
250             return value;
251         }
252 
253         return 0;
254     }
255 
256     public boolean equals(Object obj) {
257         if (obj == null) {
258             return false;
259         }
260 
261         MBStatsUserImpl mbStatsUser = null;
262 
263         try {
264             mbStatsUser = (MBStatsUserImpl)obj;
265         }
266         catch (ClassCastException cce) {
267             return false;
268         }
269 
270         long pk = mbStatsUser.getPrimaryKey();
271 
272         if (getPrimaryKey() == pk) {
273             return true;
274         }
275         else {
276             return false;
277         }
278     }
279 
280     public int hashCode() {
281         return (int)getPrimaryKey();
282     }
283 
284     private long _statsUserId;
285     private long _groupId;
286     private long _userId;
287     private int _messageCount;
288     private Date _lastPostDate;
289     private transient ExpandoBridge _expandoBridge;
290 }