1
22
23 package com.liferay.portlet.messageboards.model.impl;
24
25 import com.liferay.portal.SystemException;
26 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27 import com.liferay.portal.kernel.util.DateUtil;
28 import com.liferay.portal.kernel.util.GetterUtil;
29 import com.liferay.portal.model.impl.BaseModelImpl;
30 import com.liferay.portal.util.PortalUtil;
31
32 import com.liferay.portlet.messageboards.model.MBThread;
33 import com.liferay.portlet.messageboards.model.MBThreadSoap;
34
35 import java.io.Serializable;
36
37 import java.lang.reflect.Proxy;
38
39 import java.sql.Types;
40
41 import java.util.ArrayList;
42 import java.util.Date;
43 import java.util.List;
44
45
65 public class MBThreadModelImpl extends BaseModelImpl<MBThread> {
66 public static final String TABLE_NAME = "MBThread";
67 public static final Object[][] TABLE_COLUMNS = {
68 { "threadId", new Integer(Types.BIGINT) },
69
70
71 { "groupId", new Integer(Types.BIGINT) },
72
73
74 { "categoryId", new Integer(Types.BIGINT) },
75
76
77 { "rootMessageId", new Integer(Types.BIGINT) },
78
79
80 { "messageCount", new Integer(Types.INTEGER) },
81
82
83 { "viewCount", new Integer(Types.INTEGER) },
84
85
86 { "lastPostByUserId", new Integer(Types.BIGINT) },
87
88
89 { "lastPostDate", new Integer(Types.TIMESTAMP) },
90
91
92 { "priority", new Integer(Types.DOUBLE) }
93 };
94 public static final String TABLE_SQL_CREATE = "create table MBThread (threadId LONG not null primary key,groupId LONG,categoryId LONG,rootMessageId LONG,messageCount INTEGER,viewCount INTEGER,lastPostByUserId LONG,lastPostDate DATE null,priority DOUBLE)";
95 public static final String TABLE_SQL_DROP = "drop table MBThread";
96 public static final String DATA_SOURCE = "liferayDataSource";
97 public static final String SESSION_FACTORY = "liferaySessionFactory";
98 public static final String TX_MANAGER = "liferayTransactionManager";
99 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
100 "value.object.entity.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
101 true);
102 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
103 "value.object.finder.cache.enabled.com.liferay.portlet.messageboards.model.MBThread"),
104 true);
105
106 public static MBThread toModel(MBThreadSoap soapModel) {
107 MBThread model = new MBThreadImpl();
108
109 model.setThreadId(soapModel.getThreadId());
110 model.setGroupId(soapModel.getGroupId());
111 model.setCategoryId(soapModel.getCategoryId());
112 model.setRootMessageId(soapModel.getRootMessageId());
113 model.setMessageCount(soapModel.getMessageCount());
114 model.setViewCount(soapModel.getViewCount());
115 model.setLastPostByUserId(soapModel.getLastPostByUserId());
116 model.setLastPostDate(soapModel.getLastPostDate());
117 model.setPriority(soapModel.getPriority());
118
119 return model;
120 }
121
122 public static List<MBThread> toModels(MBThreadSoap[] soapModels) {
123 List<MBThread> models = new ArrayList<MBThread>(soapModels.length);
124
125 for (MBThreadSoap soapModel : soapModels) {
126 models.add(toModel(soapModel));
127 }
128
129 return models;
130 }
131
132 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
133 "lock.expiration.time.com.liferay.portlet.messageboards.model.MBThread"));
134
135 public MBThreadModelImpl() {
136 }
137
138 public long getPrimaryKey() {
139 return _threadId;
140 }
141
142 public void setPrimaryKey(long pk) {
143 setThreadId(pk);
144 }
145
146 public Serializable getPrimaryKeyObj() {
147 return new Long(_threadId);
148 }
149
150 public long getThreadId() {
151 return _threadId;
152 }
153
154 public void setThreadId(long threadId) {
155 _threadId = threadId;
156 }
157
158 public long getGroupId() {
159 return _groupId;
160 }
161
162 public void setGroupId(long groupId) {
163 _groupId = groupId;
164 }
165
166 public long getCategoryId() {
167 return _categoryId;
168 }
169
170 public void setCategoryId(long categoryId) {
171 _categoryId = categoryId;
172 }
173
174 public long getRootMessageId() {
175 return _rootMessageId;
176 }
177
178 public void setRootMessageId(long rootMessageId) {
179 _rootMessageId = rootMessageId;
180 }
181
182 public int getMessageCount() {
183 return _messageCount;
184 }
185
186 public void setMessageCount(int messageCount) {
187 _messageCount = messageCount;
188 }
189
190 public int getViewCount() {
191 return _viewCount;
192 }
193
194 public void setViewCount(int viewCount) {
195 _viewCount = viewCount;
196 }
197
198 public long getLastPostByUserId() {
199 return _lastPostByUserId;
200 }
201
202 public void setLastPostByUserId(long lastPostByUserId) {
203 _lastPostByUserId = lastPostByUserId;
204 }
205
206 public String getLastPostByUserUuid() throws SystemException {
207 return PortalUtil.getUserValue(getLastPostByUserId(), "uuid",
208 _lastPostByUserUuid);
209 }
210
211 public void setLastPostByUserUuid(String lastPostByUserUuid) {
212 _lastPostByUserUuid = lastPostByUserUuid;
213 }
214
215 public Date getLastPostDate() {
216 return _lastPostDate;
217 }
218
219 public void setLastPostDate(Date lastPostDate) {
220 _lastPostDate = lastPostDate;
221 }
222
223 public double getPriority() {
224 return _priority;
225 }
226
227 public void setPriority(double priority) {
228 _priority = priority;
229 }
230
231 public MBThread toEscapedModel() {
232 if (isEscapedModel()) {
233 return (MBThread)this;
234 }
235 else {
236 MBThread model = new MBThreadImpl();
237
238 model.setNew(isNew());
239 model.setEscapedModel(true);
240
241 model.setThreadId(getThreadId());
242 model.setGroupId(getGroupId());
243 model.setCategoryId(getCategoryId());
244 model.setRootMessageId(getRootMessageId());
245 model.setMessageCount(getMessageCount());
246 model.setViewCount(getViewCount());
247 model.setLastPostByUserId(getLastPostByUserId());
248 model.setLastPostDate(getLastPostDate());
249 model.setPriority(getPriority());
250
251 model = (MBThread)Proxy.newProxyInstance(MBThread.class.getClassLoader(),
252 new Class[] { MBThread.class },
253 new ReadOnlyBeanHandler(model));
254
255 return model;
256 }
257 }
258
259 public Object clone() {
260 MBThreadImpl clone = new MBThreadImpl();
261
262 clone.setThreadId(getThreadId());
263 clone.setGroupId(getGroupId());
264 clone.setCategoryId(getCategoryId());
265 clone.setRootMessageId(getRootMessageId());
266 clone.setMessageCount(getMessageCount());
267 clone.setViewCount(getViewCount());
268 clone.setLastPostByUserId(getLastPostByUserId());
269 clone.setLastPostDate(getLastPostDate());
270 clone.setPriority(getPriority());
271
272 return clone;
273 }
274
275 public int compareTo(MBThread mbThread) {
276 int value = 0;
277
278 if (getPriority() < mbThread.getPriority()) {
279 value = -1;
280 }
281 else if (getPriority() > mbThread.getPriority()) {
282 value = 1;
283 }
284 else {
285 value = 0;
286 }
287
288 value = value * -1;
289
290 if (value != 0) {
291 return value;
292 }
293
294 value = DateUtil.compareTo(getLastPostDate(), mbThread.getLastPostDate());
295
296 value = value * -1;
297
298 if (value != 0) {
299 return value;
300 }
301
302 return 0;
303 }
304
305 public boolean equals(Object obj) {
306 if (obj == null) {
307 return false;
308 }
309
310 MBThread mbThread = null;
311
312 try {
313 mbThread = (MBThread)obj;
314 }
315 catch (ClassCastException cce) {
316 return false;
317 }
318
319 long pk = mbThread.getPrimaryKey();
320
321 if (getPrimaryKey() == pk) {
322 return true;
323 }
324 else {
325 return false;
326 }
327 }
328
329 public int hashCode() {
330 return (int)getPrimaryKey();
331 }
332
333 public String toString() {
334 StringBuilder sb = new StringBuilder();
335
336 sb.append("{threadId=");
337 sb.append(getThreadId());
338 sb.append(", groupId=");
339 sb.append(getGroupId());
340 sb.append(", categoryId=");
341 sb.append(getCategoryId());
342 sb.append(", rootMessageId=");
343 sb.append(getRootMessageId());
344 sb.append(", messageCount=");
345 sb.append(getMessageCount());
346 sb.append(", viewCount=");
347 sb.append(getViewCount());
348 sb.append(", lastPostByUserId=");
349 sb.append(getLastPostByUserId());
350 sb.append(", lastPostDate=");
351 sb.append(getLastPostDate());
352 sb.append(", priority=");
353 sb.append(getPriority());
354 sb.append("}");
355
356 return sb.toString();
357 }
358
359 public String toXmlString() {
360 StringBuilder sb = new StringBuilder();
361
362 sb.append("<model><model-name>");
363 sb.append("com.liferay.portlet.messageboards.model.MBThread");
364 sb.append("</model-name>");
365
366 sb.append(
367 "<column><column-name>threadId</column-name><column-value><![CDATA[");
368 sb.append(getThreadId());
369 sb.append("]]></column-value></column>");
370 sb.append(
371 "<column><column-name>groupId</column-name><column-value><![CDATA[");
372 sb.append(getGroupId());
373 sb.append("]]></column-value></column>");
374 sb.append(
375 "<column><column-name>categoryId</column-name><column-value><![CDATA[");
376 sb.append(getCategoryId());
377 sb.append("]]></column-value></column>");
378 sb.append(
379 "<column><column-name>rootMessageId</column-name><column-value><![CDATA[");
380 sb.append(getRootMessageId());
381 sb.append("]]></column-value></column>");
382 sb.append(
383 "<column><column-name>messageCount</column-name><column-value><![CDATA[");
384 sb.append(getMessageCount());
385 sb.append("]]></column-value></column>");
386 sb.append(
387 "<column><column-name>viewCount</column-name><column-value><![CDATA[");
388 sb.append(getViewCount());
389 sb.append("]]></column-value></column>");
390 sb.append(
391 "<column><column-name>lastPostByUserId</column-name><column-value><![CDATA[");
392 sb.append(getLastPostByUserId());
393 sb.append("]]></column-value></column>");
394 sb.append(
395 "<column><column-name>lastPostDate</column-name><column-value><![CDATA[");
396 sb.append(getLastPostDate());
397 sb.append("]]></column-value></column>");
398 sb.append(
399 "<column><column-name>priority</column-name><column-value><![CDATA[");
400 sb.append(getPriority());
401 sb.append("]]></column-value></column>");
402
403 sb.append("</model>");
404
405 return sb.toString();
406 }
407
408 private long _threadId;
409 private long _groupId;
410 private long _categoryId;
411 private long _rootMessageId;
412 private int _messageCount;
413 private int _viewCount;
414 private long _lastPostByUserId;
415 private String _lastPostByUserUuid;
416 private Date _lastPostDate;
417 private double _priority;
418 }