1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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  /**
34   * <a href="MBBanUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class MBBanUtil {
40      public static com.liferay.portlet.messageboards.model.MBBan create(
41          long banId) {
42          return getPersistence().create(banId);
43      }
44  
45      public static com.liferay.portlet.messageboards.model.MBBan remove(
46          long banId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portlet.messageboards.NoSuchBanException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(banId));
53          }
54  
55          com.liferay.portlet.messageboards.model.MBBan mbBan = getPersistence()
56                                                                    .remove(banId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(mbBan);
60          }
61  
62          return mbBan;
63      }
64  
65      public static com.liferay.portlet.messageboards.model.MBBan remove(
66          com.liferay.portlet.messageboards.model.MBBan mbBan)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(mbBan);
72          }
73  
74          mbBan = getPersistence().remove(mbBan);
75  
76          if (listener != null) {
77              listener.onAfterRemove(mbBan);
78          }
79  
80          return mbBan;
81      }
82  
83      public static com.liferay.portlet.messageboards.model.MBBan update(
84          com.liferay.portlet.messageboards.model.MBBan mbBan)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = mbBan.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(mbBan);
92              }
93              else {
94                  listener.onBeforeUpdate(mbBan);
95              }
96          }
97  
98          mbBan = getPersistence().update(mbBan);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(mbBan);
103             }
104             else {
105                 listener.onAfterUpdate(mbBan);
106             }
107         }
108 
109         return mbBan;
110     }
111 
112     public static com.liferay.portlet.messageboards.model.MBBan update(
113         com.liferay.portlet.messageboards.model.MBBan mbBan, boolean merge)
114         throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = mbBan.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(mbBan);
121             }
122             else {
123                 listener.onBeforeUpdate(mbBan);
124             }
125         }
126 
127         mbBan = getPersistence().update(mbBan, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(mbBan);
132             }
133             else {
134                 listener.onAfterUpdate(mbBan);
135             }
136         }
137 
138         return mbBan;
139     }
140 
141     public static com.liferay.portlet.messageboards.model.MBBan findByPrimaryKey(
142         long banId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portlet.messageboards.NoSuchBanException {
145         return getPersistence().findByPrimaryKey(banId);
146     }
147 
148     public static com.liferay.portlet.messageboards.model.MBBan fetchByPrimaryKey(
149         long banId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(banId);
151     }
152 
153     public static java.util.List findByGroupId(long groupId)
154         throws com.liferay.portal.SystemException {
155         return getPersistence().findByGroupId(groupId);
156     }
157 
158     public static java.util.List findByGroupId(long groupId, int begin, int end)
159         throws com.liferay.portal.SystemException {
160         return getPersistence().findByGroupId(groupId, begin, end);
161     }
162 
163     public static java.util.List findByGroupId(long groupId, int begin,
164         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
165         throws com.liferay.portal.SystemException {
166         return getPersistence().findByGroupId(groupId, begin, end, obc);
167     }
168 
169     public static com.liferay.portlet.messageboards.model.MBBan findByGroupId_First(
170         long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portlet.messageboards.NoSuchBanException {
173         return getPersistence().findByGroupId_First(groupId, obc);
174     }
175 
176     public static com.liferay.portlet.messageboards.model.MBBan findByGroupId_Last(
177         long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portlet.messageboards.NoSuchBanException {
180         return getPersistence().findByGroupId_Last(groupId, obc);
181     }
182 
183     public static com.liferay.portlet.messageboards.model.MBBan[] findByGroupId_PrevAndNext(
184         long banId, long groupId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portlet.messageboards.NoSuchBanException {
188         return getPersistence().findByGroupId_PrevAndNext(banId, groupId, obc);
189     }
190 
191     public static java.util.List findByUserId(long userId)
192         throws com.liferay.portal.SystemException {
193         return getPersistence().findByUserId(userId);
194     }
195 
196     public static java.util.List findByUserId(long userId, int begin, int end)
197         throws com.liferay.portal.SystemException {
198         return getPersistence().findByUserId(userId, begin, end);
199     }
200 
201     public static java.util.List findByUserId(long userId, int begin, int end,
202         com.liferay.portal.kernel.util.OrderByComparator obc)
203         throws com.liferay.portal.SystemException {
204         return getPersistence().findByUserId(userId, begin, end, obc);
205     }
206 
207     public static com.liferay.portlet.messageboards.model.MBBan findByUserId_First(
208         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
209         throws com.liferay.portal.SystemException, 
210             com.liferay.portlet.messageboards.NoSuchBanException {
211         return getPersistence().findByUserId_First(userId, obc);
212     }
213 
214     public static com.liferay.portlet.messageboards.model.MBBan findByUserId_Last(
215         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
216         throws com.liferay.portal.SystemException, 
217             com.liferay.portlet.messageboards.NoSuchBanException {
218         return getPersistence().findByUserId_Last(userId, obc);
219     }
220 
221     public static com.liferay.portlet.messageboards.model.MBBan[] findByUserId_PrevAndNext(
222         long banId, long userId,
223         com.liferay.portal.kernel.util.OrderByComparator obc)
224         throws com.liferay.portal.SystemException, 
225             com.liferay.portlet.messageboards.NoSuchBanException {
226         return getPersistence().findByUserId_PrevAndNext(banId, userId, obc);
227     }
228 
229     public static java.util.List findByBanUserId(long banUserId)
230         throws com.liferay.portal.SystemException {
231         return getPersistence().findByBanUserId(banUserId);
232     }
233 
234     public static java.util.List findByBanUserId(long banUserId, int begin,
235         int end) throws com.liferay.portal.SystemException {
236         return getPersistence().findByBanUserId(banUserId, begin, end);
237     }
238 
239     public static java.util.List findByBanUserId(long banUserId, int begin,
240         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
241         throws com.liferay.portal.SystemException {
242         return getPersistence().findByBanUserId(banUserId, begin, end, obc);
243     }
244 
245     public static com.liferay.portlet.messageboards.model.MBBan findByBanUserId_First(
246         long banUserId, com.liferay.portal.kernel.util.OrderByComparator obc)
247         throws com.liferay.portal.SystemException, 
248             com.liferay.portlet.messageboards.NoSuchBanException {
249         return getPersistence().findByBanUserId_First(banUserId, obc);
250     }
251 
252     public static com.liferay.portlet.messageboards.model.MBBan findByBanUserId_Last(
253         long banUserId, com.liferay.portal.kernel.util.OrderByComparator obc)
254         throws com.liferay.portal.SystemException, 
255             com.liferay.portlet.messageboards.NoSuchBanException {
256         return getPersistence().findByBanUserId_Last(banUserId, obc);
257     }
258 
259     public static com.liferay.portlet.messageboards.model.MBBan[] findByBanUserId_PrevAndNext(
260         long banId, long banUserId,
261         com.liferay.portal.kernel.util.OrderByComparator obc)
262         throws com.liferay.portal.SystemException, 
263             com.liferay.portlet.messageboards.NoSuchBanException {
264         return getPersistence().findByBanUserId_PrevAndNext(banId, banUserId,
265             obc);
266     }
267 
268     public static com.liferay.portlet.messageboards.model.MBBan findByG_B(
269         long groupId, long banUserId)
270         throws com.liferay.portal.SystemException, 
271             com.liferay.portlet.messageboards.NoSuchBanException {
272         return getPersistence().findByG_B(groupId, banUserId);
273     }
274 
275     public static com.liferay.portlet.messageboards.model.MBBan fetchByG_B(
276         long groupId, long banUserId) throws com.liferay.portal.SystemException {
277         return getPersistence().fetchByG_B(groupId, banUserId);
278     }
279 
280     public static java.util.List findWithDynamicQuery(
281         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
282         throws com.liferay.portal.SystemException {
283         return getPersistence().findWithDynamicQuery(queryInitializer);
284     }
285 
286     public static java.util.List findWithDynamicQuery(
287         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
288         int begin, int end) throws com.liferay.portal.SystemException {
289         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
290             end);
291     }
292 
293     public static java.util.List findAll()
294         throws com.liferay.portal.SystemException {
295         return getPersistence().findAll();
296     }
297 
298     public static java.util.List findAll(int begin, int end)
299         throws com.liferay.portal.SystemException {
300         return getPersistence().findAll(begin, end);
301     }
302 
303     public static java.util.List findAll(int begin, int end,
304         com.liferay.portal.kernel.util.OrderByComparator obc)
305         throws com.liferay.portal.SystemException {
306         return getPersistence().findAll(begin, end, obc);
307     }
308 
309     public static void removeByGroupId(long groupId)
310         throws com.liferay.portal.SystemException {
311         getPersistence().removeByGroupId(groupId);
312     }
313 
314     public static void removeByUserId(long userId)
315         throws com.liferay.portal.SystemException {
316         getPersistence().removeByUserId(userId);
317     }
318 
319     public static void removeByBanUserId(long banUserId)
320         throws com.liferay.portal.SystemException {
321         getPersistence().removeByBanUserId(banUserId);
322     }
323 
324     public static void removeByG_B(long groupId, long banUserId)
325         throws com.liferay.portal.SystemException, 
326             com.liferay.portlet.messageboards.NoSuchBanException {
327         getPersistence().removeByG_B(groupId, banUserId);
328     }
329 
330     public static void removeAll() throws com.liferay.portal.SystemException {
331         getPersistence().removeAll();
332     }
333 
334     public static int countByGroupId(long groupId)
335         throws com.liferay.portal.SystemException {
336         return getPersistence().countByGroupId(groupId);
337     }
338 
339     public static int countByUserId(long userId)
340         throws com.liferay.portal.SystemException {
341         return getPersistence().countByUserId(userId);
342     }
343 
344     public static int countByBanUserId(long banUserId)
345         throws com.liferay.portal.SystemException {
346         return getPersistence().countByBanUserId(banUserId);
347     }
348 
349     public static int countByG_B(long groupId, long banUserId)
350         throws com.liferay.portal.SystemException {
351         return getPersistence().countByG_B(groupId, banUserId);
352     }
353 
354     public static int countAll() throws com.liferay.portal.SystemException {
355         return getPersistence().countAll();
356     }
357 
358     public static MBBanPersistence getPersistence() {
359         return _getUtil()._persistence;
360     }
361 
362     public void setPersistence(MBBanPersistence persistence) {
363         _persistence = persistence;
364     }
365 
366     private static MBBanUtil _getUtil() {
367         if (_util == null) {
368             _util = (MBBanUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
369         }
370 
371         return _util;
372     }
373 
374     private static ModelListener _getListener() {
375         if (Validator.isNotNull(_LISTENER)) {
376             try {
377                 return (ModelListener)Class.forName(_LISTENER).newInstance();
378             }
379             catch (Exception e) {
380                 _log.error(e);
381             }
382         }
383 
384         return null;
385     }
386 
387     private static final String _UTIL = MBBanUtil.class.getName();
388     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
389                 "value.object.listener.com.liferay.portlet.messageboards.model.MBBan"));
390     private static Log _log = LogFactory.getLog(MBBanUtil.class);
391     private static MBBanUtil _util;
392     private MBBanPersistence _persistence;
393 }