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