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