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.portlet.trash.service.base; 016 017 import com.liferay.portal.kernel.bean.BeanReference; 018 import com.liferay.portal.kernel.bean.IdentifiableBean; 019 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate; 020 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil; 021 import com.liferay.portal.kernel.dao.orm.DynamicQuery; 022 import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil; 023 import com.liferay.portal.kernel.dao.orm.Projection; 024 import com.liferay.portal.kernel.exception.PortalException; 025 import com.liferay.portal.kernel.exception.SystemException; 026 import com.liferay.portal.kernel.search.Indexable; 027 import com.liferay.portal.kernel.search.IndexableType; 028 import com.liferay.portal.kernel.util.OrderByComparator; 029 import com.liferay.portal.model.PersistedModel; 030 import com.liferay.portal.service.BaseLocalServiceImpl; 031 import com.liferay.portal.service.PersistedModelLocalServiceRegistry; 032 import com.liferay.portal.service.persistence.UserFinder; 033 import com.liferay.portal.service.persistence.UserPersistence; 034 035 import com.liferay.portlet.trash.model.TrashVersion; 036 import com.liferay.portlet.trash.service.TrashVersionLocalService; 037 import com.liferay.portlet.trash.service.persistence.TrashEntryPersistence; 038 import com.liferay.portlet.trash.service.persistence.TrashVersionPersistence; 039 040 import java.io.Serializable; 041 042 import java.util.List; 043 044 import javax.sql.DataSource; 045 046 /** 047 * Provides the base implementation for the trash version local service. 048 * 049 * <p> 050 * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portlet.trash.service.impl.TrashVersionLocalServiceImpl}. 051 * </p> 052 * 053 * @author Brian Wing Shun Chan 054 * @see com.liferay.portlet.trash.service.impl.TrashVersionLocalServiceImpl 055 * @see com.liferay.portlet.trash.service.TrashVersionLocalServiceUtil 056 * @generated 057 */ 058 public abstract class TrashVersionLocalServiceBaseImpl 059 extends BaseLocalServiceImpl implements TrashVersionLocalService, 060 IdentifiableBean { 061 /* 062 * NOTE FOR DEVELOPERS: 063 * 064 * Never modify or reference this class directly. Always use {@link com.liferay.portlet.trash.service.TrashVersionLocalServiceUtil} to access the trash version local service. 065 */ 066 067 /** 068 * Adds the trash version to the database. Also notifies the appropriate model listeners. 069 * 070 * @param trashVersion the trash version 071 * @return the trash version that was added 072 * @throws SystemException if a system exception occurred 073 */ 074 @Indexable(type = IndexableType.REINDEX) 075 @Override 076 public TrashVersion addTrashVersion(TrashVersion trashVersion) 077 throws SystemException { 078 trashVersion.setNew(true); 079 080 return trashVersionPersistence.update(trashVersion); 081 } 082 083 /** 084 * Creates a new trash version with the primary key. Does not add the trash version to the database. 085 * 086 * @param versionId the primary key for the new trash version 087 * @return the new trash version 088 */ 089 @Override 090 public TrashVersion createTrashVersion(long versionId) { 091 return trashVersionPersistence.create(versionId); 092 } 093 094 /** 095 * Deletes the trash version with the primary key from the database. Also notifies the appropriate model listeners. 096 * 097 * @param versionId the primary key of the trash version 098 * @return the trash version that was removed 099 * @throws PortalException if a trash version with the primary key could not be found 100 * @throws SystemException if a system exception occurred 101 */ 102 @Indexable(type = IndexableType.DELETE) 103 @Override 104 public TrashVersion deleteTrashVersion(long versionId) 105 throws PortalException, SystemException { 106 return trashVersionPersistence.remove(versionId); 107 } 108 109 /** 110 * Deletes the trash version from the database. Also notifies the appropriate model listeners. 111 * 112 * @param trashVersion the trash version 113 * @return the trash version that was removed 114 * @throws SystemException if a system exception occurred 115 */ 116 @Indexable(type = IndexableType.DELETE) 117 @Override 118 public TrashVersion deleteTrashVersion(TrashVersion trashVersion) 119 throws SystemException { 120 return trashVersionPersistence.remove(trashVersion); 121 } 122 123 @Override 124 public DynamicQuery dynamicQuery() { 125 Class<?> clazz = getClass(); 126 127 return DynamicQueryFactoryUtil.forClass(TrashVersion.class, 128 clazz.getClassLoader()); 129 } 130 131 /** 132 * Performs a dynamic query on the database and returns the matching rows. 133 * 134 * @param dynamicQuery the dynamic query 135 * @return the matching rows 136 * @throws SystemException if a system exception occurred 137 */ 138 @Override 139 @SuppressWarnings("rawtypes") 140 public List dynamicQuery(DynamicQuery dynamicQuery) 141 throws SystemException { 142 return trashVersionPersistence.findWithDynamicQuery(dynamicQuery); 143 } 144 145 /** 146 * Performs a dynamic query on the database and returns a range of the matching rows. 147 * 148 * <p> 149 * 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.portlet.trash.model.impl.TrashVersionModelImpl}. 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. 150 * </p> 151 * 152 * @param dynamicQuery the dynamic query 153 * @param start the lower bound of the range of model instances 154 * @param end the upper bound of the range of model instances (not inclusive) 155 * @return the range of matching rows 156 * @throws SystemException if a system exception occurred 157 */ 158 @Override 159 @SuppressWarnings("rawtypes") 160 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end) 161 throws SystemException { 162 return trashVersionPersistence.findWithDynamicQuery(dynamicQuery, 163 start, end); 164 } 165 166 /** 167 * Performs a dynamic query on the database and returns an ordered range of the matching rows. 168 * 169 * <p> 170 * 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.portlet.trash.model.impl.TrashVersionModelImpl}. 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. 171 * </p> 172 * 173 * @param dynamicQuery the dynamic query 174 * @param start the lower bound of the range of model instances 175 * @param end the upper bound of the range of model instances (not inclusive) 176 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 177 * @return the ordered range of matching rows 178 * @throws SystemException if a system exception occurred 179 */ 180 @Override 181 @SuppressWarnings("rawtypes") 182 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end, 183 OrderByComparator orderByComparator) throws SystemException { 184 return trashVersionPersistence.findWithDynamicQuery(dynamicQuery, 185 start, end, orderByComparator); 186 } 187 188 /** 189 * Returns the number of rows that match the dynamic query. 190 * 191 * @param dynamicQuery the dynamic query 192 * @return the number of rows that match the dynamic query 193 * @throws SystemException if a system exception occurred 194 */ 195 @Override 196 public long dynamicQueryCount(DynamicQuery dynamicQuery) 197 throws SystemException { 198 return trashVersionPersistence.countWithDynamicQuery(dynamicQuery); 199 } 200 201 /** 202 * Returns the number of rows that match the dynamic query. 203 * 204 * @param dynamicQuery the dynamic query 205 * @param projection the projection to apply to the query 206 * @return the number of rows that match the dynamic query 207 * @throws SystemException if a system exception occurred 208 */ 209 @Override 210 public long dynamicQueryCount(DynamicQuery dynamicQuery, 211 Projection projection) throws SystemException { 212 return trashVersionPersistence.countWithDynamicQuery(dynamicQuery, 213 projection); 214 } 215 216 @Override 217 public TrashVersion fetchTrashVersion(long versionId) 218 throws SystemException { 219 return trashVersionPersistence.fetchByPrimaryKey(versionId); 220 } 221 222 /** 223 * Returns the trash version with the primary key. 224 * 225 * @param versionId the primary key of the trash version 226 * @return the trash version 227 * @throws PortalException if a trash version with the primary key could not be found 228 * @throws SystemException if a system exception occurred 229 */ 230 @Override 231 public TrashVersion getTrashVersion(long versionId) 232 throws PortalException, SystemException { 233 return trashVersionPersistence.findByPrimaryKey(versionId); 234 } 235 236 @Override 237 public PersistedModel getPersistedModel(Serializable primaryKeyObj) 238 throws PortalException, SystemException { 239 return trashVersionPersistence.findByPrimaryKey(primaryKeyObj); 240 } 241 242 /** 243 * Returns a range of all the trash versions. 244 * 245 * <p> 246 * 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.portlet.trash.model.impl.TrashVersionModelImpl}. 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. 247 * </p> 248 * 249 * @param start the lower bound of the range of trash versions 250 * @param end the upper bound of the range of trash versions (not inclusive) 251 * @return the range of trash versions 252 * @throws SystemException if a system exception occurred 253 */ 254 @Override 255 public List<TrashVersion> getTrashVersions(int start, int end) 256 throws SystemException { 257 return trashVersionPersistence.findAll(start, end); 258 } 259 260 /** 261 * Returns the number of trash versions. 262 * 263 * @return the number of trash versions 264 * @throws SystemException if a system exception occurred 265 */ 266 @Override 267 public int getTrashVersionsCount() throws SystemException { 268 return trashVersionPersistence.countAll(); 269 } 270 271 /** 272 * Updates the trash version in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. 273 * 274 * @param trashVersion the trash version 275 * @return the trash version that was updated 276 * @throws SystemException if a system exception occurred 277 */ 278 @Indexable(type = IndexableType.REINDEX) 279 @Override 280 public TrashVersion updateTrashVersion(TrashVersion trashVersion) 281 throws SystemException { 282 return trashVersionPersistence.update(trashVersion); 283 } 284 285 /** 286 * Returns the trash entry local service. 287 * 288 * @return the trash entry local service 289 */ 290 public com.liferay.portlet.trash.service.TrashEntryLocalService getTrashEntryLocalService() { 291 return trashEntryLocalService; 292 } 293 294 /** 295 * Sets the trash entry local service. 296 * 297 * @param trashEntryLocalService the trash entry local service 298 */ 299 public void setTrashEntryLocalService( 300 com.liferay.portlet.trash.service.TrashEntryLocalService trashEntryLocalService) { 301 this.trashEntryLocalService = trashEntryLocalService; 302 } 303 304 /** 305 * Returns the trash entry remote service. 306 * 307 * @return the trash entry remote service 308 */ 309 public com.liferay.portlet.trash.service.TrashEntryService getTrashEntryService() { 310 return trashEntryService; 311 } 312 313 /** 314 * Sets the trash entry remote service. 315 * 316 * @param trashEntryService the trash entry remote service 317 */ 318 public void setTrashEntryService( 319 com.liferay.portlet.trash.service.TrashEntryService trashEntryService) { 320 this.trashEntryService = trashEntryService; 321 } 322 323 /** 324 * Returns the trash entry persistence. 325 * 326 * @return the trash entry persistence 327 */ 328 public TrashEntryPersistence getTrashEntryPersistence() { 329 return trashEntryPersistence; 330 } 331 332 /** 333 * Sets the trash entry persistence. 334 * 335 * @param trashEntryPersistence the trash entry persistence 336 */ 337 public void setTrashEntryPersistence( 338 TrashEntryPersistence trashEntryPersistence) { 339 this.trashEntryPersistence = trashEntryPersistence; 340 } 341 342 /** 343 * Returns the trash version local service. 344 * 345 * @return the trash version local service 346 */ 347 public com.liferay.portlet.trash.service.TrashVersionLocalService getTrashVersionLocalService() { 348 return trashVersionLocalService; 349 } 350 351 /** 352 * Sets the trash version local service. 353 * 354 * @param trashVersionLocalService the trash version local service 355 */ 356 public void setTrashVersionLocalService( 357 com.liferay.portlet.trash.service.TrashVersionLocalService trashVersionLocalService) { 358 this.trashVersionLocalService = trashVersionLocalService; 359 } 360 361 /** 362 * Returns the trash version persistence. 363 * 364 * @return the trash version persistence 365 */ 366 public TrashVersionPersistence getTrashVersionPersistence() { 367 return trashVersionPersistence; 368 } 369 370 /** 371 * Sets the trash version persistence. 372 * 373 * @param trashVersionPersistence the trash version persistence 374 */ 375 public void setTrashVersionPersistence( 376 TrashVersionPersistence trashVersionPersistence) { 377 this.trashVersionPersistence = trashVersionPersistence; 378 } 379 380 /** 381 * Returns the counter local service. 382 * 383 * @return the counter local service 384 */ 385 public com.liferay.counter.service.CounterLocalService getCounterLocalService() { 386 return counterLocalService; 387 } 388 389 /** 390 * Sets the counter local service. 391 * 392 * @param counterLocalService the counter local service 393 */ 394 public void setCounterLocalService( 395 com.liferay.counter.service.CounterLocalService counterLocalService) { 396 this.counterLocalService = counterLocalService; 397 } 398 399 /** 400 * Returns the resource local service. 401 * 402 * @return the resource local service 403 */ 404 public com.liferay.portal.service.ResourceLocalService getResourceLocalService() { 405 return resourceLocalService; 406 } 407 408 /** 409 * Sets the resource local service. 410 * 411 * @param resourceLocalService the resource local service 412 */ 413 public void setResourceLocalService( 414 com.liferay.portal.service.ResourceLocalService resourceLocalService) { 415 this.resourceLocalService = resourceLocalService; 416 } 417 418 /** 419 * Returns the user local service. 420 * 421 * @return the user local service 422 */ 423 public com.liferay.portal.service.UserLocalService getUserLocalService() { 424 return userLocalService; 425 } 426 427 /** 428 * Sets the user local service. 429 * 430 * @param userLocalService the user local service 431 */ 432 public void setUserLocalService( 433 com.liferay.portal.service.UserLocalService userLocalService) { 434 this.userLocalService = userLocalService; 435 } 436 437 /** 438 * Returns the user remote service. 439 * 440 * @return the user remote service 441 */ 442 public com.liferay.portal.service.UserService getUserService() { 443 return userService; 444 } 445 446 /** 447 * Sets the user remote service. 448 * 449 * @param userService the user remote service 450 */ 451 public void setUserService( 452 com.liferay.portal.service.UserService userService) { 453 this.userService = userService; 454 } 455 456 /** 457 * Returns the user persistence. 458 * 459 * @return the user persistence 460 */ 461 public UserPersistence getUserPersistence() { 462 return userPersistence; 463 } 464 465 /** 466 * Sets the user persistence. 467 * 468 * @param userPersistence the user persistence 469 */ 470 public void setUserPersistence(UserPersistence userPersistence) { 471 this.userPersistence = userPersistence; 472 } 473 474 /** 475 * Returns the user finder. 476 * 477 * @return the user finder 478 */ 479 public UserFinder getUserFinder() { 480 return userFinder; 481 } 482 483 /** 484 * Sets the user finder. 485 * 486 * @param userFinder the user finder 487 */ 488 public void setUserFinder(UserFinder userFinder) { 489 this.userFinder = userFinder; 490 } 491 492 public void afterPropertiesSet() { 493 persistedModelLocalServiceRegistry.register("com.liferay.portlet.trash.model.TrashVersion", 494 trashVersionLocalService); 495 } 496 497 public void destroy() { 498 persistedModelLocalServiceRegistry.unregister( 499 "com.liferay.portlet.trash.model.TrashVersion"); 500 } 501 502 /** 503 * Returns the Spring bean ID for this bean. 504 * 505 * @return the Spring bean ID for this bean 506 */ 507 @Override 508 public String getBeanIdentifier() { 509 return _beanIdentifier; 510 } 511 512 /** 513 * Sets the Spring bean ID for this bean. 514 * 515 * @param beanIdentifier the Spring bean ID for this bean 516 */ 517 @Override 518 public void setBeanIdentifier(String beanIdentifier) { 519 _beanIdentifier = beanIdentifier; 520 } 521 522 protected Class<?> getModelClass() { 523 return TrashVersion.class; 524 } 525 526 protected String getModelClassName() { 527 return TrashVersion.class.getName(); 528 } 529 530 /** 531 * Performs an SQL query. 532 * 533 * @param sql the sql query 534 */ 535 protected void runSQL(String sql) throws SystemException { 536 try { 537 DataSource dataSource = trashVersionPersistence.getDataSource(); 538 539 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource, 540 sql, new int[0]); 541 542 sqlUpdate.update(); 543 } 544 catch (Exception e) { 545 throw new SystemException(e); 546 } 547 } 548 549 @BeanReference(type = com.liferay.portlet.trash.service.TrashEntryLocalService.class) 550 protected com.liferay.portlet.trash.service.TrashEntryLocalService trashEntryLocalService; 551 @BeanReference(type = com.liferay.portlet.trash.service.TrashEntryService.class) 552 protected com.liferay.portlet.trash.service.TrashEntryService trashEntryService; 553 @BeanReference(type = TrashEntryPersistence.class) 554 protected TrashEntryPersistence trashEntryPersistence; 555 @BeanReference(type = com.liferay.portlet.trash.service.TrashVersionLocalService.class) 556 protected com.liferay.portlet.trash.service.TrashVersionLocalService trashVersionLocalService; 557 @BeanReference(type = TrashVersionPersistence.class) 558 protected TrashVersionPersistence trashVersionPersistence; 559 @BeanReference(type = com.liferay.counter.service.CounterLocalService.class) 560 protected com.liferay.counter.service.CounterLocalService counterLocalService; 561 @BeanReference(type = com.liferay.portal.service.ResourceLocalService.class) 562 protected com.liferay.portal.service.ResourceLocalService resourceLocalService; 563 @BeanReference(type = com.liferay.portal.service.UserLocalService.class) 564 protected com.liferay.portal.service.UserLocalService userLocalService; 565 @BeanReference(type = com.liferay.portal.service.UserService.class) 566 protected com.liferay.portal.service.UserService userService; 567 @BeanReference(type = UserPersistence.class) 568 protected UserPersistence userPersistence; 569 @BeanReference(type = UserFinder.class) 570 protected UserFinder userFinder; 571 @BeanReference(type = PersistedModelLocalServiceRegistry.class) 572 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry; 573 private String _beanIdentifier; 574 }