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