001 /** 002 * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil; 020 import com.liferay.portal.kernel.dao.orm.DynamicQuery; 021 import com.liferay.portal.kernel.util.OrderByComparator; 022 import com.liferay.portal.kernel.util.ReferenceRegistry; 023 import com.liferay.portal.model.Portlet; 024 import com.liferay.portal.service.ServiceContext; 025 026 import java.util.List; 027 028 /** 029 * The persistence utility for the portlet service. This utility wraps {@link com.liferay.portal.service.persistence.impl.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. 030 * 031 * <p> 032 * Caching information and settings can be found in <code>portal.properties</code> 033 * </p> 034 * 035 * @author Brian Wing Shun Chan 036 * @see PortletPersistence 037 * @see com.liferay.portal.service.persistence.impl.PortletPersistenceImpl 038 * @generated 039 */ 040 @ProviderType 041 public class PortletUtil { 042 /* 043 * NOTE FOR DEVELOPERS: 044 * 045 * Never modify this class directly. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. 046 */ 047 048 /** 049 * @see com.liferay.portal.service.persistence.BasePersistence#clearCache() 050 */ 051 public static void clearCache() { 052 getPersistence().clearCache(); 053 } 054 055 /** 056 * @see com.liferay.portal.service.persistence.BasePersistence#clearCache(com.liferay.portal.model.BaseModel) 057 */ 058 public static void clearCache(Portlet portlet) { 059 getPersistence().clearCache(portlet); 060 } 061 062 /** 063 * @see com.liferay.portal.service.persistence.BasePersistence#countWithDynamicQuery(DynamicQuery) 064 */ 065 public static long countWithDynamicQuery(DynamicQuery dynamicQuery) { 066 return getPersistence().countWithDynamicQuery(dynamicQuery); 067 } 068 069 /** 070 * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery) 071 */ 072 public static List<Portlet> findWithDynamicQuery(DynamicQuery dynamicQuery) { 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 return getPersistence().findWithDynamicQuery(dynamicQuery, start, end); 082 } 083 084 /** 085 * @see com.liferay.portal.service.persistence.BasePersistence#findWithDynamicQuery(DynamicQuery, int, int, OrderByComparator) 086 */ 087 public static List<Portlet> findWithDynamicQuery( 088 DynamicQuery dynamicQuery, int start, int end, 089 OrderByComparator<Portlet> orderByComparator) { 090 return getPersistence() 091 .findWithDynamicQuery(dynamicQuery, start, end, 092 orderByComparator); 093 } 094 095 /** 096 * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel) 097 */ 098 public static Portlet update(Portlet portlet) { 099 return getPersistence().update(portlet); 100 } 101 102 /** 103 * @see com.liferay.portal.service.persistence.BasePersistence#update(com.liferay.portal.model.BaseModel, ServiceContext) 104 */ 105 public static Portlet update(Portlet portlet, ServiceContext serviceContext) { 106 return getPersistence().update(portlet, serviceContext); 107 } 108 109 /** 110 * Returns all the portlets where companyId = ?. 111 * 112 * @param companyId the company ID 113 * @return the matching portlets 114 */ 115 public static List<Portlet> findByCompanyId(long companyId) { 116 return getPersistence().findByCompanyId(companyId); 117 } 118 119 /** 120 * Returns a range of all the portlets where companyId = ?. 121 * 122 * <p> 123 * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PortletModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 124 * </p> 125 * 126 * @param companyId the company ID 127 * @param start the lower bound of the range of portlets 128 * @param end the upper bound of the range of portlets (not inclusive) 129 * @return the range of matching portlets 130 */ 131 public static List<Portlet> findByCompanyId(long companyId, int start, 132 int end) { 133 return getPersistence().findByCompanyId(companyId, start, end); 134 } 135 136 /** 137 * Returns an ordered range of all the portlets where companyId = ?. 138 * 139 * <p> 140 * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PortletModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 141 * </p> 142 * 143 * @param companyId the company ID 144 * @param start the lower bound of the range of portlets 145 * @param end the upper bound of the range of portlets (not inclusive) 146 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 147 * @return the ordered range of matching portlets 148 */ 149 public static List<Portlet> findByCompanyId(long companyId, int start, 150 int end, OrderByComparator<Portlet> orderByComparator) { 151 return getPersistence() 152 .findByCompanyId(companyId, start, end, orderByComparator); 153 } 154 155 /** 156 * Returns the first portlet in the ordered set where companyId = ?. 157 * 158 * @param companyId the company ID 159 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) 160 * @return the first matching portlet 161 * @throws NoSuchPortletException if a matching portlet could not be found 162 */ 163 public static Portlet findByCompanyId_First(long companyId, 164 OrderByComparator<Portlet> orderByComparator) 165 throws com.liferay.portal.NoSuchPortletException { 166 return getPersistence() 167 .findByCompanyId_First(companyId, orderByComparator); 168 } 169 170 /** 171 * Returns the first portlet in the ordered set where companyId = ?. 172 * 173 * @param companyId the company ID 174 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) 175 * @return the first matching portlet, or <code>null</code> if a matching portlet could not be found 176 */ 177 public static Portlet fetchByCompanyId_First(long companyId, 178 OrderByComparator<Portlet> orderByComparator) { 179 return getPersistence() 180 .fetchByCompanyId_First(companyId, orderByComparator); 181 } 182 183 /** 184 * Returns the last portlet in the ordered set where companyId = ?. 185 * 186 * @param companyId the company ID 187 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) 188 * @return the last matching portlet 189 * @throws NoSuchPortletException if a matching portlet could not be found 190 */ 191 public static Portlet findByCompanyId_Last(long companyId, 192 OrderByComparator<Portlet> orderByComparator) 193 throws com.liferay.portal.NoSuchPortletException { 194 return getPersistence() 195 .findByCompanyId_Last(companyId, orderByComparator); 196 } 197 198 /** 199 * Returns the last portlet in the ordered set where companyId = ?. 200 * 201 * @param companyId the company ID 202 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) 203 * @return the last matching portlet, or <code>null</code> if a matching portlet could not be found 204 */ 205 public static Portlet fetchByCompanyId_Last(long companyId, 206 OrderByComparator<Portlet> orderByComparator) { 207 return getPersistence() 208 .fetchByCompanyId_Last(companyId, orderByComparator); 209 } 210 211 /** 212 * Returns the portlets before and after the current portlet in the ordered set where companyId = ?. 213 * 214 * @param id the primary key of the current portlet 215 * @param companyId the company ID 216 * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) 217 * @return the previous, current, and next portlet 218 * @throws NoSuchPortletException if a portlet with the primary key could not be found 219 */ 220 public static Portlet[] findByCompanyId_PrevAndNext(long id, 221 long companyId, OrderByComparator<Portlet> orderByComparator) 222 throws com.liferay.portal.NoSuchPortletException { 223 return getPersistence() 224 .findByCompanyId_PrevAndNext(id, companyId, orderByComparator); 225 } 226 227 /** 228 * Removes all the portlets where companyId = ? from the database. 229 * 230 * @param companyId the company ID 231 */ 232 public static void removeByCompanyId(long companyId) { 233 getPersistence().removeByCompanyId(companyId); 234 } 235 236 /** 237 * Returns the number of portlets where companyId = ?. 238 * 239 * @param companyId the company ID 240 * @return the number of matching portlets 241 */ 242 public static int countByCompanyId(long companyId) { 243 return getPersistence().countByCompanyId(companyId); 244 } 245 246 /** 247 * Returns the portlet where companyId = ? and portletId = ? or throws a {@link NoSuchPortletException} if it could not be found. 248 * 249 * @param companyId the company ID 250 * @param portletId the portlet ID 251 * @return the matching portlet 252 * @throws NoSuchPortletException if a matching portlet could not be found 253 */ 254 public static Portlet findByC_P(long companyId, java.lang.String portletId) 255 throws com.liferay.portal.NoSuchPortletException { 256 return getPersistence().findByC_P(companyId, portletId); 257 } 258 259 /** 260 * Returns the portlet where companyId = ? and portletId = ? or returns <code>null</code> if it could not be found. Uses the finder cache. 261 * 262 * @param companyId the company ID 263 * @param portletId the portlet ID 264 * @return the matching portlet, or <code>null</code> if a matching portlet could not be found 265 */ 266 public static Portlet fetchByC_P(long companyId, java.lang.String portletId) { 267 return getPersistence().fetchByC_P(companyId, portletId); 268 } 269 270 /** 271 * Returns the portlet where companyId = ? and portletId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache. 272 * 273 * @param companyId the company ID 274 * @param portletId the portlet ID 275 * @param retrieveFromCache whether to use the finder cache 276 * @return the matching portlet, or <code>null</code> if a matching portlet could not be found 277 */ 278 public static Portlet fetchByC_P(long companyId, 279 java.lang.String portletId, boolean retrieveFromCache) { 280 return getPersistence() 281 .fetchByC_P(companyId, portletId, retrieveFromCache); 282 } 283 284 /** 285 * Removes the portlet where companyId = ? and portletId = ? from the database. 286 * 287 * @param companyId the company ID 288 * @param portletId the portlet ID 289 * @return the portlet that was removed 290 */ 291 public static Portlet removeByC_P(long companyId, java.lang.String portletId) 292 throws com.liferay.portal.NoSuchPortletException { 293 return getPersistence().removeByC_P(companyId, portletId); 294 } 295 296 /** 297 * Returns the number of portlets where companyId = ? and portletId = ?. 298 * 299 * @param companyId the company ID 300 * @param portletId the portlet ID 301 * @return the number of matching portlets 302 */ 303 public static int countByC_P(long companyId, java.lang.String portletId) { 304 return getPersistence().countByC_P(companyId, portletId); 305 } 306 307 /** 308 * Caches the portlet in the entity cache if it is enabled. 309 * 310 * @param portlet the portlet 311 */ 312 public static void cacheResult(Portlet portlet) { 313 getPersistence().cacheResult(portlet); 314 } 315 316 /** 317 * Caches the portlets in the entity cache if it is enabled. 318 * 319 * @param portlets the portlets 320 */ 321 public static void cacheResult(List<Portlet> portlets) { 322 getPersistence().cacheResult(portlets); 323 } 324 325 /** 326 * Creates a new portlet with the primary key. Does not add the portlet to the database. 327 * 328 * @param id the primary key for the new portlet 329 * @return the new portlet 330 */ 331 public static Portlet create(long id) { 332 return getPersistence().create(id); 333 } 334 335 /** 336 * Removes the portlet with the primary key from the database. Also notifies the appropriate model listeners. 337 * 338 * @param id the primary key of the portlet 339 * @return the portlet that was removed 340 * @throws NoSuchPortletException if a portlet with the primary key could not be found 341 */ 342 public static Portlet remove(long id) 343 throws com.liferay.portal.NoSuchPortletException { 344 return getPersistence().remove(id); 345 } 346 347 public static Portlet updateImpl(Portlet portlet) { 348 return getPersistence().updateImpl(portlet); 349 } 350 351 /** 352 * Returns the portlet with the primary key or throws a {@link NoSuchPortletException} if it could not be found. 353 * 354 * @param id the primary key of the portlet 355 * @return the portlet 356 * @throws NoSuchPortletException if a portlet with the primary key could not be found 357 */ 358 public static Portlet findByPrimaryKey(long id) 359 throws com.liferay.portal.NoSuchPortletException { 360 return getPersistence().findByPrimaryKey(id); 361 } 362 363 /** 364 * Returns the portlet with the primary key or returns <code>null</code> if it could not be found. 365 * 366 * @param id the primary key of the portlet 367 * @return the portlet, or <code>null</code> if a portlet with the primary key could not be found 368 */ 369 public static Portlet fetchByPrimaryKey(long id) { 370 return getPersistence().fetchByPrimaryKey(id); 371 } 372 373 public static java.util.Map<java.io.Serializable, Portlet> fetchByPrimaryKeys( 374 java.util.Set<java.io.Serializable> primaryKeys) { 375 return getPersistence().fetchByPrimaryKeys(primaryKeys); 376 } 377 378 /** 379 * Returns all the portlets. 380 * 381 * @return the portlets 382 */ 383 public static List<Portlet> findAll() { 384 return getPersistence().findAll(); 385 } 386 387 /** 388 * Returns a range of all the portlets. 389 * 390 * <p> 391 * 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PortletModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 392 * </p> 393 * 394 * @param start the lower bound of the range of portlets 395 * @param end the upper bound of the range of portlets (not inclusive) 396 * @return the range of portlets 397 */ 398 public static List<Portlet> findAll(int start, int end) { 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 QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link PortletModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 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 */ 414 public static List<Portlet> findAll(int start, int end, 415 OrderByComparator<Portlet> orderByComparator) { 416 return getPersistence().findAll(start, end, orderByComparator); 417 } 418 419 /** 420 * Removes all the portlets from the database. 421 */ 422 public static void removeAll() { 423 getPersistence().removeAll(); 424 } 425 426 /** 427 * Returns the number of portlets. 428 * 429 * @return the number of portlets 430 */ 431 public static int countAll() { 432 return getPersistence().countAll(); 433 } 434 435 public static PortletPersistence getPersistence() { 436 if (_persistence == null) { 437 _persistence = (PortletPersistence)PortalBeanLocatorUtil.locate(PortletPersistence.class.getName()); 438 439 ReferenceRegistry.registerReference(PortletUtil.class, 440 "_persistence"); 441 } 442 443 return _persistence; 444 } 445 446 /** 447 * @deprecated As of 6.2.0 448 */ 449 @Deprecated 450 public void setPersistence(PortletPersistence persistence) { 451 } 452 453 private static PortletPersistence _persistence; 454 }