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)
098             */
099            public static Portlet update(Portlet portlet) throws SystemException {
100                    return getPersistence().update(portlet);
101            }
102    
103            /**
104             * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, ServiceContext)
105             */
106            public static Portlet update(Portlet portlet, ServiceContext serviceContext)
107                    throws SystemException {
108                    return getPersistence().update(portlet, serviceContext);
109            }
110    
111            /**
112            * Caches the portlet in the entity cache if it is enabled.
113            *
114            * @param portlet the portlet
115            */
116            public static void cacheResult(com.liferay.portal.model.Portlet portlet) {
117                    getPersistence().cacheResult(portlet);
118            }
119    
120            /**
121            * Caches the portlets in the entity cache if it is enabled.
122            *
123            * @param portlets the portlets
124            */
125            public static void cacheResult(
126                    java.util.List<com.liferay.portal.model.Portlet> portlets) {
127                    getPersistence().cacheResult(portlets);
128            }
129    
130            /**
131            * Creates a new portlet with the primary key. Does not add the portlet to the database.
132            *
133            * @param id the primary key for the new portlet
134            * @return the new portlet
135            */
136            public static com.liferay.portal.model.Portlet create(long id) {
137                    return getPersistence().create(id);
138            }
139    
140            /**
141            * Removes the portlet with the primary key from the database. Also notifies the appropriate model listeners.
142            *
143            * @param id the primary key of the portlet
144            * @return the portlet that was removed
145            * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
146            * @throws SystemException if a system exception occurred
147            */
148            public static com.liferay.portal.model.Portlet remove(long id)
149                    throws com.liferay.portal.NoSuchPortletException,
150                            com.liferay.portal.kernel.exception.SystemException {
151                    return getPersistence().remove(id);
152            }
153    
154            public static com.liferay.portal.model.Portlet updateImpl(
155                    com.liferay.portal.model.Portlet portlet)
156                    throws com.liferay.portal.kernel.exception.SystemException {
157                    return getPersistence().updateImpl(portlet);
158            }
159    
160            /**
161            * Returns the portlet with the primary key or throws a {@link com.liferay.portal.NoSuchPortletException} if it could not be found.
162            *
163            * @param id the primary key of the portlet
164            * @return the portlet
165            * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
166            * @throws SystemException if a system exception occurred
167            */
168            public static com.liferay.portal.model.Portlet findByPrimaryKey(long id)
169                    throws com.liferay.portal.NoSuchPortletException,
170                            com.liferay.portal.kernel.exception.SystemException {
171                    return getPersistence().findByPrimaryKey(id);
172            }
173    
174            /**
175            * Returns the portlet with the primary key or returns <code>null</code> if it could not be found.
176            *
177            * @param id the primary key of the portlet
178            * @return the portlet, or <code>null</code> if a portlet with the primary key could not be found
179            * @throws SystemException if a system exception occurred
180            */
181            public static com.liferay.portal.model.Portlet fetchByPrimaryKey(long id)
182                    throws com.liferay.portal.kernel.exception.SystemException {
183                    return getPersistence().fetchByPrimaryKey(id);
184            }
185    
186            /**
187            * Returns all the portlets where companyId = &#63;.
188            *
189            * @param companyId the company ID
190            * @return the matching portlets
191            * @throws SystemException if a system exception occurred
192            */
193            public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
194                    long companyId)
195                    throws com.liferay.portal.kernel.exception.SystemException {
196                    return getPersistence().findByCompanyId(companyId);
197            }
198    
199            /**
200            * Returns a range of all the portlets where companyId = &#63;.
201            *
202            * <p>
203            * 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.
204            * </p>
205            *
206            * @param companyId the company ID
207            * @param start the lower bound of the range of portlets
208            * @param end the upper bound of the range of portlets (not inclusive)
209            * @return the range of matching portlets
210            * @throws SystemException if a system exception occurred
211            */
212            public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
213                    long companyId, int start, int end)
214                    throws com.liferay.portal.kernel.exception.SystemException {
215                    return getPersistence().findByCompanyId(companyId, start, end);
216            }
217    
218            /**
219            * Returns an ordered range of all the portlets where companyId = &#63;.
220            *
221            * <p>
222            * 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.
223            * </p>
224            *
225            * @param companyId the company ID
226            * @param start the lower bound of the range of portlets
227            * @param end the upper bound of the range of portlets (not inclusive)
228            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
229            * @return the ordered range of matching portlets
230            * @throws SystemException if a system exception occurred
231            */
232            public static java.util.List<com.liferay.portal.model.Portlet> findByCompanyId(
233                    long companyId, int start, int end,
234                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
235                    throws com.liferay.portal.kernel.exception.SystemException {
236                    return getPersistence()
237                                       .findByCompanyId(companyId, start, end, orderByComparator);
238            }
239    
240            /**
241            * Returns the first portlet in the ordered set where companyId = &#63;.
242            *
243            * @param companyId the company ID
244            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
245            * @return the first matching portlet
246            * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
247            * @throws SystemException if a system exception occurred
248            */
249            public static com.liferay.portal.model.Portlet findByCompanyId_First(
250                    long companyId,
251                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
252                    throws com.liferay.portal.NoSuchPortletException,
253                            com.liferay.portal.kernel.exception.SystemException {
254                    return getPersistence()
255                                       .findByCompanyId_First(companyId, orderByComparator);
256            }
257    
258            /**
259            * Returns the first portlet in the ordered set where companyId = &#63;.
260            *
261            * @param companyId the company ID
262            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
263            * @return the first matching portlet, or <code>null</code> if a matching portlet could not be found
264            * @throws SystemException if a system exception occurred
265            */
266            public static com.liferay.portal.model.Portlet fetchByCompanyId_First(
267                    long companyId,
268                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
269                    throws com.liferay.portal.kernel.exception.SystemException {
270                    return getPersistence()
271                                       .fetchByCompanyId_First(companyId, orderByComparator);
272            }
273    
274            /**
275            * Returns the last portlet in the ordered set where companyId = &#63;.
276            *
277            * @param companyId the company ID
278            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
279            * @return the last matching portlet
280            * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
281            * @throws SystemException if a system exception occurred
282            */
283            public static com.liferay.portal.model.Portlet findByCompanyId_Last(
284                    long companyId,
285                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
286                    throws com.liferay.portal.NoSuchPortletException,
287                            com.liferay.portal.kernel.exception.SystemException {
288                    return getPersistence()
289                                       .findByCompanyId_Last(companyId, orderByComparator);
290            }
291    
292            /**
293            * Returns the last portlet in the ordered set where companyId = &#63;.
294            *
295            * @param companyId the company ID
296            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
297            * @return the last matching portlet, or <code>null</code> if a matching portlet could not be found
298            * @throws SystemException if a system exception occurred
299            */
300            public static com.liferay.portal.model.Portlet fetchByCompanyId_Last(
301                    long companyId,
302                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
303                    throws com.liferay.portal.kernel.exception.SystemException {
304                    return getPersistence()
305                                       .fetchByCompanyId_Last(companyId, orderByComparator);
306            }
307    
308            /**
309            * Returns the portlets before and after the current portlet in the ordered set where companyId = &#63;.
310            *
311            * @param id the primary key of the current portlet
312            * @param companyId the company ID
313            * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
314            * @return the previous, current, and next portlet
315            * @throws com.liferay.portal.NoSuchPortletException if a portlet with the primary key could not be found
316            * @throws SystemException if a system exception occurred
317            */
318            public static com.liferay.portal.model.Portlet[] findByCompanyId_PrevAndNext(
319                    long id, long companyId,
320                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
321                    throws com.liferay.portal.NoSuchPortletException,
322                            com.liferay.portal.kernel.exception.SystemException {
323                    return getPersistence()
324                                       .findByCompanyId_PrevAndNext(id, companyId, orderByComparator);
325            }
326    
327            /**
328            * Returns the portlet where companyId = &#63; and portletId = &#63; or throws a {@link com.liferay.portal.NoSuchPortletException} if it could not be found.
329            *
330            * @param companyId the company ID
331            * @param portletId the portlet ID
332            * @return the matching portlet
333            * @throws com.liferay.portal.NoSuchPortletException if a matching portlet could not be found
334            * @throws SystemException if a system exception occurred
335            */
336            public static com.liferay.portal.model.Portlet findByC_P(long companyId,
337                    java.lang.String portletId)
338                    throws com.liferay.portal.NoSuchPortletException,
339                            com.liferay.portal.kernel.exception.SystemException {
340                    return getPersistence().findByC_P(companyId, portletId);
341            }
342    
343            /**
344            * Returns the portlet where companyId = &#63; and portletId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
345            *
346            * @param companyId the company ID
347            * @param portletId the portlet ID
348            * @return the matching portlet, or <code>null</code> if a matching portlet could not be found
349            * @throws SystemException if a system exception occurred
350            */
351            public static com.liferay.portal.model.Portlet fetchByC_P(long companyId,
352                    java.lang.String portletId)
353                    throws com.liferay.portal.kernel.exception.SystemException {
354                    return getPersistence().fetchByC_P(companyId, portletId);
355            }
356    
357            /**
358            * 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.
359            *
360            * @param companyId the company ID
361            * @param portletId the portlet ID
362            * @param retrieveFromCache whether to use the finder cache
363            * @return the matching portlet, or <code>null</code> if a matching portlet could not be found
364            * @throws SystemException if a system exception occurred
365            */
366            public static com.liferay.portal.model.Portlet fetchByC_P(long companyId,
367                    java.lang.String portletId, boolean retrieveFromCache)
368                    throws com.liferay.portal.kernel.exception.SystemException {
369                    return getPersistence()
370                                       .fetchByC_P(companyId, portletId, retrieveFromCache);
371            }
372    
373            /**
374            * Returns all the portlets.
375            *
376            * @return the portlets
377            * @throws SystemException if a system exception occurred
378            */
379            public static java.util.List<com.liferay.portal.model.Portlet> findAll()
380                    throws com.liferay.portal.kernel.exception.SystemException {
381                    return getPersistence().findAll();
382            }
383    
384            /**
385            * Returns a range of all the portlets.
386            *
387            * <p>
388            * 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.
389            * </p>
390            *
391            * @param start the lower bound of the range of portlets
392            * @param end the upper bound of the range of portlets (not inclusive)
393            * @return the 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                    throws com.liferay.portal.kernel.exception.SystemException {
399                    return getPersistence().findAll(start, end);
400            }
401    
402            /**
403            * Returns an ordered range of all the portlets.
404            *
405            * <p>
406            * 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.
407            * </p>
408            *
409            * @param start the lower bound of the range of portlets
410            * @param end the upper bound of the range of portlets (not inclusive)
411            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
412            * @return the ordered range of portlets
413            * @throws SystemException if a system exception occurred
414            */
415            public static java.util.List<com.liferay.portal.model.Portlet> findAll(
416                    int start, int end,
417                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
418                    throws com.liferay.portal.kernel.exception.SystemException {
419                    return getPersistence().findAll(start, end, orderByComparator);
420            }
421    
422            /**
423            * Removes all the portlets where companyId = &#63; from the database.
424            *
425            * @param companyId the company ID
426            * @throws SystemException if a system exception occurred
427            */
428            public static void removeByCompanyId(long companyId)
429                    throws com.liferay.portal.kernel.exception.SystemException {
430                    getPersistence().removeByCompanyId(companyId);
431            }
432    
433            /**
434            * Removes the portlet where companyId = &#63; and portletId = &#63; from the database.
435            *
436            * @param companyId the company ID
437            * @param portletId the portlet ID
438            * @return the portlet that was removed
439            * @throws SystemException if a system exception occurred
440            */
441            public static com.liferay.portal.model.Portlet removeByC_P(long companyId,
442                    java.lang.String portletId)
443                    throws com.liferay.portal.NoSuchPortletException,
444                            com.liferay.portal.kernel.exception.SystemException {
445                    return getPersistence().removeByC_P(companyId, portletId);
446            }
447    
448            /**
449            * Removes all the portlets from the database.
450            *
451            * @throws SystemException if a system exception occurred
452            */
453            public static void removeAll()
454                    throws com.liferay.portal.kernel.exception.SystemException {
455                    getPersistence().removeAll();
456            }
457    
458            /**
459            * Returns the number of portlets where companyId = &#63;.
460            *
461            * @param companyId the company ID
462            * @return the number of matching portlets
463            * @throws SystemException if a system exception occurred
464            */
465            public static int countByCompanyId(long companyId)
466                    throws com.liferay.portal.kernel.exception.SystemException {
467                    return getPersistence().countByCompanyId(companyId);
468            }
469    
470            /**
471            * Returns the number of portlets where companyId = &#63; and portletId = &#63;.
472            *
473            * @param companyId the company ID
474            * @param portletId the portlet ID
475            * @return the number of matching portlets
476            * @throws SystemException if a system exception occurred
477            */
478            public static int countByC_P(long companyId, java.lang.String portletId)
479                    throws com.liferay.portal.kernel.exception.SystemException {
480                    return getPersistence().countByC_P(companyId, portletId);
481            }
482    
483            /**
484            * Returns the number of portlets.
485            *
486            * @return the number of portlets
487            * @throws SystemException if a system exception occurred
488            */
489            public static int countAll()
490                    throws com.liferay.portal.kernel.exception.SystemException {
491                    return getPersistence().countAll();
492            }
493    
494            public static PortletPersistence getPersistence() {
495                    if (_persistence == null) {
496                            _persistence = (PortletPersistence)PortalBeanLocatorUtil.locate(PortletPersistence.class.getName());
497    
498                            ReferenceRegistry.registerReference(PortletUtil.class,
499                                    "_persistence");
500                    }
501    
502                    return _persistence;
503            }
504    
505            /**
506             * @deprecated
507             */
508            public void setPersistence(PortletPersistence persistence) {
509            }
510    
511            private static PortletPersistence _persistence;
512    }