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="BlogsEntryUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class BlogsEntryUtil {
40      public static com.liferay.portlet.blogs.model.BlogsEntry create(
41          long entryId) {
42          return getPersistence().create(entryId);
43      }
44  
45      public static com.liferay.portlet.blogs.model.BlogsEntry remove(
46          long entryId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portlet.blogs.NoSuchEntryException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(entryId));
53          }
54  
55          com.liferay.portlet.blogs.model.BlogsEntry blogsEntry = getPersistence()
56                                                                      .remove(entryId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(blogsEntry);
60          }
61  
62          return blogsEntry;
63      }
64  
65      public static com.liferay.portlet.blogs.model.BlogsEntry remove(
66          com.liferay.portlet.blogs.model.BlogsEntry blogsEntry)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(blogsEntry);
72          }
73  
74          blogsEntry = getPersistence().remove(blogsEntry);
75  
76          if (listener != null) {
77              listener.onAfterRemove(blogsEntry);
78          }
79  
80          return blogsEntry;
81      }
82  
83      public static com.liferay.portlet.blogs.model.BlogsEntry update(
84          com.liferay.portlet.blogs.model.BlogsEntry blogsEntry)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = blogsEntry.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(blogsEntry);
92              }
93              else {
94                  listener.onBeforeUpdate(blogsEntry);
95              }
96          }
97  
98          blogsEntry = getPersistence().update(blogsEntry);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(blogsEntry);
103             }
104             else {
105                 listener.onAfterUpdate(blogsEntry);
106             }
107         }
108 
109         return blogsEntry;
110     }
111 
112     public static com.liferay.portlet.blogs.model.BlogsEntry update(
113         com.liferay.portlet.blogs.model.BlogsEntry blogsEntry, boolean merge)
114         throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = blogsEntry.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(blogsEntry);
121             }
122             else {
123                 listener.onBeforeUpdate(blogsEntry);
124             }
125         }
126 
127         blogsEntry = getPersistence().update(blogsEntry, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(blogsEntry);
132             }
133             else {
134                 listener.onAfterUpdate(blogsEntry);
135             }
136         }
137 
138         return blogsEntry;
139     }
140 
141     public static com.liferay.portlet.blogs.model.BlogsEntry findByPrimaryKey(
142         long entryId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portlet.blogs.NoSuchEntryException {
145         return getPersistence().findByPrimaryKey(entryId);
146     }
147 
148     public static com.liferay.portlet.blogs.model.BlogsEntry fetchByPrimaryKey(
149         long entryId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(entryId);
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.BlogsEntry findByGroupId_First(
170         long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portlet.blogs.NoSuchEntryException {
173         return getPersistence().findByGroupId_First(groupId, obc);
174     }
175 
176     public static com.liferay.portlet.blogs.model.BlogsEntry findByGroupId_Last(
177         long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portlet.blogs.NoSuchEntryException {
180         return getPersistence().findByGroupId_Last(groupId, obc);
181     }
182 
183     public static com.liferay.portlet.blogs.model.BlogsEntry[] findByGroupId_PrevAndNext(
184         long entryId, long groupId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portlet.blogs.NoSuchEntryException {
188         return getPersistence().findByGroupId_PrevAndNext(entryId, groupId, obc);
189     }
190 
191     public static java.util.List findByCompanyId(long companyId)
192         throws com.liferay.portal.SystemException {
193         return getPersistence().findByCompanyId(companyId);
194     }
195 
196     public static java.util.List findByCompanyId(long companyId, int begin,
197         int end) throws com.liferay.portal.SystemException {
198         return getPersistence().findByCompanyId(companyId, begin, end);
199     }
200 
201     public static java.util.List findByCompanyId(long companyId, int begin,
202         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
203         throws com.liferay.portal.SystemException {
204         return getPersistence().findByCompanyId(companyId, begin, end, obc);
205     }
206 
207     public static com.liferay.portlet.blogs.model.BlogsEntry findByCompanyId_First(
208         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
209         throws com.liferay.portal.SystemException, 
210             com.liferay.portlet.blogs.NoSuchEntryException {
211         return getPersistence().findByCompanyId_First(companyId, obc);
212     }
213 
214     public static com.liferay.portlet.blogs.model.BlogsEntry findByCompanyId_Last(
215         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
216         throws com.liferay.portal.SystemException, 
217             com.liferay.portlet.blogs.NoSuchEntryException {
218         return getPersistence().findByCompanyId_Last(companyId, obc);
219     }
220 
221     public static com.liferay.portlet.blogs.model.BlogsEntry[] findByCompanyId_PrevAndNext(
222         long entryId, long companyId,
223         com.liferay.portal.kernel.util.OrderByComparator obc)
224         throws com.liferay.portal.SystemException, 
225             com.liferay.portlet.blogs.NoSuchEntryException {
226         return getPersistence().findByCompanyId_PrevAndNext(entryId, companyId,
227             obc);
228     }
229 
230     public static java.util.List findByCategoryId(long categoryId)
231         throws com.liferay.portal.SystemException {
232         return getPersistence().findByCategoryId(categoryId);
233     }
234 
235     public static java.util.List findByCategoryId(long categoryId, int begin,
236         int end) throws com.liferay.portal.SystemException {
237         return getPersistence().findByCategoryId(categoryId, begin, end);
238     }
239 
240     public static java.util.List findByCategoryId(long categoryId, int begin,
241         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
242         throws com.liferay.portal.SystemException {
243         return getPersistence().findByCategoryId(categoryId, begin, end, obc);
244     }
245 
246     public static com.liferay.portlet.blogs.model.BlogsEntry findByCategoryId_First(
247         long categoryId, com.liferay.portal.kernel.util.OrderByComparator obc)
248         throws com.liferay.portal.SystemException, 
249             com.liferay.portlet.blogs.NoSuchEntryException {
250         return getPersistence().findByCategoryId_First(categoryId, obc);
251     }
252 
253     public static com.liferay.portlet.blogs.model.BlogsEntry findByCategoryId_Last(
254         long categoryId, com.liferay.portal.kernel.util.OrderByComparator obc)
255         throws com.liferay.portal.SystemException, 
256             com.liferay.portlet.blogs.NoSuchEntryException {
257         return getPersistence().findByCategoryId_Last(categoryId, obc);
258     }
259 
260     public static com.liferay.portlet.blogs.model.BlogsEntry[] findByCategoryId_PrevAndNext(
261         long entryId, long categoryId,
262         com.liferay.portal.kernel.util.OrderByComparator obc)
263         throws com.liferay.portal.SystemException, 
264             com.liferay.portlet.blogs.NoSuchEntryException {
265         return getPersistence().findByCategoryId_PrevAndNext(entryId,
266             categoryId, obc);
267     }
268 
269     public static java.util.List findByG_U(long groupId, long userId)
270         throws com.liferay.portal.SystemException {
271         return getPersistence().findByG_U(groupId, userId);
272     }
273 
274     public static java.util.List findByG_U(long groupId, long userId,
275         int begin, int end) throws com.liferay.portal.SystemException {
276         return getPersistence().findByG_U(groupId, userId, begin, end);
277     }
278 
279     public static java.util.List findByG_U(long groupId, long userId,
280         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
281         throws com.liferay.portal.SystemException {
282         return getPersistence().findByG_U(groupId, userId, begin, end, obc);
283     }
284 
285     public static com.liferay.portlet.blogs.model.BlogsEntry findByG_U_First(
286         long groupId, long userId,
287         com.liferay.portal.kernel.util.OrderByComparator obc)
288         throws com.liferay.portal.SystemException, 
289             com.liferay.portlet.blogs.NoSuchEntryException {
290         return getPersistence().findByG_U_First(groupId, userId, obc);
291     }
292 
293     public static com.liferay.portlet.blogs.model.BlogsEntry findByG_U_Last(
294         long groupId, long userId,
295         com.liferay.portal.kernel.util.OrderByComparator obc)
296         throws com.liferay.portal.SystemException, 
297             com.liferay.portlet.blogs.NoSuchEntryException {
298         return getPersistence().findByG_U_Last(groupId, userId, obc);
299     }
300 
301     public static com.liferay.portlet.blogs.model.BlogsEntry[] findByG_U_PrevAndNext(
302         long entryId, long groupId, long userId,
303         com.liferay.portal.kernel.util.OrderByComparator obc)
304         throws com.liferay.portal.SystemException, 
305             com.liferay.portlet.blogs.NoSuchEntryException {
306         return getPersistence().findByG_U_PrevAndNext(entryId, groupId, userId,
307             obc);
308     }
309 
310     public static com.liferay.portlet.blogs.model.BlogsEntry findByG_UT(
311         long groupId, java.lang.String urlTitle)
312         throws com.liferay.portal.SystemException, 
313             com.liferay.portlet.blogs.NoSuchEntryException {
314         return getPersistence().findByG_UT(groupId, urlTitle);
315     }
316 
317     public static com.liferay.portlet.blogs.model.BlogsEntry fetchByG_UT(
318         long groupId, java.lang.String urlTitle)
319         throws com.liferay.portal.SystemException {
320         return getPersistence().fetchByG_UT(groupId, urlTitle);
321     }
322 
323     public static java.util.List findByC_U(long companyId, long userId)
324         throws com.liferay.portal.SystemException {
325         return getPersistence().findByC_U(companyId, userId);
326     }
327 
328     public static java.util.List findByC_U(long companyId, long userId,
329         int begin, int end) throws com.liferay.portal.SystemException {
330         return getPersistence().findByC_U(companyId, userId, begin, end);
331     }
332 
333     public static java.util.List findByC_U(long companyId, long userId,
334         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
335         throws com.liferay.portal.SystemException {
336         return getPersistence().findByC_U(companyId, userId, begin, end, obc);
337     }
338 
339     public static com.liferay.portlet.blogs.model.BlogsEntry findByC_U_First(
340         long companyId, long userId,
341         com.liferay.portal.kernel.util.OrderByComparator obc)
342         throws com.liferay.portal.SystemException, 
343             com.liferay.portlet.blogs.NoSuchEntryException {
344         return getPersistence().findByC_U_First(companyId, userId, obc);
345     }
346 
347     public static com.liferay.portlet.blogs.model.BlogsEntry findByC_U_Last(
348         long companyId, long userId,
349         com.liferay.portal.kernel.util.OrderByComparator obc)
350         throws com.liferay.portal.SystemException, 
351             com.liferay.portlet.blogs.NoSuchEntryException {
352         return getPersistence().findByC_U_Last(companyId, userId, obc);
353     }
354 
355     public static com.liferay.portlet.blogs.model.BlogsEntry[] findByC_U_PrevAndNext(
356         long entryId, long companyId, long userId,
357         com.liferay.portal.kernel.util.OrderByComparator obc)
358         throws com.liferay.portal.SystemException, 
359             com.liferay.portlet.blogs.NoSuchEntryException {
360         return getPersistence().findByC_U_PrevAndNext(entryId, companyId,
361             userId, obc);
362     }
363 
364     public static java.util.List findWithDynamicQuery(
365         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
366         throws com.liferay.portal.SystemException {
367         return getPersistence().findWithDynamicQuery(queryInitializer);
368     }
369 
370     public static java.util.List findWithDynamicQuery(
371         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
372         int begin, int end) throws com.liferay.portal.SystemException {
373         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
374             end);
375     }
376 
377     public static java.util.List findAll()
378         throws com.liferay.portal.SystemException {
379         return getPersistence().findAll();
380     }
381 
382     public static java.util.List findAll(int begin, int end)
383         throws com.liferay.portal.SystemException {
384         return getPersistence().findAll(begin, end);
385     }
386 
387     public static java.util.List findAll(int begin, int end,
388         com.liferay.portal.kernel.util.OrderByComparator obc)
389         throws com.liferay.portal.SystemException {
390         return getPersistence().findAll(begin, end, obc);
391     }
392 
393     public static void removeByGroupId(long groupId)
394         throws com.liferay.portal.SystemException {
395         getPersistence().removeByGroupId(groupId);
396     }
397 
398     public static void removeByCompanyId(long companyId)
399         throws com.liferay.portal.SystemException {
400         getPersistence().removeByCompanyId(companyId);
401     }
402 
403     public static void removeByCategoryId(long categoryId)
404         throws com.liferay.portal.SystemException {
405         getPersistence().removeByCategoryId(categoryId);
406     }
407 
408     public static void removeByG_U(long groupId, long userId)
409         throws com.liferay.portal.SystemException {
410         getPersistence().removeByG_U(groupId, userId);
411     }
412 
413     public static void removeByG_UT(long groupId, java.lang.String urlTitle)
414         throws com.liferay.portal.SystemException, 
415             com.liferay.portlet.blogs.NoSuchEntryException {
416         getPersistence().removeByG_UT(groupId, urlTitle);
417     }
418 
419     public static void removeByC_U(long companyId, long userId)
420         throws com.liferay.portal.SystemException {
421         getPersistence().removeByC_U(companyId, userId);
422     }
423 
424     public static void removeAll() throws com.liferay.portal.SystemException {
425         getPersistence().removeAll();
426     }
427 
428     public static int countByGroupId(long groupId)
429         throws com.liferay.portal.SystemException {
430         return getPersistence().countByGroupId(groupId);
431     }
432 
433     public static int countByCompanyId(long companyId)
434         throws com.liferay.portal.SystemException {
435         return getPersistence().countByCompanyId(companyId);
436     }
437 
438     public static int countByCategoryId(long categoryId)
439         throws com.liferay.portal.SystemException {
440         return getPersistence().countByCategoryId(categoryId);
441     }
442 
443     public static int countByG_U(long groupId, long userId)
444         throws com.liferay.portal.SystemException {
445         return getPersistence().countByG_U(groupId, userId);
446     }
447 
448     public static int countByG_UT(long groupId, java.lang.String urlTitle)
449         throws com.liferay.portal.SystemException {
450         return getPersistence().countByG_UT(groupId, urlTitle);
451     }
452 
453     public static int countByC_U(long companyId, long userId)
454         throws com.liferay.portal.SystemException {
455         return getPersistence().countByC_U(companyId, userId);
456     }
457 
458     public static int countAll() throws com.liferay.portal.SystemException {
459         return getPersistence().countAll();
460     }
461 
462     public static BlogsEntryPersistence getPersistence() {
463         return _getUtil()._persistence;
464     }
465 
466     public void setPersistence(BlogsEntryPersistence persistence) {
467         _persistence = persistence;
468     }
469 
470     private static BlogsEntryUtil _getUtil() {
471         if (_util == null) {
472             _util = (BlogsEntryUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
473         }
474 
475         return _util;
476     }
477 
478     private static ModelListener _getListener() {
479         if (Validator.isNotNull(_LISTENER)) {
480             try {
481                 return (ModelListener)Class.forName(_LISTENER).newInstance();
482             }
483             catch (Exception e) {
484                 _log.error(e);
485             }
486         }
487 
488         return null;
489     }
490 
491     private static final String _UTIL = BlogsEntryUtil.class.getName();
492     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
493                 "value.object.listener.com.liferay.portlet.blogs.model.BlogsEntry"));
494     private static Log _log = LogFactory.getLog(BlogsEntryUtil.class);
495     private static BlogsEntryUtil _util;
496     private BlogsEntryPersistence _persistence;
497 }