001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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.dao.orm.DynamicQueryFactoryUtil;
025    import com.liferay.portal.kernel.exception.PortalException;
026    import com.liferay.portal.kernel.exception.SystemException;
027    import com.liferay.portal.kernel.search.Indexable;
028    import com.liferay.portal.kernel.search.IndexableType;
029    import com.liferay.portal.kernel.util.OrderByComparator;
030    import com.liferay.portal.model.PersistedModel;
031    import com.liferay.portal.service.BaseLocalServiceImpl;
032    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
033    import com.liferay.portal.service.ResourceLocalService;
034    import com.liferay.portal.service.UserLocalService;
035    import com.liferay.portal.service.UserService;
036    import com.liferay.portal.service.persistence.UserFinder;
037    import com.liferay.portal.service.persistence.UserPersistence;
038    
039    import com.liferay.portlet.polls.model.PollsQuestion;
040    import com.liferay.portlet.polls.service.PollsChoiceLocalService;
041    import com.liferay.portlet.polls.service.PollsChoiceService;
042    import com.liferay.portlet.polls.service.PollsQuestionLocalService;
043    import com.liferay.portlet.polls.service.PollsQuestionService;
044    import com.liferay.portlet.polls.service.PollsVoteLocalService;
045    import com.liferay.portlet.polls.service.PollsVoteService;
046    import com.liferay.portlet.polls.service.persistence.PollsChoiceFinder;
047    import com.liferay.portlet.polls.service.persistence.PollsChoicePersistence;
048    import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
049    import com.liferay.portlet.polls.service.persistence.PollsVotePersistence;
050    
051    import java.io.Serializable;
052    
053    import java.util.List;
054    
055    import javax.sql.DataSource;
056    
057    /**
058     * The base implementation of the polls question local service.
059     *
060     * <p>
061     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portlet.polls.service.impl.PollsQuestionLocalServiceImpl}.
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see com.liferay.portlet.polls.service.impl.PollsQuestionLocalServiceImpl
066     * @see com.liferay.portlet.polls.service.PollsQuestionLocalServiceUtil
067     * @generated
068     */
069    public abstract class PollsQuestionLocalServiceBaseImpl
070            extends BaseLocalServiceImpl implements PollsQuestionLocalService,
071                    IdentifiableBean {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.polls.service.PollsQuestionLocalServiceUtil} to access the polls question local service.
076             */
077    
078            /**
079             * Adds the polls question to the database. Also notifies the appropriate model listeners.
080             *
081             * @param pollsQuestion the polls question
082             * @return the polls question that was added
083             * @throws SystemException if a system exception occurred
084             */
085            @Indexable(type = IndexableType.REINDEX)
086            public PollsQuestion addPollsQuestion(PollsQuestion pollsQuestion)
087                    throws SystemException {
088                    pollsQuestion.setNew(true);
089    
090                    return pollsQuestionPersistence.update(pollsQuestion);
091            }
092    
093            /**
094             * Creates a new polls question with the primary key. Does not add the polls question to the database.
095             *
096             * @param questionId the primary key for the new polls question
097             * @return the new polls question
098             */
099            public PollsQuestion createPollsQuestion(long questionId) {
100                    return pollsQuestionPersistence.create(questionId);
101            }
102    
103            /**
104             * Deletes the polls question with the primary key from the database. Also notifies the appropriate model listeners.
105             *
106             * @param questionId the primary key of the polls question
107             * @return the polls question that was removed
108             * @throws PortalException if a polls question with the primary key could not be found
109             * @throws SystemException if a system exception occurred
110             */
111            @Indexable(type = IndexableType.DELETE)
112            public PollsQuestion deletePollsQuestion(long questionId)
113                    throws PortalException, SystemException {
114                    return pollsQuestionPersistence.remove(questionId);
115            }
116    
117            /**
118             * Deletes the polls question from the database. Also notifies the appropriate model listeners.
119             *
120             * @param pollsQuestion the polls question
121             * @return the polls question that was removed
122             * @throws SystemException if a system exception occurred
123             */
124            @Indexable(type = IndexableType.DELETE)
125            public PollsQuestion deletePollsQuestion(PollsQuestion pollsQuestion)
126                    throws SystemException {
127                    return pollsQuestionPersistence.remove(pollsQuestion);
128            }
129    
130            public DynamicQuery dynamicQuery() {
131                    Class<?> clazz = getClass();
132    
133                    return DynamicQueryFactoryUtil.forClass(PollsQuestion.class,
134                            clazz.getClassLoader());
135            }
136    
137            /**
138             * Performs a dynamic query on the database and returns the matching rows.
139             *
140             * @param dynamicQuery the dynamic query
141             * @return the matching rows
142             * @throws SystemException if a system exception occurred
143             */
144            @SuppressWarnings("rawtypes")
145            public List dynamicQuery(DynamicQuery dynamicQuery)
146                    throws SystemException {
147                    return pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery);
148            }
149    
150            /**
151             * Performs a dynamic query on the database and returns a range of the matching rows.
152             *
153             * <p>
154             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
155             * </p>
156             *
157             * @param dynamicQuery the dynamic query
158             * @param start the lower bound of the range of model instances
159             * @param end the upper bound of the range of model instances (not inclusive)
160             * @return the range of matching rows
161             * @throws SystemException if a system exception occurred
162             */
163            @SuppressWarnings("rawtypes")
164            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
165                    throws SystemException {
166                    return pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery,
167                            start, end);
168            }
169    
170            /**
171             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
172             *
173             * <p>
174             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
175             * </p>
176             *
177             * @param dynamicQuery the dynamic query
178             * @param start the lower bound of the range of model instances
179             * @param end the upper bound of the range of model instances (not inclusive)
180             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
181             * @return the ordered range of matching rows
182             * @throws SystemException if a system exception occurred
183             */
184            @SuppressWarnings("rawtypes")
185            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
186                    OrderByComparator orderByComparator) throws SystemException {
187                    return pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery,
188                            start, end, orderByComparator);
189            }
190    
191            /**
192             * Returns the number of rows that match the dynamic query.
193             *
194             * @param dynamicQuery the dynamic query
195             * @return the number of rows that match the dynamic query
196             * @throws SystemException if a system exception occurred
197             */
198            public long dynamicQueryCount(DynamicQuery dynamicQuery)
199                    throws SystemException {
200                    return pollsQuestionPersistence.countWithDynamicQuery(dynamicQuery);
201            }
202    
203            public PollsQuestion fetchPollsQuestion(long questionId)
204                    throws SystemException {
205                    return pollsQuestionPersistence.fetchByPrimaryKey(questionId);
206            }
207    
208            /**
209             * Returns the polls question with the primary key.
210             *
211             * @param questionId the primary key of the polls question
212             * @return the polls question
213             * @throws PortalException if a polls question with the primary key could not be found
214             * @throws SystemException if a system exception occurred
215             */
216            public PollsQuestion getPollsQuestion(long questionId)
217                    throws PortalException, SystemException {
218                    return pollsQuestionPersistence.findByPrimaryKey(questionId);
219            }
220    
221            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
222                    throws PortalException, SystemException {
223                    return pollsQuestionPersistence.findByPrimaryKey(primaryKeyObj);
224            }
225    
226            /**
227             * Returns the polls question with the UUID in the group.
228             *
229             * @param uuid the UUID of polls question
230             * @param groupId the group id of the polls question
231             * @return the polls question
232             * @throws PortalException if a polls question with the UUID in the group could not be found
233             * @throws SystemException if a system exception occurred
234             */
235            public PollsQuestion getPollsQuestionByUuidAndGroupId(String uuid,
236                    long groupId) throws PortalException, SystemException {
237                    return pollsQuestionPersistence.findByUUID_G(uuid, groupId);
238            }
239    
240            /**
241             * Returns a range of all the polls questions.
242             *
243             * <p>
244             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
245             * </p>
246             *
247             * @param start the lower bound of the range of polls questions
248             * @param end the upper bound of the range of polls questions (not inclusive)
249             * @return the range of polls questions
250             * @throws SystemException if a system exception occurred
251             */
252            public List<PollsQuestion> getPollsQuestions(int start, int end)
253                    throws SystemException {
254                    return pollsQuestionPersistence.findAll(start, end);
255            }
256    
257            /**
258             * Returns the number of polls questions.
259             *
260             * @return the number of polls questions
261             * @throws SystemException if a system exception occurred
262             */
263            public int getPollsQuestionsCount() throws SystemException {
264                    return pollsQuestionPersistence.countAll();
265            }
266    
267            /**
268             * Updates the polls question in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
269             *
270             * @param pollsQuestion the polls question
271             * @return the polls question that was updated
272             * @throws SystemException if a system exception occurred
273             */
274            @Indexable(type = IndexableType.REINDEX)
275            public PollsQuestion updatePollsQuestion(PollsQuestion pollsQuestion)
276                    throws SystemException {
277                    return pollsQuestionPersistence.update(pollsQuestion);
278            }
279    
280            /**
281             * Returns the polls choice local service.
282             *
283             * @return the polls choice local service
284             */
285            public PollsChoiceLocalService getPollsChoiceLocalService() {
286                    return pollsChoiceLocalService;
287            }
288    
289            /**
290             * Sets the polls choice local service.
291             *
292             * @param pollsChoiceLocalService the polls choice local service
293             */
294            public void setPollsChoiceLocalService(
295                    PollsChoiceLocalService pollsChoiceLocalService) {
296                    this.pollsChoiceLocalService = pollsChoiceLocalService;
297            }
298    
299            /**
300             * Returns the polls choice remote service.
301             *
302             * @return the polls choice remote service
303             */
304            public PollsChoiceService getPollsChoiceService() {
305                    return pollsChoiceService;
306            }
307    
308            /**
309             * Sets the polls choice remote service.
310             *
311             * @param pollsChoiceService the polls choice remote service
312             */
313            public void setPollsChoiceService(PollsChoiceService pollsChoiceService) {
314                    this.pollsChoiceService = pollsChoiceService;
315            }
316    
317            /**
318             * Returns the polls choice persistence.
319             *
320             * @return the polls choice persistence
321             */
322            public PollsChoicePersistence getPollsChoicePersistence() {
323                    return pollsChoicePersistence;
324            }
325    
326            /**
327             * Sets the polls choice persistence.
328             *
329             * @param pollsChoicePersistence the polls choice persistence
330             */
331            public void setPollsChoicePersistence(
332                    PollsChoicePersistence pollsChoicePersistence) {
333                    this.pollsChoicePersistence = pollsChoicePersistence;
334            }
335    
336            /**
337             * Returns the polls choice finder.
338             *
339             * @return the polls choice finder
340             */
341            public PollsChoiceFinder getPollsChoiceFinder() {
342                    return pollsChoiceFinder;
343            }
344    
345            /**
346             * Sets the polls choice finder.
347             *
348             * @param pollsChoiceFinder the polls choice finder
349             */
350            public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
351                    this.pollsChoiceFinder = pollsChoiceFinder;
352            }
353    
354            /**
355             * Returns the polls question local service.
356             *
357             * @return the polls question local service
358             */
359            public PollsQuestionLocalService getPollsQuestionLocalService() {
360                    return pollsQuestionLocalService;
361            }
362    
363            /**
364             * Sets the polls question local service.
365             *
366             * @param pollsQuestionLocalService the polls question local service
367             */
368            public void setPollsQuestionLocalService(
369                    PollsQuestionLocalService pollsQuestionLocalService) {
370                    this.pollsQuestionLocalService = pollsQuestionLocalService;
371            }
372    
373            /**
374             * Returns the polls question remote service.
375             *
376             * @return the polls question remote service
377             */
378            public PollsQuestionService getPollsQuestionService() {
379                    return pollsQuestionService;
380            }
381    
382            /**
383             * Sets the polls question remote service.
384             *
385             * @param pollsQuestionService the polls question remote service
386             */
387            public void setPollsQuestionService(
388                    PollsQuestionService pollsQuestionService) {
389                    this.pollsQuestionService = pollsQuestionService;
390            }
391    
392            /**
393             * Returns the polls question persistence.
394             *
395             * @return the polls question persistence
396             */
397            public PollsQuestionPersistence getPollsQuestionPersistence() {
398                    return pollsQuestionPersistence;
399            }
400    
401            /**
402             * Sets the polls question persistence.
403             *
404             * @param pollsQuestionPersistence the polls question persistence
405             */
406            public void setPollsQuestionPersistence(
407                    PollsQuestionPersistence pollsQuestionPersistence) {
408                    this.pollsQuestionPersistence = pollsQuestionPersistence;
409            }
410    
411            /**
412             * Returns the polls vote local service.
413             *
414             * @return the polls vote local service
415             */
416            public PollsVoteLocalService getPollsVoteLocalService() {
417                    return pollsVoteLocalService;
418            }
419    
420            /**
421             * Sets the polls vote local service.
422             *
423             * @param pollsVoteLocalService the polls vote local service
424             */
425            public void setPollsVoteLocalService(
426                    PollsVoteLocalService pollsVoteLocalService) {
427                    this.pollsVoteLocalService = pollsVoteLocalService;
428            }
429    
430            /**
431             * Returns the polls vote remote service.
432             *
433             * @return the polls vote remote service
434             */
435            public PollsVoteService getPollsVoteService() {
436                    return pollsVoteService;
437            }
438    
439            /**
440             * Sets the polls vote remote service.
441             *
442             * @param pollsVoteService the polls vote remote service
443             */
444            public void setPollsVoteService(PollsVoteService pollsVoteService) {
445                    this.pollsVoteService = pollsVoteService;
446            }
447    
448            /**
449             * Returns the polls vote persistence.
450             *
451             * @return the polls vote persistence
452             */
453            public PollsVotePersistence getPollsVotePersistence() {
454                    return pollsVotePersistence;
455            }
456    
457            /**
458             * Sets the polls vote persistence.
459             *
460             * @param pollsVotePersistence the polls vote persistence
461             */
462            public void setPollsVotePersistence(
463                    PollsVotePersistence pollsVotePersistence) {
464                    this.pollsVotePersistence = pollsVotePersistence;
465            }
466    
467            /**
468             * Returns the counter local service.
469             *
470             * @return the counter local service
471             */
472            public CounterLocalService getCounterLocalService() {
473                    return counterLocalService;
474            }
475    
476            /**
477             * Sets the counter local service.
478             *
479             * @param counterLocalService the counter local service
480             */
481            public void setCounterLocalService(CounterLocalService counterLocalService) {
482                    this.counterLocalService = counterLocalService;
483            }
484    
485            /**
486             * Returns the resource local service.
487             *
488             * @return the resource local service
489             */
490            public ResourceLocalService getResourceLocalService() {
491                    return resourceLocalService;
492            }
493    
494            /**
495             * Sets the resource local service.
496             *
497             * @param resourceLocalService the resource local service
498             */
499            public void setResourceLocalService(
500                    ResourceLocalService resourceLocalService) {
501                    this.resourceLocalService = resourceLocalService;
502            }
503    
504            /**
505             * Returns the user local service.
506             *
507             * @return the user local service
508             */
509            public UserLocalService getUserLocalService() {
510                    return userLocalService;
511            }
512    
513            /**
514             * Sets the user local service.
515             *
516             * @param userLocalService the user local service
517             */
518            public void setUserLocalService(UserLocalService userLocalService) {
519                    this.userLocalService = userLocalService;
520            }
521    
522            /**
523             * Returns the user remote service.
524             *
525             * @return the user remote service
526             */
527            public UserService getUserService() {
528                    return userService;
529            }
530    
531            /**
532             * Sets the user remote service.
533             *
534             * @param userService the user remote service
535             */
536            public void setUserService(UserService userService) {
537                    this.userService = userService;
538            }
539    
540            /**
541             * Returns the user persistence.
542             *
543             * @return the user persistence
544             */
545            public UserPersistence getUserPersistence() {
546                    return userPersistence;
547            }
548    
549            /**
550             * Sets the user persistence.
551             *
552             * @param userPersistence the user persistence
553             */
554            public void setUserPersistence(UserPersistence userPersistence) {
555                    this.userPersistence = userPersistence;
556            }
557    
558            /**
559             * Returns the user finder.
560             *
561             * @return the user finder
562             */
563            public UserFinder getUserFinder() {
564                    return userFinder;
565            }
566    
567            /**
568             * Sets the user finder.
569             *
570             * @param userFinder the user finder
571             */
572            public void setUserFinder(UserFinder userFinder) {
573                    this.userFinder = userFinder;
574            }
575    
576            public void afterPropertiesSet() {
577                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.polls.model.PollsQuestion",
578                            pollsQuestionLocalService);
579            }
580    
581            public void destroy() {
582                    persistedModelLocalServiceRegistry.unregister(
583                            "com.liferay.portlet.polls.model.PollsQuestion");
584            }
585    
586            /**
587             * Returns the Spring bean ID for this bean.
588             *
589             * @return the Spring bean ID for this bean
590             */
591            public String getBeanIdentifier() {
592                    return _beanIdentifier;
593            }
594    
595            /**
596             * Sets the Spring bean ID for this bean.
597             *
598             * @param beanIdentifier the Spring bean ID for this bean
599             */
600            public void setBeanIdentifier(String beanIdentifier) {
601                    _beanIdentifier = beanIdentifier;
602            }
603    
604            protected Class<?> getModelClass() {
605                    return PollsQuestion.class;
606            }
607    
608            protected String getModelClassName() {
609                    return PollsQuestion.class.getName();
610            }
611    
612            /**
613             * Performs an SQL query.
614             *
615             * @param sql the sql query
616             */
617            protected void runSQL(String sql) throws SystemException {
618                    try {
619                            DataSource dataSource = pollsQuestionPersistence.getDataSource();
620    
621                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
622                                            sql, new int[0]);
623    
624                            sqlUpdate.update();
625                    }
626                    catch (Exception e) {
627                            throw new SystemException(e);
628                    }
629            }
630    
631            @BeanReference(type = PollsChoiceLocalService.class)
632            protected PollsChoiceLocalService pollsChoiceLocalService;
633            @BeanReference(type = PollsChoiceService.class)
634            protected PollsChoiceService pollsChoiceService;
635            @BeanReference(type = PollsChoicePersistence.class)
636            protected PollsChoicePersistence pollsChoicePersistence;
637            @BeanReference(type = PollsChoiceFinder.class)
638            protected PollsChoiceFinder pollsChoiceFinder;
639            @BeanReference(type = PollsQuestionLocalService.class)
640            protected PollsQuestionLocalService pollsQuestionLocalService;
641            @BeanReference(type = PollsQuestionService.class)
642            protected PollsQuestionService pollsQuestionService;
643            @BeanReference(type = PollsQuestionPersistence.class)
644            protected PollsQuestionPersistence pollsQuestionPersistence;
645            @BeanReference(type = PollsVoteLocalService.class)
646            protected PollsVoteLocalService pollsVoteLocalService;
647            @BeanReference(type = PollsVoteService.class)
648            protected PollsVoteService pollsVoteService;
649            @BeanReference(type = PollsVotePersistence.class)
650            protected PollsVotePersistence pollsVotePersistence;
651            @BeanReference(type = CounterLocalService.class)
652            protected CounterLocalService counterLocalService;
653            @BeanReference(type = ResourceLocalService.class)
654            protected ResourceLocalService resourceLocalService;
655            @BeanReference(type = UserLocalService.class)
656            protected UserLocalService userLocalService;
657            @BeanReference(type = UserService.class)
658            protected UserService userService;
659            @BeanReference(type = UserPersistence.class)
660            protected UserPersistence userPersistence;
661            @BeanReference(type = UserFinder.class)
662            protected UserFinder userFinder;
663            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
664            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
665            private String _beanIdentifier;
666    }