001    /**
002     * Copyright (c) 2000-2010 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.annotation.BeanReference;
020    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
021    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
022    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
023    import com.liferay.portal.kernel.exception.PortalException;
024    import com.liferay.portal.kernel.exception.SystemException;
025    import com.liferay.portal.kernel.util.OrderByComparator;
026    import com.liferay.portal.service.ResourceLocalService;
027    import com.liferay.portal.service.ResourceService;
028    import com.liferay.portal.service.UserLocalService;
029    import com.liferay.portal.service.UserService;
030    import com.liferay.portal.service.persistence.ResourceFinder;
031    import com.liferay.portal.service.persistence.ResourcePersistence;
032    import com.liferay.portal.service.persistence.UserFinder;
033    import com.liferay.portal.service.persistence.UserPersistence;
034    
035    import com.liferay.portlet.polls.model.PollsChoice;
036    import com.liferay.portlet.polls.service.PollsChoiceLocalService;
037    import com.liferay.portlet.polls.service.PollsQuestionLocalService;
038    import com.liferay.portlet.polls.service.PollsQuestionService;
039    import com.liferay.portlet.polls.service.PollsVoteLocalService;
040    import com.liferay.portlet.polls.service.PollsVoteService;
041    import com.liferay.portlet.polls.service.persistence.PollsChoiceFinder;
042    import com.liferay.portlet.polls.service.persistence.PollsChoicePersistence;
043    import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
044    import com.liferay.portlet.polls.service.persistence.PollsVotePersistence;
045    
046    import java.util.List;
047    
048    import javax.sql.DataSource;
049    
050    /**
051     * The base implementation of the polls choice local service.
052     *
053     * <p>
054     * 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.PollsChoiceLocalServiceImpl}.
055     * </p>
056     *
057     * <p>
058     * Never modify or reference this class directly. Always use {@link com.liferay.portlet.polls.service.PollsChoiceLocalServiceUtil} to access the polls choice local service.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portlet.polls.service.impl.PollsChoiceLocalServiceImpl
063     * @see com.liferay.portlet.polls.service.PollsChoiceLocalServiceUtil
064     * @generated
065     */
066    public abstract class PollsChoiceLocalServiceBaseImpl
067            implements PollsChoiceLocalService {
068            /**
069             * Adds the polls choice to the database. Also notifies the appropriate model listeners.
070             *
071             * @param pollsChoice the polls choice to add
072             * @return the polls choice that was added
073             * @throws SystemException if a system exception occurred
074             */
075            public PollsChoice addPollsChoice(PollsChoice pollsChoice)
076                    throws SystemException {
077                    pollsChoice.setNew(true);
078    
079                    return pollsChoicePersistence.update(pollsChoice, false);
080            }
081    
082            /**
083             * Creates a new polls choice with the primary key. Does not add the polls choice to the database.
084             *
085             * @param choiceId the primary key for the new polls choice
086             * @return the new polls choice
087             */
088            public PollsChoice createPollsChoice(long choiceId) {
089                    return pollsChoicePersistence.create(choiceId);
090            }
091    
092            /**
093             * Deletes the polls choice with the primary key from the database. Also notifies the appropriate model listeners.
094             *
095             * @param choiceId the primary key of the polls choice to delete
096             * @throws PortalException if a polls choice with the primary key could not be found
097             * @throws SystemException if a system exception occurred
098             */
099            public void deletePollsChoice(long choiceId)
100                    throws PortalException, SystemException {
101                    pollsChoicePersistence.remove(choiceId);
102            }
103    
104            /**
105             * Deletes the polls choice from the database. Also notifies the appropriate model listeners.
106             *
107             * @param pollsChoice the polls choice to delete
108             * @throws SystemException if a system exception occurred
109             */
110            public void deletePollsChoice(PollsChoice pollsChoice)
111                    throws SystemException {
112                    pollsChoicePersistence.remove(pollsChoice);
113            }
114    
115            /**
116             * Performs a dynamic query on the database and returns the matching rows.
117             *
118             * @param dynamicQuery the dynamic query to search with
119             * @return the matching rows
120             * @throws SystemException if a system exception occurred
121             */
122            @SuppressWarnings("rawtypes")
123            public List dynamicQuery(DynamicQuery dynamicQuery)
124                    throws SystemException {
125                    return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery);
126            }
127    
128            /**
129             * Performs a dynamic query on the database and returns a range of the matching rows.
130             *
131             * <p>
132             * 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.
133             * </p>
134             *
135             * @param dynamicQuery the dynamic query to search with
136             * @param start the lower bound of the range of model instances to return
137             * @param end the upper bound of the range of model instances to return (not inclusive)
138             * @return the range of matching rows
139             * @throws SystemException if a system exception occurred
140             */
141            @SuppressWarnings("rawtypes")
142            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
143                    throws SystemException {
144                    return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery, start,
145                            end);
146            }
147    
148            /**
149             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
150             *
151             * <p>
152             * 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.
153             * </p>
154             *
155             * @param dynamicQuery the dynamic query to search with
156             * @param start the lower bound of the range of model instances to return
157             * @param end the upper bound of the range of model instances to return (not inclusive)
158             * @param orderByComparator the comparator to order the results by
159             * @return the ordered range of matching rows
160             * @throws SystemException if a system exception occurred
161             */
162            @SuppressWarnings("rawtypes")
163            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
164                    OrderByComparator orderByComparator) throws SystemException {
165                    return pollsChoicePersistence.findWithDynamicQuery(dynamicQuery, start,
166                            end, orderByComparator);
167            }
168    
169            /**
170             * Counts the number of rows that match the dynamic query.
171             *
172             * @param dynamicQuery the dynamic query to search with
173             * @return the number of rows that match the dynamic query
174             * @throws SystemException if a system exception occurred
175             */
176            public long dynamicQueryCount(DynamicQuery dynamicQuery)
177                    throws SystemException {
178                    return pollsChoicePersistence.countWithDynamicQuery(dynamicQuery);
179            }
180    
181            /**
182             * Gets the polls choice with the primary key.
183             *
184             * @param choiceId the primary key of the polls choice to get
185             * @return the polls choice
186             * @throws PortalException if a polls choice with the primary key could not be found
187             * @throws SystemException if a system exception occurred
188             */
189            public PollsChoice getPollsChoice(long choiceId)
190                    throws PortalException, SystemException {
191                    return pollsChoicePersistence.findByPrimaryKey(choiceId);
192            }
193    
194            /**
195             * Gets a range of all the polls choices.
196             *
197             * <p>
198             * 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.
199             * </p>
200             *
201             * @param start the lower bound of the range of polls choices to return
202             * @param end the upper bound of the range of polls choices to return (not inclusive)
203             * @return the range of polls choices
204             * @throws SystemException if a system exception occurred
205             */
206            public List<PollsChoice> getPollsChoices(int start, int end)
207                    throws SystemException {
208                    return pollsChoicePersistence.findAll(start, end);
209            }
210    
211            /**
212             * Gets the number of polls choices.
213             *
214             * @return the number of polls choices
215             * @throws SystemException if a system exception occurred
216             */
217            public int getPollsChoicesCount() throws SystemException {
218                    return pollsChoicePersistence.countAll();
219            }
220    
221            /**
222             * Updates the polls choice in the database. Also notifies the appropriate model listeners.
223             *
224             * @param pollsChoice the polls choice to update
225             * @return the polls choice that was updated
226             * @throws SystemException if a system exception occurred
227             */
228            public PollsChoice updatePollsChoice(PollsChoice pollsChoice)
229                    throws SystemException {
230                    pollsChoice.setNew(false);
231    
232                    return pollsChoicePersistence.update(pollsChoice, true);
233            }
234    
235            /**
236             * Updates the polls choice in the database. Also notifies the appropriate model listeners.
237             *
238             * @param pollsChoice the polls choice to update
239             * @param merge whether to merge the polls choice with the current session. See {@link com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session, com.liferay.portal.model.BaseModel, boolean)} for an explanation.
240             * @return the polls choice that was updated
241             * @throws SystemException if a system exception occurred
242             */
243            public PollsChoice updatePollsChoice(PollsChoice pollsChoice, boolean merge)
244                    throws SystemException {
245                    pollsChoice.setNew(false);
246    
247                    return pollsChoicePersistence.update(pollsChoice, merge);
248            }
249    
250            /**
251             * Gets the polls choice local service.
252             *
253             * @return the polls choice local service
254             */
255            public PollsChoiceLocalService getPollsChoiceLocalService() {
256                    return pollsChoiceLocalService;
257            }
258    
259            /**
260             * Sets the polls choice local service.
261             *
262             * @param pollsChoiceLocalService the polls choice local service
263             */
264            public void setPollsChoiceLocalService(
265                    PollsChoiceLocalService pollsChoiceLocalService) {
266                    this.pollsChoiceLocalService = pollsChoiceLocalService;
267            }
268    
269            /**
270             * Gets the polls choice persistence.
271             *
272             * @return the polls choice persistence
273             */
274            public PollsChoicePersistence getPollsChoicePersistence() {
275                    return pollsChoicePersistence;
276            }
277    
278            /**
279             * Sets the polls choice persistence.
280             *
281             * @param pollsChoicePersistence the polls choice persistence
282             */
283            public void setPollsChoicePersistence(
284                    PollsChoicePersistence pollsChoicePersistence) {
285                    this.pollsChoicePersistence = pollsChoicePersistence;
286            }
287    
288            /**
289             * Gets the polls choice finder.
290             *
291             * @return the polls choice finder
292             */
293            public PollsChoiceFinder getPollsChoiceFinder() {
294                    return pollsChoiceFinder;
295            }
296    
297            /**
298             * Sets the polls choice finder.
299             *
300             * @param pollsChoiceFinder the polls choice finder
301             */
302            public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
303                    this.pollsChoiceFinder = pollsChoiceFinder;
304            }
305    
306            /**
307             * Gets the polls question local service.
308             *
309             * @return the polls question local service
310             */
311            public PollsQuestionLocalService getPollsQuestionLocalService() {
312                    return pollsQuestionLocalService;
313            }
314    
315            /**
316             * Sets the polls question local service.
317             *
318             * @param pollsQuestionLocalService the polls question local service
319             */
320            public void setPollsQuestionLocalService(
321                    PollsQuestionLocalService pollsQuestionLocalService) {
322                    this.pollsQuestionLocalService = pollsQuestionLocalService;
323            }
324    
325            /**
326             * Gets the polls question remote service.
327             *
328             * @return the polls question remote service
329             */
330            public PollsQuestionService getPollsQuestionService() {
331                    return pollsQuestionService;
332            }
333    
334            /**
335             * Sets the polls question remote service.
336             *
337             * @param pollsQuestionService the polls question remote service
338             */
339            public void setPollsQuestionService(
340                    PollsQuestionService pollsQuestionService) {
341                    this.pollsQuestionService = pollsQuestionService;
342            }
343    
344            /**
345             * Gets the polls question persistence.
346             *
347             * @return the polls question persistence
348             */
349            public PollsQuestionPersistence getPollsQuestionPersistence() {
350                    return pollsQuestionPersistence;
351            }
352    
353            /**
354             * Sets the polls question persistence.
355             *
356             * @param pollsQuestionPersistence the polls question persistence
357             */
358            public void setPollsQuestionPersistence(
359                    PollsQuestionPersistence pollsQuestionPersistence) {
360                    this.pollsQuestionPersistence = pollsQuestionPersistence;
361            }
362    
363            /**
364             * Gets the polls vote local service.
365             *
366             * @return the polls vote local service
367             */
368            public PollsVoteLocalService getPollsVoteLocalService() {
369                    return pollsVoteLocalService;
370            }
371    
372            /**
373             * Sets the polls vote local service.
374             *
375             * @param pollsVoteLocalService the polls vote local service
376             */
377            public void setPollsVoteLocalService(
378                    PollsVoteLocalService pollsVoteLocalService) {
379                    this.pollsVoteLocalService = pollsVoteLocalService;
380            }
381    
382            /**
383             * Gets the polls vote remote service.
384             *
385             * @return the polls vote remote service
386             */
387            public PollsVoteService getPollsVoteService() {
388                    return pollsVoteService;
389            }
390    
391            /**
392             * Sets the polls vote remote service.
393             *
394             * @param pollsVoteService the polls vote remote service
395             */
396            public void setPollsVoteService(PollsVoteService pollsVoteService) {
397                    this.pollsVoteService = pollsVoteService;
398            }
399    
400            /**
401             * Gets the polls vote persistence.
402             *
403             * @return the polls vote persistence
404             */
405            public PollsVotePersistence getPollsVotePersistence() {
406                    return pollsVotePersistence;
407            }
408    
409            /**
410             * Sets the polls vote persistence.
411             *
412             * @param pollsVotePersistence the polls vote persistence
413             */
414            public void setPollsVotePersistence(
415                    PollsVotePersistence pollsVotePersistence) {
416                    this.pollsVotePersistence = pollsVotePersistence;
417            }
418    
419            /**
420             * Gets the counter local service.
421             *
422             * @return the counter local service
423             */
424            public CounterLocalService getCounterLocalService() {
425                    return counterLocalService;
426            }
427    
428            /**
429             * Sets the counter local service.
430             *
431             * @param counterLocalService the counter local service
432             */
433            public void setCounterLocalService(CounterLocalService counterLocalService) {
434                    this.counterLocalService = counterLocalService;
435            }
436    
437            /**
438             * Gets the resource local service.
439             *
440             * @return the resource local service
441             */
442            public ResourceLocalService getResourceLocalService() {
443                    return resourceLocalService;
444            }
445    
446            /**
447             * Sets the resource local service.
448             *
449             * @param resourceLocalService the resource local service
450             */
451            public void setResourceLocalService(
452                    ResourceLocalService resourceLocalService) {
453                    this.resourceLocalService = resourceLocalService;
454            }
455    
456            /**
457             * Gets the resource remote service.
458             *
459             * @return the resource remote service
460             */
461            public ResourceService getResourceService() {
462                    return resourceService;
463            }
464    
465            /**
466             * Sets the resource remote service.
467             *
468             * @param resourceService the resource remote service
469             */
470            public void setResourceService(ResourceService resourceService) {
471                    this.resourceService = resourceService;
472            }
473    
474            /**
475             * Gets the resource persistence.
476             *
477             * @return the resource persistence
478             */
479            public ResourcePersistence getResourcePersistence() {
480                    return resourcePersistence;
481            }
482    
483            /**
484             * Sets the resource persistence.
485             *
486             * @param resourcePersistence the resource persistence
487             */
488            public void setResourcePersistence(ResourcePersistence resourcePersistence) {
489                    this.resourcePersistence = resourcePersistence;
490            }
491    
492            /**
493             * Gets the resource finder.
494             *
495             * @return the resource finder
496             */
497            public ResourceFinder getResourceFinder() {
498                    return resourceFinder;
499            }
500    
501            /**
502             * Sets the resource finder.
503             *
504             * @param resourceFinder the resource finder
505             */
506            public void setResourceFinder(ResourceFinder resourceFinder) {
507                    this.resourceFinder = resourceFinder;
508            }
509    
510            /**
511             * Gets the user local service.
512             *
513             * @return the user local service
514             */
515            public UserLocalService getUserLocalService() {
516                    return userLocalService;
517            }
518    
519            /**
520             * Sets the user local service.
521             *
522             * @param userLocalService the user local service
523             */
524            public void setUserLocalService(UserLocalService userLocalService) {
525                    this.userLocalService = userLocalService;
526            }
527    
528            /**
529             * Gets the user remote service.
530             *
531             * @return the user remote service
532             */
533            public UserService getUserService() {
534                    return userService;
535            }
536    
537            /**
538             * Sets the user remote service.
539             *
540             * @param userService the user remote service
541             */
542            public void setUserService(UserService userService) {
543                    this.userService = userService;
544            }
545    
546            /**
547             * Gets the user persistence.
548             *
549             * @return the user persistence
550             */
551            public UserPersistence getUserPersistence() {
552                    return userPersistence;
553            }
554    
555            /**
556             * Sets the user persistence.
557             *
558             * @param userPersistence the user persistence
559             */
560            public void setUserPersistence(UserPersistence userPersistence) {
561                    this.userPersistence = userPersistence;
562            }
563    
564            /**
565             * Gets the user finder.
566             *
567             * @return the user finder
568             */
569            public UserFinder getUserFinder() {
570                    return userFinder;
571            }
572    
573            /**
574             * Sets the user finder.
575             *
576             * @param userFinder the user finder
577             */
578            public void setUserFinder(UserFinder userFinder) {
579                    this.userFinder = userFinder;
580            }
581    
582            /**
583             * Performs an SQL query.
584             *
585             * @param sql the sql query to perform
586             */
587            protected void runSQL(String sql) throws SystemException {
588                    try {
589                            DataSource dataSource = pollsChoicePersistence.getDataSource();
590    
591                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
592                                            sql, new int[0]);
593    
594                            sqlUpdate.update();
595                    }
596                    catch (Exception e) {
597                            throw new SystemException(e);
598                    }
599            }
600    
601            @BeanReference(type = PollsChoiceLocalService.class)
602            protected PollsChoiceLocalService pollsChoiceLocalService;
603            @BeanReference(type = PollsChoicePersistence.class)
604            protected PollsChoicePersistence pollsChoicePersistence;
605            @BeanReference(type = PollsChoiceFinder.class)
606            protected PollsChoiceFinder pollsChoiceFinder;
607            @BeanReference(type = PollsQuestionLocalService.class)
608            protected PollsQuestionLocalService pollsQuestionLocalService;
609            @BeanReference(type = PollsQuestionService.class)
610            protected PollsQuestionService pollsQuestionService;
611            @BeanReference(type = PollsQuestionPersistence.class)
612            protected PollsQuestionPersistence pollsQuestionPersistence;
613            @BeanReference(type = PollsVoteLocalService.class)
614            protected PollsVoteLocalService pollsVoteLocalService;
615            @BeanReference(type = PollsVoteService.class)
616            protected PollsVoteService pollsVoteService;
617            @BeanReference(type = PollsVotePersistence.class)
618            protected PollsVotePersistence pollsVotePersistence;
619            @BeanReference(type = CounterLocalService.class)
620            protected CounterLocalService counterLocalService;
621            @BeanReference(type = ResourceLocalService.class)
622            protected ResourceLocalService resourceLocalService;
623            @BeanReference(type = ResourceService.class)
624            protected ResourceService resourceService;
625            @BeanReference(type = ResourcePersistence.class)
626            protected ResourcePersistence resourcePersistence;
627            @BeanReference(type = ResourceFinder.class)
628            protected ResourceFinder resourceFinder;
629            @BeanReference(type = UserLocalService.class)
630            protected UserLocalService userLocalService;
631            @BeanReference(type = UserService.class)
632            protected UserService userService;
633            @BeanReference(type = UserPersistence.class)
634            protected UserPersistence userPersistence;
635            @BeanReference(type = UserFinder.class)
636            protected UserFinder userFinder;
637    }