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