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