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