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