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