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.PollsChoice;
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 PollsChoiceLocalServiceBaseImpl
074 implements PollsChoiceLocalService, IdentifiableBean {
075
080
081
088 public PollsChoice addPollsChoice(PollsChoice pollsChoice)
089 throws SystemException {
090 pollsChoice.setNew(true);
091
092 pollsChoice = pollsChoicePersistence.update(pollsChoice, false);
093
094 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
095
096 if (indexer != null) {
097 try {
098 indexer.reindex(pollsChoice);
099 }
100 catch (SearchException se) {
101 if (_log.isWarnEnabled()) {
102 _log.warn(se, se);
103 }
104 }
105 }
106
107 return pollsChoice;
108 }
109
110
116 public PollsChoice createPollsChoice(long choiceId) {
117 return pollsChoicePersistence.create(choiceId);
118 }
119
120
127 public void deletePollsChoice(long choiceId)
128 throws PortalException, SystemException {
129 PollsChoice pollsChoice = pollsChoicePersistence.remove(choiceId);
130
131 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
132
133 if (indexer != null) {
134 try {
135 indexer.delete(pollsChoice);
136 }
137 catch (SearchException se) {
138 if (_log.isWarnEnabled()) {
139 _log.warn(se, se);
140 }
141 }
142 }
143 }
144
145
151 public void deletePollsChoice(PollsChoice pollsChoice)
152 throws SystemException {
153 pollsChoicePersistence.remove(pollsChoice);
154
155 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
156
157 if (indexer != null) {
158 try {
159 indexer.delete(pollsChoice);
160 }
161 catch (SearchException se) {
162 if (_log.isWarnEnabled()) {
163 _log.warn(se, se);
164 }
165 }
166 }
167 }
168
169
176 @SuppressWarnings("rawtypes")
177 public List dynamicQuery(DynamicQuery dynamicQuery)
178 throws SystemException {
179 return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery);
180 }
181
182
195 @SuppressWarnings("rawtypes")
196 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
197 throws SystemException {
198 return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery, start,
199 end);
200 }
201
202
216 @SuppressWarnings("rawtypes")
217 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
218 OrderByComparator orderByComparator) throws SystemException {
219 return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery, start,
220 end, orderByComparator);
221 }
222
223
230 public long dynamicQueryCount(DynamicQuery dynamicQuery)
231 throws SystemException {
232 return pollsChoicePersistence.countWithDynamicQuery(dynamicQuery);
233 }
234
235 public PollsChoice fetchPollsChoice(long choiceId)
236 throws SystemException {
237 return pollsChoicePersistence.fetchByPrimaryKey(choiceId);
238 }
239
240
248 public PollsChoice getPollsChoice(long choiceId)
249 throws PortalException, SystemException {
250 return pollsChoicePersistence.findByPrimaryKey(choiceId);
251 }
252
253 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
254 throws PortalException, SystemException {
255 return pollsChoicePersistence.findByPrimaryKey(primaryKeyObj);
256 }
257
258
270 public List<PollsChoice> getPollsChoices(int start, int end)
271 throws SystemException {
272 return pollsChoicePersistence.findAll(start, end);
273 }
274
275
281 public int getPollsChoicesCount() throws SystemException {
282 return pollsChoicePersistence.countAll();
283 }
284
285
292 public PollsChoice updatePollsChoice(PollsChoice pollsChoice)
293 throws SystemException {
294 return updatePollsChoice(pollsChoice, true);
295 }
296
297
305 public PollsChoice updatePollsChoice(PollsChoice pollsChoice, boolean merge)
306 throws SystemException {
307 pollsChoice.setNew(false);
308
309 pollsChoice = pollsChoicePersistence.update(pollsChoice, merge);
310
311 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
312
313 if (indexer != null) {
314 try {
315 indexer.reindex(pollsChoice);
316 }
317 catch (SearchException se) {
318 if (_log.isWarnEnabled()) {
319 _log.warn(se, se);
320 }
321 }
322 }
323
324 return pollsChoice;
325 }
326
327
332 public PollsChoiceLocalService getPollsChoiceLocalService() {
333 return pollsChoiceLocalService;
334 }
335
336
341 public void setPollsChoiceLocalService(
342 PollsChoiceLocalService pollsChoiceLocalService) {
343 this.pollsChoiceLocalService = pollsChoiceLocalService;
344 }
345
346
351 public PollsChoiceService getPollsChoiceService() {
352 return pollsChoiceService;
353 }
354
355
360 public void setPollsChoiceService(PollsChoiceService pollsChoiceService) {
361 this.pollsChoiceService = pollsChoiceService;
362 }
363
364
369 public PollsChoicePersistence getPollsChoicePersistence() {
370 return pollsChoicePersistence;
371 }
372
373
378 public void setPollsChoicePersistence(
379 PollsChoicePersistence pollsChoicePersistence) {
380 this.pollsChoicePersistence = pollsChoicePersistence;
381 }
382
383
388 public PollsChoiceFinder getPollsChoiceFinder() {
389 return pollsChoiceFinder;
390 }
391
392
397 public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
398 this.pollsChoiceFinder = pollsChoiceFinder;
399 }
400
401
406 public PollsQuestionLocalService getPollsQuestionLocalService() {
407 return pollsQuestionLocalService;
408 }
409
410
415 public void setPollsQuestionLocalService(
416 PollsQuestionLocalService pollsQuestionLocalService) {
417 this.pollsQuestionLocalService = pollsQuestionLocalService;
418 }
419
420
425 public PollsQuestionService getPollsQuestionService() {
426 return pollsQuestionService;
427 }
428
429
434 public void setPollsQuestionService(
435 PollsQuestionService pollsQuestionService) {
436 this.pollsQuestionService = pollsQuestionService;
437 }
438
439
444 public PollsQuestionPersistence getPollsQuestionPersistence() {
445 return pollsQuestionPersistence;
446 }
447
448
453 public void setPollsQuestionPersistence(
454 PollsQuestionPersistence pollsQuestionPersistence) {
455 this.pollsQuestionPersistence = pollsQuestionPersistence;
456 }
457
458
463 public PollsVoteLocalService getPollsVoteLocalService() {
464 return pollsVoteLocalService;
465 }
466
467
472 public void setPollsVoteLocalService(
473 PollsVoteLocalService pollsVoteLocalService) {
474 this.pollsVoteLocalService = pollsVoteLocalService;
475 }
476
477
482 public PollsVoteService getPollsVoteService() {
483 return pollsVoteService;
484 }
485
486
491 public void setPollsVoteService(PollsVoteService pollsVoteService) {
492 this.pollsVoteService = pollsVoteService;
493 }
494
495
500 public PollsVotePersistence getPollsVotePersistence() {
501 return pollsVotePersistence;
502 }
503
504
509 public void setPollsVotePersistence(
510 PollsVotePersistence pollsVotePersistence) {
511 this.pollsVotePersistence = pollsVotePersistence;
512 }
513
514
519 public CounterLocalService getCounterLocalService() {
520 return counterLocalService;
521 }
522
523
528 public void setCounterLocalService(CounterLocalService counterLocalService) {
529 this.counterLocalService = counterLocalService;
530 }
531
532
537 public ResourceLocalService getResourceLocalService() {
538 return resourceLocalService;
539 }
540
541
546 public void setResourceLocalService(
547 ResourceLocalService resourceLocalService) {
548 this.resourceLocalService = resourceLocalService;
549 }
550
551
556 public ResourceService getResourceService() {
557 return resourceService;
558 }
559
560
565 public void setResourceService(ResourceService resourceService) {
566 this.resourceService = resourceService;
567 }
568
569
574 public ResourcePersistence getResourcePersistence() {
575 return resourcePersistence;
576 }
577
578
583 public void setResourcePersistence(ResourcePersistence resourcePersistence) {
584 this.resourcePersistence = resourcePersistence;
585 }
586
587
592 public ResourceFinder getResourceFinder() {
593 return resourceFinder;
594 }
595
596
601 public void setResourceFinder(ResourceFinder resourceFinder) {
602 this.resourceFinder = resourceFinder;
603 }
604
605
610 public UserLocalService getUserLocalService() {
611 return userLocalService;
612 }
613
614
619 public void setUserLocalService(UserLocalService userLocalService) {
620 this.userLocalService = userLocalService;
621 }
622
623
628 public UserService getUserService() {
629 return userService;
630 }
631
632
637 public void setUserService(UserService userService) {
638 this.userService = userService;
639 }
640
641
646 public UserPersistence getUserPersistence() {
647 return userPersistence;
648 }
649
650
655 public void setUserPersistence(UserPersistence userPersistence) {
656 this.userPersistence = userPersistence;
657 }
658
659
664 public UserFinder getUserFinder() {
665 return userFinder;
666 }
667
668
673 public void setUserFinder(UserFinder userFinder) {
674 this.userFinder = userFinder;
675 }
676
677 public void afterPropertiesSet() {
678 persistedModelLocalServiceRegistry.register("com.liferay.portlet.polls.model.PollsChoice",
679 pollsChoiceLocalService);
680 }
681
682 public void destroy() {
683 persistedModelLocalServiceRegistry.unregister(
684 "com.liferay.portlet.polls.model.PollsChoice");
685 }
686
687
692 public String getBeanIdentifier() {
693 return _beanIdentifier;
694 }
695
696
701 public void setBeanIdentifier(String beanIdentifier) {
702 _beanIdentifier = beanIdentifier;
703 }
704
705 protected ClassLoader getClassLoader() {
706 Class<?> clazz = getClass();
707
708 return clazz.getClassLoader();
709 }
710
711 protected Class<?> getModelClass() {
712 return PollsChoice.class;
713 }
714
715 protected String getModelClassName() {
716 return PollsChoice.class.getName();
717 }
718
719
724 protected void runSQL(String sql) throws SystemException {
725 try {
726 DataSource dataSource = pollsChoicePersistence.getDataSource();
727
728 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
729 sql, new int[0]);
730
731 sqlUpdate.update();
732 }
733 catch (Exception e) {
734 throw new SystemException(e);
735 }
736 }
737
738 @BeanReference(type = PollsChoiceLocalService.class)
739 protected PollsChoiceLocalService pollsChoiceLocalService;
740 @BeanReference(type = PollsChoiceService.class)
741 protected PollsChoiceService pollsChoiceService;
742 @BeanReference(type = PollsChoicePersistence.class)
743 protected PollsChoicePersistence pollsChoicePersistence;
744 @BeanReference(type = PollsChoiceFinder.class)
745 protected PollsChoiceFinder pollsChoiceFinder;
746 @BeanReference(type = PollsQuestionLocalService.class)
747 protected PollsQuestionLocalService pollsQuestionLocalService;
748 @BeanReference(type = PollsQuestionService.class)
749 protected PollsQuestionService pollsQuestionService;
750 @BeanReference(type = PollsQuestionPersistence.class)
751 protected PollsQuestionPersistence pollsQuestionPersistence;
752 @BeanReference(type = PollsVoteLocalService.class)
753 protected PollsVoteLocalService pollsVoteLocalService;
754 @BeanReference(type = PollsVoteService.class)
755 protected PollsVoteService pollsVoteService;
756 @BeanReference(type = PollsVotePersistence.class)
757 protected PollsVotePersistence pollsVotePersistence;
758 @BeanReference(type = CounterLocalService.class)
759 protected CounterLocalService counterLocalService;
760 @BeanReference(type = ResourceLocalService.class)
761 protected ResourceLocalService resourceLocalService;
762 @BeanReference(type = ResourceService.class)
763 protected ResourceService resourceService;
764 @BeanReference(type = ResourcePersistence.class)
765 protected ResourcePersistence resourcePersistence;
766 @BeanReference(type = ResourceFinder.class)
767 protected ResourceFinder resourceFinder;
768 @BeanReference(type = UserLocalService.class)
769 protected UserLocalService userLocalService;
770 @BeanReference(type = UserService.class)
771 protected UserService userService;
772 @BeanReference(type = UserPersistence.class)
773 protected UserPersistence userPersistence;
774 @BeanReference(type = UserFinder.class)
775 protected UserFinder userFinder;
776 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
777 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
778 private static Log _log = LogFactoryUtil.getLog(PollsChoiceLocalServiceBaseImpl.class);
779 private String _beanIdentifier;
780 }