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