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