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.softwarecatalog.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="SCProductScreenshotUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class SCProductScreenshotUtil {
40      public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot create(
41          long productScreenshotId) {
42          return getPersistence().create(productScreenshotId);
43      }
44  
45      public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot remove(
46          long productScreenshotId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(productScreenshotId));
53          }
54  
55          com.liferay.portlet.softwarecatalog.model.SCProductScreenshot scProductScreenshot =
56              getPersistence().remove(productScreenshotId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(scProductScreenshot);
60          }
61  
62          return scProductScreenshot;
63      }
64  
65      public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot remove(
66          com.liferay.portlet.softwarecatalog.model.SCProductScreenshot scProductScreenshot)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(scProductScreenshot);
72          }
73  
74          scProductScreenshot = getPersistence().remove(scProductScreenshot);
75  
76          if (listener != null) {
77              listener.onAfterRemove(scProductScreenshot);
78          }
79  
80          return scProductScreenshot;
81      }
82  
83      public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot update(
84          com.liferay.portlet.softwarecatalog.model.SCProductScreenshot scProductScreenshot)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = scProductScreenshot.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(scProductScreenshot);
92              }
93              else {
94                  listener.onBeforeUpdate(scProductScreenshot);
95              }
96          }
97  
98          scProductScreenshot = getPersistence().update(scProductScreenshot);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(scProductScreenshot);
103             }
104             else {
105                 listener.onAfterUpdate(scProductScreenshot);
106             }
107         }
108 
109         return scProductScreenshot;
110     }
111 
112     public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot update(
113         com.liferay.portlet.softwarecatalog.model.SCProductScreenshot scProductScreenshot,
114         boolean merge) throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = scProductScreenshot.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(scProductScreenshot);
121             }
122             else {
123                 listener.onBeforeUpdate(scProductScreenshot);
124             }
125         }
126 
127         scProductScreenshot = getPersistence().update(scProductScreenshot, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(scProductScreenshot);
132             }
133             else {
134                 listener.onAfterUpdate(scProductScreenshot);
135             }
136         }
137 
138         return scProductScreenshot;
139     }
140 
141     public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot findByPrimaryKey(
142         long productScreenshotId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException {
145         return getPersistence().findByPrimaryKey(productScreenshotId);
146     }
147 
148     public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot fetchByPrimaryKey(
149         long productScreenshotId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(productScreenshotId);
151     }
152 
153     public static java.util.List findByProductEntryId(long productEntryId)
154         throws com.liferay.portal.SystemException {
155         return getPersistence().findByProductEntryId(productEntryId);
156     }
157 
158     public static java.util.List findByProductEntryId(long productEntryId,
159         int begin, int end) throws com.liferay.portal.SystemException {
160         return getPersistence().findByProductEntryId(productEntryId, begin, end);
161     }
162 
163     public static java.util.List findByProductEntryId(long productEntryId,
164         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
165         throws com.liferay.portal.SystemException {
166         return getPersistence().findByProductEntryId(productEntryId, begin,
167             end, obc);
168     }
169 
170     public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot findByProductEntryId_First(
171         long productEntryId,
172         com.liferay.portal.kernel.util.OrderByComparator obc)
173         throws com.liferay.portal.SystemException, 
174             com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException {
175         return getPersistence().findByProductEntryId_First(productEntryId, obc);
176     }
177 
178     public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot findByProductEntryId_Last(
179         long productEntryId,
180         com.liferay.portal.kernel.util.OrderByComparator obc)
181         throws com.liferay.portal.SystemException, 
182             com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException {
183         return getPersistence().findByProductEntryId_Last(productEntryId, obc);
184     }
185 
186     public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot[] findByProductEntryId_PrevAndNext(
187         long productScreenshotId, long productEntryId,
188         com.liferay.portal.kernel.util.OrderByComparator obc)
189         throws com.liferay.portal.SystemException, 
190             com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException {
191         return getPersistence().findByProductEntryId_PrevAndNext(productScreenshotId,
192             productEntryId, obc);
193     }
194 
195     public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot findByP_P(
196         long productEntryId, int priority)
197         throws com.liferay.portal.SystemException, 
198             com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException {
199         return getPersistence().findByP_P(productEntryId, priority);
200     }
201 
202     public static com.liferay.portlet.softwarecatalog.model.SCProductScreenshot fetchByP_P(
203         long productEntryId, int priority)
204         throws com.liferay.portal.SystemException {
205         return getPersistence().fetchByP_P(productEntryId, priority);
206     }
207 
208     public static java.util.List findWithDynamicQuery(
209         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
210         throws com.liferay.portal.SystemException {
211         return getPersistence().findWithDynamicQuery(queryInitializer);
212     }
213 
214     public static java.util.List findWithDynamicQuery(
215         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
216         int begin, int end) throws com.liferay.portal.SystemException {
217         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
218             end);
219     }
220 
221     public static java.util.List findAll()
222         throws com.liferay.portal.SystemException {
223         return getPersistence().findAll();
224     }
225 
226     public static java.util.List findAll(int begin, int end)
227         throws com.liferay.portal.SystemException {
228         return getPersistence().findAll(begin, end);
229     }
230 
231     public static java.util.List findAll(int begin, int end,
232         com.liferay.portal.kernel.util.OrderByComparator obc)
233         throws com.liferay.portal.SystemException {
234         return getPersistence().findAll(begin, end, obc);
235     }
236 
237     public static void removeByProductEntryId(long productEntryId)
238         throws com.liferay.portal.SystemException {
239         getPersistence().removeByProductEntryId(productEntryId);
240     }
241 
242     public static void removeByP_P(long productEntryId, int priority)
243         throws com.liferay.portal.SystemException, 
244             com.liferay.portlet.softwarecatalog.NoSuchProductScreenshotException {
245         getPersistence().removeByP_P(productEntryId, priority);
246     }
247 
248     public static void removeAll() throws com.liferay.portal.SystemException {
249         getPersistence().removeAll();
250     }
251 
252     public static int countByProductEntryId(long productEntryId)
253         throws com.liferay.portal.SystemException {
254         return getPersistence().countByProductEntryId(productEntryId);
255     }
256 
257     public static int countByP_P(long productEntryId, int priority)
258         throws com.liferay.portal.SystemException {
259         return getPersistence().countByP_P(productEntryId, priority);
260     }
261 
262     public static int countAll() throws com.liferay.portal.SystemException {
263         return getPersistence().countAll();
264     }
265 
266     public static SCProductScreenshotPersistence getPersistence() {
267         return _getUtil()._persistence;
268     }
269 
270     public void setPersistence(SCProductScreenshotPersistence persistence) {
271         _persistence = persistence;
272     }
273 
274     private static SCProductScreenshotUtil _getUtil() {
275         if (_util == null) {
276             _util = (SCProductScreenshotUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
277         }
278 
279         return _util;
280     }
281 
282     private static ModelListener _getListener() {
283         if (Validator.isNotNull(_LISTENER)) {
284             try {
285                 return (ModelListener)Class.forName(_LISTENER).newInstance();
286             }
287             catch (Exception e) {
288                 _log.error(e);
289             }
290         }
291 
292         return null;
293     }
294 
295     private static final String _UTIL = SCProductScreenshotUtil.class.getName();
296     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
297                 "value.object.listener.com.liferay.portlet.softwarecatalog.model.SCProductScreenshot"));
298     private static Log _log = LogFactory.getLog(SCProductScreenshotUtil.class);
299     private static SCProductScreenshotUtil _util;
300     private SCProductScreenshotPersistence _persistence;
301 }