001
014
015 package com.liferay.portlet.polls.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.polls.model.PollsVote;
044 import com.liferay.portlet.polls.service.PollsChoiceLocalService;
045 import com.liferay.portlet.polls.service.PollsChoiceService;
046 import com.liferay.portlet.polls.service.PollsQuestionLocalService;
047 import com.liferay.portlet.polls.service.PollsQuestionService;
048 import com.liferay.portlet.polls.service.PollsVoteLocalService;
049 import com.liferay.portlet.polls.service.PollsVoteService;
050 import com.liferay.portlet.polls.service.persistence.PollsChoiceFinder;
051 import com.liferay.portlet.polls.service.persistence.PollsChoicePersistence;
052 import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
053 import com.liferay.portlet.polls.service.persistence.PollsVotePersistence;
054
055 import java.io.Serializable;
056
057 import java.util.List;
058
059 import javax.sql.DataSource;
060
061
073 public abstract class PollsVoteLocalServiceBaseImpl
074 implements PollsVoteLocalService, IdentifiableBean {
075
080
081
088 public PollsVote addPollsVote(PollsVote pollsVote)
089 throws SystemException {
090 pollsVote.setNew(true);
091
092 pollsVote = pollsVotePersistence.update(pollsVote, false);
093
094 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
095
096 if (indexer != null) {
097 try {
098 indexer.reindex(pollsVote);
099 }
100 catch (SearchException se) {
101 if (_log.isWarnEnabled()) {
102 _log.warn(se, se);
103 }
104 }
105 }
106
107 return pollsVote;
108 }
109
110
116 public PollsVote createPollsVote(long voteId) {
117 return pollsVotePersistence.create(voteId);
118 }
119
120
127 public void deletePollsVote(long voteId)
128 throws PortalException, SystemException {
129 PollsVote pollsVote = pollsVotePersistence.remove(voteId);
130
131 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
132
133 if (indexer != null) {
134 try {
135 indexer.delete(pollsVote);
136 }
137 catch (SearchException se) {
138 if (_log.isWarnEnabled()) {
139 _log.warn(se, se);
140 }
141 }
142 }
143 }
144
145
151 public void deletePollsVote(PollsVote pollsVote) throws SystemException {
152 pollsVotePersistence.remove(pollsVote);
153
154 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
155
156 if (indexer != null) {
157 try {
158 indexer.delete(pollsVote);
159 }
160 catch (SearchException se) {
161 if (_log.isWarnEnabled()) {
162 _log.warn(se, se);
163 }
164 }
165 }
166 }
167
168
175 @SuppressWarnings("rawtypes")
176 public List dynamicQuery(DynamicQuery dynamicQuery)
177 throws SystemException {
178 return pollsVotePersistence.findWithDynamicQuery(dynamicQuery);
179 }
180
181
194 @SuppressWarnings("rawtypes")
195 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
196 throws SystemException {
197 return pollsVotePersistence.findWithDynamicQuery(dynamicQuery, start,
198 end);
199 }
200
201
215 @SuppressWarnings("rawtypes")
216 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
217 OrderByComparator orderByComparator) throws SystemException {
218 return pollsVotePersistence.findWithDynamicQuery(dynamicQuery, start,
219 end, orderByComparator);
220 }
221
222
229 public long dynamicQueryCount(DynamicQuery dynamicQuery)
230 throws SystemException {
231 return pollsVotePersistence.countWithDynamicQuery(dynamicQuery);
232 }
233
234 public PollsVote fetchPollsVote(long voteId) throws SystemException {
235 return pollsVotePersistence.fetchByPrimaryKey(voteId);
236 }
237
238
246 public PollsVote getPollsVote(long voteId)
247 throws PortalException, SystemException {
248 return pollsVotePersistence.findByPrimaryKey(voteId);
249 }
250
251 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
252 throws PortalException, SystemException {
253 return pollsVotePersistence.findByPrimaryKey(primaryKeyObj);
254 }
255
256
268 public List<PollsVote> getPollsVotes(int start, int end)
269 throws SystemException {
270 return pollsVotePersistence.findAll(start, end);
271 }
272
273
279 public int getPollsVotesCount() throws SystemException {
280 return pollsVotePersistence.countAll();
281 }
282
283
290 public PollsVote updatePollsVote(PollsVote pollsVote)
291 throws SystemException {
292 return updatePollsVote(pollsVote, true);
293 }
294
295
303 public PollsVote updatePollsVote(PollsVote pollsVote, boolean merge)
304 throws SystemException {
305 pollsVote.setNew(false);
306
307 pollsVote = pollsVotePersistence.update(pollsVote, merge);
308
309 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
310
311 if (indexer != null) {
312 try {
313 indexer.reindex(pollsVote);
314 }
315 catch (SearchException se) {
316 if (_log.isWarnEnabled()) {
317 _log.warn(se, se);
318 }
319 }
320 }
321
322 return pollsVote;
323 }
324
325
330 public PollsChoiceLocalService getPollsChoiceLocalService() {
331 return pollsChoiceLocalService;
332 }
333
334
339 public void setPollsChoiceLocalService(
340 PollsChoiceLocalService pollsChoiceLocalService) {
341 this.pollsChoiceLocalService = pollsChoiceLocalService;
342 }
343
344
349 public PollsChoiceService getPollsChoiceService() {
350 return pollsChoiceService;
351 }
352
353
358 public void setPollsChoiceService(PollsChoiceService pollsChoiceService) {
359 this.pollsChoiceService = pollsChoiceService;
360 }
361
362
367 public PollsChoicePersistence getPollsChoicePersistence() {
368 return pollsChoicePersistence;
369 }
370
371
376 public void setPollsChoicePersistence(
377 PollsChoicePersistence pollsChoicePersistence) {
378 this.pollsChoicePersistence = pollsChoicePersistence;
379 }
380
381
386 public PollsChoiceFinder getPollsChoiceFinder() {
387 return pollsChoiceFinder;
388 }
389
390
395 public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
396 this.pollsChoiceFinder = pollsChoiceFinder;
397 }
398
399
404 public PollsQuestionLocalService getPollsQuestionLocalService() {
405 return pollsQuestionLocalService;
406 }
407
408
413 public void setPollsQuestionLocalService(
414 PollsQuestionLocalService pollsQuestionLocalService) {
415 this.pollsQuestionLocalService = pollsQuestionLocalService;
416 }
417
418
423 public PollsQuestionService getPollsQuestionService() {
424 return pollsQuestionService;
425 }
426
427
432 public void setPollsQuestionService(
433 PollsQuestionService pollsQuestionService) {
434 this.pollsQuestionService = pollsQuestionService;
435 }
436
437
442 public PollsQuestionPersistence getPollsQuestionPersistence() {
443 return pollsQuestionPersistence;
444 }
445
446
451 public void setPollsQuestionPersistence(
452 PollsQuestionPersistence pollsQuestionPersistence) {
453 this.pollsQuestionPersistence = pollsQuestionPersistence;
454 }
455
456
461 public PollsVoteLocalService getPollsVoteLocalService() {
462 return pollsVoteLocalService;
463 }
464
465
470 public void setPollsVoteLocalService(
471 PollsVoteLocalService pollsVoteLocalService) {
472 this.pollsVoteLocalService = pollsVoteLocalService;
473 }
474
475
480 public PollsVoteService getPollsVoteService() {
481 return pollsVoteService;
482 }
483
484
489 public void setPollsVoteService(PollsVoteService pollsVoteService) {
490 this.pollsVoteService = pollsVoteService;
491 }
492
493
498 public PollsVotePersistence getPollsVotePersistence() {
499 return pollsVotePersistence;
500 }
501
502
507 public void setPollsVotePersistence(
508 PollsVotePersistence pollsVotePersistence) {
509 this.pollsVotePersistence = pollsVotePersistence;
510 }
511
512
517 public CounterLocalService getCounterLocalService() {
518 return counterLocalService;
519 }
520
521
526 public void setCounterLocalService(CounterLocalService counterLocalService) {
527 this.counterLocalService = counterLocalService;
528 }
529
530
535 public ResourceLocalService getResourceLocalService() {
536 return resourceLocalService;
537 }
538
539
544 public void setResourceLocalService(
545 ResourceLocalService resourceLocalService) {
546 this.resourceLocalService = resourceLocalService;
547 }
548
549
554 public ResourceService getResourceService() {
555 return resourceService;
556 }
557
558
563 public void setResourceService(ResourceService resourceService) {
564 this.resourceService = resourceService;
565 }
566
567
572 public ResourcePersistence getResourcePersistence() {
573 return resourcePersistence;
574 }
575
576
581 public void setResourcePersistence(ResourcePersistence resourcePersistence) {
582 this.resourcePersistence = resourcePersistence;
583 }
584
585
590 public ResourceFinder getResourceFinder() {
591 return resourceFinder;
592 }
593
594
599 public void setResourceFinder(ResourceFinder resourceFinder) {
600 this.resourceFinder = resourceFinder;
601 }
602
603
608 public UserLocalService getUserLocalService() {
609 return userLocalService;
610 }
611
612
617 public void setUserLocalService(UserLocalService userLocalService) {
618 this.userLocalService = userLocalService;
619 }
620
621
626 public UserService getUserService() {
627 return userService;
628 }
629
630
635 public void setUserService(UserService userService) {
636 this.userService = userService;
637 }
638
639
644 public UserPersistence getUserPersistence() {
645 return userPersistence;
646 }
647
648
653 public void setUserPersistence(UserPersistence userPersistence) {
654 this.userPersistence = userPersistence;
655 }
656
657
662 public UserFinder getUserFinder() {
663 return userFinder;
664 }
665
666
671 public void setUserFinder(UserFinder userFinder) {
672 this.userFinder = userFinder;
673 }
674
675 public void afterPropertiesSet() {
676 persistedModelLocalServiceRegistry.register("com.liferay.portlet.polls.model.PollsVote",
677 pollsVoteLocalService);
678 }
679
680 public void destroy() {
681 persistedModelLocalServiceRegistry.unregister(
682 "com.liferay.portlet.polls.model.PollsVote");
683 }
684
685
690 public String getBeanIdentifier() {
691 return _beanIdentifier;
692 }
693
694
699 public void setBeanIdentifier(String beanIdentifier) {
700 _beanIdentifier = beanIdentifier;
701 }
702
703 protected ClassLoader getClassLoader() {
704 Class<?> clazz = getClass();
705
706 return clazz.getClassLoader();
707 }
708
709 protected Class<?> getModelClass() {
710 return PollsVote.class;
711 }
712
713 protected String getModelClassName() {
714 return PollsVote.class.getName();
715 }
716
717
722 protected void runSQL(String sql) throws SystemException {
723 try {
724 DataSource dataSource = pollsVotePersistence.getDataSource();
725
726 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
727 sql, new int[0]);
728
729 sqlUpdate.update();
730 }
731 catch (Exception e) {
732 throw new SystemException(e);
733 }
734 }
735
736 @BeanReference(type = PollsChoiceLocalService.class)
737 protected PollsChoiceLocalService pollsChoiceLocalService;
738 @BeanReference(type = PollsChoiceService.class)
739 protected PollsChoiceService pollsChoiceService;
740 @BeanReference(type = PollsChoicePersistence.class)
741 protected PollsChoicePersistence pollsChoicePersistence;
742 @BeanReference(type = PollsChoiceFinder.class)
743 protected PollsChoiceFinder pollsChoiceFinder;
744 @BeanReference(type = PollsQuestionLocalService.class)
745 protected PollsQuestionLocalService pollsQuestionLocalService;
746 @BeanReference(type = PollsQuestionService.class)
747 protected PollsQuestionService pollsQuestionService;
748 @BeanReference(type = PollsQuestionPersistence.class)
749 protected PollsQuestionPersistence pollsQuestionPersistence;
750 @BeanReference(type = PollsVoteLocalService.class)
751 protected PollsVoteLocalService pollsVoteLocalService;
752 @BeanReference(type = PollsVoteService.class)
753 protected PollsVoteService pollsVoteService;
754 @BeanReference(type = PollsVotePersistence.class)
755 protected PollsVotePersistence pollsVotePersistence;
756 @BeanReference(type = CounterLocalService.class)
757 protected CounterLocalService counterLocalService;
758 @BeanReference(type = ResourceLocalService.class)
759 protected ResourceLocalService resourceLocalService;
760 @BeanReference(type = ResourceService.class)
761 protected ResourceService resourceService;
762 @BeanReference(type = ResourcePersistence.class)
763 protected ResourcePersistence resourcePersistence;
764 @BeanReference(type = ResourceFinder.class)
765 protected ResourceFinder resourceFinder;
766 @BeanReference(type = UserLocalService.class)
767 protected UserLocalService userLocalService;
768 @BeanReference(type = UserService.class)
769 protected UserService userService;
770 @BeanReference(type = UserPersistence.class)
771 protected UserPersistence userPersistence;
772 @BeanReference(type = UserFinder.class)
773 protected UserFinder userFinder;
774 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
775 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
776 private static Log _log = LogFactoryUtil.getLog(PollsVoteLocalServiceBaseImpl.class);
777 private String _beanIdentifier;
778 }