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