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