1
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.DateUtil;
27 import com.liferay.portal.kernel.util.GetterUtil;
28 import com.liferay.portal.model.impl.BaseModelImpl;
29 import com.liferay.portal.util.PropsUtil;
30
31 import com.liferay.portlet.messageboards.model.MBThread;
32
33 import java.io.Serializable;
34
35 import java.lang.reflect.Proxy;
36
37 import java.sql.Types;
38
39 import java.util.Date;
40
41
61 public class MBThreadModelImpl extends BaseModelImpl {
62 public static final String TABLE_NAME = "MBThread";
63 public static final Object[][] TABLE_COLUMNS = {
64 { "threadId", new Integer(Types.BIGINT) },
65
66
67 { "categoryId", new Integer(Types.BIGINT) },
68
69
70 { "rootMessageId", new Integer(Types.BIGINT) },
71
72
73 { "messageCount", new Integer(Types.INTEGER) },
74
75
76 { "viewCount", new Integer(Types.INTEGER) },
77
78
79 { "lastPostByUserId", new Integer(Types.BIGINT) },
80
81
82 { "lastPostDate", new Integer(Types.TIMESTAMP) },
83
84
85 { "priority", new Integer(Types.DOUBLE) }
86 };
87 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)";
88 public static final String TABLE_SQL_DROP = "drop table MBThread";
89 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
90 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
91 true);
92 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
93 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBThread"));
94
95 public MBThreadModelImpl() {
96 }
97
98 public long getPrimaryKey() {
99 return _threadId;
100 }
101
102 public void setPrimaryKey(long pk) {
103 setThreadId(pk);
104 }
105
106 public Serializable getPrimaryKeyObj() {
107 return new Long(_threadId);
108 }
109
110 public long getThreadId() {
111 return _threadId;
112 }
113
114 public void setThreadId(long threadId) {
115 if (threadId != _threadId) {
116 _threadId = threadId;
117 }
118 }
119
120 public long getCategoryId() {
121 return _categoryId;
122 }
123
124 public void setCategoryId(long categoryId) {
125 if (categoryId != _categoryId) {
126 _categoryId = categoryId;
127 }
128 }
129
130 public long getRootMessageId() {
131 return _rootMessageId;
132 }
133
134 public void setRootMessageId(long rootMessageId) {
135 if (rootMessageId != _rootMessageId) {
136 _rootMessageId = rootMessageId;
137 }
138 }
139
140 public int getMessageCount() {
141 return _messageCount;
142 }
143
144 public void setMessageCount(int messageCount) {
145 if (messageCount != _messageCount) {
146 _messageCount = messageCount;
147 }
148 }
149
150 public int getViewCount() {
151 return _viewCount;
152 }
153
154 public void setViewCount(int viewCount) {
155 if (viewCount != _viewCount) {
156 _viewCount = viewCount;
157 }
158 }
159
160 public long getLastPostByUserId() {
161 return _lastPostByUserId;
162 }
163
164 public void setLastPostByUserId(long lastPostByUserId) {
165 if (lastPostByUserId != _lastPostByUserId) {
166 _lastPostByUserId = lastPostByUserId;
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 double getPriority() {
184 return _priority;
185 }
186
187 public void setPriority(double priority) {
188 if (priority != _priority) {
189 _priority = priority;
190 }
191 }
192
193 public MBThread toEscapedModel() {
194 if (isEscapedModel()) {
195 return (MBThread)this;
196 }
197 else {
198 MBThread model = new MBThreadImpl();
199
200 model.setEscapedModel(true);
201
202 model.setThreadId(getThreadId());
203 model.setCategoryId(getCategoryId());
204 model.setRootMessageId(getRootMessageId());
205 model.setMessageCount(getMessageCount());
206 model.setViewCount(getViewCount());
207 model.setLastPostByUserId(getLastPostByUserId());
208 model.setLastPostDate(getLastPostDate());
209 model.setPriority(getPriority());
210
211 model = (MBThread)Proxy.newProxyInstance(MBThread.class.getClassLoader(),
212 new Class[] { MBThread.class },
213 new ReadOnlyBeanHandler(model));
214
215 return model;
216 }
217 }
218
219 public Object clone() {
220 MBThreadImpl clone = new MBThreadImpl();
221
222 clone.setThreadId(getThreadId());
223 clone.setCategoryId(getCategoryId());
224 clone.setRootMessageId(getRootMessageId());
225 clone.setMessageCount(getMessageCount());
226 clone.setViewCount(getViewCount());
227 clone.setLastPostByUserId(getLastPostByUserId());
228 clone.setLastPostDate(getLastPostDate());
229 clone.setPriority(getPriority());
230
231 return clone;
232 }
233
234 public int compareTo(Object obj) {
235 if (obj == null) {
236 return -1;
237 }
238
239 MBThreadImpl mbThread = (MBThreadImpl)obj;
240
241 int value = 0;
242
243 if (getPriority() < mbThread.getPriority()) {
244 value = -1;
245 }
246 else if (getPriority() > mbThread.getPriority()) {
247 value = 1;
248 }
249 else {
250 value = 0;
251 }
252
253 value = value * -1;
254
255 if (value != 0) {
256 return value;
257 }
258
259 value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
260
261 value = value * -1;
262
263 if (value != 0) {
264 return value;
265 }
266
267 return 0;
268 }
269
270 public boolean equals(Object obj) {
271 if (obj == null) {
272 return false;
273 }
274
275 MBThreadImpl mbThread = null;
276
277 try {
278 mbThread = (MBThreadImpl)obj;
279 }
280 catch (ClassCastException cce) {
281 return false;
282 }
283
284 long pk = mbThread.getPrimaryKey();
285
286 if (getPrimaryKey() == pk) {
287 return true;
288 }
289 else {
290 return false;
291 }
292 }
293
294 public int hashCode() {
295 return (int)getPrimaryKey();
296 }
297
298 private long _threadId;
299 private long _categoryId;
300 private long _rootMessageId;
301 private int _messageCount;
302 private int _viewCount;
303 private long _lastPostByUserId;
304 private Date _lastPostDate;
305 private double _priority;
306 }