001 /** 002 * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved. 003 * 004 * The contents of this file are subject to the terms of the Liferay Enterprise 005 * Subscription License ("License"). You may not use this file except in 006 * compliance with the License. You can obtain a copy of the License by 007 * contacting Liferay, Inc. See the License for the specific language governing 008 * permissions and limitations under the License, including but not limited to 009 * distribution rights of the Software. 010 * 011 * 012 * 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 to cache 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 to cache 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 to remove 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 * Finds 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 to find 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 * Finds 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 to find 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 * Finds all the portlets where companyId = ?. 196 * 197 * @param companyId the company ID to search with 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 * Finds 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 to search with 215 * @param start the lower bound of the range of portlets to return 216 * @param end the upper bound of the range of portlets to return (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 * Finds 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 to search with 234 * @param start the lower bound of the range of portlets to return 235 * @param end the upper bound of the range of portlets to return (not inclusive) 236 * @param orderByComparator the comparator to order the results by 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 * Finds 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 to search with 256 * @param orderByComparator the comparator to order the set by 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 * Finds 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 to search with 278 * @param orderByComparator the comparator to order the set by 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 * Finds 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 to search with 301 * @param orderByComparator the comparator to order the set by 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 * Finds 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 to search with 319 * @param portletId the portlet ID to search with 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 * Finds 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 to search with 335 * @param portletId the portlet ID to search with 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 * Finds 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 to search with 349 * @param portletId the portlet ID to search with 350 * @return the matching portlet, or <code>null</code> if a matching portlet could not be found 351 * @throws SystemException if a system exception occurred 352 */ 353 public static com.liferay.portal.model.Portlet fetchByC_P(long companyId, 354 java.lang.String portletId, boolean retrieveFromCache) 355 throws com.liferay.portal.kernel.exception.SystemException { 356 return getPersistence() 357 .fetchByC_P(companyId, portletId, retrieveFromCache); 358 } 359 360 /** 361 * Finds all the portlets. 362 * 363 * @return the portlets 364 * @throws SystemException if a system exception occurred 365 */ 366 public static java.util.List<com.liferay.portal.model.Portlet> findAll() 367 throws com.liferay.portal.kernel.exception.SystemException { 368 return getPersistence().findAll(); 369 } 370 371 /** 372 * Finds a range of all the portlets. 373 * 374 * <p> 375 * 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. 376 * </p> 377 * 378 * @param start the lower bound of the range of portlets to return 379 * @param end the upper bound of the range of portlets to return (not inclusive) 380 * @return the range of portlets 381 * @throws SystemException if a system exception occurred 382 */ 383 public static java.util.List<com.liferay.portal.model.Portlet> findAll( 384 int start, int end) 385 throws com.liferay.portal.kernel.exception.SystemException { 386 return getPersistence().findAll(start, end); 387 } 388 389 /** 390 * Finds an ordered range of all the portlets. 391 * 392 * <p> 393 * 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. 394 * </p> 395 * 396 * @param start the lower bound of the range of portlets to return 397 * @param end the upper bound of the range of portlets to return (not inclusive) 398 * @param orderByComparator the comparator to order the results by 399 * @return the ordered range of portlets 400 * @throws SystemException if a system exception occurred 401 */ 402 public static java.util.List<com.liferay.portal.model.Portlet> findAll( 403 int start, int end, 404 com.liferay.portal.kernel.util.OrderByComparator orderByComparator) 405 throws com.liferay.portal.kernel.exception.SystemException { 406 return getPersistence().findAll(start, end, orderByComparator); 407 } 408 409 /** 410 * Removes all the portlets where companyId = ? from the database. 411 * 412 * @param companyId the company ID to search with 413 * @throws SystemException if a system exception occurred 414 */ 415 public static void removeByCompanyId(long companyId) 416 throws com.liferay.portal.kernel.exception.SystemException { 417 getPersistence().removeByCompanyId(companyId); 418 } 419 420 /** 421 * Removes the portlet where companyId = ? and portletId = ? from the database. 422 * 423 * @param companyId the company ID to search with 424 * @param portletId the portlet ID to search with 425 * @throws SystemException if a system exception occurred 426 */ 427 public static void removeByC_P(long companyId, java.lang.String portletId) 428 throws com.liferay.portal.NoSuchPortletException, 429 com.liferay.portal.kernel.exception.SystemException { 430 getPersistence().removeByC_P(companyId, portletId); 431 } 432 433 /** 434 * Removes all the portlets from the database. 435 * 436 * @throws SystemException if a system exception occurred 437 */ 438 public static void removeAll() 439 throws com.liferay.portal.kernel.exception.SystemException { 440 getPersistence().removeAll(); 441 } 442 443 /** 444 * Counts all the portlets where companyId = ?. 445 * 446 * @param companyId the company ID to search with 447 * @return the number of matching portlets 448 * @throws SystemException if a system exception occurred 449 */ 450 public static int countByCompanyId(long companyId) 451 throws com.liferay.portal.kernel.exception.SystemException { 452 return getPersistence().countByCompanyId(companyId); 453 } 454 455 /** 456 * Counts all the portlets where companyId = ? and portletId = ?. 457 * 458 * @param companyId the company ID to search with 459 * @param portletId the portlet ID to search with 460 * @return the number of matching portlets 461 * @throws SystemException if a system exception occurred 462 */ 463 public static int countByC_P(long companyId, java.lang.String portletId) 464 throws com.liferay.portal.kernel.exception.SystemException { 465 return getPersistence().countByC_P(companyId, portletId); 466 } 467 468 /** 469 * Counts all the portlets. 470 * 471 * @return the number of portlets 472 * @throws SystemException if a system exception occurred 473 */ 474 public static int countAll() 475 throws com.liferay.portal.kernel.exception.SystemException { 476 return getPersistence().countAll(); 477 } 478 479 public static PortletPersistence getPersistence() { 480 if (_persistence == null) { 481 _persistence = (PortletPersistence)PortalBeanLocatorUtil.locate(PortletPersistence.class.getName()); 482 483 ReferenceRegistry.registerReference(PortletUtil.class, 484 "_persistence"); 485 } 486 487 return _persistence; 488 } 489 490 public void setPersistence(PortletPersistence persistence) { 491 _persistence = persistence; 492 493 ReferenceRegistry.registerReference(PortletUtil.class, "_persistence"); 494 } 495 496 private static PortletPersistence _persistence; 497 }