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="MBStatsUserUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class MBStatsUserUtil {
40      public static com.liferay.portlet.messageboards.model.MBStatsUser create(
41          long statsUserId) {
42          return getPersistence().create(statsUserId);
43      }
44  
45      public static com.liferay.portlet.messageboards.model.MBStatsUser remove(
46          long statsUserId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portlet.messageboards.NoSuchStatsUserException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(statsUserId));
53          }
54  
55          com.liferay.portlet.messageboards.model.MBStatsUser mbStatsUser = getPersistence()
56                                                                                .remove(statsUserId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(mbStatsUser);
60          }
61  
62          return mbStatsUser;
63      }
64  
65      public static com.liferay.portlet.messageboards.model.MBStatsUser remove(
66          com.liferay.portlet.messageboards.model.MBStatsUser mbStatsUser)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(mbStatsUser);
72          }
73  
74          mbStatsUser = getPersistence().remove(mbStatsUser);
75  
76          if (listener != null) {
77              listener.onAfterRemove(mbStatsUser);
78          }
79  
80          return mbStatsUser;
81      }
82  
83      public static com.liferay.portlet.messageboards.model.MBStatsUser update(
84          com.liferay.portlet.messageboards.model.MBStatsUser mbStatsUser)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = mbStatsUser.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(mbStatsUser);
92              }
93              else {
94                  listener.onBeforeUpdate(mbStatsUser);
95              }
96          }
97  
98          mbStatsUser = getPersistence().update(mbStatsUser);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(mbStatsUser);
103             }
104             else {
105                 listener.onAfterUpdate(mbStatsUser);
106             }
107         }
108 
109         return mbStatsUser;
110     }
111 
112     public static com.liferay.portlet.messageboards.model.MBStatsUser update(
113         com.liferay.portlet.messageboards.model.MBStatsUser mbStatsUser,
114         boolean merge) throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = mbStatsUser.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(mbStatsUser);
121             }
122             else {
123                 listener.onBeforeUpdate(mbStatsUser);
124             }
125         }
126 
127         mbStatsUser = getPersistence().update(mbStatsUser, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(mbStatsUser);
132             }
133             else {
134                 listener.onAfterUpdate(mbStatsUser);
135             }
136         }
137 
138         return mbStatsUser;
139     }
140 
141     public static com.liferay.portlet.messageboards.model.MBStatsUser findByPrimaryKey(
142         long statsUserId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portlet.messageboards.NoSuchStatsUserException {
145         return getPersistence().findByPrimaryKey(statsUserId);
146     }
147 
148     public static com.liferay.portlet.messageboards.model.MBStatsUser fetchByPrimaryKey(
149         long statsUserId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(statsUserId);
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.MBStatsUser findByGroupId_First(
170         long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portlet.messageboards.NoSuchStatsUserException {
173         return getPersistence().findByGroupId_First(groupId, obc);
174     }
175 
176     public static com.liferay.portlet.messageboards.model.MBStatsUser findByGroupId_Last(
177         long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portlet.messageboards.NoSuchStatsUserException {
180         return getPersistence().findByGroupId_Last(groupId, obc);
181     }
182 
183     public static com.liferay.portlet.messageboards.model.MBStatsUser[] findByGroupId_PrevAndNext(
184         long statsUserId, long groupId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portlet.messageboards.NoSuchStatsUserException {
188         return getPersistence().findByGroupId_PrevAndNext(statsUserId, groupId,
189             obc);
190     }
191 
192     public static java.util.List findByUserId(long userId)
193         throws com.liferay.portal.SystemException {
194         return getPersistence().findByUserId(userId);
195     }
196 
197     public static java.util.List findByUserId(long userId, int begin, int end)
198         throws com.liferay.portal.SystemException {
199         return getPersistence().findByUserId(userId, begin, end);
200     }
201 
202     public static java.util.List findByUserId(long userId, int begin, int end,
203         com.liferay.portal.kernel.util.OrderByComparator obc)
204         throws com.liferay.portal.SystemException {
205         return getPersistence().findByUserId(userId, begin, end, obc);
206     }
207 
208     public static com.liferay.portlet.messageboards.model.MBStatsUser findByUserId_First(
209         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
210         throws com.liferay.portal.SystemException, 
211             com.liferay.portlet.messageboards.NoSuchStatsUserException {
212         return getPersistence().findByUserId_First(userId, obc);
213     }
214 
215     public static com.liferay.portlet.messageboards.model.MBStatsUser findByUserId_Last(
216         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
217         throws com.liferay.portal.SystemException, 
218             com.liferay.portlet.messageboards.NoSuchStatsUserException {
219         return getPersistence().findByUserId_Last(userId, obc);
220     }
221 
222     public static com.liferay.portlet.messageboards.model.MBStatsUser[] findByUserId_PrevAndNext(
223         long statsUserId, long userId,
224         com.liferay.portal.kernel.util.OrderByComparator obc)
225         throws com.liferay.portal.SystemException, 
226             com.liferay.portlet.messageboards.NoSuchStatsUserException {
227         return getPersistence().findByUserId_PrevAndNext(statsUserId, userId,
228             obc);
229     }
230 
231     public static com.liferay.portlet.messageboards.model.MBStatsUser findByG_U(
232         long groupId, long userId)
233         throws com.liferay.portal.SystemException, 
234             com.liferay.portlet.messageboards.NoSuchStatsUserException {
235         return getPersistence().findByG_U(groupId, userId);
236     }
237 
238     public static com.liferay.portlet.messageboards.model.MBStatsUser fetchByG_U(
239         long groupId, long userId) throws com.liferay.portal.SystemException {
240         return getPersistence().fetchByG_U(groupId, userId);
241     }
242 
243     public static java.util.List findByG_M(long groupId, int messageCount)
244         throws com.liferay.portal.SystemException {
245         return getPersistence().findByG_M(groupId, messageCount);
246     }
247 
248     public static java.util.List findByG_M(long groupId, int messageCount,
249         int begin, int end) throws com.liferay.portal.SystemException {
250         return getPersistence().findByG_M(groupId, messageCount, begin, end);
251     }
252 
253     public static java.util.List findByG_M(long groupId, int messageCount,
254         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
255         throws com.liferay.portal.SystemException {
256         return getPersistence().findByG_M(groupId, messageCount, begin, end, obc);
257     }
258 
259     public static com.liferay.portlet.messageboards.model.MBStatsUser findByG_M_First(
260         long groupId, int messageCount,
261         com.liferay.portal.kernel.util.OrderByComparator obc)
262         throws com.liferay.portal.SystemException, 
263             com.liferay.portlet.messageboards.NoSuchStatsUserException {
264         return getPersistence().findByG_M_First(groupId, messageCount, obc);
265     }
266 
267     public static com.liferay.portlet.messageboards.model.MBStatsUser findByG_M_Last(
268         long groupId, int messageCount,
269         com.liferay.portal.kernel.util.OrderByComparator obc)
270         throws com.liferay.portal.SystemException, 
271             com.liferay.portlet.messageboards.NoSuchStatsUserException {
272         return getPersistence().findByG_M_Last(groupId, messageCount, obc);
273     }
274 
275     public static com.liferay.portlet.messageboards.model.MBStatsUser[] findByG_M_PrevAndNext(
276         long statsUserId, long groupId, int messageCount,
277         com.liferay.portal.kernel.util.OrderByComparator obc)
278         throws com.liferay.portal.SystemException, 
279             com.liferay.portlet.messageboards.NoSuchStatsUserException {
280         return getPersistence().findByG_M_PrevAndNext(statsUserId, groupId,
281             messageCount, obc);
282     }
283 
284     public static java.util.List findWithDynamicQuery(
285         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
286         throws com.liferay.portal.SystemException {
287         return getPersistence().findWithDynamicQuery(queryInitializer);
288     }
289 
290     public static java.util.List findWithDynamicQuery(
291         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
292         int begin, int end) throws com.liferay.portal.SystemException {
293         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
294             end);
295     }
296 
297     public static java.util.List findAll()
298         throws com.liferay.portal.SystemException {
299         return getPersistence().findAll();
300     }
301 
302     public static java.util.List findAll(int begin, int end)
303         throws com.liferay.portal.SystemException {
304         return getPersistence().findAll(begin, end);
305     }
306 
307     public static java.util.List findAll(int begin, int end,
308         com.liferay.portal.kernel.util.OrderByComparator obc)
309         throws com.liferay.portal.SystemException {
310         return getPersistence().findAll(begin, end, obc);
311     }
312 
313     public static void removeByGroupId(long groupId)
314         throws com.liferay.portal.SystemException {
315         getPersistence().removeByGroupId(groupId);
316     }
317 
318     public static void removeByUserId(long userId)
319         throws com.liferay.portal.SystemException {
320         getPersistence().removeByUserId(userId);
321     }
322 
323     public static void removeByG_U(long groupId, long userId)
324         throws com.liferay.portal.SystemException, 
325             com.liferay.portlet.messageboards.NoSuchStatsUserException {
326         getPersistence().removeByG_U(groupId, userId);
327     }
328 
329     public static void removeByG_M(long groupId, int messageCount)
330         throws com.liferay.portal.SystemException {
331         getPersistence().removeByG_M(groupId, messageCount);
332     }
333 
334     public static void removeAll() throws com.liferay.portal.SystemException {
335         getPersistence().removeAll();
336     }
337 
338     public static int countByGroupId(long groupId)
339         throws com.liferay.portal.SystemException {
340         return getPersistence().countByGroupId(groupId);
341     }
342 
343     public static int countByUserId(long userId)
344         throws com.liferay.portal.SystemException {
345         return getPersistence().countByUserId(userId);
346     }
347 
348     public static int countByG_U(long groupId, long userId)
349         throws com.liferay.portal.SystemException {
350         return getPersistence().countByG_U(groupId, userId);
351     }
352 
353     public static int countByG_M(long groupId, int messageCount)
354         throws com.liferay.portal.SystemException {
355         return getPersistence().countByG_M(groupId, messageCount);
356     }
357 
358     public static int countAll() throws com.liferay.portal.SystemException {
359         return getPersistence().countAll();
360     }
361 
362     public static MBStatsUserPersistence getPersistence() {
363         return _getUtil()._persistence;
364     }
365 
366     public void setPersistence(MBStatsUserPersistence persistence) {
367         _persistence = persistence;
368     }
369 
370     private static MBStatsUserUtil _getUtil() {
371         if (_util == null) {
372             _util = (MBStatsUserUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
373         }
374 
375         return _util;
376     }
377 
378     private static ModelListener _getListener() {
379         if (Validator.isNotNull(_LISTENER)) {
380             try {
381                 return (ModelListener)Class.forName(_LISTENER).newInstance();
382             }
383             catch (Exception e) {
384                 _log.error(e);
385             }
386         }
387 
388         return null;
389     }
390 
391     private static final String _UTIL = MBStatsUserUtil.class.getName();
392     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
393                 "value.object.listener.com.liferay.portlet.messageboards.model.MBStatsUser"));
394     private static Log _log = LogFactory.getLog(MBStatsUserUtil.class);
395     private static MBStatsUserUtil _util;
396     private MBStatsUserPersistence _persistence;
397 }