1   /**
2    * Copyright (c) 2000-2007 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import java.io.Serializable;
30  
31  import java.sql.Types;
32  
33  import java.util.Date;
34  
35  /**
36   * <a href="MBStatsUserModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>MBStatsUser</code> table in the
45   * database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portlet.messageboards.service.model.MBStatsUser
51   * @see com.liferay.portlet.messageboards.service.model.MBStatsUserModel
52   * @see com.liferay.portlet.messageboards.service.model.impl.MBStatsUserImpl
53   *
54   */
55  public class MBStatsUserModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "MBStatsUser";
57      public static Object[][] TABLE_COLUMNS = {
58              { "statsUserId", new Integer(Types.BIGINT) },
59              { "groupId", new Integer(Types.BIGINT) },
60              { "userId", new Integer(Types.BIGINT) },
61              { "messageCount", new Integer(Types.INTEGER) },
62              { "lastPostDate", new Integer(Types.TIMESTAMP) }
63          };
64      public static String TABLE_SQL_CREATE = "create table MBStatsUser (statsUserId LONG not null primary key,groupId LONG,userId LONG,messageCount INTEGER,lastPostDate DATE null)";
65      public static String TABLE_SQL_DROP = "drop table MBStatsUser";
66      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
67                  "xss.allow.com.liferay.portlet.messageboards.model.MBStatsUser"),
68              XSS_ALLOW);
69      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
70                  "lock.expiration.time.com.liferay.portlet.messageboards.model.MBStatsUserModel"));
71  
72      public MBStatsUserModelImpl() {
73      }
74  
75      public long getPrimaryKey() {
76          return _statsUserId;
77      }
78  
79      public void setPrimaryKey(long pk) {
80          setStatsUserId(pk);
81      }
82  
83      public Serializable getPrimaryKeyObj() {
84          return new Long(_statsUserId);
85      }
86  
87      public long getStatsUserId() {
88          return _statsUserId;
89      }
90  
91      public void setStatsUserId(long statsUserId) {
92          if (statsUserId != _statsUserId) {
93              _statsUserId = statsUserId;
94          }
95      }
96  
97      public long getGroupId() {
98          return _groupId;
99      }
100 
101     public void setGroupId(long groupId) {
102         if (groupId != _groupId) {
103             _groupId = groupId;
104         }
105     }
106 
107     public long getUserId() {
108         return _userId;
109     }
110 
111     public void setUserId(long userId) {
112         if (userId != _userId) {
113             _userId = userId;
114         }
115     }
116 
117     public int getMessageCount() {
118         return _messageCount;
119     }
120 
121     public void setMessageCount(int messageCount) {
122         if (messageCount != _messageCount) {
123             _messageCount = messageCount;
124         }
125     }
126 
127     public Date getLastPostDate() {
128         return _lastPostDate;
129     }
130 
131     public void setLastPostDate(Date lastPostDate) {
132         if (((lastPostDate == null) && (_lastPostDate != null)) ||
133                 ((lastPostDate != null) && (_lastPostDate == null)) ||
134                 ((lastPostDate != null) && (_lastPostDate != null) &&
135                 !lastPostDate.equals(_lastPostDate))) {
136             _lastPostDate = lastPostDate;
137         }
138     }
139 
140     public Object clone() {
141         MBStatsUserImpl clone = new MBStatsUserImpl();
142         clone.setStatsUserId(getStatsUserId());
143         clone.setGroupId(getGroupId());
144         clone.setUserId(getUserId());
145         clone.setMessageCount(getMessageCount());
146         clone.setLastPostDate(getLastPostDate());
147 
148         return clone;
149     }
150 
151     public int compareTo(Object obj) {
152         if (obj == null) {
153             return -1;
154         }
155 
156         MBStatsUserImpl mbStatsUser = (MBStatsUserImpl)obj;
157         int value = 0;
158 
159         if (getMessageCount() < mbStatsUser.getMessageCount()) {
160             value = -1;
161         }
162         else if (getMessageCount() > mbStatsUser.getMessageCount()) {
163             value = 1;
164         }
165         else {
166             value = 0;
167         }
168 
169         value = value * -1;
170 
171         if (value != 0) {
172             return value;
173         }
174 
175         return 0;
176     }
177 
178     public boolean equals(Object obj) {
179         if (obj == null) {
180             return false;
181         }
182 
183         MBStatsUserImpl mbStatsUser = null;
184 
185         try {
186             mbStatsUser = (MBStatsUserImpl)obj;
187         }
188         catch (ClassCastException cce) {
189             return false;
190         }
191 
192         long pk = mbStatsUser.getPrimaryKey();
193 
194         if (getPrimaryKey() == pk) {
195             return true;
196         }
197         else {
198             return false;
199         }
200     }
201 
202     public int hashCode() {
203         return (int)getPrimaryKey();
204     }
205 
206     private long _statsUserId;
207     private long _groupId;
208     private long _userId;
209     private int _messageCount;
210     private Date _lastPostDate;
211 }