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