1   /**
2    * Copyright (c) 2000-2008 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  /**
26   * <a href="PortletUtil.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   *
30   */
31  public class PortletUtil {
32      public static com.liferay.portal.model.Portlet create(long id) {
33          return getPersistence().create(id);
34      }
35  
36      public static com.liferay.portal.model.Portlet remove(long id)
37          throws com.liferay.portal.SystemException,
38              com.liferay.portal.NoSuchPortletException {
39          return getPersistence().remove(id);
40      }
41  
42      public static com.liferay.portal.model.Portlet remove(
43          com.liferay.portal.model.Portlet portlet)
44          throws com.liferay.portal.SystemException {
45          return getPersistence().remove(portlet);
46      }
47  
48      /**
49       * @deprecated Use <code>update(Portlet portlet, boolean merge)</code>.
50       */
51      public static com.liferay.portal.model.Portlet update(
52          com.liferay.portal.model.Portlet portlet)
53          throws com.liferay.portal.SystemException {
54          return getPersistence().update(portlet);
55      }
56  
57      /**
58       * Add, update, or merge, the entity. This method also calls the model
59       * listeners to trigger the proper events associated with adding, deleting,
60       * or updating an entity.
61       *
62       * @param        portlet the entity to add, update, or merge
63       * @param        merge boolean value for whether to merge the entity. The
64       *                default value is false. Setting merge to true is more
65       *                expensive and should only be true when portlet is
66       *                transient. See LEP-5473 for a detailed discussion of this
67       *                method.
68       * @return        true if the portlet can be displayed via Ajax
69       */
70      public static com.liferay.portal.model.Portlet update(
71          com.liferay.portal.model.Portlet portlet, boolean merge)
72          throws com.liferay.portal.SystemException {
73          return getPersistence().update(portlet, merge);
74      }
75  
76      public static com.liferay.portal.model.Portlet updateImpl(
77          com.liferay.portal.model.Portlet portlet, boolean merge)
78          throws com.liferay.portal.SystemException {
79          return getPersistence().updateImpl(portlet, merge);
80      }
81  
82      public static com.liferay.portal.model.Portlet findByPrimaryKey(long id)
83          throws com.liferay.portal.SystemException,
84              com.liferay.portal.NoSuchPortletException {
85          return getPersistence().findByPrimaryKey(id);
86      }
87  
88      public static com.liferay.portal.model.Portlet fetchByPrimaryKey(long id)
89          throws com.liferay.portal.SystemException {
90          return getPersistence().fetchByPrimaryKey(id);
91      }
92  
93      public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
94          long companyId) throws com.liferay.portal.SystemException {
95          return getPersistence().findByCompanyId(companyId);
96      }
97  
98      public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
99          long companyId, int begin, int end)
100         throws com.liferay.portal.SystemException {
101         return getPersistence().findByCompanyId(companyId, begin, end);
102     }
103 
104     public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
105         long companyId, int begin, int end,
106         com.liferay.portal.kernel.util.OrderByComparator obc)
107         throws com.liferay.portal.SystemException {
108         return getPersistence().findByCompanyId(companyId, begin, end, obc);
109     }
110 
111     public static com.liferay.portal.model.Portlet findByCompanyId_First(
112         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
113         throws com.liferay.portal.SystemException,
114             com.liferay.portal.NoSuchPortletException {
115         return getPersistence().findByCompanyId_First(companyId, obc);
116     }
117 
118     public static com.liferay.portal.model.Portlet findByCompanyId_Last(
119         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
120         throws com.liferay.portal.SystemException,
121             com.liferay.portal.NoSuchPortletException {
122         return getPersistence().findByCompanyId_Last(companyId, obc);
123     }
124 
125     public static com.liferay.portal.model.Portlet[] findByCompanyId_PrevAndNext(
126         long id, long companyId,
127         com.liferay.portal.kernel.util.OrderByComparator obc)
128         throws com.liferay.portal.SystemException,
129             com.liferay.portal.NoSuchPortletException {
130         return getPersistence().findByCompanyId_PrevAndNext(id, companyId, obc);
131     }
132 
133     public static com.liferay.portal.model.Portlet findByC_P(long companyId,
134         java.lang.String portletId)
135         throws com.liferay.portal.SystemException,
136             com.liferay.portal.NoSuchPortletException {
137         return getPersistence().findByC_P(companyId, portletId);
138     }
139 
140     public static com.liferay.portal.model.Portlet fetchByC_P(long companyId,
141         java.lang.String portletId) throws com.liferay.portal.SystemException {
142         return getPersistence().fetchByC_P(companyId, portletId);
143     }
144 
145     public static java.util.List<com.liferay.portal.model.Portlet> findWithDynamicQuery(
146         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
147         throws com.liferay.portal.SystemException {
148         return getPersistence().findWithDynamicQuery(queryInitializer);
149     }
150 
151     public static java.util.List<com.liferay.portal.model.Portlet> findWithDynamicQuery(
152         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
153         int begin, int end) throws com.liferay.portal.SystemException {
154         return getPersistence()
155                    .findWithDynamicQuery(queryInitializer, begin, end);
156     }
157 
158     public static java.util.List<com.liferay.portal.model.Portlet> findAll()
159         throws com.liferay.portal.SystemException {
160         return getPersistence().findAll();
161     }
162 
163     public static java.util.List<com.liferay.portal.model.Portlet> findAll(
164         int begin, int end) throws com.liferay.portal.SystemException {
165         return getPersistence().findAll(begin, end);
166     }
167 
168     public static java.util.List<com.liferay.portal.model.Portlet> findAll(
169         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
170         throws com.liferay.portal.SystemException {
171         return getPersistence().findAll(begin, end, obc);
172     }
173 
174     public static void removeByCompanyId(long companyId)
175         throws com.liferay.portal.SystemException {
176         getPersistence().removeByCompanyId(companyId);
177     }
178 
179     public static void removeByC_P(long companyId, java.lang.String portletId)
180         throws com.liferay.portal.SystemException,
181             com.liferay.portal.NoSuchPortletException {
182         getPersistence().removeByC_P(companyId, portletId);
183     }
184 
185     public static void removeAll() throws com.liferay.portal.SystemException {
186         getPersistence().removeAll();
187     }
188 
189     public static int countByCompanyId(long companyId)
190         throws com.liferay.portal.SystemException {
191         return getPersistence().countByCompanyId(companyId);
192     }
193 
194     public static int countByC_P(long companyId, java.lang.String portletId)
195         throws com.liferay.portal.SystemException {
196         return getPersistence().countByC_P(companyId, portletId);
197     }
198 
199     public static int countAll() throws com.liferay.portal.SystemException {
200         return getPersistence().countAll();
201     }
202 
203     public static PortletPersistence getPersistence() {
204         return _getUtil()._persistence;
205     }
206 
207     public void setPersistence(PortletPersistence persistence) {
208         _persistence = persistence;
209     }
210 
211     private static PortletUtil _getUtil() {
212         if (_util == null) {
213             _util = (PortletUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
214         }
215 
216         return _util;
217     }
218 
219     private static final String _UTIL = PortletUtil.class.getName();
220     private static PortletUtil _util;
221     private PortletPersistence _persistence;
222 }