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.PollsQuestion;
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 PollsQuestionLocalServiceBaseImpl
074 implements PollsQuestionLocalService, IdentifiableBean {
075
080
081
088 public PollsQuestion addPollsQuestion(PollsQuestion pollsQuestion)
089 throws SystemException {
090 pollsQuestion.setNew(true);
091
092 pollsQuestion = pollsQuestionPersistence.update(pollsQuestion, false);
093
094 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
095
096 if (indexer != null) {
097 try {
098 indexer.reindex(pollsQuestion);
099 }
100 catch (SearchException se) {
101 if (_log.isWarnEnabled()) {
102 _log.warn(se, se);
103 }
104 }
105 }
106
107 return pollsQuestion;
108 }
109
110
116 public PollsQuestion createPollsQuestion(long questionId) {
117 return pollsQuestionPersistence.create(questionId);
118 }
119
120
127 public void deletePollsQuestion(long questionId)
128 throws PortalException, SystemException {
129 PollsQuestion pollsQuestion = pollsQuestionPersistence.remove(questionId);
130
131 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
132
133 if (indexer != null) {
134 try {
135 indexer.delete(pollsQuestion);
136 }
137 catch (SearchException se) {
138 if (_log.isWarnEnabled()) {
139 _log.warn(se, se);
140 }
141 }
142 }
143 }
144
145
151 public void deletePollsQuestion(PollsQuestion pollsQuestion)
152 throws SystemException {
153 pollsQuestionPersistence.remove(pollsQuestion);
154
155 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
156
157 if (indexer != null) {
158 try {
159 indexer.delete(pollsQuestion);
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 pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery);
180 }
181
182
195 @SuppressWarnings("rawtypes")
196 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
197 throws SystemException {
198 return pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery,
199 start, end);
200 }
201
202
216 @SuppressWarnings("rawtypes")
217 public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
218 OrderByComparator orderByComparator) throws SystemException {
219 return pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery,
220 start, end, orderByComparator);
221 }
222
223
230 public long dynamicQueryCount(DynamicQuery dynamicQuery)
231 throws SystemException {
232 return pollsQuestionPersistence.countWithDynamicQuery(dynamicQuery);
233 }
234
235 public PollsQuestion fetchPollsQuestion(long questionId)
236 throws SystemException {
237 return pollsQuestionPersistence.fetchByPrimaryKey(questionId);
238 }
239
240
248 public PollsQuestion getPollsQuestion(long questionId)
249 throws PortalException, SystemException {
250 return pollsQuestionPersistence.findByPrimaryKey(questionId);
251 }
252
253 public PersistedModel getPersistedModel(Serializable primaryKeyObj)
254 throws PortalException, SystemException {
255 return pollsQuestionPersistence.findByPrimaryKey(primaryKeyObj);
256 }
257
258
267 public PollsQuestion getPollsQuestionByUuidAndGroupId(String uuid,
268 long groupId) throws PortalException, SystemException {
269 return pollsQuestionPersistence.findByUUID_G(uuid, groupId);
270 }
271
272
284 public List<PollsQuestion> getPollsQuestions(int start, int end)
285 throws SystemException {
286 return pollsQuestionPersistence.findAll(start, end);
287 }
288
289
295 public int getPollsQuestionsCount() throws SystemException {
296 return pollsQuestionPersistence.countAll();
297 }
298
299
306 public PollsQuestion updatePollsQuestion(PollsQuestion pollsQuestion)
307 throws SystemException {
308 return updatePollsQuestion(pollsQuestion, true);
309 }
310
311
319 public PollsQuestion updatePollsQuestion(PollsQuestion pollsQuestion,
320 boolean merge) throws SystemException {
321 pollsQuestion.setNew(false);
322
323 pollsQuestion = pollsQuestionPersistence.update(pollsQuestion, merge);
324
325 Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());
326
327 if (indexer != null) {
328 try {
329 indexer.reindex(pollsQuestion);
330 }
331 catch (SearchException se) {
332 if (_log.isWarnEnabled()) {
333 _log.warn(se, se);
334 }
335 }
336 }
337
338 return pollsQuestion;
339 }
340
341
346 public PollsChoiceLocalService getPollsChoiceLocalService() {
347 return pollsChoiceLocalService;
348 }
349
350
355 public void setPollsChoiceLocalService(
356 PollsChoiceLocalService pollsChoiceLocalService) {
357 this.pollsChoiceLocalService = pollsChoiceLocalService;
358 }
359
360
365 public PollsChoiceService getPollsChoiceService() {
366 return pollsChoiceService;
367 }
368
369
374 public void setPollsChoiceService(PollsChoiceService pollsChoiceService) {
375 this.pollsChoiceService = pollsChoiceService;
376 }
377
378
383 public PollsChoicePersistence getPollsChoicePersistence() {
384 return pollsChoicePersistence;
385 }
386
387
392 public void setPollsChoicePersistence(
393 PollsChoicePersistence pollsChoicePersistence) {
394 this.pollsChoicePersistence = pollsChoicePersistence;
395 }
396
397
402 public PollsChoiceFinder getPollsChoiceFinder() {
403 return pollsChoiceFinder;
404 }
405
406
411 public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
412 this.pollsChoiceFinder = pollsChoiceFinder;
413 }
414
415
420 public PollsQuestionLocalService getPollsQuestionLocalService() {
421 return pollsQuestionLocalService;
422 }
423
424
429 public void setPollsQuestionLocalService(
430 PollsQuestionLocalService pollsQuestionLocalService) {
431 this.pollsQuestionLocalService = pollsQuestionLocalService;
432 }
433
434
439 public PollsQuestionService getPollsQuestionService() {
440 return pollsQuestionService;
441 }
442
443
448 public void setPollsQuestionService(
449 PollsQuestionService pollsQuestionService) {
450 this.pollsQuestionService = pollsQuestionService;
451 }
452
453
458 public PollsQuestionPersistence getPollsQuestionPersistence() {
459 return pollsQuestionPersistence;
460 }
461
462
467 public void setPollsQuestionPersistence(
468 PollsQuestionPersistence pollsQuestionPersistence) {
469 this.pollsQuestionPersistence = pollsQuestionPersistence;
470 }
471
472
477 public PollsVoteLocalService getPollsVoteLocalService() {
478 return pollsVoteLocalService;
479 }
480
481
486 public void setPollsVoteLocalService(
487 PollsVoteLocalService pollsVoteLocalService) {
488 this.pollsVoteLocalService = pollsVoteLocalService;
489 }
490
491
496 public PollsVoteService getPollsVoteService() {
497 return pollsVoteService;
498 }
499
500
505 public void setPollsVoteService(PollsVoteService pollsVoteService) {
506 this.pollsVoteService = pollsVoteService;
507 }
508
509
514 public PollsVotePersistence getPollsVotePersistence() {
515 return pollsVotePersistence;
516 }
517
518
523 public void setPollsVotePersistence(
524 PollsVotePersistence pollsVotePersistence) {
525 this.pollsVotePersistence = pollsVotePersistence;
526 }
527
528
533 public CounterLocalService getCounterLocalService() {
534 return counterLocalService;
535 }
536
537
542 public void setCounterLocalService(CounterLocalService counterLocalService) {
543 this.counterLocalService = counterLocalService;
544 }
545
546
551 public ResourceLocalService getResourceLocalService() {
552 return resourceLocalService;
553 }
554
555
560 public void setResourceLocalService(
561 ResourceLocalService resourceLocalService) {
562 this.resourceLocalService = resourceLocalService;
563 }
564
565
570 public ResourceService getResourceService() {
571 return resourceService;
572 }
573
574
579 public void setResourceService(ResourceService resourceService) {
580 this.resourceService = resourceService;
581 }
582
583
588 public ResourcePersistence getResourcePersistence() {
589 return resourcePersistence;
590 }
591
592
597 public void setResourcePersistence(ResourcePersistence resourcePersistence) {
598 this.resourcePersistence = resourcePersistence;
599 }
600
601
606 public ResourceFinder getResourceFinder() {
607 return resourceFinder;
608 }
609
610
615 public void setResourceFinder(ResourceFinder resourceFinder) {
616 this.resourceFinder = resourceFinder;
617 }
618
619
624 public UserLocalService getUserLocalService() {
625 return userLocalService;
626 }
627
628
633 public void setUserLocalService(UserLocalService userLocalService) {
634 this.userLocalService = userLocalService;
635 }
636
637
642 public UserService getUserService() {
643 return userService;
644 }
645
646
651 public void setUserService(UserService userService) {
652 this.userService = userService;
653 }
654
655
660 public UserPersistence getUserPersistence() {
661 return userPersistence;
662 }
663
664
669 public void setUserPersistence(UserPersistence userPersistence) {
670 this.userPersistence = userPersistence;
671 }
672
673
678 public UserFinder getUserFinder() {
679 return userFinder;
680 }
681
682
687 public void setUserFinder(UserFinder userFinder) {
688 this.userFinder = userFinder;
689 }
690
691 public void afterPropertiesSet() {
692 persistedModelLocalServiceRegistry.register("com.liferay.portlet.polls.model.PollsQuestion",
693 pollsQuestionLocalService);
694 }
695
696 public void destroy() {
697 persistedModelLocalServiceRegistry.unregister(
698 "com.liferay.portlet.polls.model.PollsQuestion");
699 }
700
701
706 public String getBeanIdentifier() {
707 return _beanIdentifier;
708 }
709
710
715 public void setBeanIdentifier(String beanIdentifier) {
716 _beanIdentifier = beanIdentifier;
717 }
718
719 protected ClassLoader getClassLoader() {
720 Class<?> clazz = getClass();
721
722 return clazz.getClassLoader();
723 }
724
725 protected Class<?> getModelClass() {
726 return PollsQuestion.class;
727 }
728
729 protected String getModelClassName() {
730 return PollsQuestion.class.getName();
731 }
732
733
738 protected void runSQL(String sql) throws SystemException {
739 try {
740 DataSource dataSource = pollsQuestionPersistence.getDataSource();
741
742 SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
743 sql, new int[0]);
744
745 sqlUpdate.update();
746 }
747 catch (Exception e) {
748 throw new SystemException(e);
749 }
750 }
751
752 @BeanReference(type = PollsChoiceLocalService.class)
753 protected PollsChoiceLocalService pollsChoiceLocalService;
754 @BeanReference(type = PollsChoiceService.class)
755 protected PollsChoiceService pollsChoiceService;
756 @BeanReference(type = PollsChoicePersistence.class)
757 protected PollsChoicePersistence pollsChoicePersistence;
758 @BeanReference(type = PollsChoiceFinder.class)
759 protected PollsChoiceFinder pollsChoiceFinder;
760 @BeanReference(type = PollsQuestionLocalService.class)
761 protected PollsQuestionLocalService pollsQuestionLocalService;
762 @BeanReference(type = PollsQuestionService.class)
763 protected PollsQuestionService pollsQuestionService;
764 @BeanReference(type = PollsQuestionPersistence.class)
765 protected PollsQuestionPersistence pollsQuestionPersistence;
766 @BeanReference(type = PollsVoteLocalService.class)
767 protected PollsVoteLocalService pollsVoteLocalService;
768 @BeanReference(type = PollsVoteService.class)
769 protected PollsVoteService pollsVoteService;
770 @BeanReference(type = PollsVotePersistence.class)
771 protected PollsVotePersistence pollsVotePersistence;
772 @BeanReference(type = CounterLocalService.class)
773 protected CounterLocalService counterLocalService;
774 @BeanReference(type = ResourceLocalService.class)
775 protected ResourceLocalService resourceLocalService;
776 @BeanReference(type = ResourceService.class)
777 protected ResourceService resourceService;
778 @BeanReference(type = ResourcePersistence.class)
779 protected ResourcePersistence resourcePersistence;
780 @BeanReference(type = ResourceFinder.class)
781 protected ResourceFinder resourceFinder;
782 @BeanReference(type = UserLocalService.class)
783 protected UserLocalService userLocalService;
784 @BeanReference(type = UserService.class)
785 protected UserService userService;
786 @BeanReference(type = UserPersistence.class)
787 protected UserPersistence userPersistence;
788 @BeanReference(type = UserFinder.class)
789 protected UserFinder userFinder;
790 @BeanReference(type = PersistedModelLocalServiceRegistry.class)
791 protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
792 private static Log _log = LogFactoryUtil.getLog(PollsQuestionLocalServiceBaseImpl.class);
793 private String _beanIdentifier;
794 }