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