001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.messageboards.model.impl;
022:
023: import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
024: import com.liferay.portal.kernel.util.GetterUtil;
025: import com.liferay.portal.model.impl.BaseModelImpl;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.portlet.messageboards.model.MBStatsUser;
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: /**
039: * <a href="MBStatsUserModelImpl.java.html"><b><i>View Source</i></b></a>
040: *
041: * <p>
042: * ServiceBuilder generated this class. Modifications in this class will be
043: * overwritten the next time is generated.
044: * </p>
045: *
046: * <p>
047: * This class is a model that represents the <code>MBStatsUser</code> table
048: * in the database.
049: * </p>
050: *
051: * @author Brian Wing Shun Chan
052: *
053: * @see com.liferay.portlet.messageboards.service.model.MBStatsUser
054: * @see com.liferay.portlet.messageboards.service.model.MBStatsUserModel
055: * @see com.liferay.portlet.messageboards.service.model.impl.MBStatsUserImpl
056: *
057: */
058: public class MBStatsUserModelImpl extends BaseModelImpl {
059: public static final String TABLE_NAME = "MBStatsUser";
060: public static final Object[][] TABLE_COLUMNS = {
061: { "statsUserId", new Integer(Types.BIGINT) },
062:
063: { "groupId", new Integer(Types.BIGINT) },
064:
065: { "userId", new Integer(Types.BIGINT) },
066:
067: { "messageCount", new Integer(Types.INTEGER) },
068:
069: { "lastPostDate", new Integer(Types.TIMESTAMP) } };
070: 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)";
071: public static final String TABLE_SQL_DROP = "drop table MBStatsUser";
072: public static final boolean CACHE_ENABLED = GetterUtil
073: .getBoolean(
074: PropsUtil
075: .get("value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBStatsUser"),
076: true);
077: public static final long LOCK_EXPIRATION_TIME = GetterUtil
078: .getLong(PropsUtil
079: .get("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: if (statsUserId != _statsUserId) {
102: _statsUserId = statsUserId;
103: }
104: }
105:
106: public long getGroupId() {
107: return _groupId;
108: }
109:
110: public void setGroupId(long groupId) {
111: if (groupId != _groupId) {
112: _groupId = groupId;
113: }
114: }
115:
116: public long getUserId() {
117: return _userId;
118: }
119:
120: public void setUserId(long userId) {
121: if (userId != _userId) {
122: _userId = userId;
123: }
124: }
125:
126: public int getMessageCount() {
127: return _messageCount;
128: }
129:
130: public void setMessageCount(int messageCount) {
131: if (messageCount != _messageCount) {
132: _messageCount = messageCount;
133: }
134: }
135:
136: public Date getLastPostDate() {
137: return _lastPostDate;
138: }
139:
140: public void setLastPostDate(Date lastPostDate) {
141: if (((lastPostDate == null) && (_lastPostDate != null))
142: || ((lastPostDate != null) && (_lastPostDate == null))
143: || ((lastPostDate != null) && (_lastPostDate != null) && !lastPostDate
144: .equals(_lastPostDate))) {
145: _lastPostDate = lastPostDate;
146: }
147: }
148:
149: public MBStatsUser toEscapedModel() {
150: if (isEscapedModel()) {
151: return (MBStatsUser) this ;
152: } else {
153: MBStatsUser model = new MBStatsUserImpl();
154:
155: model.setEscapedModel(true);
156:
157: model.setStatsUserId(getStatsUserId());
158: model.setGroupId(getGroupId());
159: model.setUserId(getUserId());
160: model.setMessageCount(getMessageCount());
161: model.setLastPostDate(getLastPostDate());
162:
163: model = (MBStatsUser) Proxy.newProxyInstance(
164: MBStatsUser.class.getClassLoader(),
165: new Class[] { MBStatsUser.class },
166: new ReadOnlyBeanHandler(model));
167:
168: return model;
169: }
170: }
171:
172: public Object clone() {
173: MBStatsUserImpl clone = new MBStatsUserImpl();
174:
175: clone.setStatsUserId(getStatsUserId());
176: clone.setGroupId(getGroupId());
177: clone.setUserId(getUserId());
178: clone.setMessageCount(getMessageCount());
179: clone.setLastPostDate(getLastPostDate());
180:
181: return clone;
182: }
183:
184: public int compareTo(Object obj) {
185: if (obj == null) {
186: return -1;
187: }
188:
189: MBStatsUserImpl mbStatsUser = (MBStatsUserImpl) obj;
190:
191: int value = 0;
192:
193: if (getMessageCount() < mbStatsUser.getMessageCount()) {
194: value = -1;
195: } else if (getMessageCount() > mbStatsUser.getMessageCount()) {
196: value = 1;
197: } else {
198: value = 0;
199: }
200:
201: value = value * -1;
202:
203: if (value != 0) {
204: return value;
205: }
206:
207: return 0;
208: }
209:
210: public boolean equals(Object obj) {
211: if (obj == null) {
212: return false;
213: }
214:
215: MBStatsUserImpl mbStatsUser = null;
216:
217: try {
218: mbStatsUser = (MBStatsUserImpl) obj;
219: } catch (ClassCastException cce) {
220: return false;
221: }
222:
223: long pk = mbStatsUser.getPrimaryKey();
224:
225: if (getPrimaryKey() == pk) {
226: return true;
227: } else {
228: return false;
229: }
230: }
231:
232: public int hashCode() {
233: return (int) getPrimaryKey();
234: }
235:
236: private long _statsUserId;
237: private long _groupId;
238: private long _userId;
239: private int _messageCount;
240: private Date _lastPostDate;
241: }
|