1
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
39 public class ShoppingCartUtil {
40 public static com.liferay.portlet.shopping.model.ShoppingCart create(
41 long cartId) {
42 return getPersistence().create(cartId);
43 }
44
45 public static com.liferay.portlet.shopping.model.ShoppingCart remove(
46 long cartId)
47 throws com.liferay.portal.SystemException,
48 com.liferay.portlet.shopping.NoSuchCartException {
49 ModelListener listener = _getListener();
50
51 if (listener != null) {
52 listener.onBeforeRemove(findByPrimaryKey(cartId));
53 }
54
55 com.liferay.portlet.shopping.model.ShoppingCart shoppingCart = getPersistence()
56 .remove(cartId);
57
58 if (listener != null) {
59 listener.onAfterRemove(shoppingCart);
60 }
61
62 return shoppingCart;
63 }
64
65 public static com.liferay.portlet.shopping.model.ShoppingCart remove(
66 com.liferay.portlet.shopping.model.ShoppingCart shoppingCart)
67 throws com.liferay.portal.SystemException {
68 ModelListener listener = _getListener();
69
70 if (listener != null) {
71 listener.onBeforeRemove(shoppingCart);
72 }
73
74 shoppingCart = getPersistence().remove(shoppingCart);
75
76 if (listener != null) {
77 listener.onAfterRemove(shoppingCart);
78 }
79
80 return shoppingCart;
81 }
82
83 public static com.liferay.portlet.shopping.model.ShoppingCart update(
84 com.liferay.portlet.shopping.model.ShoppingCart shoppingCart)
85 throws com.liferay.portal.SystemException {
86 ModelListener listener = _getListener();
87 boolean isNew = shoppingCart.isNew();
88
89 if (listener != null) {
90 if (isNew) {
91 listener.onBeforeCreate(shoppingCart);
92 }
93 else {
94 listener.onBeforeUpdate(shoppingCart);
95 }
96 }
97
98 shoppingCart = getPersistence().update(shoppingCart);
99
100 if (listener != null) {
101 if (isNew) {
102 listener.onAfterCreate(shoppingCart);
103 }
104 else {
105 listener.onAfterUpdate(shoppingCart);
106 }
107 }
108
109 return shoppingCart;
110 }
111
112 public static com.liferay.portlet.shopping.model.ShoppingCart update(
113 com.liferay.portlet.shopping.model.ShoppingCart shoppingCart,
114 boolean merge) throws com.liferay.portal.SystemException {
115 ModelListener listener = _getListener();
116 boolean isNew = shoppingCart.isNew();
117
118 if (listener != null) {
119 if (isNew) {
120 listener.onBeforeCreate(shoppingCart);
121 }
122 else {
123 listener.onBeforeUpdate(shoppingCart);
124 }
125 }
126
127 shoppingCart = getPersistence().update(shoppingCart, merge);
128
129 if (listener != null) {
130 if (isNew) {
131 listener.onAfterCreate(shoppingCart);
132 }
133 else {
134 listener.onAfterUpdate(shoppingCart);
135 }
136 }
137
138 return shoppingCart;
139 }
140
141 public static com.liferay.portlet.shopping.model.ShoppingCart findByPrimaryKey(
142 long cartId)
143 throws com.liferay.portal.SystemException,
144 com.liferay.portlet.shopping.NoSuchCartException {
145 return getPersistence().findByPrimaryKey(cartId);
146 }
147
148 public static com.liferay.portlet.shopping.model.ShoppingCart fetchByPrimaryKey(
149 long cartId) throws com.liferay.portal.SystemException {
150 return getPersistence().fetchByPrimaryKey(cartId);
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.shopping.model.ShoppingCart findByGroupId_First(
170 long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
171 throws com.liferay.portal.SystemException,
172 com.liferay.portlet.shopping.NoSuchCartException {
173 return getPersistence().findByGroupId_First(groupId, obc);
174 }
175
176 public static com.liferay.portlet.shopping.model.ShoppingCart findByGroupId_Last(
177 long groupId, com.liferay.portal.kernel.util.OrderByComparator obc)
178 throws com.liferay.portal.SystemException,
179 com.liferay.portlet.shopping.NoSuchCartException {
180 return getPersistence().findByGroupId_Last(groupId, obc);
181 }
182
183 public static com.liferay.portlet.shopping.model.ShoppingCart[] findByGroupId_PrevAndNext(
184 long cartId, long groupId,
185 com.liferay.portal.kernel.util.OrderByComparator obc)
186 throws com.liferay.portal.SystemException,
187 com.liferay.portlet.shopping.NoSuchCartException {
188 return getPersistence().findByGroupId_PrevAndNext(cartId, groupId, obc);
189 }
190
191 public static java.util.List findByUserId(long userId)
192 throws com.liferay.portal.SystemException {
193 return getPersistence().findByUserId(userId);
194 }
195
196 public static java.util.List findByUserId(long userId, int begin, int end)
197 throws com.liferay.portal.SystemException {
198 return getPersistence().findByUserId(userId, begin, end);
199 }
200
201 public static java.util.List findByUserId(long userId, int begin, int end,
202 com.liferay.portal.kernel.util.OrderByComparator obc)
203 throws com.liferay.portal.SystemException {
204 return getPersistence().findByUserId(userId, begin, end, obc);
205 }
206
207 public static com.liferay.portlet.shopping.model.ShoppingCart findByUserId_First(
208 long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
209 throws com.liferay.portal.SystemException,
210 com.liferay.portlet.shopping.NoSuchCartException {
211 return getPersistence().findByUserId_First(userId, obc);
212 }
213
214 public static com.liferay.portlet.shopping.model.ShoppingCart findByUserId_Last(
215 long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
216 throws com.liferay.portal.SystemException,
217 com.liferay.portlet.shopping.NoSuchCartException {
218 return getPersistence().findByUserId_Last(userId, obc);
219 }
220
221 public static com.liferay.portlet.shopping.model.ShoppingCart[] findByUserId_PrevAndNext(
222 long cartId, long userId,
223 com.liferay.portal.kernel.util.OrderByComparator obc)
224 throws com.liferay.portal.SystemException,
225 com.liferay.portlet.shopping.NoSuchCartException {
226 return getPersistence().findByUserId_PrevAndNext(cartId, userId, obc);
227 }
228
229 public static com.liferay.portlet.shopping.model.ShoppingCart findByG_U(
230 long groupId, long userId)
231 throws com.liferay.portal.SystemException,
232 com.liferay.portlet.shopping.NoSuchCartException {
233 return getPersistence().findByG_U(groupId, userId);
234 }
235
236 public static com.liferay.portlet.shopping.model.ShoppingCart fetchByG_U(
237 long groupId, long userId) throws com.liferay.portal.SystemException {
238 return getPersistence().fetchByG_U(groupId, userId);
239 }
240
241 public static java.util.List findWithDynamicQuery(
242 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
243 throws com.liferay.portal.SystemException {
244 return getPersistence().findWithDynamicQuery(queryInitializer);
245 }
246
247 public static java.util.List findWithDynamicQuery(
248 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
249 int begin, int end) throws com.liferay.portal.SystemException {
250 return getPersistence().findWithDynamicQuery(queryInitializer, begin,
251 end);
252 }
253
254 public static java.util.List findAll()
255 throws com.liferay.portal.SystemException {
256 return getPersistence().findAll();
257 }
258
259 public static java.util.List findAll(int begin, int end)
260 throws com.liferay.portal.SystemException {
261 return getPersistence().findAll(begin, end);
262 }
263
264 public static java.util.List findAll(int begin, int end,
265 com.liferay.portal.kernel.util.OrderByComparator obc)
266 throws com.liferay.portal.SystemException {
267 return getPersistence().findAll(begin, end, obc);
268 }
269
270 public static void removeByGroupId(long groupId)
271 throws com.liferay.portal.SystemException {
272 getPersistence().removeByGroupId(groupId);
273 }
274
275 public static void removeByUserId(long userId)
276 throws com.liferay.portal.SystemException {
277 getPersistence().removeByUserId(userId);
278 }
279
280 public static void removeByG_U(long groupId, long userId)
281 throws com.liferay.portal.SystemException,
282 com.liferay.portlet.shopping.NoSuchCartException {
283 getPersistence().removeByG_U(groupId, userId);
284 }
285
286 public static void removeAll() throws com.liferay.portal.SystemException {
287 getPersistence().removeAll();
288 }
289
290 public static int countByGroupId(long groupId)
291 throws com.liferay.portal.SystemException {
292 return getPersistence().countByGroupId(groupId);
293 }
294
295 public static int countByUserId(long userId)
296 throws com.liferay.portal.SystemException {
297 return getPersistence().countByUserId(userId);
298 }
299
300 public static int countByG_U(long groupId, long userId)
301 throws com.liferay.portal.SystemException {
302 return getPersistence().countByG_U(groupId, userId);
303 }
304
305 public static int countAll() throws com.liferay.portal.SystemException {
306 return getPersistence().countAll();
307 }
308
309 public static ShoppingCartPersistence getPersistence() {
310 return _getUtil()._persistence;
311 }
312
313 public void setPersistence(ShoppingCartPersistence persistence) {
314 _persistence = persistence;
315 }
316
317 private static ShoppingCartUtil _getUtil() {
318 if (_util == null) {
319 _util = (ShoppingCartUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
320 }
321
322 return _util;
323 }
324
325 private static ModelListener _getListener() {
326 if (Validator.isNotNull(_LISTENER)) {
327 try {
328 return (ModelListener)Class.forName(_LISTENER).newInstance();
329 }
330 catch (Exception e) {
331 _log.error(e);
332 }
333 }
334
335 return null;
336 }
337
338 private static final String _UTIL = ShoppingCartUtil.class.getName();
339 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
340 "value.object.listener.com.liferay.portlet.shopping.model.ShoppingCart"));
341 private static Log _log = LogFactory.getLog(ShoppingCartUtil.class);
342 private static ShoppingCartUtil _util;
343 private ShoppingCartPersistence _persistence;
344 }