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="UserTrackerUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class UserTrackerUtil {
40      public static com.liferay.portal.model.UserTracker create(
41          long userTrackerId) {
42          return getPersistence().create(userTrackerId);
43      }
44  
45      public static com.liferay.portal.model.UserTracker remove(
46          long userTrackerId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portal.NoSuchUserTrackerException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(userTrackerId));
53          }
54  
55          com.liferay.portal.model.UserTracker userTracker = getPersistence()
56                                                                 .remove(userTrackerId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(userTracker);
60          }
61  
62          return userTracker;
63      }
64  
65      public static com.liferay.portal.model.UserTracker remove(
66          com.liferay.portal.model.UserTracker userTracker)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(userTracker);
72          }
73  
74          userTracker = getPersistence().remove(userTracker);
75  
76          if (listener != null) {
77              listener.onAfterRemove(userTracker);
78          }
79  
80          return userTracker;
81      }
82  
83      public static com.liferay.portal.model.UserTracker update(
84          com.liferay.portal.model.UserTracker userTracker)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = userTracker.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(userTracker);
92              }
93              else {
94                  listener.onBeforeUpdate(userTracker);
95              }
96          }
97  
98          userTracker = getPersistence().update(userTracker);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(userTracker);
103             }
104             else {
105                 listener.onAfterUpdate(userTracker);
106             }
107         }
108 
109         return userTracker;
110     }
111 
112     public static com.liferay.portal.model.UserTracker update(
113         com.liferay.portal.model.UserTracker userTracker, boolean merge)
114         throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = userTracker.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(userTracker);
121             }
122             else {
123                 listener.onBeforeUpdate(userTracker);
124             }
125         }
126 
127         userTracker = getPersistence().update(userTracker, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(userTracker);
132             }
133             else {
134                 listener.onAfterUpdate(userTracker);
135             }
136         }
137 
138         return userTracker;
139     }
140 
141     public static com.liferay.portal.model.UserTracker findByPrimaryKey(
142         long userTrackerId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portal.NoSuchUserTrackerException {
145         return getPersistence().findByPrimaryKey(userTrackerId);
146     }
147 
148     public static com.liferay.portal.model.UserTracker fetchByPrimaryKey(
149         long userTrackerId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(userTrackerId);
151     }
152 
153     public static java.util.List findByCompanyId(long companyId)
154         throws com.liferay.portal.SystemException {
155         return getPersistence().findByCompanyId(companyId);
156     }
157 
158     public static java.util.List findByCompanyId(long companyId, int begin,
159         int end) throws com.liferay.portal.SystemException {
160         return getPersistence().findByCompanyId(companyId, begin, end);
161     }
162 
163     public static java.util.List findByCompanyId(long companyId, int begin,
164         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
165         throws com.liferay.portal.SystemException {
166         return getPersistence().findByCompanyId(companyId, begin, end, obc);
167     }
168 
169     public static com.liferay.portal.model.UserTracker findByCompanyId_First(
170         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portal.NoSuchUserTrackerException {
173         return getPersistence().findByCompanyId_First(companyId, obc);
174     }
175 
176     public static com.liferay.portal.model.UserTracker findByCompanyId_Last(
177         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portal.NoSuchUserTrackerException {
180         return getPersistence().findByCompanyId_Last(companyId, obc);
181     }
182 
183     public static com.liferay.portal.model.UserTracker[] findByCompanyId_PrevAndNext(
184         long userTrackerId, long companyId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portal.NoSuchUserTrackerException {
188         return getPersistence().findByCompanyId_PrevAndNext(userTrackerId,
189             companyId, obc);
190     }
191 
192     public static java.util.List findByUserId(long userId)
193         throws com.liferay.portal.SystemException {
194         return getPersistence().findByUserId(userId);
195     }
196 
197     public static java.util.List findByUserId(long userId, int begin, int end)
198         throws com.liferay.portal.SystemException {
199         return getPersistence().findByUserId(userId, begin, end);
200     }
201 
202     public static java.util.List findByUserId(long userId, int begin, int end,
203         com.liferay.portal.kernel.util.OrderByComparator obc)
204         throws com.liferay.portal.SystemException {
205         return getPersistence().findByUserId(userId, begin, end, obc);
206     }
207 
208     public static com.liferay.portal.model.UserTracker findByUserId_First(
209         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
210         throws com.liferay.portal.SystemException, 
211             com.liferay.portal.NoSuchUserTrackerException {
212         return getPersistence().findByUserId_First(userId, obc);
213     }
214 
215     public static com.liferay.portal.model.UserTracker findByUserId_Last(
216         long userId, com.liferay.portal.kernel.util.OrderByComparator obc)
217         throws com.liferay.portal.SystemException, 
218             com.liferay.portal.NoSuchUserTrackerException {
219         return getPersistence().findByUserId_Last(userId, obc);
220     }
221 
222     public static com.liferay.portal.model.UserTracker[] findByUserId_PrevAndNext(
223         long userTrackerId, long userId,
224         com.liferay.portal.kernel.util.OrderByComparator obc)
225         throws com.liferay.portal.SystemException, 
226             com.liferay.portal.NoSuchUserTrackerException {
227         return getPersistence().findByUserId_PrevAndNext(userTrackerId, userId,
228             obc);
229     }
230 
231     public static java.util.List findBySessionId(java.lang.String sessionId)
232         throws com.liferay.portal.SystemException {
233         return getPersistence().findBySessionId(sessionId);
234     }
235 
236     public static java.util.List findBySessionId(java.lang.String sessionId,
237         int begin, int end) throws com.liferay.portal.SystemException {
238         return getPersistence().findBySessionId(sessionId, begin, end);
239     }
240 
241     public static java.util.List findBySessionId(java.lang.String sessionId,
242         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
243         throws com.liferay.portal.SystemException {
244         return getPersistence().findBySessionId(sessionId, begin, end, obc);
245     }
246 
247     public static com.liferay.portal.model.UserTracker findBySessionId_First(
248         java.lang.String sessionId,
249         com.liferay.portal.kernel.util.OrderByComparator obc)
250         throws com.liferay.portal.SystemException, 
251             com.liferay.portal.NoSuchUserTrackerException {
252         return getPersistence().findBySessionId_First(sessionId, obc);
253     }
254 
255     public static com.liferay.portal.model.UserTracker findBySessionId_Last(
256         java.lang.String sessionId,
257         com.liferay.portal.kernel.util.OrderByComparator obc)
258         throws com.liferay.portal.SystemException, 
259             com.liferay.portal.NoSuchUserTrackerException {
260         return getPersistence().findBySessionId_Last(sessionId, obc);
261     }
262 
263     public static com.liferay.portal.model.UserTracker[] findBySessionId_PrevAndNext(
264         long userTrackerId, java.lang.String sessionId,
265         com.liferay.portal.kernel.util.OrderByComparator obc)
266         throws com.liferay.portal.SystemException, 
267             com.liferay.portal.NoSuchUserTrackerException {
268         return getPersistence().findBySessionId_PrevAndNext(userTrackerId,
269             sessionId, obc);
270     }
271 
272     public static java.util.List findWithDynamicQuery(
273         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
274         throws com.liferay.portal.SystemException {
275         return getPersistence().findWithDynamicQuery(queryInitializer);
276     }
277 
278     public static java.util.List findWithDynamicQuery(
279         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
280         int begin, int end) throws com.liferay.portal.SystemException {
281         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
282             end);
283     }
284 
285     public static java.util.List findAll()
286         throws com.liferay.portal.SystemException {
287         return getPersistence().findAll();
288     }
289 
290     public static java.util.List findAll(int begin, int end)
291         throws com.liferay.portal.SystemException {
292         return getPersistence().findAll(begin, end);
293     }
294 
295     public static java.util.List findAll(int begin, int end,
296         com.liferay.portal.kernel.util.OrderByComparator obc)
297         throws com.liferay.portal.SystemException {
298         return getPersistence().findAll(begin, end, obc);
299     }
300 
301     public static void removeByCompanyId(long companyId)
302         throws com.liferay.portal.SystemException {
303         getPersistence().removeByCompanyId(companyId);
304     }
305 
306     public static void removeByUserId(long userId)
307         throws com.liferay.portal.SystemException {
308         getPersistence().removeByUserId(userId);
309     }
310 
311     public static void removeBySessionId(java.lang.String sessionId)
312         throws com.liferay.portal.SystemException {
313         getPersistence().removeBySessionId(sessionId);
314     }
315 
316     public static void removeAll() throws com.liferay.portal.SystemException {
317         getPersistence().removeAll();
318     }
319 
320     public static int countByCompanyId(long companyId)
321         throws com.liferay.portal.SystemException {
322         return getPersistence().countByCompanyId(companyId);
323     }
324 
325     public static int countByUserId(long userId)
326         throws com.liferay.portal.SystemException {
327         return getPersistence().countByUserId(userId);
328     }
329 
330     public static int countBySessionId(java.lang.String sessionId)
331         throws com.liferay.portal.SystemException {
332         return getPersistence().countBySessionId(sessionId);
333     }
334 
335     public static int countAll() throws com.liferay.portal.SystemException {
336         return getPersistence().countAll();
337     }
338 
339     public static UserTrackerPersistence getPersistence() {
340         return _getUtil()._persistence;
341     }
342 
343     public void setPersistence(UserTrackerPersistence persistence) {
344         _persistence = persistence;
345     }
346 
347     private static UserTrackerUtil _getUtil() {
348         if (_util == null) {
349             _util = (UserTrackerUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
350         }
351 
352         return _util;
353     }
354 
355     private static ModelListener _getListener() {
356         if (Validator.isNotNull(_LISTENER)) {
357             try {
358                 return (ModelListener)Class.forName(_LISTENER).newInstance();
359             }
360             catch (Exception e) {
361                 _log.error(e);
362             }
363         }
364 
365         return null;
366     }
367 
368     private static final String _UTIL = UserTrackerUtil.class.getName();
369     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
370                 "value.object.listener.com.liferay.portal.model.UserTracker"));
371     private static Log _log = LogFactory.getLog(UserTrackerUtil.class);
372     private static UserTrackerUtil _util;
373     private UserTrackerPersistence _persistence;
374 }