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