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.blogs.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="BlogsStatsUserUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class BlogsStatsUserUtil {
40      public static com.liferay.portlet.blogs.model.BlogsStatsUser create(
41          long statsUserId) {
42          return getPersistence().create(statsUserId);
43      }
44  
45      public static com.liferay.portlet.blogs.model.BlogsStatsUser remove(
46          long statsUserId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portlet.blogs.NoSuchStatsUserException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(statsUserId));
53          }
54  
55          com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser = getPersistence()
56                                                                              .remove(statsUserId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(blogsStatsUser);
60          }
61  
62          return blogsStatsUser;
63      }
64  
65      public static com.liferay.portlet.blogs.model.BlogsStatsUser remove(
66          com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(blogsStatsUser);
72          }
73  
74          blogsStatsUser = getPersistence().remove(blogsStatsUser);
75  
76          if (listener != null) {
77              listener.onAfterRemove(blogsStatsUser);
78          }
79  
80          return blogsStatsUser;
81      }
82  
83      public static com.liferay.portlet.blogs.model.BlogsStatsUser update(
84          com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = blogsStatsUser.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(blogsStatsUser);
92              }
93              else {
94                  listener.onBeforeUpdate(blogsStatsUser);
95              }
96          }
97  
98          blogsStatsUser = getPersistence().update(blogsStatsUser);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(blogsStatsUser);
103             }
104             else {
105                 listener.onAfterUpdate(blogsStatsUser);
106             }
107         }
108 
109         return blogsStatsUser;
110     }
111 
112     public static com.liferay.portlet.blogs.model.BlogsStatsUser update(
113         com.liferay.portlet.blogs.model.BlogsStatsUser blogsStatsUser,
114         boolean merge) throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = blogsStatsUser.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(blogsStatsUser);
121             }
122             else {
123                 listener.onBeforeUpdate(blogsStatsUser);
124             }
125         }
126 
127         blogsStatsUser = getPersistence().update(blogsStatsUser, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(blogsStatsUser);
132             }
133             else {
134                 listener.onAfterUpdate(blogsStatsUser);
135             }
136         }
137 
138         return blogsStatsUser;
139     }
140 
141     public static com.liferay.portlet.blogs.model.BlogsStatsUser findByPrimaryKey(
142         long statsUserId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portlet.blogs.NoSuchStatsUserException {
145         return getPersistence().findByPrimaryKey(statsUserId);
146     }
147 
148     public static com.liferay.portlet.blogs.model.BlogsStatsUser 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.blogs.model.BlogsStatsUser findByGroupId_First(
170         long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portlet.blogs.NoSuchStatsUserException {
173         return getPersistence().findByGroupId_First(groupId, obc);
174     }
175 
176     public static com.liferay.portlet.blogs.model.BlogsStatsUser findByGroupId_Last(
177         long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portlet.blogs.NoSuchStatsUserException {
180         return getPersistence().findByGroupId_Last(groupId, obc);
181     }
182 
183     public static com.liferay.portlet.blogs.model.BlogsStatsUser[] 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.blogs.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.blogs.model.BlogsStatsUser findByUserId_First(
209         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
210         throws com.liferay.portal.SystemException, 
211             com.liferay.portlet.blogs.NoSuchStatsUserException {
212         return getPersistence().findByUserId_First(userId, obc);
213     }
214 
215     public static com.liferay.portlet.blogs.model.BlogsStatsUser findByUserId_Last(
216         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
217         throws com.liferay.portal.SystemException, 
218             com.liferay.portlet.blogs.NoSuchStatsUserException {
219         return getPersistence().findByUserId_Last(userId, obc);
220     }
221 
222     public static com.liferay.portlet.blogs.model.BlogsStatsUser[] 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.blogs.NoSuchStatsUserException {
227         return getPersistence().findByUserId_PrevAndNext(statsUserId, userId,
228             obc);
229     }
230 
231     public static com.liferay.portlet.blogs.model.BlogsStatsUser findByG_U(
232         long groupId, long userId)
233         throws com.liferay.portal.SystemException, 
234             com.liferay.portlet.blogs.NoSuchStatsUserException {
235         return getPersistence().findByG_U(groupId, userId);
236     }
237 
238     public static com.liferay.portlet.blogs.model.BlogsStatsUser 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_E(long groupId, int entryCount)
244         throws com.liferay.portal.SystemException {
245         return getPersistence().findByG_E(groupId, entryCount);
246     }
247 
248     public static java.util.List findByG_E(long groupId, int entryCount,
249         int begin, int end) throws com.liferay.portal.SystemException {
250         return getPersistence().findByG_E(groupId, entryCount, begin, end);
251     }
252 
253     public static java.util.List findByG_E(long groupId, int entryCount,
254         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
255         throws com.liferay.portal.SystemException {
256         return getPersistence().findByG_E(groupId, entryCount, begin, end, obc);
257     }
258 
259     public static com.liferay.portlet.blogs.model.BlogsStatsUser findByG_E_First(
260         long groupId, int entryCount,
261         com.liferay.portal.kernel.util.OrderByComparator obc)
262         throws com.liferay.portal.SystemException, 
263             com.liferay.portlet.blogs.NoSuchStatsUserException {
264         return getPersistence().findByG_E_First(groupId, entryCount, obc);
265     }
266 
267     public static com.liferay.portlet.blogs.model.BlogsStatsUser findByG_E_Last(
268         long groupId, int entryCount,
269         com.liferay.portal.kernel.util.OrderByComparator obc)
270         throws com.liferay.portal.SystemException, 
271             com.liferay.portlet.blogs.NoSuchStatsUserException {
272         return getPersistence().findByG_E_Last(groupId, entryCount, obc);
273     }
274 
275     public static com.liferay.portlet.blogs.model.BlogsStatsUser[] findByG_E_PrevAndNext(
276         long statsUserId, long groupId, int entryCount,
277         com.liferay.portal.kernel.util.OrderByComparator obc)
278         throws com.liferay.portal.SystemException, 
279             com.liferay.portlet.blogs.NoSuchStatsUserException {
280         return getPersistence().findByG_E_PrevAndNext(statsUserId, groupId,
281             entryCount, obc);
282     }
283 
284     public static java.util.List findByC_E(long companyId, int entryCount)
285         throws com.liferay.portal.SystemException {
286         return getPersistence().findByC_E(companyId, entryCount);
287     }
288 
289     public static java.util.List findByC_E(long companyId, int entryCount,
290         int begin, int end) throws com.liferay.portal.SystemException {
291         return getPersistence().findByC_E(companyId, entryCount, begin, end);
292     }
293 
294     public static java.util.List findByC_E(long companyId, int entryCount,
295         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
296         throws com.liferay.portal.SystemException {
297         return getPersistence().findByC_E(companyId, entryCount, begin, end, obc);
298     }
299 
300     public static com.liferay.portlet.blogs.model.BlogsStatsUser findByC_E_First(
301         long companyId, int entryCount,
302         com.liferay.portal.kernel.util.OrderByComparator obc)
303         throws com.liferay.portal.SystemException, 
304             com.liferay.portlet.blogs.NoSuchStatsUserException {
305         return getPersistence().findByC_E_First(companyId, entryCount, obc);
306     }
307 
308     public static com.liferay.portlet.blogs.model.BlogsStatsUser findByC_E_Last(
309         long companyId, int entryCount,
310         com.liferay.portal.kernel.util.OrderByComparator obc)
311         throws com.liferay.portal.SystemException, 
312             com.liferay.portlet.blogs.NoSuchStatsUserException {
313         return getPersistence().findByC_E_Last(companyId, entryCount, obc);
314     }
315 
316     public static com.liferay.portlet.blogs.model.BlogsStatsUser[] findByC_E_PrevAndNext(
317         long statsUserId, long companyId, int entryCount,
318         com.liferay.portal.kernel.util.OrderByComparator obc)
319         throws com.liferay.portal.SystemException, 
320             com.liferay.portlet.blogs.NoSuchStatsUserException {
321         return getPersistence().findByC_E_PrevAndNext(statsUserId, companyId,
322             entryCount, obc);
323     }
324 
325     public static java.util.List findWithDynamicQuery(
326         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
327         throws com.liferay.portal.SystemException {
328         return getPersistence().findWithDynamicQuery(queryInitializer);
329     }
330 
331     public static java.util.List findWithDynamicQuery(
332         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
333         int begin, int end) throws com.liferay.portal.SystemException {
334         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
335             end);
336     }
337 
338     public static java.util.List findAll()
339         throws com.liferay.portal.SystemException {
340         return getPersistence().findAll();
341     }
342 
343     public static java.util.List findAll(int begin, int end)
344         throws com.liferay.portal.SystemException {
345         return getPersistence().findAll(begin, end);
346     }
347 
348     public static java.util.List findAll(int begin, int end,
349         com.liferay.portal.kernel.util.OrderByComparator obc)
350         throws com.liferay.portal.SystemException {
351         return getPersistence().findAll(begin, end, obc);
352     }
353 
354     public static void removeByGroupId(long groupId)
355         throws com.liferay.portal.SystemException {
356         getPersistence().removeByGroupId(groupId);
357     }
358 
359     public static void removeByUserId(long userId)
360         throws com.liferay.portal.SystemException {
361         getPersistence().removeByUserId(userId);
362     }
363 
364     public static void removeByG_U(long groupId, long userId)
365         throws com.liferay.portal.SystemException, 
366             com.liferay.portlet.blogs.NoSuchStatsUserException {
367         getPersistence().removeByG_U(groupId, userId);
368     }
369 
370     public static void removeByG_E(long groupId, int entryCount)
371         throws com.liferay.portal.SystemException {
372         getPersistence().removeByG_E(groupId, entryCount);
373     }
374 
375     public static void removeByC_E(long companyId, int entryCount)
376         throws com.liferay.portal.SystemException {
377         getPersistence().removeByC_E(companyId, entryCount);
378     }
379 
380     public static void removeAll() throws com.liferay.portal.SystemException {
381         getPersistence().removeAll();
382     }
383 
384     public static int countByGroupId(long groupId)
385         throws com.liferay.portal.SystemException {
386         return getPersistence().countByGroupId(groupId);
387     }
388 
389     public static int countByUserId(long userId)
390         throws com.liferay.portal.SystemException {
391         return getPersistence().countByUserId(userId);
392     }
393 
394     public static int countByG_U(long groupId, long userId)
395         throws com.liferay.portal.SystemException {
396         return getPersistence().countByG_U(groupId, userId);
397     }
398 
399     public static int countByG_E(long groupId, int entryCount)
400         throws com.liferay.portal.SystemException {
401         return getPersistence().countByG_E(groupId, entryCount);
402     }
403 
404     public static int countByC_E(long companyId, int entryCount)
405         throws com.liferay.portal.SystemException {
406         return getPersistence().countByC_E(companyId, entryCount);
407     }
408 
409     public static int countAll() throws com.liferay.portal.SystemException {
410         return getPersistence().countAll();
411     }
412 
413     public static BlogsStatsUserPersistence getPersistence() {
414         return _getUtil()._persistence;
415     }
416 
417     public void setPersistence(BlogsStatsUserPersistence persistence) {
418         _persistence = persistence;
419     }
420 
421     private static BlogsStatsUserUtil _getUtil() {
422         if (_util == null) {
423             _util = (BlogsStatsUserUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
424         }
425 
426         return _util;
427     }
428 
429     private static ModelListener _getListener() {
430         if (Validator.isNotNull(_LISTENER)) {
431             try {
432                 return (ModelListener)Class.forName(_LISTENER).newInstance();
433             }
434             catch (Exception e) {
435                 _log.error(e);
436             }
437         }
438 
439         return null;
440     }
441 
442     private static final String _UTIL = BlogsStatsUserUtil.class.getName();
443     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
444                 "value.object.listener.com.liferay.portlet.blogs.model.BlogsStatsUser"));
445     private static Log _log = LogFactory.getLog(BlogsStatsUserUtil.class);
446     private static BlogsStatsUserUtil _util;
447     private BlogsStatsUserPersistence _persistence;
448 }