1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.messageboards.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  /**
34   * <a href="MBMessageFlagUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class MBMessageFlagUtil {
40      public static com.liferay.portlet.messageboards.model.MBMessageFlag create(
41          long messageFlagId) {
42          return getPersistence().create(messageFlagId);
43      }
44  
45      public static com.liferay.portlet.messageboards.model.MBMessageFlag remove(
46          long messageFlagId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portlet.messageboards.NoSuchMessageFlagException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(messageFlagId));
53          }
54  
55          com.liferay.portlet.messageboards.model.MBMessageFlag mbMessageFlag = getPersistence()
56                                                                                    .remove(messageFlagId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(mbMessageFlag);
60          }
61  
62          return mbMessageFlag;
63      }
64  
65      public static com.liferay.portlet.messageboards.model.MBMessageFlag remove(
66          com.liferay.portlet.messageboards.model.MBMessageFlag mbMessageFlag)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(mbMessageFlag);
72          }
73  
74          mbMessageFlag = getPersistence().remove(mbMessageFlag);
75  
76          if (listener != null) {
77              listener.onAfterRemove(mbMessageFlag);
78          }
79  
80          return mbMessageFlag;
81      }
82  
83      public static com.liferay.portlet.messageboards.model.MBMessageFlag update(
84          com.liferay.portlet.messageboards.model.MBMessageFlag mbMessageFlag)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = mbMessageFlag.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(mbMessageFlag);
92              }
93              else {
94                  listener.onBeforeUpdate(mbMessageFlag);
95              }
96          }
97  
98          mbMessageFlag = getPersistence().update(mbMessageFlag);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(mbMessageFlag);
103             }
104             else {
105                 listener.onAfterUpdate(mbMessageFlag);
106             }
107         }
108 
109         return mbMessageFlag;
110     }
111 
112     public static com.liferay.portlet.messageboards.model.MBMessageFlag update(
113         com.liferay.portlet.messageboards.model.MBMessageFlag mbMessageFlag,
114         boolean merge) throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = mbMessageFlag.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(mbMessageFlag);
121             }
122             else {
123                 listener.onBeforeUpdate(mbMessageFlag);
124             }
125         }
126 
127         mbMessageFlag = getPersistence().update(mbMessageFlag, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(mbMessageFlag);
132             }
133             else {
134                 listener.onAfterUpdate(mbMessageFlag);
135             }
136         }
137 
138         return mbMessageFlag;
139     }
140 
141     public static com.liferay.portlet.messageboards.model.MBMessageFlag findByPrimaryKey(
142         long messageFlagId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
145         return getPersistence().findByPrimaryKey(messageFlagId);
146     }
147 
148     public static com.liferay.portlet.messageboards.model.MBMessageFlag fetchByPrimaryKey(
149         long messageFlagId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(messageFlagId);
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.portlet.messageboards.model.MBMessageFlag findByUserId_First(
170         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
173         return getPersistence().findByUserId_First(userId, obc);
174     }
175 
176     public static com.liferay.portlet.messageboards.model.MBMessageFlag findByUserId_Last(
177         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
180         return getPersistence().findByUserId_Last(userId, obc);
181     }
182 
183     public static com.liferay.portlet.messageboards.model.MBMessageFlag[] findByUserId_PrevAndNext(
184         long messageFlagId, long userId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
188         return getPersistence().findByUserId_PrevAndNext(messageFlagId, userId,
189             obc);
190     }
191 
192     public static java.util.List findByMessageId(long messageId)
193         throws com.liferay.portal.SystemException {
194         return getPersistence().findByMessageId(messageId);
195     }
196 
197     public static java.util.List findByMessageId(long messageId, int begin,
198         int end) throws com.liferay.portal.SystemException {
199         return getPersistence().findByMessageId(messageId, begin, end);
200     }
201 
202     public static java.util.List findByMessageId(long messageId, int begin,
203         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
204         throws com.liferay.portal.SystemException {
205         return getPersistence().findByMessageId(messageId, begin, end, obc);
206     }
207 
208     public static com.liferay.portlet.messageboards.model.MBMessageFlag findByMessageId_First(
209         long messageId, com.liferay.portal.kernel.util.OrderByComparator obc)
210         throws com.liferay.portal.SystemException, 
211             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
212         return getPersistence().findByMessageId_First(messageId, obc);
213     }
214 
215     public static com.liferay.portlet.messageboards.model.MBMessageFlag findByMessageId_Last(
216         long messageId, com.liferay.portal.kernel.util.OrderByComparator obc)
217         throws com.liferay.portal.SystemException, 
218             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
219         return getPersistence().findByMessageId_Last(messageId, obc);
220     }
221 
222     public static com.liferay.portlet.messageboards.model.MBMessageFlag[] findByMessageId_PrevAndNext(
223         long messageFlagId, long messageId,
224         com.liferay.portal.kernel.util.OrderByComparator obc)
225         throws com.liferay.portal.SystemException, 
226             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
227         return getPersistence().findByMessageId_PrevAndNext(messageFlagId,
228             messageId, obc);
229     }
230 
231     public static com.liferay.portlet.messageboards.model.MBMessageFlag findByU_M(
232         long userId, long messageId)
233         throws com.liferay.portal.SystemException, 
234             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
235         return getPersistence().findByU_M(userId, messageId);
236     }
237 
238     public static com.liferay.portlet.messageboards.model.MBMessageFlag fetchByU_M(
239         long userId, long messageId) throws com.liferay.portal.SystemException {
240         return getPersistence().fetchByU_M(userId, messageId);
241     }
242 
243     public static java.util.List findWithDynamicQuery(
244         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
245         throws com.liferay.portal.SystemException {
246         return getPersistence().findWithDynamicQuery(queryInitializer);
247     }
248 
249     public static java.util.List findWithDynamicQuery(
250         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
251         int begin, int end) throws com.liferay.portal.SystemException {
252         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
253             end);
254     }
255 
256     public static java.util.List findAll()
257         throws com.liferay.portal.SystemException {
258         return getPersistence().findAll();
259     }
260 
261     public static java.util.List findAll(int begin, int end)
262         throws com.liferay.portal.SystemException {
263         return getPersistence().findAll(begin, end);
264     }
265 
266     public static java.util.List findAll(int begin, int end,
267         com.liferay.portal.kernel.util.OrderByComparator obc)
268         throws com.liferay.portal.SystemException {
269         return getPersistence().findAll(begin, end, obc);
270     }
271 
272     public static void removeByUserId(long userId)
273         throws com.liferay.portal.SystemException {
274         getPersistence().removeByUserId(userId);
275     }
276 
277     public static void removeByMessageId(long messageId)
278         throws com.liferay.portal.SystemException {
279         getPersistence().removeByMessageId(messageId);
280     }
281 
282     public static void removeByU_M(long userId, long messageId)
283         throws com.liferay.portal.SystemException, 
284             com.liferay.portlet.messageboards.NoSuchMessageFlagException {
285         getPersistence().removeByU_M(userId, messageId);
286     }
287 
288     public static void removeAll() throws com.liferay.portal.SystemException {
289         getPersistence().removeAll();
290     }
291 
292     public static int countByUserId(long userId)
293         throws com.liferay.portal.SystemException {
294         return getPersistence().countByUserId(userId);
295     }
296 
297     public static int countByMessageId(long messageId)
298         throws com.liferay.portal.SystemException {
299         return getPersistence().countByMessageId(messageId);
300     }
301 
302     public static int countByU_M(long userId, long messageId)
303         throws com.liferay.portal.SystemException {
304         return getPersistence().countByU_M(userId, messageId);
305     }
306 
307     public static int countAll() throws com.liferay.portal.SystemException {
308         return getPersistence().countAll();
309     }
310 
311     public static MBMessageFlagPersistence getPersistence() {
312         return _getUtil()._persistence;
313     }
314 
315     public void setPersistence(MBMessageFlagPersistence persistence) {
316         _persistence = persistence;
317     }
318 
319     private static MBMessageFlagUtil _getUtil() {
320         if (_util == null) {
321             _util = (MBMessageFlagUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
322         }
323 
324         return _util;
325     }
326 
327     private static ModelListener _getListener() {
328         if (Validator.isNotNull(_LISTENER)) {
329             try {
330                 return (ModelListener)Class.forName(_LISTENER).newInstance();
331             }
332             catch (Exception e) {
333                 _log.error(e);
334             }
335         }
336 
337         return null;
338     }
339 
340     private static final String _UTIL = MBMessageFlagUtil.class.getName();
341     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
342                 "value.object.listener.com.liferay.portlet.messageboards.model.MBMessageFlag"));
343     private static Log _log = LogFactory.getLog(MBMessageFlagUtil.class);
344     private static MBMessageFlagUtil _util;
345     private MBMessageFlagPersistence _persistence;
346 }