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