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