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