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