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