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