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.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 PollsChoiceLocalServiceBaseImpl
073 implements PollsChoiceLocalService, IdentifiableBean {
074
079
080
087 public PollsChoice addPollsChoice(PollsChoice pollsChoice)
088 throws SystemException {
089 pollsChoice.setNew(true);
090
091 pollsChoice = pollsChoicePersistence.update(pollsChoice, false);
092
093 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
094
095 if (indexer != null) {
096 try {
097 indexer.reindex(pollsChoice);
098 }
099 catch (SearchException se) {
100 if (_log.isWarnEnabled()) {
101 _log.warn(se, se);
102 }
103 }
104 }
105
106 return pollsChoice;
107 }
108
109
115 public PollsChoice createPollsChoice(long choiceId) {
116 return pollsChoicePersistence.create(choiceId);
117 }
118
119
126 public void deletePollsChoice(long choiceId)
127 throws PortalException, SystemException {
128 PollsChoice pollsChoice = pollsChoicePersistence.remove(choiceId);
129
130 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
131
132 if (indexer != null) {
133 try {
134 indexer.delete(pollsChoice);
135 }
136 catch (SearchException se) {
137 if (_log.isWarnEnabled()) {
138 _log.warn(se, se);
139 }
140 }
141 }
142 }
143
144
150 public void deletePollsChoice(PollsChoice pollsChoice)
151 throws SystemException {
152 pollsChoicePersistence.remove(pollsChoice);
153
154 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
155
156 if (indexer != null) {
157 try {
158 indexer.delete(pollsChoice);
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 pollsChoicePersistence.findWithDynamicQuery(dynamicQuery);
179 }
180
181
194 @SuppressWarnings("rawtypes")
195 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
196 throws SystemException {
197 return pollsChoicePersistence.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 pollsChoicePersistence.findWithDynamicQuery(dynamicQuery, start,
219 end, orderByComparator);
220 }
221
222
229 public long dynamicQueryCount(DynamicQuery dynamicQuery)
230 throws SystemException {
231 return pollsChoicePersistence.countWithDynamicQuery(dynamicQuery);
232 }
233
234 public PollsChoice fetchPollsChoice(long choiceId)
235 throws SystemException {
236 return pollsChoicePersistence.fetchByPrimaryKey(choiceId);
237 }
238
239
247 public PollsChoice getPollsChoice(long choiceId)
248 throws PortalException, SystemException {
249 return pollsChoicePersistence.findByPrimaryKey(choiceId);
250 }
251
252 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
253 throws PortalException, SystemException {
254 return pollsChoicePersistence.findByPrimaryKey(primaryKeyObj);
255 }
256
257
269 public List<PollsChoice> getPollsChoices(int start, int end)
270 throws SystemException {
271 return pollsChoicePersistence.findAll(start, end);
272 }
273
274
280 public int getPollsChoicesCount() throws SystemException {
281 return pollsChoicePersistence.countAll();
282 }
283
284
291 public PollsChoice updatePollsChoice(PollsChoice pollsChoice)
292 throws SystemException {
293 return updatePollsChoice(pollsChoice, true);
294 }
295
296
304 public PollsChoice updatePollsChoice(PollsChoice pollsChoice, boolean merge)
305 throws SystemException {
306 pollsChoice.setNew(false);
307
308 pollsChoice = pollsChoicePersistence.update(pollsChoice, merge);
309
310 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
311
312 if (indexer != null) {
313 try {
314 indexer.reindex(pollsChoice);
315 }
316 catch (SearchException se) {
317 if (_log.isWarnEnabled()) {
318 _log.warn(se, se);
319 }
320 }
321 }
322
323 return pollsChoice;
324 }
325
326
331 public PollsChoiceLocalService getPollsChoiceLocalService() {
332 return pollsChoiceLocalService;
333 }
334
335
340 public void setPollsChoiceLocalService(
341 PollsChoiceLocalService pollsChoiceLocalService) {
342 this.pollsChoiceLocalService = pollsChoiceLocalService;
343 }
344
345
350 public PollsChoicePersistence getPollsChoicePersistence() {
351 return pollsChoicePersistence;
352 }
353
354
359 public void setPollsChoicePersistence(
360 PollsChoicePersistence pollsChoicePersistence) {
361 this.pollsChoicePersistence = pollsChoicePersistence;
362 }
363
364
369 public PollsChoiceFinder getPollsChoiceFinder() {
370 return pollsChoiceFinder;
371 }
372
373
378 public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
379 this.pollsChoiceFinder = pollsChoiceFinder;
380 }
381
382
387 public PollsQuestionLocalService getPollsQuestionLocalService() {
388 return pollsQuestionLocalService;
389 }
390
391
396 public void setPollsQuestionLocalService(
397 PollsQuestionLocalService pollsQuestionLocalService) {
398 this.pollsQuestionLocalService = pollsQuestionLocalService;
399 }
400
401
406 public PollsQuestionService getPollsQuestionService() {
407 return pollsQuestionService;
408 }
409
410
415 public void setPollsQuestionService(
416 PollsQuestionService pollsQuestionService) {
417 this.pollsQuestionService = pollsQuestionService;
418 }
419
420
425 public PollsQuestionPersistence getPollsQuestionPersistence() {
426 return pollsQuestionPersistence;
427 }
428
429
434 public void setPollsQuestionPersistence(
435 PollsQuestionPersistence pollsQuestionPersistence) {
436 this.pollsQuestionPersistence = pollsQuestionPersistence;
437 }
438
439
444 public PollsVoteLocalService getPollsVoteLocalService() {
445 return pollsVoteLocalService;
446 }
447
448
453 public void setPollsVoteLocalService(
454 PollsVoteLocalService pollsVoteLocalService) {
455 this.pollsVoteLocalService = pollsVoteLocalService;
456 }
457
458
463 public PollsVoteService getPollsVoteService() {
464 return pollsVoteService;
465 }
466
467
472 public void setPollsVoteService(PollsVoteService pollsVoteService) {
473 this.pollsVoteService = pollsVoteService;
474 }
475
476
481 public PollsVotePersistence getPollsVotePersistence() {
482 return pollsVotePersistence;
483 }
484
485
490 public void setPollsVotePersistence(
491 PollsVotePersistence pollsVotePersistence) {
492 this.pollsVotePersistence = pollsVotePersistence;
493 }
494
495
500 public CounterLocalService getCounterLocalService() {
501 return counterLocalService;
502 }
503
504
509 public void setCounterLocalService(CounterLocalService counterLocalService) {
510 this.counterLocalService = counterLocalService;
511 }
512
513
518 public ResourceLocalService getResourceLocalService() {
519 return resourceLocalService;
520 }
521
522
527 public void setResourceLocalService(
528 ResourceLocalService resourceLocalService) {
529 this.resourceLocalService = resourceLocalService;
530 }
531
532
537 public ResourceService getResourceService() {
538 return resourceService;
539 }
540
541
546 public void setResourceService(ResourceService resourceService) {
547 this.resourceService = resourceService;
548 }
549
550
555 public ResourcePersistence getResourcePersistence() {
556 return resourcePersistence;
557 }
558
559
564 public void setResourcePersistence(ResourcePersistence resourcePersistence) {
565 this.resourcePersistence = resourcePersistence;
566 }
567
568
573 public ResourceFinder getResourceFinder() {
574 return resourceFinder;
575 }
576
577
582 public void setResourceFinder(ResourceFinder resourceFinder) {
583 this.resourceFinder = resourceFinder;
584 }
585
586
591 public UserLocalService getUserLocalService() {
592 return userLocalService;
593 }
594
595
600 public void setUserLocalService(UserLocalService userLocalService) {
601 this.userLocalService = userLocalService;
602 }
603
604
609 public UserService getUserService() {
610 return userService;
611 }
612
613
618 public void setUserService(UserService userService) {
619 this.userService = userService;
620 }
621
622
627 public UserPersistence getUserPersistence() {
628 return userPersistence;
629 }
630
631
636 public void setUserPersistence(UserPersistence userPersistence) {
637 this.userPersistence = userPersistence;
638 }
639
640
645 public UserFinder getUserFinder() {
646 return userFinder;
647 }
648
649
654 public void setUserFinder(UserFinder userFinder) {
655 this.userFinder = userFinder;
656 }
657
658 public void afterPropertiesSet() {
659 persistedModelLocalServiceRegistry.register("com.liferay.portlet.polls.model.PollsChoice",
660 pollsChoiceLocalService);
661 }
662
663 public void destroy() {
664 persistedModelLocalServiceRegistry.unregister(
665 "com.liferay.portlet.polls.model.PollsChoice");
666 }
667
668
673 public String getBeanIdentifier() {
674 return _beanIdentifier;
675 }
676
677
682 public void setBeanIdentifier(String beanIdentifier) {
683 _beanIdentifier = beanIdentifier;
684 }
685
686 protected Class<?> getModelClass() {
687 return PollsChoice.class;
688 }
689
690 protected String getModelClassName() {
691 return PollsChoice.class.getName();
692 }
693
694
699 protected void runSQL(String sql) throws SystemException {
700 try {
701 DataSource dataSource = pollsChoicePersistence.getDataSource();
702
703 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
704 sql, new int[0]);
705
706 sqlUpdate.update();
707 }
708 catch (Exception e) {
709 throw new SystemException(e);
710 }
711 }
712
713 @BeanReference(type = PollsChoiceLocalService.class)
714 protected PollsChoiceLocalService pollsChoiceLocalService;
715 @BeanReference(type = PollsChoicePersistence.class)
716 protected PollsChoicePersistence pollsChoicePersistence;
717 @BeanReference(type = PollsChoiceFinder.class)
718 protected PollsChoiceFinder pollsChoiceFinder;
719 @BeanReference(type = PollsQuestionLocalService.class)
720 protected PollsQuestionLocalService pollsQuestionLocalService;
721 @BeanReference(type = PollsQuestionService.class)
722 protected PollsQuestionService pollsQuestionService;
723 @BeanReference(type = PollsQuestionPersistence.class)
724 protected PollsQuestionPersistence pollsQuestionPersistence;
725 @BeanReference(type = PollsVoteLocalService.class)
726 protected PollsVoteLocalService pollsVoteLocalService;
727 @BeanReference(type = PollsVoteService.class)
728 protected PollsVoteService pollsVoteService;
729 @BeanReference(type = PollsVotePersistence.class)
730 protected PollsVotePersistence pollsVotePersistence;
731 @BeanReference(type = CounterLocalService.class)
732 protected CounterLocalService counterLocalService;
733 @BeanReference(type = ResourceLocalService.class)
734 protected ResourceLocalService resourceLocalService;
735 @BeanReference(type = ResourceService.class)
736 protected ResourceService resourceService;
737 @BeanReference(type = ResourcePersistence.class)
738 protected ResourcePersistence resourcePersistence;
739 @BeanReference(type = ResourceFinder.class)
740 protected ResourceFinder resourceFinder;
741 @BeanReference(type = UserLocalService.class)
742 protected UserLocalService userLocalService;
743 @BeanReference(type = UserService.class)
744 protected UserService userService;
745 @BeanReference(type = UserPersistence.class)
746 protected UserPersistence userPersistence;
747 @BeanReference(type = UserFinder.class)
748 protected UserFinder userFinder;
749 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
750 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
751 private static Log _log = LogFactoryUtil.getLog(PollsChoiceLocalServiceBaseImpl.class);
752 private String _beanIdentifier;
753 }