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