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