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