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