001
014
015 package com.liferay.portlet.messageboards.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.model.impl.BaseModelImpl;
022 import com.liferay.portal.service.ServiceContext;
023 import com.liferay.portal.util.PortalUtil;
024
025 import com.liferay.portlet.expando.model.ExpandoBridge;
026 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027 import com.liferay.portlet.messageboards.model.MBStatsUser;
028 import com.liferay.portlet.messageboards.model.MBStatsUserModel;
029
030 import java.io.Serializable;
031
032 import java.lang.reflect.Proxy;
033
034 import java.sql.Types;
035
036 import java.util.Date;
037
038
055 public class MBStatsUserModelImpl extends BaseModelImpl<MBStatsUser>
056 implements MBStatsUserModel {
057 public static final String TABLE_NAME = "MBStatsUser";
058 public static final Object[][] TABLE_COLUMNS = {
059 { "statsUserId", new Integer(Types.BIGINT) },
060 { "groupId", new Integer(Types.BIGINT) },
061 { "userId", new Integer(Types.BIGINT) },
062 { "messageCount", new Integer(Types.INTEGER) },
063 { "lastPostDate", new Integer(Types.TIMESTAMP) }
064 };
065 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)";
066 public static final String TABLE_SQL_DROP = "drop table MBStatsUser";
067 public static final String ORDER_BY_JPQL = " ORDER BY mbStatsUser.messageCount DESC";
068 public static final String ORDER_BY_SQL = " ORDER BY MBStatsUser.messageCount DESC";
069 public static final String DATA_SOURCE = "liferayDataSource";
070 public static final String SESSION_FACTORY = "liferaySessionFactory";
071 public static final String TX_MANAGER = "liferayTransactionManager";
072 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073 "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBStatsUser"),
074 true);
075 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBStatsUser"),
077 true);
078 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
079 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBStatsUser"));
080
081 public MBStatsUserModelImpl() {
082 }
083
084 public long getPrimaryKey() {
085 return _statsUserId;
086 }
087
088 public void setPrimaryKey(long pk) {
089 setStatsUserId(pk);
090 }
091
092 public Serializable getPrimaryKeyObj() {
093 return new Long(_statsUserId);
094 }
095
096 public long getStatsUserId() {
097 return _statsUserId;
098 }
099
100 public void setStatsUserId(long statsUserId) {
101 _statsUserId = statsUserId;
102 }
103
104 public String getStatsUserUuid() throws SystemException {
105 return PortalUtil.getUserValue(getStatsUserId(), "uuid", _statsUserUuid);
106 }
107
108 public void setStatsUserUuid(String statsUserUuid) {
109 _statsUserUuid = statsUserUuid;
110 }
111
112 public long getGroupId() {
113 return _groupId;
114 }
115
116 public void setGroupId(long groupId) {
117 _groupId = groupId;
118
119 if (!_setOriginalGroupId) {
120 _setOriginalGroupId = true;
121
122 _originalGroupId = groupId;
123 }
124 }
125
126 public long getOriginalGroupId() {
127 return _originalGroupId;
128 }
129
130 public long getUserId() {
131 return _userId;
132 }
133
134 public void setUserId(long userId) {
135 _userId = userId;
136
137 if (!_setOriginalUserId) {
138 _setOriginalUserId = true;
139
140 _originalUserId = userId;
141 }
142 }
143
144 public String getUserUuid() throws SystemException {
145 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
146 }
147
148 public void setUserUuid(String userUuid) {
149 _userUuid = userUuid;
150 }
151
152 public long getOriginalUserId() {
153 return _originalUserId;
154 }
155
156 public int getMessageCount() {
157 return _messageCount;
158 }
159
160 public void setMessageCount(int messageCount) {
161 _messageCount = messageCount;
162 }
163
164 public Date getLastPostDate() {
165 return _lastPostDate;
166 }
167
168 public void setLastPostDate(Date lastPostDate) {
169 _lastPostDate = lastPostDate;
170 }
171
172 public MBStatsUser toEscapedModel() {
173 if (isEscapedModel()) {
174 return (MBStatsUser)this;
175 }
176 else {
177 return (MBStatsUser)Proxy.newProxyInstance(MBStatsUser.class.getClassLoader(),
178 new Class[] { MBStatsUser.class },
179 new AutoEscapeBeanHandler(this));
180 }
181 }
182
183 public ExpandoBridge getExpandoBridge() {
184 if (_expandoBridge == null) {
185 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
186 MBStatsUser.class.getName(), getPrimaryKey());
187 }
188
189 return _expandoBridge;
190 }
191
192 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
193 getExpandoBridge().setAttributes(serviceContext);
194 }
195
196 public Object clone() {
197 MBStatsUserImpl clone = new MBStatsUserImpl();
198
199 clone.setStatsUserId(getStatsUserId());
200 clone.setGroupId(getGroupId());
201 clone.setUserId(getUserId());
202 clone.setMessageCount(getMessageCount());
203 clone.setLastPostDate(getLastPostDate());
204
205 return clone;
206 }
207
208 public int compareTo(MBStatsUser mbStatsUser) {
209 int value = 0;
210
211 if (getMessageCount() < mbStatsUser.getMessageCount()) {
212 value = -1;
213 }
214 else if (getMessageCount() > mbStatsUser.getMessageCount()) {
215 value = 1;
216 }
217 else {
218 value = 0;
219 }
220
221 value = value * -1;
222
223 if (value != 0) {
224 return value;
225 }
226
227 return 0;
228 }
229
230 public boolean equals(Object obj) {
231 if (obj == null) {
232 return false;
233 }
234
235 MBStatsUser mbStatsUser = null;
236
237 try {
238 mbStatsUser = (MBStatsUser)obj;
239 }
240 catch (ClassCastException cce) {
241 return false;
242 }
243
244 long pk = mbStatsUser.getPrimaryKey();
245
246 if (getPrimaryKey() == pk) {
247 return true;
248 }
249 else {
250 return false;
251 }
252 }
253
254 public int hashCode() {
255 return (int)getPrimaryKey();
256 }
257
258 public String toString() {
259 StringBundler sb = new StringBundler(11);
260
261 sb.append("{statsUserId=");
262 sb.append(getStatsUserId());
263 sb.append(", groupId=");
264 sb.append(getGroupId());
265 sb.append(", userId=");
266 sb.append(getUserId());
267 sb.append(", messageCount=");
268 sb.append(getMessageCount());
269 sb.append(", lastPostDate=");
270 sb.append(getLastPostDate());
271 sb.append("}");
272
273 return sb.toString();
274 }
275
276 public String toXmlString() {
277 StringBundler sb = new StringBundler(19);
278
279 sb.append("<model><model-name>");
280 sb.append("com.liferay.portlet.messageboards.model.MBStatsUser");
281 sb.append("</model-name>");
282
283 sb.append(
284 "<column><column-name>statsUserId</column-name><column-value><![CDATA[");
285 sb.append(getStatsUserId());
286 sb.append("]]></column-value></column>");
287 sb.append(
288 "<column><column-name>groupId</column-name><column-value><![CDATA[");
289 sb.append(getGroupId());
290 sb.append("]]></column-value></column>");
291 sb.append(
292 "<column><column-name>userId</column-name><column-value><![CDATA[");
293 sb.append(getUserId());
294 sb.append("]]></column-value></column>");
295 sb.append(
296 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
297 sb.append(getMessageCount());
298 sb.append("]]></column-value></column>");
299 sb.append(
300 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
301 sb.append(getLastPostDate());
302 sb.append("]]></column-value></column>");
303
304 sb.append("</model>");
305
306 return sb.toString();
307 }
308
309 private long _statsUserId;
310 private String _statsUserUuid;
311 private long _groupId;
312 private long _originalGroupId;
313 private boolean _setOriginalGroupId;
314 private long _userId;
315 private String _userUuid;
316 private long _originalUserId;
317 private boolean _setOriginalUserId;
318 private int _messageCount;
319 private Date _lastPostDate;
320 private transient ExpandoBridge _expandoBridge;
321 }