001
014
015 package com.liferay.portlet.ratings.service.base;
016
017 import com.liferay.counter.service.CounterLocalService;
018
019 import com.liferay.portal.kernel.bean.BeanReference;
020 import com.liferay.portal.kernel.bean.IdentifiableBean;
021 import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
022 import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
023 import com.liferay.portal.kernel.dao.orm.DynamicQuery;
024 import com.liferay.portal.kernel.exception.PortalException;
025 import com.liferay.portal.kernel.exception.SystemException;
026 import com.liferay.portal.kernel.log.Log;
027 import com.liferay.portal.kernel.log.LogFactoryUtil;
028 import com.liferay.portal.kernel.search.Indexer;
029 import com.liferay.portal.kernel.search.IndexerRegistryUtil;
030 import com.liferay.portal.kernel.search.SearchException;
031 import com.liferay.portal.kernel.util.OrderByComparator;
032 import com.liferay.portal.model.PersistedModel;
033 import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
034 import com.liferay.portal.service.ResourceLocalService;
035 import com.liferay.portal.service.ResourceService;
036 import com.liferay.portal.service.UserLocalService;
037 import com.liferay.portal.service.UserService;
038 import com.liferay.portal.service.persistence.ResourceFinder;
039 import com.liferay.portal.service.persistence.ResourcePersistence;
040 import com.liferay.portal.service.persistence.UserFinder;
041 import com.liferay.portal.service.persistence.UserPersistence;
042
043 import com.liferay.portlet.ratings.model.RatingsStats;
044 import com.liferay.portlet.ratings.service.RatingsEntryLocalService;
045 import com.liferay.portlet.ratings.service.RatingsEntryService;
046 import com.liferay.portlet.ratings.service.RatingsStatsLocalService;
047 import com.liferay.portlet.ratings.service.persistence.RatingsEntryFinder;
048 import com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence;
049 import com.liferay.portlet.ratings.service.persistence.RatingsStatsFinder;
050 import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
051
052 import java.io.Serializable;
053
054 import java.util.List;
055
056 import javax.sql.DataSource;
057
058
070 public abstract class RatingsStatsLocalServiceBaseImpl
071 implements RatingsStatsLocalService, IdentifiableBean {
072
077
078
085 public RatingsStats addRatingsStats(RatingsStats ratingsStats)
086 throws SystemException {
087 ratingsStats.setNew(true);
088
089 ratingsStats = ratingsStatsPersistence.update(ratingsStats, false);
090
091 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
092
093 if (indexer != null) {
094 try {
095 indexer.reindex(ratingsStats);
096 }
097 catch (SearchException se) {
098 if (_log.isWarnEnabled()) {
099 _log.warn(se, se);
100 }
101 }
102 }
103
104 return ratingsStats;
105 }
106
107
113 public RatingsStats createRatingsStats(long statsId) {
114 return ratingsStatsPersistence.create(statsId);
115 }
116
117
124 public void deleteRatingsStats(long statsId)
125 throws PortalException, SystemException {
126 RatingsStats ratingsStats = ratingsStatsPersistence.remove(statsId);
127
128 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
129
130 if (indexer != null) {
131 try {
132 indexer.delete(ratingsStats);
133 }
134 catch (SearchException se) {
135 if (_log.isWarnEnabled()) {
136 _log.warn(se, se);
137 }
138 }
139 }
140 }
141
142
148 public void deleteRatingsStats(RatingsStats ratingsStats)
149 throws SystemException {
150 ratingsStatsPersistence.remove(ratingsStats);
151
152 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
153
154 if (indexer != null) {
155 try {
156 indexer.delete(ratingsStats);
157 }
158 catch (SearchException se) {
159 if (_log.isWarnEnabled()) {
160 _log.warn(se, se);
161 }
162 }
163 }
164 }
165
166
173 @SuppressWarnings("rawtypes")
174 public List dynamicQuery(DynamicQuery dynamicQuery)
175 throws SystemException {
176 return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery);
177 }
178
179
192 @SuppressWarnings("rawtypes")
193 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
194 throws SystemException {
195 return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery,
196 start, end);
197 }
198
199
213 @SuppressWarnings("rawtypes")
214 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
215 OrderByComparator orderByComparator) throws SystemException {
216 return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery,
217 start, end, orderByComparator);
218 }
219
220
227 public long dynamicQueryCount(DynamicQuery dynamicQuery)
228 throws SystemException {
229 return ratingsStatsPersistence.countWithDynamicQuery(dynamicQuery);
230 }
231
232 public RatingsStats fetchRatingsStats(long statsId)
233 throws SystemException {
234 return ratingsStatsPersistence.fetchByPrimaryKey(statsId);
235 }
236
237
245 public RatingsStats getRatingsStats(long statsId)
246 throws PortalException, SystemException {
247 return ratingsStatsPersistence.findByPrimaryKey(statsId);
248 }
249
250 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
251 throws PortalException, SystemException {
252 return ratingsStatsPersistence.findByPrimaryKey(primaryKeyObj);
253 }
254
255
267 public List<RatingsStats> getRatingsStatses(int start, int end)
268 throws SystemException {
269 return ratingsStatsPersistence.findAll(start, end);
270 }
271
272
278 public int getRatingsStatsesCount() throws SystemException {
279 return ratingsStatsPersistence.countAll();
280 }
281
282
289 public RatingsStats updateRatingsStats(RatingsStats ratingsStats)
290 throws SystemException {
291 return updateRatingsStats(ratingsStats, true);
292 }
293
294
302 public RatingsStats updateRatingsStats(RatingsStats ratingsStats,
303 boolean merge) throws SystemException {
304 ratingsStats.setNew(false);
305
306 ratingsStats = ratingsStatsPersistence.update(ratingsStats, merge);
307
308 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
309
310 if (indexer != null) {
311 try {
312 indexer.reindex(ratingsStats);
313 }
314 catch (SearchException se) {
315 if (_log.isWarnEnabled()) {
316 _log.warn(se, se);
317 }
318 }
319 }
320
321 return ratingsStats;
322 }
323
324
329 public RatingsEntryLocalService getRatingsEntryLocalService() {
330 return ratingsEntryLocalService;
331 }
332
333
338 public void setRatingsEntryLocalService(
339 RatingsEntryLocalService ratingsEntryLocalService) {
340 this.ratingsEntryLocalService = ratingsEntryLocalService;
341 }
342
343
348 public RatingsEntryService getRatingsEntryService() {
349 return ratingsEntryService;
350 }
351
352
357 public void setRatingsEntryService(RatingsEntryService ratingsEntryService) {
358 this.ratingsEntryService = ratingsEntryService;
359 }
360
361
366 public RatingsEntryPersistence getRatingsEntryPersistence() {
367 return ratingsEntryPersistence;
368 }
369
370
375 public void setRatingsEntryPersistence(
376 RatingsEntryPersistence ratingsEntryPersistence) {
377 this.ratingsEntryPersistence = ratingsEntryPersistence;
378 }
379
380
385 public RatingsEntryFinder getRatingsEntryFinder() {
386 return ratingsEntryFinder;
387 }
388
389
394 public void setRatingsEntryFinder(RatingsEntryFinder ratingsEntryFinder) {
395 this.ratingsEntryFinder = ratingsEntryFinder;
396 }
397
398
403 public RatingsStatsLocalService getRatingsStatsLocalService() {
404 return ratingsStatsLocalService;
405 }
406
407
412 public void setRatingsStatsLocalService(
413 RatingsStatsLocalService ratingsStatsLocalService) {
414 this.ratingsStatsLocalService = ratingsStatsLocalService;
415 }
416
417
422 public RatingsStatsPersistence getRatingsStatsPersistence() {
423 return ratingsStatsPersistence;
424 }
425
426
431 public void setRatingsStatsPersistence(
432 RatingsStatsPersistence ratingsStatsPersistence) {
433 this.ratingsStatsPersistence = ratingsStatsPersistence;
434 }
435
436
441 public RatingsStatsFinder getRatingsStatsFinder() {
442 return ratingsStatsFinder;
443 }
444
445
450 public void setRatingsStatsFinder(RatingsStatsFinder ratingsStatsFinder) {
451 this.ratingsStatsFinder = ratingsStatsFinder;
452 }
453
454
459 public CounterLocalService getCounterLocalService() {
460 return counterLocalService;
461 }
462
463
468 public void setCounterLocalService(CounterLocalService counterLocalService) {
469 this.counterLocalService = counterLocalService;
470 }
471
472
477 public ResourceLocalService getResourceLocalService() {
478 return resourceLocalService;
479 }
480
481
486 public void setResourceLocalService(
487 ResourceLocalService resourceLocalService) {
488 this.resourceLocalService = resourceLocalService;
489 }
490
491
496 public ResourceService getResourceService() {
497 return resourceService;
498 }
499
500
505 public void setResourceService(ResourceService resourceService) {
506 this.resourceService = resourceService;
507 }
508
509
514 public ResourcePersistence getResourcePersistence() {
515 return resourcePersistence;
516 }
517
518
523 public void setResourcePersistence(ResourcePersistence resourcePersistence) {
524 this.resourcePersistence = resourcePersistence;
525 }
526
527
532 public ResourceFinder getResourceFinder() {
533 return resourceFinder;
534 }
535
536
541 public void setResourceFinder(ResourceFinder resourceFinder) {
542 this.resourceFinder = resourceFinder;
543 }
544
545
550 public UserLocalService getUserLocalService() {
551 return userLocalService;
552 }
553
554
559 public void setUserLocalService(UserLocalService userLocalService) {
560 this.userLocalService = userLocalService;
561 }
562
563
568 public UserService getUserService() {
569 return userService;
570 }
571
572
577 public void setUserService(UserService userService) {
578 this.userService = userService;
579 }
580
581
586 public UserPersistence getUserPersistence() {
587 return userPersistence;
588 }
589
590
595 public void setUserPersistence(UserPersistence userPersistence) {
596 this.userPersistence = userPersistence;
597 }
598
599
604 public UserFinder getUserFinder() {
605 return userFinder;
606 }
607
608
613 public void setUserFinder(UserFinder userFinder) {
614 this.userFinder = userFinder;
615 }
616
617 public void afterPropertiesSet() {
618 persistedModelLocalServiceRegistry.register("com.liferay.portlet.ratings.model.RatingsStats",
619 ratingsStatsLocalService);
620 }
621
622 public void destroy() {
623 persistedModelLocalServiceRegistry.unregister(
624 "com.liferay.portlet.ratings.model.RatingsStats");
625 }
626
627
632 public String getBeanIdentifier() {
633 return _beanIdentifier;
634 }
635
636
641 public void setBeanIdentifier(String beanIdentifier) {
642 _beanIdentifier = beanIdentifier;
643 }
644
645 protected ClassLoader getClassLoader() {
646 Class<?> clazz = getClass();
647
648 return clazz.getClassLoader();
649 }
650
651 protected Class<?> getModelClass() {
652 return RatingsStats.class;
653 }
654
655 protected String getModelClassName() {
656 return RatingsStats.class.getName();
657 }
658
659
664 protected void runSQL(String sql) throws SystemException {
665 try {
666 DataSource dataSource = ratingsStatsPersistence.getDataSource();
667
668 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
669 sql, new int[0]);
670
671 sqlUpdate.update();
672 }
673 catch (Exception e) {
674 throw new SystemException(e);
675 }
676 }
677
678 @BeanReference(type = RatingsEntryLocalService.class)
679 protected RatingsEntryLocalService ratingsEntryLocalService;
680 @BeanReference(type = RatingsEntryService.class)
681 protected RatingsEntryService ratingsEntryService;
682 @BeanReference(type = RatingsEntryPersistence.class)
683 protected RatingsEntryPersistence ratingsEntryPersistence;
684 @BeanReference(type = RatingsEntryFinder.class)
685 protected RatingsEntryFinder ratingsEntryFinder;
686 @BeanReference(type = RatingsStatsLocalService.class)
687 protected RatingsStatsLocalService ratingsStatsLocalService;
688 @BeanReference(type = RatingsStatsPersistence.class)
689 protected RatingsStatsPersistence ratingsStatsPersistence;
690 @BeanReference(type = RatingsStatsFinder.class)
691 protected RatingsStatsFinder ratingsStatsFinder;
692 @BeanReference(type = CounterLocalService.class)
693 protected CounterLocalService counterLocalService;
694 @BeanReference(type = ResourceLocalService.class)
695 protected ResourceLocalService resourceLocalService;
696 @BeanReference(type = ResourceService.class)
697 protected ResourceService resourceService;
698 @BeanReference(type = ResourcePersistence.class)
699 protected ResourcePersistence resourcePersistence;
700 @BeanReference(type = ResourceFinder.class)
701 protected ResourceFinder resourceFinder;
702 @BeanReference(type = UserLocalService.class)
703 protected UserLocalService userLocalService;
704 @BeanReference(type = UserService.class)
705 protected UserService userService;
706 @BeanReference(type = UserPersistence.class)
707 protected UserPersistence userPersistence;
708 @BeanReference(type = UserFinder.class)
709 protected UserFinder userFinder;
710 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
711 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
712 private static Log _log = LogFactoryUtil.getLog(RatingsStatsLocalServiceBaseImpl.class);
713 private String _beanIdentifier;
714 }