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.DateUtil;
025: import com.liferay.portal.kernel.util.GetterUtil;
026: import com.liferay.portal.model.impl.BaseModelImpl;
027: import com.liferay.portal.util.PropsUtil;
028:
029: import com.liferay.portlet.messageboards.model.MBThread;
030:
031: import java.io.Serializable;
032:
033: import java.lang.reflect.Proxy;
034:
035: import java.sql.Types;
036:
037: import java.util.Date;
038:
039: /**
040: * <a href="MBThreadModelImpl.java.html"><b><i>View Source</i></b></a>
041: *
042: * <p>
043: * ServiceBuilder generated this class. Modifications in this class will be
044: * overwritten the next time is generated.
045: * </p>
046: *
047: * <p>
048: * This class is a model that represents the <code>MBThread</code> table
049: * in the database.
050: * </p>
051: *
052: * @author Brian Wing Shun Chan
053: *
054: * @see com.liferay.portlet.messageboards.service.model.MBThread
055: * @see com.liferay.portlet.messageboards.service.model.MBThreadModel
056: * @see com.liferay.portlet.messageboards.service.model.impl.MBThreadImpl
057: *
058: */
059: public class MBThreadModelImpl extends BaseModelImpl {
060: public static final String TABLE_NAME = "MBThread";
061: public static final Object[][] TABLE_COLUMNS = {
062: { "threadId", new Integer(Types.BIGINT) },
063:
064: { "categoryId", new Integer(Types.BIGINT) },
065:
066: { "rootMessageId", new Integer(Types.BIGINT) },
067:
068: { "messageCount", new Integer(Types.INTEGER) },
069:
070: { "viewCount", new Integer(Types.INTEGER) },
071:
072: { "lastPostByUserId", new Integer(Types.BIGINT) },
073:
074: { "lastPostDate", new Integer(Types.TIMESTAMP) },
075:
076: { "priority", new Integer(Types.DOUBLE) } };
077: public static final String TABLE_SQL_CREATE = "create table MBThread (threadId LONG not null primary key,categoryId LONG,rootMessageId LONG,messageCount INTEGER,viewCount INTEGER,lastPostByUserId LONG,lastPostDate DATE null,priority DOUBLE)";
078: public static final String TABLE_SQL_DROP = "drop table MBThread";
079: public static final boolean CACHE_ENABLED = GetterUtil
080: .getBoolean(
081: PropsUtil
082: .get("value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
083: true);
084: public static final long LOCK_EXPIRATION_TIME = GetterUtil
085: .getLong(PropsUtil
086: .get("lock.expiration.time.com.liferay.portlet.messageboards.model.MBThread"));
087:
088: public MBThreadModelImpl() {
089: }
090:
091: public long getPrimaryKey() {
092: return _threadId;
093: }
094:
095: public void setPrimaryKey(long pk) {
096: setThreadId(pk);
097: }
098:
099: public Serializable getPrimaryKeyObj() {
100: return new Long(_threadId);
101: }
102:
103: public long getThreadId() {
104: return _threadId;
105: }
106:
107: public void setThreadId(long threadId) {
108: if (threadId != _threadId) {
109: _threadId = threadId;
110: }
111: }
112:
113: public long getCategoryId() {
114: return _categoryId;
115: }
116:
117: public void setCategoryId(long categoryId) {
118: if (categoryId != _categoryId) {
119: _categoryId = categoryId;
120: }
121: }
122:
123: public long getRootMessageId() {
124: return _rootMessageId;
125: }
126:
127: public void setRootMessageId(long rootMessageId) {
128: if (rootMessageId != _rootMessageId) {
129: _rootMessageId = rootMessageId;
130: }
131: }
132:
133: public int getMessageCount() {
134: return _messageCount;
135: }
136:
137: public void setMessageCount(int messageCount) {
138: if (messageCount != _messageCount) {
139: _messageCount = messageCount;
140: }
141: }
142:
143: public int getViewCount() {
144: return _viewCount;
145: }
146:
147: public void setViewCount(int viewCount) {
148: if (viewCount != _viewCount) {
149: _viewCount = viewCount;
150: }
151: }
152:
153: public long getLastPostByUserId() {
154: return _lastPostByUserId;
155: }
156:
157: public void setLastPostByUserId(long lastPostByUserId) {
158: if (lastPostByUserId != _lastPostByUserId) {
159: _lastPostByUserId = lastPostByUserId;
160: }
161: }
162:
163: public Date getLastPostDate() {
164: return _lastPostDate;
165: }
166:
167: public void setLastPostDate(Date lastPostDate) {
168: if (((lastPostDate == null) && (_lastPostDate != null))
169: || ((lastPostDate != null) && (_lastPostDate == null))
170: || ((lastPostDate != null) && (_lastPostDate != null) && !lastPostDate
171: .equals(_lastPostDate))) {
172: _lastPostDate = lastPostDate;
173: }
174: }
175:
176: public double getPriority() {
177: return _priority;
178: }
179:
180: public void setPriority(double priority) {
181: if (priority != _priority) {
182: _priority = priority;
183: }
184: }
185:
186: public MBThread toEscapedModel() {
187: if (isEscapedModel()) {
188: return (MBThread) this ;
189: } else {
190: MBThread model = new MBThreadImpl();
191:
192: model.setEscapedModel(true);
193:
194: model.setThreadId(getThreadId());
195: model.setCategoryId(getCategoryId());
196: model.setRootMessageId(getRootMessageId());
197: model.setMessageCount(getMessageCount());
198: model.setViewCount(getViewCount());
199: model.setLastPostByUserId(getLastPostByUserId());
200: model.setLastPostDate(getLastPostDate());
201: model.setPriority(getPriority());
202:
203: model = (MBThread) Proxy.newProxyInstance(MBThread.class
204: .getClassLoader(), new Class[] { MBThread.class },
205: new ReadOnlyBeanHandler(model));
206:
207: return model;
208: }
209: }
210:
211: public Object clone() {
212: MBThreadImpl clone = new MBThreadImpl();
213:
214: clone.setThreadId(getThreadId());
215: clone.setCategoryId(getCategoryId());
216: clone.setRootMessageId(getRootMessageId());
217: clone.setMessageCount(getMessageCount());
218: clone.setViewCount(getViewCount());
219: clone.setLastPostByUserId(getLastPostByUserId());
220: clone.setLastPostDate(getLastPostDate());
221: clone.setPriority(getPriority());
222:
223: return clone;
224: }
225:
226: public int compareTo(Object obj) {
227: if (obj == null) {
228: return -1;
229: }
230:
231: MBThreadImpl mbThread = (MBThreadImpl) obj;
232:
233: int value = 0;
234:
235: if (getPriority() < mbThread.getPriority()) {
236: value = -1;
237: } else if (getPriority() > mbThread.getPriority()) {
238: value = 1;
239: } else {
240: value = 0;
241: }
242:
243: value = value * -1;
244:
245: if (value != 0) {
246: return value;
247: }
248:
249: value = DateUtil.compareTo(getLastPostDate(), mbThread
250: .getLastPostDate());
251:
252: value = value * -1;
253:
254: if (value != 0) {
255: return value;
256: }
257:
258: return 0;
259: }
260:
261: public boolean equals(Object obj) {
262: if (obj == null) {
263: return false;
264: }
265:
266: MBThreadImpl mbThread = null;
267:
268: try {
269: mbThread = (MBThreadImpl) obj;
270: } catch (ClassCastException cce) {
271: return false;
272: }
273:
274: long pk = mbThread.getPrimaryKey();
275:
276: if (getPrimaryKey() == pk) {
277: return true;
278: } else {
279: return false;
280: }
281: }
282:
283: public int hashCode() {
284: return (int) getPrimaryKey();
285: }
286:
287: private long _threadId;
288: private long _categoryId;
289: private long _rootMessageId;
290: private int _messageCount;
291: private int _viewCount;
292: private long _lastPostByUserId;
293: private Date _lastPostDate;
294: private double _priority;
295: }
|