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