001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.service.persistence;
016    
017    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
018    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.kernel.util.OrderByComparator;
021    import com.liferay.portal.kernel.util.ReferenceRegistry;
022    import com.liferay.portal.model.Portlet;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import java.util.List;
026    
027    /**
028     * The persistence utility for the portlet service. This utility wraps {@link PortletPersistenceImpl} and provides direct access to the database for CRUD operations. This utility should only be used by the service layer, as it must operate within a transaction. Never access this utility in a JSP, controller, model, or other front-end class.
029     *
030     * <p>
031     * Caching information and settings can be found in <code>portal.properties</code>
032     * </p>
033     *
034     * @author Brian Wing Shun Chan
035     * @see PortletPersistence
036     * @see PortletPersistenceImpl
037     * @generated
038     */
039    public class PortletUtil {
040            /*
041             * NOTE FOR DEVELOPERS:
042             *
043             * Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
044             */
045    
046            /**
047             * @see com.liferay.portal.service.persistence.BasePersistence#clearCache()
048             */
049            public static void clearCache() {
050                    getPersistence().clearCache();
051            }
052    
053            /**
054             * @see com.liferay.portal.service.persistence.BasePersistence#clearCache(com.liferay.portal.model.BaseModel)
055             */
056            public static void clearCache(Portlet portlet) {
057                    getPersistence().clearCache(portlet);
058            }
059    
060            /**
061             * @see com.liferay.portal.service.persistence.BasePersistence#countWithDynamicQuery(DynamicQuery)
062             */
063            public long countWithDynamicQuery(DynamicQuery dynamicQuery)
064                    throws SystemException {
065                    return getPersistence().countWithDynamicQuery(dynamicQuery);
066            }
067    
068            /**
069             * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery)
070             */
071            public static List<Portlet> findWithDynamicQuery(DynamicQuery dynamicQuery)
072                    throws SystemException {
073                    return getPersistence().findWithDynamicQuery(dynamicQuery);
074            }
075    
076            /**
077             * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int)
078             */
079            public static List<Portlet> findWithDynamicQuery(
080                    DynamicQuery dynamicQuery, int start, int end)
081                    throws SystemException {
082                    return getPersistence().findWithDynamicQuery(dynamicQuery, start, end);
083            }
084    
085            /**
086             * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int, OrderByComparator)
087             */
088            public static List<Portlet> findWithDynamicQuery(
089                    DynamicQuery dynamicQuery, int start, int end,
090                    OrderByComparator orderByComparator) throws SystemException {
091                    return getPersistence()
092                                       .findWithDynamicQuery(dynamicQuery, start, end,
093                            orderByComparator);
094            }
095    
096            /**
097             * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, boolean)
098             */
099            public static Portlet update(Portlet portlet, boolean merge)
100                    throws SystemException {
101                    return getPersistence().update(portlet, merge);
102            }
103    
104            /**
105             * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, boolean, ServiceContext)
106             */
107            public static Portlet update(Portlet portlet, boolean merge,
108                    ServiceContext serviceContext) throws SystemException {
109                    return getPersistence().update(portlet, merge, serviceContext);
110            }
111    
112            /**
113            * Caches the portlet in the entity cache if it is enabled.
114            *
115            * @param portlet the portlet
116            */
117            public static void cacheResult(com.liferay.portal.model.Portlet portlet) {
118                    getPersistence().cacheResult(portlet);
119            }
120    
121            /**
122            * Caches the portlets in the entity cache if it is enabled.
123            *
124            * @param portlets the portlets
125            */
126            public static void cacheResult(
127                    java.util.List<com.liferay.portal.model.Portlet> portlets) {
128                    getPersistence().cacheResult(portlets);
129            }
130    
131            /**
132            * Creates a new portlet with the primary key. Does not add the portlet to the database.
133            *
134            * @param id the primary key for the new portlet
135            * @return the new portlet
136            */
137            public static com.liferay.portal.model.Portlet create(long id) {
138                    return getPersistence().create(id);
139            }
140    
141            /**
142            * Removes the portlet with the primary key from the database. Also notifies the appropriate model listeners.
143            *
144            * @param id the primary key of the portlet
145            * @return the portlet that was removed
146            * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
147            * @throws SystemException if a system exception occurred
148            */
149            public static com.liferay.portal.model.Portlet remove(long id)
150                    throws com.liferay.portal.NoSuchPortletException,
151                            com.liferay.portal.kernel.exception.SystemException {
152                    return getPersistence().remove(id);
153            }
154    
155            public static com.liferay.portal.model.Portlet updateImpl(
156                    com.liferay.portal.model.Portlet portlet, boolean merge)
157                    throws com.liferay.portal.kernel.exception.SystemException {
158                    return getPersistence().updateImpl(portlet, merge);
159            }
160    
161            /**
162            * Returns the portlet with the primary key or throws a {@link com.liferay.portal.NoSuchPortletException} if it could not be found.
163            *
164            * @param id the primary key of the portlet
165            * @return the portlet
166            * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
167            * @throws SystemException if a system exception occurred
168            */
169            public static com.liferay.portal.model.Portlet findByPrimaryKey(long id)
170                    throws com.liferay.portal.NoSuchPortletException,
171                            com.liferay.portal.kernel.exception.SystemException {
172                    return getPersistence().findByPrimaryKey(id);
173            }
174    
175            /**
176            * Returns the portlet with the primary key or returns <code>null</code> if it could not be found.
177            *
178            * @param id the primary key of the portlet
179            * @return the portlet, or <code>null</code> if a portlet with the primary key could not be found
180            * @throws SystemException if a system exception occurred
181            */
182            public static com.liferay.portal.model.Portlet fetchByPrimaryKey(long id)
183                    throws com.liferay.portal.kernel.exception.SystemException {
184                    return getPersistence().fetchByPrimaryKey(id);
185            }
186    
187            /**
188            * Returns all the portlets where companyId = &#63;.
189            *
190            * @param companyId the company ID
191            * @return the matching portlets
192            * @throws SystemException if a system exception occurred
193            */
194            public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
195                    long companyId)
196                    throws com.liferay.portal.kernel.exception.SystemException {
197                    return getPersistence().findByCompanyId(companyId);
198            }
199    
200            /**
201            * Returns a range of all the portlets where companyId = &#63;.
202            *
203            * <p>
204            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
205            * </p>
206            *
207            * @param companyId the company ID
208            * @param start the lower bound of the range of portlets
209            * @param end the upper bound of the range of portlets (not inclusive)
210            * @return the range of matching portlets
211            * @throws SystemException if a system exception occurred
212            */
213            public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
214                    long companyId, int start, int end)
215                    throws com.liferay.portal.kernel.exception.SystemException {
216                    return getPersistence().findByCompanyId(companyId, start, end);
217            }
218    
219            /**
220            * Returns an ordered range of all the portlets where companyId = &#63;.
221            *
222            * <p>
223            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
224            * </p>
225            *
226            * @param companyId the company ID
227            * @param start the lower bound of the range of portlets
228            * @param end the upper bound of the range of portlets (not inclusive)
229            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
230            * @return the ordered range of matching portlets
231            * @throws SystemException if a system exception occurred
232            */
233            public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
234                    long companyId, int start, int end,
235                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
236                    throws com.liferay.portal.kernel.exception.SystemException {
237                    return getPersistence()
238                                       .findByCompanyId(companyId, start, end, orderByComparator);
239            }
240    
241            /**
242            * Returns the first portlet in the ordered set where companyId = &#63;.
243            *
244            * <p>
245            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
246            * </p>
247            *
248            * @param companyId the company ID
249            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
250            * @return the first matching portlet
251            * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
252            * @throws SystemException if a system exception occurred
253            */
254            public static com.liferay.portal.model.Portlet findByCompanyId_First(
255                    long companyId,
256                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
257                    throws com.liferay.portal.NoSuchPortletException,
258                            com.liferay.portal.kernel.exception.SystemException {
259                    return getPersistence()
260                                       .findByCompanyId_First(companyId, orderByComparator);
261            }
262    
263            /**
264            * Returns the last portlet in the ordered set where companyId = &#63;.
265            *
266            * <p>
267            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
268            * </p>
269            *
270            * @param companyId the company ID
271            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
272            * @return the last matching portlet
273            * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
274            * @throws SystemException if a system exception occurred
275            */
276            public static com.liferay.portal.model.Portlet findByCompanyId_Last(
277                    long companyId,
278                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
279                    throws com.liferay.portal.NoSuchPortletException,
280                            com.liferay.portal.kernel.exception.SystemException {
281                    return getPersistence()
282                                       .findByCompanyId_Last(companyId, orderByComparator);
283            }
284    
285            /**
286            * Returns the portlets before and after the current portlet in the ordered set where companyId = &#63;.
287            *
288            * <p>
289            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
290            * </p>
291            *
292            * @param id the primary key of the current portlet
293            * @param companyId the company ID
294            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
295            * @return the previous, current, and next portlet
296            * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
297            * @throws SystemException if a system exception occurred
298            */
299            public static com.liferay.portal.model.Portlet[] findByCompanyId_PrevAndNext(
300                    long id, long companyId,
301                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
302                    throws com.liferay.portal.NoSuchPortletException,
303                            com.liferay.portal.kernel.exception.SystemException {
304                    return getPersistence()
305                                       .findByCompanyId_PrevAndNext(id, companyId, orderByComparator);
306            }
307    
308            /**
309            * Returns the portlet where companyId = &#63; and portletId = &#63; or throws a {@link com.liferay.portal.NoSuchPortletException} if it could not be found.
310            *
311            * @param companyId the company ID
312            * @param portletId the portlet ID
313            * @return the matching portlet
314            * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
315            * @throws SystemException if a system exception occurred
316            */
317            public static com.liferay.portal.model.Portlet findByC_P(long companyId,
318                    java.lang.String portletId)
319                    throws com.liferay.portal.NoSuchPortletException,
320                            com.liferay.portal.kernel.exception.SystemException {
321                    return getPersistence().findByC_P(companyId, portletId);
322            }
323    
324            /**
325            * Returns the portlet where companyId = &#63; and portletId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
326            *
327            * @param companyId the company ID
328            * @param portletId the portlet ID
329            * @return the matching portlet, or <code>null</code> if a matching portlet could not be found
330            * @throws SystemException if a system exception occurred
331            */
332            public static com.liferay.portal.model.Portlet fetchByC_P(long companyId,
333                    java.lang.String portletId)
334                    throws com.liferay.portal.kernel.exception.SystemException {
335                    return getPersistence().fetchByC_P(companyId, portletId);
336            }
337    
338            /**
339            * Returns the portlet where companyId = &#63; and portletId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
340            *
341            * @param companyId the company ID
342            * @param portletId the portlet ID
343            * @param retrieveFromCache whether to use the finder cache
344            * @return the matching portlet, or <code>null</code> if a matching portlet could not be found
345            * @throws SystemException if a system exception occurred
346            */
347            public static com.liferay.portal.model.Portlet fetchByC_P(long companyId,
348                    java.lang.String portletId, boolean retrieveFromCache)
349                    throws com.liferay.portal.kernel.exception.SystemException {
350                    return getPersistence()
351                                       .fetchByC_P(companyId, portletId, retrieveFromCache);
352            }
353    
354            /**
355            * Returns all the portlets.
356            *
357            * @return the portlets
358            * @throws SystemException if a system exception occurred
359            */
360            public static java.util.List<com.liferay.portal.model.Portlet> findAll()
361                    throws com.liferay.portal.kernel.exception.SystemException {
362                    return getPersistence().findAll();
363            }
364    
365            /**
366            * Returns a range of all the portlets.
367            *
368            * <p>
369            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
370            * </p>
371            *
372            * @param start the lower bound of the range of portlets
373            * @param end the upper bound of the range of portlets (not inclusive)
374            * @return the range of portlets
375            * @throws SystemException if a system exception occurred
376            */
377            public static java.util.List<com.liferay.portal.model.Portlet> findAll(
378                    int start, int end)
379                    throws com.liferay.portal.kernel.exception.SystemException {
380                    return getPersistence().findAll(start, end);
381            }
382    
383            /**
384            * Returns an ordered range of all the portlets.
385            *
386            * <p>
387            * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
388            * </p>
389            *
390            * @param start the lower bound of the range of portlets
391            * @param end the upper bound of the range of portlets (not inclusive)
392            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
393            * @return the ordered range of portlets
394            * @throws SystemException if a system exception occurred
395            */
396            public static java.util.List<com.liferay.portal.model.Portlet> findAll(
397                    int start, int end,
398                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
399                    throws com.liferay.portal.kernel.exception.SystemException {
400                    return getPersistence().findAll(start, end, orderByComparator);
401            }
402    
403            /**
404            * Removes all the portlets where companyId = &#63; from the database.
405            *
406            * @param companyId the company ID
407            * @throws SystemException if a system exception occurred
408            */
409            public static void removeByCompanyId(long companyId)
410                    throws com.liferay.portal.kernel.exception.SystemException {
411                    getPersistence().removeByCompanyId(companyId);
412            }
413    
414            /**
415            * Removes the portlet where companyId = &#63; and portletId = &#63; from the database.
416            *
417            * @param companyId the company ID
418            * @param portletId the portlet ID
419            * @throws SystemException if a system exception occurred
420            */
421            public static void removeByC_P(long companyId, java.lang.String portletId)
422                    throws com.liferay.portal.NoSuchPortletException,
423                            com.liferay.portal.kernel.exception.SystemException {
424                    getPersistence().removeByC_P(companyId, portletId);
425            }
426    
427            /**
428            * Removes all the portlets from the database.
429            *
430            * @throws SystemException if a system exception occurred
431            */
432            public static void removeAll()
433                    throws com.liferay.portal.kernel.exception.SystemException {
434                    getPersistence().removeAll();
435            }
436    
437            /**
438            * Returns the number of portlets where companyId = &#63;.
439            *
440            * @param companyId the company ID
441            * @return the number of matching portlets
442            * @throws SystemException if a system exception occurred
443            */
444            public static int countByCompanyId(long companyId)
445                    throws com.liferay.portal.kernel.exception.SystemException {
446                    return getPersistence().countByCompanyId(companyId);
447            }
448    
449            /**
450            * Returns the number of portlets where companyId = &#63; and portletId = &#63;.
451            *
452            * @param companyId the company ID
453            * @param portletId the portlet ID
454            * @return the number of matching portlets
455            * @throws SystemException if a system exception occurred
456            */
457            public static int countByC_P(long companyId, java.lang.String portletId)
458                    throws com.liferay.portal.kernel.exception.SystemException {
459                    return getPersistence().countByC_P(companyId, portletId);
460            }
461    
462            /**
463            * Returns the number of portlets.
464            *
465            * @return the number of portlets
466            * @throws SystemException if a system exception occurred
467            */
468            public static int countAll()
469                    throws com.liferay.portal.kernel.exception.SystemException {
470                    return getPersistence().countAll();
471            }
472    
473            public static PortletPersistence getPersistence() {
474                    if (_persistence == null) {
475                            _persistence = (PortletPersistence)PortalBeanLocatorUtil.locate(PortletPersistence.class.getName());
476    
477                            ReferenceRegistry.registerReference(PortletUtil.class,
478                                    "_persistence");
479                    }
480    
481                    return _persistence;
482            }
483    
484            public void setPersistence(PortletPersistence persistence) {
485                    _persistence = persistence;
486    
487                    ReferenceRegistry.registerReference(PortletUtil.class, "_persistence");
488            }
489    
490            private static PortletPersistence _persistence;
491    }