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.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  /**
34   * <a href="PhoneUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class PhoneUtil {
40      public static com.liferay.portal.model.Phone create(long phoneId) {
41          return getPersistence().create(phoneId);
42      }
43  
44      public static com.liferay.portal.model.Phone remove(long phoneId)
45          throws com.liferay.portal.SystemException, 
46              com.liferay.portal.NoSuchPhoneException {
47          ModelListener listener = _getListener();
48  
49          if (listener != null) {
50              listener.onBeforeRemove(findByPrimaryKey(phoneId));
51          }
52  
53          com.liferay.portal.model.Phone phone = getPersistence().remove(phoneId);
54  
55          if (listener != null) {
56              listener.onAfterRemove(phone);
57          }
58  
59          return phone;
60      }
61  
62      public static com.liferay.portal.model.Phone remove(
63          com.liferay.portal.model.Phone phone)
64          throws com.liferay.portal.SystemException {
65          ModelListener listener = _getListener();
66  
67          if (listener != null) {
68              listener.onBeforeRemove(phone);
69          }
70  
71          phone = getPersistence().remove(phone);
72  
73          if (listener != null) {
74              listener.onAfterRemove(phone);
75          }
76  
77          return phone;
78      }
79  
80      public static com.liferay.portal.model.Phone update(
81          com.liferay.portal.model.Phone phone)
82          throws com.liferay.portal.SystemException {
83          ModelListener listener = _getListener();
84          boolean isNew = phone.isNew();
85  
86          if (listener != null) {
87              if (isNew) {
88                  listener.onBeforeCreate(phone);
89              }
90              else {
91                  listener.onBeforeUpdate(phone);
92              }
93          }
94  
95          phone = getPersistence().update(phone);
96  
97          if (listener != null) {
98              if (isNew) {
99                  listener.onAfterCreate(phone);
100             }
101             else {
102                 listener.onAfterUpdate(phone);
103             }
104         }
105 
106         return phone;
107     }
108 
109     public static com.liferay.portal.model.Phone update(
110         com.liferay.portal.model.Phone phone, boolean merge)
111         throws com.liferay.portal.SystemException {
112         ModelListener listener = _getListener();
113         boolean isNew = phone.isNew();
114 
115         if (listener != null) {
116             if (isNew) {
117                 listener.onBeforeCreate(phone);
118             }
119             else {
120                 listener.onBeforeUpdate(phone);
121             }
122         }
123 
124         phone = getPersistence().update(phone, merge);
125 
126         if (listener != null) {
127             if (isNew) {
128                 listener.onAfterCreate(phone);
129             }
130             else {
131                 listener.onAfterUpdate(phone);
132             }
133         }
134 
135         return phone;
136     }
137 
138     public static com.liferay.portal.model.Phone findByPrimaryKey(long phoneId)
139         throws com.liferay.portal.SystemException, 
140             com.liferay.portal.NoSuchPhoneException {
141         return getPersistence().findByPrimaryKey(phoneId);
142     }
143 
144     public static com.liferay.portal.model.Phone fetchByPrimaryKey(long phoneId)
145         throws com.liferay.portal.SystemException {
146         return getPersistence().fetchByPrimaryKey(phoneId);
147     }
148 
149     public static java.util.List findByCompanyId(long companyId)
150         throws com.liferay.portal.SystemException {
151         return getPersistence().findByCompanyId(companyId);
152     }
153 
154     public static java.util.List findByCompanyId(long companyId, int begin,
155         int end) throws com.liferay.portal.SystemException {
156         return getPersistence().findByCompanyId(companyId, begin, end);
157     }
158 
159     public static java.util.List findByCompanyId(long companyId, int begin,
160         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
161         throws com.liferay.portal.SystemException {
162         return getPersistence().findByCompanyId(companyId, begin, end, obc);
163     }
164 
165     public static com.liferay.portal.model.Phone findByCompanyId_First(
166         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
167         throws com.liferay.portal.SystemException, 
168             com.liferay.portal.NoSuchPhoneException {
169         return getPersistence().findByCompanyId_First(companyId, obc);
170     }
171 
172     public static com.liferay.portal.model.Phone findByCompanyId_Last(
173         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
174         throws com.liferay.portal.SystemException, 
175             com.liferay.portal.NoSuchPhoneException {
176         return getPersistence().findByCompanyId_Last(companyId, obc);
177     }
178 
179     public static com.liferay.portal.model.Phone[] findByCompanyId_PrevAndNext(
180         long phoneId, long companyId,
181         com.liferay.portal.kernel.util.OrderByComparator obc)
182         throws com.liferay.portal.SystemException, 
183             com.liferay.portal.NoSuchPhoneException {
184         return getPersistence().findByCompanyId_PrevAndNext(phoneId, companyId,
185             obc);
186     }
187 
188     public static java.util.List findByUserId(long userId)
189         throws com.liferay.portal.SystemException {
190         return getPersistence().findByUserId(userId);
191     }
192 
193     public static java.util.List findByUserId(long userId, int begin, int end)
194         throws com.liferay.portal.SystemException {
195         return getPersistence().findByUserId(userId, begin, end);
196     }
197 
198     public static java.util.List findByUserId(long userId, int begin, int end,
199         com.liferay.portal.kernel.util.OrderByComparator obc)
200         throws com.liferay.portal.SystemException {
201         return getPersistence().findByUserId(userId, begin, end, obc);
202     }
203 
204     public static com.liferay.portal.model.Phone findByUserId_First(
205         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
206         throws com.liferay.portal.SystemException, 
207             com.liferay.portal.NoSuchPhoneException {
208         return getPersistence().findByUserId_First(userId, obc);
209     }
210 
211     public static com.liferay.portal.model.Phone findByUserId_Last(
212         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
213         throws com.liferay.portal.SystemException, 
214             com.liferay.portal.NoSuchPhoneException {
215         return getPersistence().findByUserId_Last(userId, obc);
216     }
217 
218     public static com.liferay.portal.model.Phone[] findByUserId_PrevAndNext(
219         long phoneId, long userId,
220         com.liferay.portal.kernel.util.OrderByComparator obc)
221         throws com.liferay.portal.SystemException, 
222             com.liferay.portal.NoSuchPhoneException {
223         return getPersistence().findByUserId_PrevAndNext(phoneId, userId, obc);
224     }
225 
226     public static java.util.List findByC_C(long companyId, long classNameId)
227         throws com.liferay.portal.SystemException {
228         return getPersistence().findByC_C(companyId, classNameId);
229     }
230 
231     public static java.util.List findByC_C(long companyId, long classNameId,
232         int begin, int end) throws com.liferay.portal.SystemException {
233         return getPersistence().findByC_C(companyId, classNameId, begin, end);
234     }
235 
236     public static java.util.List findByC_C(long companyId, long classNameId,
237         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
238         throws com.liferay.portal.SystemException {
239         return getPersistence().findByC_C(companyId, classNameId, begin, end,
240             obc);
241     }
242 
243     public static com.liferay.portal.model.Phone findByC_C_First(
244         long companyId, long classNameId,
245         com.liferay.portal.kernel.util.OrderByComparator obc)
246         throws com.liferay.portal.SystemException, 
247             com.liferay.portal.NoSuchPhoneException {
248         return getPersistence().findByC_C_First(companyId, classNameId, obc);
249     }
250 
251     public static com.liferay.portal.model.Phone findByC_C_Last(
252         long companyId, long classNameId,
253         com.liferay.portal.kernel.util.OrderByComparator obc)
254         throws com.liferay.portal.SystemException, 
255             com.liferay.portal.NoSuchPhoneException {
256         return getPersistence().findByC_C_Last(companyId, classNameId, obc);
257     }
258 
259     public static com.liferay.portal.model.Phone[] findByC_C_PrevAndNext(
260         long phoneId, long companyId, long classNameId,
261         com.liferay.portal.kernel.util.OrderByComparator obc)
262         throws com.liferay.portal.SystemException, 
263             com.liferay.portal.NoSuchPhoneException {
264         return getPersistence().findByC_C_PrevAndNext(phoneId, companyId,
265             classNameId, obc);
266     }
267 
268     public static java.util.List findByC_C_C(long companyId, long classNameId,
269         long classPK) throws com.liferay.portal.SystemException {
270         return getPersistence().findByC_C_C(companyId, classNameId, classPK);
271     }
272 
273     public static java.util.List findByC_C_C(long companyId, long classNameId,
274         long classPK, int begin, int end)
275         throws com.liferay.portal.SystemException {
276         return getPersistence().findByC_C_C(companyId, classNameId, classPK,
277             begin, end);
278     }
279 
280     public static java.util.List findByC_C_C(long companyId, long classNameId,
281         long classPK, int begin, int end,
282         com.liferay.portal.kernel.util.OrderByComparator obc)
283         throws com.liferay.portal.SystemException {
284         return getPersistence().findByC_C_C(companyId, classNameId, classPK,
285             begin, end, obc);
286     }
287 
288     public static com.liferay.portal.model.Phone findByC_C_C_First(
289         long companyId, long classNameId, long classPK,
290         com.liferay.portal.kernel.util.OrderByComparator obc)
291         throws com.liferay.portal.SystemException, 
292             com.liferay.portal.NoSuchPhoneException {
293         return getPersistence().findByC_C_C_First(companyId, classNameId,
294             classPK, obc);
295     }
296 
297     public static com.liferay.portal.model.Phone findByC_C_C_Last(
298         long companyId, long classNameId, long classPK,
299         com.liferay.portal.kernel.util.OrderByComparator obc)
300         throws com.liferay.portal.SystemException, 
301             com.liferay.portal.NoSuchPhoneException {
302         return getPersistence().findByC_C_C_Last(companyId, classNameId,
303             classPK, obc);
304     }
305 
306     public static com.liferay.portal.model.Phone[] findByC_C_C_PrevAndNext(
307         long phoneId, long companyId, long classNameId, long classPK,
308         com.liferay.portal.kernel.util.OrderByComparator obc)
309         throws com.liferay.portal.SystemException, 
310             com.liferay.portal.NoSuchPhoneException {
311         return getPersistence().findByC_C_C_PrevAndNext(phoneId, companyId,
312             classNameId, classPK, obc);
313     }
314 
315     public static java.util.List findByC_C_C_P(long companyId,
316         long classNameId, long classPK, boolean primary)
317         throws com.liferay.portal.SystemException {
318         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
319             primary);
320     }
321 
322     public static java.util.List findByC_C_C_P(long companyId,
323         long classNameId, long classPK, boolean primary, int begin, int end)
324         throws com.liferay.portal.SystemException {
325         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
326             primary, begin, end);
327     }
328 
329     public static java.util.List findByC_C_C_P(long companyId,
330         long classNameId, long classPK, boolean primary, int begin, int end,
331         com.liferay.portal.kernel.util.OrderByComparator obc)
332         throws com.liferay.portal.SystemException {
333         return getPersistence().findByC_C_C_P(companyId, classNameId, classPK,
334             primary, begin, end, obc);
335     }
336 
337     public static com.liferay.portal.model.Phone findByC_C_C_P_First(
338         long companyId, long classNameId, long classPK, boolean primary,
339         com.liferay.portal.kernel.util.OrderByComparator obc)
340         throws com.liferay.portal.SystemException, 
341             com.liferay.portal.NoSuchPhoneException {
342         return getPersistence().findByC_C_C_P_First(companyId, classNameId,
343             classPK, primary, obc);
344     }
345 
346     public static com.liferay.portal.model.Phone findByC_C_C_P_Last(
347         long companyId, long classNameId, long classPK, boolean primary,
348         com.liferay.portal.kernel.util.OrderByComparator obc)
349         throws com.liferay.portal.SystemException, 
350             com.liferay.portal.NoSuchPhoneException {
351         return getPersistence().findByC_C_C_P_Last(companyId, classNameId,
352             classPK, primary, obc);
353     }
354 
355     public static com.liferay.portal.model.Phone[] findByC_C_C_P_PrevAndNext(
356         long phoneId, long companyId, long classNameId, long classPK,
357         boolean primary, com.liferay.portal.kernel.util.OrderByComparator obc)
358         throws com.liferay.portal.SystemException, 
359             com.liferay.portal.NoSuchPhoneException {
360         return getPersistence().findByC_C_C_P_PrevAndNext(phoneId, companyId,
361             classNameId, classPK, primary, obc);
362     }
363 
364     public static java.util.List findWithDynamicQuery(
365         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
366         throws com.liferay.portal.SystemException {
367         return getPersistence().findWithDynamicQuery(queryInitializer);
368     }
369 
370     public static java.util.List findWithDynamicQuery(
371         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
372         int begin, int end) throws com.liferay.portal.SystemException {
373         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
374             end);
375     }
376 
377     public static java.util.List findAll()
378         throws com.liferay.portal.SystemException {
379         return getPersistence().findAll();
380     }
381 
382     public static java.util.List findAll(int begin, int end)
383         throws com.liferay.portal.SystemException {
384         return getPersistence().findAll(begin, end);
385     }
386 
387     public static java.util.List findAll(int begin, int end,
388         com.liferay.portal.kernel.util.OrderByComparator obc)
389         throws com.liferay.portal.SystemException {
390         return getPersistence().findAll(begin, end, obc);
391     }
392 
393     public static void removeByCompanyId(long companyId)
394         throws com.liferay.portal.SystemException {
395         getPersistence().removeByCompanyId(companyId);
396     }
397 
398     public static void removeByUserId(long userId)
399         throws com.liferay.portal.SystemException {
400         getPersistence().removeByUserId(userId);
401     }
402 
403     public static void removeByC_C(long companyId, long classNameId)
404         throws com.liferay.portal.SystemException {
405         getPersistence().removeByC_C(companyId, classNameId);
406     }
407 
408     public static void removeByC_C_C(long companyId, long classNameId,
409         long classPK) throws com.liferay.portal.SystemException {
410         getPersistence().removeByC_C_C(companyId, classNameId, classPK);
411     }
412 
413     public static void removeByC_C_C_P(long companyId, long classNameId,
414         long classPK, boolean primary)
415         throws com.liferay.portal.SystemException {
416         getPersistence().removeByC_C_C_P(companyId, classNameId, classPK,
417             primary);
418     }
419 
420     public static void removeAll() throws com.liferay.portal.SystemException {
421         getPersistence().removeAll();
422     }
423 
424     public static int countByCompanyId(long companyId)
425         throws com.liferay.portal.SystemException {
426         return getPersistence().countByCompanyId(companyId);
427     }
428 
429     public static int countByUserId(long userId)
430         throws com.liferay.portal.SystemException {
431         return getPersistence().countByUserId(userId);
432     }
433 
434     public static int countByC_C(long companyId, long classNameId)
435         throws com.liferay.portal.SystemException {
436         return getPersistence().countByC_C(companyId, classNameId);
437     }
438 
439     public static int countByC_C_C(long companyId, long classNameId,
440         long classPK) throws com.liferay.portal.SystemException {
441         return getPersistence().countByC_C_C(companyId, classNameId, classPK);
442     }
443 
444     public static int countByC_C_C_P(long companyId, long classNameId,
445         long classPK, boolean primary)
446         throws com.liferay.portal.SystemException {
447         return getPersistence().countByC_C_C_P(companyId, classNameId, classPK,
448             primary);
449     }
450 
451     public static int countAll() throws com.liferay.portal.SystemException {
452         return getPersistence().countAll();
453     }
454 
455     public static PhonePersistence getPersistence() {
456         return _getUtil()._persistence;
457     }
458 
459     public void setPersistence(PhonePersistence persistence) {
460         _persistence = persistence;
461     }
462 
463     private static PhoneUtil _getUtil() {
464         if (_util == null) {
465             _util = (PhoneUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
466         }
467 
468         return _util;
469     }
470 
471     private static ModelListener _getListener() {
472         if (Validator.isNotNull(_LISTENER)) {
473             try {
474                 return (ModelListener)Class.forName(_LISTENER).newInstance();
475             }
476             catch (Exception e) {
477                 _log.error(e);
478             }
479         }
480 
481         return null;
482     }
483 
484     private static final String _UTIL = PhoneUtil.class.getName();
485     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
486                 "value.object.listener.com.liferay.portal.model.Phone"));
487     private static Log _log = LogFactory.getLog(PhoneUtil.class);
488     private static PhoneUtil _util;
489     private PhonePersistence _persistence;
490 }