1
22
23 package com.liferay.portlet.messageboards.service.persistence;
24
25 import com.liferay.portal.kernel.util.GetterUtil;
26 import com.liferay.portal.kernel.util.Validator;
27 import com.liferay.portal.model.ModelListener;
28 import com.liferay.portal.util.PropsUtil;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32
33
39 public class MBMessageUtil {
40 public static com.liferay.portlet.messageboards.model.MBMessage create(
41 long messageId) {
42 return getPersistence().create(messageId);
43 }
44
45 public static com.liferay.portlet.messageboards.model.MBMessage remove(
46 long messageId)
47 throws com.liferay.portal.SystemException,
48 com.liferay.portlet.messageboards.NoSuchMessageException {
49 ModelListener listener = _getListener();
50
51 if (listener != null) {
52 listener.onBeforeRemove(findByPrimaryKey(messageId));
53 }
54
55 com.liferay.portlet.messageboards.model.MBMessage mbMessage = getPersistence()
56 .remove(messageId);
57
58 if (listener != null) {
59 listener.onAfterRemove(mbMessage);
60 }
61
62 return mbMessage;
63 }
64
65 public static com.liferay.portlet.messageboards.model.MBMessage remove(
66 com.liferay.portlet.messageboards.model.MBMessage mbMessage)
67 throws com.liferay.portal.SystemException {
68 ModelListener listener = _getListener();
69
70 if (listener != null) {
71 listener.onBeforeRemove(mbMessage);
72 }
73
74 mbMessage = getPersistence().remove(mbMessage);
75
76 if (listener != null) {
77 listener.onAfterRemove(mbMessage);
78 }
79
80 return mbMessage;
81 }
82
83 public static com.liferay.portlet.messageboards.model.MBMessage update(
84 com.liferay.portlet.messageboards.model.MBMessage mbMessage)
85 throws com.liferay.portal.SystemException {
86 ModelListener listener = _getListener();
87 boolean isNew = mbMessage.isNew();
88
89 if (listener != null) {
90 if (isNew) {
91 listener.onBeforeCreate(mbMessage);
92 }
93 else {
94 listener.onBeforeUpdate(mbMessage);
95 }
96 }
97
98 mbMessage = getPersistence().update(mbMessage);
99
100 if (listener != null) {
101 if (isNew) {
102 listener.onAfterCreate(mbMessage);
103 }
104 else {
105 listener.onAfterUpdate(mbMessage);
106 }
107 }
108
109 return mbMessage;
110 }
111
112 public static com.liferay.portlet.messageboards.model.MBMessage update(
113 com.liferay.portlet.messageboards.model.MBMessage mbMessage,
114 boolean merge) throws com.liferay.portal.SystemException {
115 ModelListener listener = _getListener();
116 boolean isNew = mbMessage.isNew();
117
118 if (listener != null) {
119 if (isNew) {
120 listener.onBeforeCreate(mbMessage);
121 }
122 else {
123 listener.onBeforeUpdate(mbMessage);
124 }
125 }
126
127 mbMessage = getPersistence().update(mbMessage, merge);
128
129 if (listener != null) {
130 if (isNew) {
131 listener.onAfterCreate(mbMessage);
132 }
133 else {
134 listener.onAfterUpdate(mbMessage);
135 }
136 }
137
138 return mbMessage;
139 }
140
141 public static com.liferay.portlet.messageboards.model.MBMessage findByPrimaryKey(
142 long messageId)
143 throws com.liferay.portal.SystemException,
144 com.liferay.portlet.messageboards.NoSuchMessageException {
145 return getPersistence().findByPrimaryKey(messageId);
146 }
147
148 public static com.liferay.portlet.messageboards.model.MBMessage fetchByPrimaryKey(
149 long messageId) throws com.liferay.portal.SystemException {
150 return getPersistence().fetchByPrimaryKey(messageId);
151 }
152
153 public static java.util.List findByCompanyId(long companyId)
154 throws com.liferay.portal.SystemException {
155 return getPersistence().findByCompanyId(companyId);
156 }
157
158 public static java.util.List findByCompanyId(long companyId, int begin,
159 int end) throws com.liferay.portal.SystemException {
160 return getPersistence().findByCompanyId(companyId, begin, end);
161 }
162
163 public static java.util.List findByCompanyId(long companyId, int begin,
164 int end, com.liferay.portal.kernel.util.OrderByComparator obc)
165 throws com.liferay.portal.SystemException {
166 return getPersistence().findByCompanyId(companyId, begin, end, obc);
167 }
168
169 public static com.liferay.portlet.messageboards.model.MBMessage findByCompanyId_First(
170 long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
171 throws com.liferay.portal.SystemException,
172 com.liferay.portlet.messageboards.NoSuchMessageException {
173 return getPersistence().findByCompanyId_First(companyId, obc);
174 }
175
176 public static com.liferay.portlet.messageboards.model.MBMessage findByCompanyId_Last(
177 long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
178 throws com.liferay.portal.SystemException,
179 com.liferay.portlet.messageboards.NoSuchMessageException {
180 return getPersistence().findByCompanyId_Last(companyId, obc);
181 }
182
183 public static com.liferay.portlet.messageboards.model.MBMessage[] findByCompanyId_PrevAndNext(
184 long messageId, long companyId,
185 com.liferay.portal.kernel.util.OrderByComparator obc)
186 throws com.liferay.portal.SystemException,
187 com.liferay.portlet.messageboards.NoSuchMessageException {
188 return getPersistence().findByCompanyId_PrevAndNext(messageId,
189 companyId, obc);
190 }
191
192 public static java.util.List findByCategoryId(long categoryId)
193 throws com.liferay.portal.SystemException {
194 return getPersistence().findByCategoryId(categoryId);
195 }
196
197 public static java.util.List findByCategoryId(long categoryId, int begin,
198 int end) throws com.liferay.portal.SystemException {
199 return getPersistence().findByCategoryId(categoryId, begin, end);
200 }
201
202 public static java.util.List findByCategoryId(long categoryId, int begin,
203 int end, com.liferay.portal.kernel.util.OrderByComparator obc)
204 throws com.liferay.portal.SystemException {
205 return getPersistence().findByCategoryId(categoryId, begin, end, obc);
206 }
207
208 public static com.liferay.portlet.messageboards.model.MBMessage findByCategoryId_First(
209 long categoryId, com.liferay.portal.kernel.util.OrderByComparator obc)
210 throws com.liferay.portal.SystemException,
211 com.liferay.portlet.messageboards.NoSuchMessageException {
212 return getPersistence().findByCategoryId_First(categoryId, obc);
213 }
214
215 public static com.liferay.portlet.messageboards.model.MBMessage findByCategoryId_Last(
216 long categoryId, com.liferay.portal.kernel.util.OrderByComparator obc)
217 throws com.liferay.portal.SystemException,
218 com.liferay.portlet.messageboards.NoSuchMessageException {
219 return getPersistence().findByCategoryId_Last(categoryId, obc);
220 }
221
222 public static com.liferay.portlet.messageboards.model.MBMessage[] findByCategoryId_PrevAndNext(
223 long messageId, long categoryId,
224 com.liferay.portal.kernel.util.OrderByComparator obc)
225 throws com.liferay.portal.SystemException,
226 com.liferay.portlet.messageboards.NoSuchMessageException {
227 return getPersistence().findByCategoryId_PrevAndNext(messageId,
228 categoryId, obc);
229 }
230
231 public static java.util.List findByThreadId(long threadId)
232 throws com.liferay.portal.SystemException {
233 return getPersistence().findByThreadId(threadId);
234 }
235
236 public static java.util.List findByThreadId(long threadId, int begin,
237 int end) throws com.liferay.portal.SystemException {
238 return getPersistence().findByThreadId(threadId, begin, end);
239 }
240
241 public static java.util.List findByThreadId(long threadId, int begin,
242 int end, com.liferay.portal.kernel.util.OrderByComparator obc)
243 throws com.liferay.portal.SystemException {
244 return getPersistence().findByThreadId(threadId, begin, end, obc);
245 }
246
247 public static com.liferay.portlet.messageboards.model.MBMessage findByThreadId_First(
248 long threadId, com.liferay.portal.kernel.util.OrderByComparator obc)
249 throws com.liferay.portal.SystemException,
250 com.liferay.portlet.messageboards.NoSuchMessageException {
251 return getPersistence().findByThreadId_First(threadId, obc);
252 }
253
254 public static com.liferay.portlet.messageboards.model.MBMessage findByThreadId_Last(
255 long threadId, com.liferay.portal.kernel.util.OrderByComparator obc)
256 throws com.liferay.portal.SystemException,
257 com.liferay.portlet.messageboards.NoSuchMessageException {
258 return getPersistence().findByThreadId_Last(threadId, obc);
259 }
260
261 public static com.liferay.portlet.messageboards.model.MBMessage[] findByThreadId_PrevAndNext(
262 long messageId, long threadId,
263 com.liferay.portal.kernel.util.OrderByComparator obc)
264 throws com.liferay.portal.SystemException,
265 com.liferay.portlet.messageboards.NoSuchMessageException {
266 return getPersistence().findByThreadId_PrevAndNext(messageId, threadId,
267 obc);
268 }
269
270 public static java.util.List findByC_T(long categoryId, long threadId)
271 throws com.liferay.portal.SystemException {
272 return getPersistence().findByC_T(categoryId, threadId);
273 }
274
275 public static java.util.List findByC_T(long categoryId, long threadId,
276 int begin, int end) throws com.liferay.portal.SystemException {
277 return getPersistence().findByC_T(categoryId, threadId, begin, end);
278 }
279
280 public static java.util.List findByC_T(long categoryId, long threadId,
281 int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
282 throws com.liferay.portal.SystemException {
283 return getPersistence().findByC_T(categoryId, threadId, begin, end, obc);
284 }
285
286 public static com.liferay.portlet.messageboards.model.MBMessage findByC_T_First(
287 long categoryId, long threadId,
288 com.liferay.portal.kernel.util.OrderByComparator obc)
289 throws com.liferay.portal.SystemException,
290 com.liferay.portlet.messageboards.NoSuchMessageException {
291 return getPersistence().findByC_T_First(categoryId, threadId, obc);
292 }
293
294 public static com.liferay.portlet.messageboards.model.MBMessage findByC_T_Last(
295 long categoryId, long threadId,
296 com.liferay.portal.kernel.util.OrderByComparator obc)
297 throws com.liferay.portal.SystemException,
298 com.liferay.portlet.messageboards.NoSuchMessageException {
299 return getPersistence().findByC_T_Last(categoryId, threadId, obc);
300 }
301
302 public static com.liferay.portlet.messageboards.model.MBMessage[] findByC_T_PrevAndNext(
303 long messageId, long categoryId, long threadId,
304 com.liferay.portal.kernel.util.OrderByComparator obc)
305 throws com.liferay.portal.SystemException,
306 com.liferay.portlet.messageboards.NoSuchMessageException {
307 return getPersistence().findByC_T_PrevAndNext(messageId, categoryId,
308 threadId, obc);
309 }
310
311 public static java.util.List findByT_P(long threadId, long parentMessageId)
312 throws com.liferay.portal.SystemException {
313 return getPersistence().findByT_P(threadId, parentMessageId);
314 }
315
316 public static java.util.List findByT_P(long threadId, long parentMessageId,
317 int begin, int end) throws com.liferay.portal.SystemException {
318 return getPersistence().findByT_P(threadId, parentMessageId, begin, end);
319 }
320
321 public static java.util.List findByT_P(long threadId, long parentMessageId,
322 int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
323 throws com.liferay.portal.SystemException {
324 return getPersistence().findByT_P(threadId, parentMessageId, begin,
325 end, obc);
326 }
327
328 public static com.liferay.portlet.messageboards.model.MBMessage findByT_P_First(
329 long threadId, long parentMessageId,
330 com.liferay.portal.kernel.util.OrderByComparator obc)
331 throws com.liferay.portal.SystemException,
332 com.liferay.portlet.messageboards.NoSuchMessageException {
333 return getPersistence().findByT_P_First(threadId, parentMessageId, obc);
334 }
335
336 public static com.liferay.portlet.messageboards.model.MBMessage findByT_P_Last(
337 long threadId, long parentMessageId,
338 com.liferay.portal.kernel.util.OrderByComparator obc)
339 throws com.liferay.portal.SystemException,
340 com.liferay.portlet.messageboards.NoSuchMessageException {
341 return getPersistence().findByT_P_Last(threadId, parentMessageId, obc);
342 }
343
344 public static com.liferay.portlet.messageboards.model.MBMessage[] findByT_P_PrevAndNext(
345 long messageId, long threadId, long parentMessageId,
346 com.liferay.portal.kernel.util.OrderByComparator obc)
347 throws com.liferay.portal.SystemException,
348 com.liferay.portlet.messageboards.NoSuchMessageException {
349 return getPersistence().findByT_P_PrevAndNext(messageId, threadId,
350 parentMessageId, obc);
351 }
352
353 public static java.util.List findWithDynamicQuery(
354 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
355 throws com.liferay.portal.SystemException {
356 return getPersistence().findWithDynamicQuery(queryInitializer);
357 }
358
359 public static java.util.List findWithDynamicQuery(
360 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
361 int begin, int end) throws com.liferay.portal.SystemException {
362 return getPersistence().findWithDynamicQuery(queryInitializer, begin,
363 end);
364 }
365
366 public static java.util.List findAll()
367 throws com.liferay.portal.SystemException {
368 return getPersistence().findAll();
369 }
370
371 public static java.util.List findAll(int begin, int end)
372 throws com.liferay.portal.SystemException {
373 return getPersistence().findAll(begin, end);
374 }
375
376 public static java.util.List findAll(int begin, int end,
377 com.liferay.portal.kernel.util.OrderByComparator obc)
378 throws com.liferay.portal.SystemException {
379 return getPersistence().findAll(begin, end, obc);
380 }
381
382 public static void removeByCompanyId(long companyId)
383 throws com.liferay.portal.SystemException {
384 getPersistence().removeByCompanyId(companyId);
385 }
386
387 public static void removeByCategoryId(long categoryId)
388 throws com.liferay.portal.SystemException {
389 getPersistence().removeByCategoryId(categoryId);
390 }
391
392 public static void removeByThreadId(long threadId)
393 throws com.liferay.portal.SystemException {
394 getPersistence().removeByThreadId(threadId);
395 }
396
397 public static void removeByC_T(long categoryId, long threadId)
398 throws com.liferay.portal.SystemException {
399 getPersistence().removeByC_T(categoryId, threadId);
400 }
401
402 public static void removeByT_P(long threadId, long parentMessageId)
403 throws com.liferay.portal.SystemException {
404 getPersistence().removeByT_P(threadId, parentMessageId);
405 }
406
407 public static void removeAll() throws com.liferay.portal.SystemException {
408 getPersistence().removeAll();
409 }
410
411 public static int countByCompanyId(long companyId)
412 throws com.liferay.portal.SystemException {
413 return getPersistence().countByCompanyId(companyId);
414 }
415
416 public static int countByCategoryId(long categoryId)
417 throws com.liferay.portal.SystemException {
418 return getPersistence().countByCategoryId(categoryId);
419 }
420
421 public static int countByThreadId(long threadId)
422 throws com.liferay.portal.SystemException {
423 return getPersistence().countByThreadId(threadId);
424 }
425
426 public static int countByC_T(long categoryId, long threadId)
427 throws com.liferay.portal.SystemException {
428 return getPersistence().countByC_T(categoryId, threadId);
429 }
430
431 public static int countByT_P(long threadId, long parentMessageId)
432 throws com.liferay.portal.SystemException {
433 return getPersistence().countByT_P(threadId, parentMessageId);
434 }
435
436 public static int countAll() throws com.liferay.portal.SystemException {
437 return getPersistence().countAll();
438 }
439
440 public static MBMessagePersistence getPersistence() {
441 return _getUtil()._persistence;
442 }
443
444 public void setPersistence(MBMessagePersistence persistence) {
445 _persistence = persistence;
446 }
447
448 private static MBMessageUtil _getUtil() {
449 if (_util == null) {
450 _util = (MBMessageUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
451 }
452
453 return _util;
454 }
455
456 private static ModelListener _getListener() {
457 if (Validator.isNotNull(_LISTENER)) {
458 try {
459 return (ModelListener)Class.forName(_LISTENER).newInstance();
460 }
461 catch (Exception e) {
462 _log.error(e);
463 }
464 }
465
466 return null;
467 }
468
469 private static final String _UTIL = MBMessageUtil.class.getName();
470 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
471 "value.object.listener.com.liferay.portlet.messageboards.model.MBMessage"));
472 private static Log _log = LogFactory.getLog(MBMessageUtil.class);
473 private static MBMessageUtil _util;
474 private MBMessagePersistence _persistence;
475 }