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.PollsQuestion;
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 question 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.PollsQuestionLocalServiceImpl}.
055     * </p>
056     *
057     * <p>
058     * Never modify or reference this class directly. Always use {@link com.liferay.portlet.polls.service.PollsQuestionLocalServiceUtil} to access the polls question local service.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portlet.polls.service.impl.PollsQuestionLocalServiceImpl
063     * @see com.liferay.portlet.polls.service.PollsQuestionLocalServiceUtil
064     * @generated
065     */
066    public abstract class PollsQuestionLocalServiceBaseImpl
067            implements PollsQuestionLocalService {
068            /**
069             * Adds the polls question to the database. Also notifies the appropriate model listeners.
070             *
071             * @param pollsQuestion the polls question to add
072             * @return the polls question that was added
073             * @throws SystemException if a system exception occurred
074             */
075            public PollsQuestion addPollsQuestion(PollsQuestion pollsQuestion)
076                    throws SystemException {
077                    pollsQuestion.setNew(true);
078    
079                    return pollsQuestionPersistence.update(pollsQuestion, false);
080            }
081    
082            /**
083             * Creates a new polls question with the primary key. Does not add the polls question to the database.
084             *
085             * @param questionId the primary key for the new polls question
086             * @return the new polls question
087             */
088            public PollsQuestion createPollsQuestion(long questionId) {
089                    return pollsQuestionPersistence.create(questionId);
090            }
091    
092            /**
093             * Deletes the polls question with the primary key from the database. Also notifies the appropriate model listeners.
094             *
095             * @param questionId the primary key of the polls question to delete
096             * @throws PortalException if a polls question with the primary key could not be found
097             * @throws SystemException if a system exception occurred
098             */
099            public void deletePollsQuestion(long questionId)
100                    throws PortalException, SystemException {
101                    pollsQuestionPersistence.remove(questionId);
102            }
103    
104            /**
105             * Deletes the polls question from the database. Also notifies the appropriate model listeners.
106             *
107             * @param pollsQuestion the polls question to delete
108             * @throws SystemException if a system exception occurred
109             */
110            public void deletePollsQuestion(PollsQuestion pollsQuestion)
111                    throws SystemException {
112                    pollsQuestionPersistence.remove(pollsQuestion);
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 pollsQuestionPersistence.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 pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery,
145                            start, 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 pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery,
166                            start, 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 pollsQuestionPersistence.countWithDynamicQuery(dynamicQuery);
179            }
180    
181            /**
182             * Gets the polls question with the primary key.
183             *
184             * @param questionId the primary key of the polls question to get
185             * @return the polls question
186             * @throws PortalException if a polls question with the primary key could not be found
187             * @throws SystemException if a system exception occurred
188             */
189            public PollsQuestion getPollsQuestion(long questionId)
190                    throws PortalException, SystemException {
191                    return pollsQuestionPersistence.findByPrimaryKey(questionId);
192            }
193    
194            /**
195             * Gets the polls question with the UUID and group id.
196             *
197             * @param uuid the UUID of polls question to get
198             * @param groupId the group id of the polls question to get
199             * @return the polls question
200             * @throws PortalException if a polls question with the UUID and group id could not be found
201             * @throws SystemException if a system exception occurred
202             */
203            public PollsQuestion getPollsQuestionByUuidAndGroupId(String uuid,
204                    long groupId) throws PortalException, SystemException {
205                    return pollsQuestionPersistence.findByUUID_G(uuid, groupId);
206            }
207    
208            /**
209             * Gets a range of all the polls questions.
210             *
211             * <p>
212             * 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.
213             * </p>
214             *
215             * @param start the lower bound of the range of polls questions to return
216             * @param end the upper bound of the range of polls questions to return (not inclusive)
217             * @return the range of polls questions
218             * @throws SystemException if a system exception occurred
219             */
220            public List<PollsQuestion> getPollsQuestions(int start, int end)
221                    throws SystemException {
222                    return pollsQuestionPersistence.findAll(start, end);
223            }
224    
225            /**
226             * Gets the number of polls questions.
227             *
228             * @return the number of polls questions
229             * @throws SystemException if a system exception occurred
230             */
231            public int getPollsQuestionsCount() throws SystemException {
232                    return pollsQuestionPersistence.countAll();
233            }
234    
235            /**
236             * Updates the polls question in the database. Also notifies the appropriate model listeners.
237             *
238             * @param pollsQuestion the polls question to update
239             * @return the polls question that was updated
240             * @throws SystemException if a system exception occurred
241             */
242            public PollsQuestion updatePollsQuestion(PollsQuestion pollsQuestion)
243                    throws SystemException {
244                    pollsQuestion.setNew(false);
245    
246                    return pollsQuestionPersistence.update(pollsQuestion, true);
247            }
248    
249            /**
250             * Updates the polls question in the database. Also notifies the appropriate model listeners.
251             *
252             * @param pollsQuestion the polls question to update
253             * @param merge whether to merge the polls question 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.
254             * @return the polls question that was updated
255             * @throws SystemException if a system exception occurred
256             */
257            public PollsQuestion updatePollsQuestion(PollsQuestion pollsQuestion,
258                    boolean merge) throws SystemException {
259                    pollsQuestion.setNew(false);
260    
261                    return pollsQuestionPersistence.update(pollsQuestion, merge);
262            }
263    
264            /**
265             * Gets the polls choice local service.
266             *
267             * @return the polls choice local service
268             */
269            public PollsChoiceLocalService getPollsChoiceLocalService() {
270                    return pollsChoiceLocalService;
271            }
272    
273            /**
274             * Sets the polls choice local service.
275             *
276             * @param pollsChoiceLocalService the polls choice local service
277             */
278            public void setPollsChoiceLocalService(
279                    PollsChoiceLocalService pollsChoiceLocalService) {
280                    this.pollsChoiceLocalService = pollsChoiceLocalService;
281            }
282    
283            /**
284             * Gets the polls choice persistence.
285             *
286             * @return the polls choice persistence
287             */
288            public PollsChoicePersistence getPollsChoicePersistence() {
289                    return pollsChoicePersistence;
290            }
291    
292            /**
293             * Sets the polls choice persistence.
294             *
295             * @param pollsChoicePersistence the polls choice persistence
296             */
297            public void setPollsChoicePersistence(
298                    PollsChoicePersistence pollsChoicePersistence) {
299                    this.pollsChoicePersistence = pollsChoicePersistence;
300            }
301    
302            /**
303             * Gets the polls choice finder.
304             *
305             * @return the polls choice finder
306             */
307            public PollsChoiceFinder getPollsChoiceFinder() {
308                    return pollsChoiceFinder;
309            }
310    
311            /**
312             * Sets the polls choice finder.
313             *
314             * @param pollsChoiceFinder the polls choice finder
315             */
316            public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
317                    this.pollsChoiceFinder = pollsChoiceFinder;
318            }
319    
320            /**
321             * Gets the polls question local service.
322             *
323             * @return the polls question local service
324             */
325            public PollsQuestionLocalService getPollsQuestionLocalService() {
326                    return pollsQuestionLocalService;
327            }
328    
329            /**
330             * Sets the polls question local service.
331             *
332             * @param pollsQuestionLocalService the polls question local service
333             */
334            public void setPollsQuestionLocalService(
335                    PollsQuestionLocalService pollsQuestionLocalService) {
336                    this.pollsQuestionLocalService = pollsQuestionLocalService;
337            }
338    
339            /**
340             * Gets the polls question remote service.
341             *
342             * @return the polls question remote service
343             */
344            public PollsQuestionService getPollsQuestionService() {
345                    return pollsQuestionService;
346            }
347    
348            /**
349             * Sets the polls question remote service.
350             *
351             * @param pollsQuestionService the polls question remote service
352             */
353            public void setPollsQuestionService(
354                    PollsQuestionService pollsQuestionService) {
355                    this.pollsQuestionService = pollsQuestionService;
356            }
357    
358            /**
359             * Gets the polls question persistence.
360             *
361             * @return the polls question persistence
362             */
363            public PollsQuestionPersistence getPollsQuestionPersistence() {
364                    return pollsQuestionPersistence;
365            }
366    
367            /**
368             * Sets the polls question persistence.
369             *
370             * @param pollsQuestionPersistence the polls question persistence
371             */
372            public void setPollsQuestionPersistence(
373                    PollsQuestionPersistence pollsQuestionPersistence) {
374                    this.pollsQuestionPersistence = pollsQuestionPersistence;
375            }
376    
377            /**
378             * Gets the polls vote local service.
379             *
380             * @return the polls vote local service
381             */
382            public PollsVoteLocalService getPollsVoteLocalService() {
383                    return pollsVoteLocalService;
384            }
385    
386            /**
387             * Sets the polls vote local service.
388             *
389             * @param pollsVoteLocalService the polls vote local service
390             */
391            public void setPollsVoteLocalService(
392                    PollsVoteLocalService pollsVoteLocalService) {
393                    this.pollsVoteLocalService = pollsVoteLocalService;
394            }
395    
396            /**
397             * Gets the polls vote remote service.
398             *
399             * @return the polls vote remote service
400             */
401            public PollsVoteService getPollsVoteService() {
402                    return pollsVoteService;
403            }
404    
405            /**
406             * Sets the polls vote remote service.
407             *
408             * @param pollsVoteService the polls vote remote service
409             */
410            public void setPollsVoteService(PollsVoteService pollsVoteService) {
411                    this.pollsVoteService = pollsVoteService;
412            }
413    
414            /**
415             * Gets the polls vote persistence.
416             *
417             * @return the polls vote persistence
418             */
419            public PollsVotePersistence getPollsVotePersistence() {
420                    return pollsVotePersistence;
421            }
422    
423            /**
424             * Sets the polls vote persistence.
425             *
426             * @param pollsVotePersistence the polls vote persistence
427             */
428            public void setPollsVotePersistence(
429                    PollsVotePersistence pollsVotePersistence) {
430                    this.pollsVotePersistence = pollsVotePersistence;
431            }
432    
433            /**
434             * Gets the counter local service.
435             *
436             * @return the counter local service
437             */
438            public CounterLocalService getCounterLocalService() {
439                    return counterLocalService;
440            }
441    
442            /**
443             * Sets the counter local service.
444             *
445             * @param counterLocalService the counter local service
446             */
447            public void setCounterLocalService(CounterLocalService counterLocalService) {
448                    this.counterLocalService = counterLocalService;
449            }
450    
451            /**
452             * Gets the resource local service.
453             *
454             * @return the resource local service
455             */
456            public ResourceLocalService getResourceLocalService() {
457                    return resourceLocalService;
458            }
459    
460            /**
461             * Sets the resource local service.
462             *
463             * @param resourceLocalService the resource local service
464             */
465            public void setResourceLocalService(
466                    ResourceLocalService resourceLocalService) {
467                    this.resourceLocalService = resourceLocalService;
468            }
469    
470            /**
471             * Gets the resource remote service.
472             *
473             * @return the resource remote service
474             */
475            public ResourceService getResourceService() {
476                    return resourceService;
477            }
478    
479            /**
480             * Sets the resource remote service.
481             *
482             * @param resourceService the resource remote service
483             */
484            public void setResourceService(ResourceService resourceService) {
485                    this.resourceService = resourceService;
486            }
487    
488            /**
489             * Gets the resource persistence.
490             *
491             * @return the resource persistence
492             */
493            public ResourcePersistence getResourcePersistence() {
494                    return resourcePersistence;
495            }
496    
497            /**
498             * Sets the resource persistence.
499             *
500             * @param resourcePersistence the resource persistence
501             */
502            public void setResourcePersistence(ResourcePersistence resourcePersistence) {
503                    this.resourcePersistence = resourcePersistence;
504            }
505    
506            /**
507             * Gets the resource finder.
508             *
509             * @return the resource finder
510             */
511            public ResourceFinder getResourceFinder() {
512                    return resourceFinder;
513            }
514    
515            /**
516             * Sets the resource finder.
517             *
518             * @param resourceFinder the resource finder
519             */
520            public void setResourceFinder(ResourceFinder resourceFinder) {
521                    this.resourceFinder = resourceFinder;
522            }
523    
524            /**
525             * Gets the user local service.
526             *
527             * @return the user local service
528             */
529            public UserLocalService getUserLocalService() {
530                    return userLocalService;
531            }
532    
533            /**
534             * Sets the user local service.
535             *
536             * @param userLocalService the user local service
537             */
538            public void setUserLocalService(UserLocalService userLocalService) {
539                    this.userLocalService = userLocalService;
540            }
541    
542            /**
543             * Gets the user remote service.
544             *
545             * @return the user remote service
546             */
547            public UserService getUserService() {
548                    return userService;
549            }
550    
551            /**
552             * Sets the user remote service.
553             *
554             * @param userService the user remote service
555             */
556            public void setUserService(UserService userService) {
557                    this.userService = userService;
558            }
559    
560            /**
561             * Gets the user persistence.
562             *
563             * @return the user persistence
564             */
565            public UserPersistence getUserPersistence() {
566                    return userPersistence;
567            }
568    
569            /**
570             * Sets the user persistence.
571             *
572             * @param userPersistence the user persistence
573             */
574            public void setUserPersistence(UserPersistence userPersistence) {
575                    this.userPersistence = userPersistence;
576            }
577    
578            /**
579             * Gets the user finder.
580             *
581             * @return the user finder
582             */
583            public UserFinder getUserFinder() {
584                    return userFinder;
585            }
586    
587            /**
588             * Sets the user finder.
589             *
590             * @param userFinder the user finder
591             */
592            public void setUserFinder(UserFinder userFinder) {
593                    this.userFinder = userFinder;
594            }
595    
596            /**
597             * Performs an SQL query.
598             *
599             * @param sql the sql query to perform
600             */
601            protected void runSQL(String sql) throws SystemException {
602                    try {
603                            DataSource dataSource = pollsQuestionPersistence.getDataSource();
604    
605                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
606                                            sql, new int[0]);
607    
608                            sqlUpdate.update();
609                    }
610                    catch (Exception e) {
611                            throw new SystemException(e);
612                    }
613            }
614    
615            @BeanReference(type = PollsChoiceLocalService.class)
616            protected PollsChoiceLocalService pollsChoiceLocalService;
617            @BeanReference(type = PollsChoicePersistence.class)
618            protected PollsChoicePersistence pollsChoicePersistence;
619            @BeanReference(type = PollsChoiceFinder.class)
620            protected PollsChoiceFinder pollsChoiceFinder;
621            @BeanReference(type = PollsQuestionLocalService.class)
622            protected PollsQuestionLocalService pollsQuestionLocalService;
623            @BeanReference(type = PollsQuestionService.class)
624            protected PollsQuestionService pollsQuestionService;
625            @BeanReference(type = PollsQuestionPersistence.class)
626            protected PollsQuestionPersistence pollsQuestionPersistence;
627            @BeanReference(type = PollsVoteLocalService.class)
628            protected PollsVoteLocalService pollsVoteLocalService;
629            @BeanReference(type = PollsVoteService.class)
630            protected PollsVoteService pollsVoteService;
631            @BeanReference(type = PollsVotePersistence.class)
632            protected PollsVotePersistence pollsVotePersistence;
633            @BeanReference(type = CounterLocalService.class)
634            protected CounterLocalService counterLocalService;
635            @BeanReference(type = ResourceLocalService.class)
636            protected ResourceLocalService resourceLocalService;
637            @BeanReference(type = ResourceService.class)
638            protected ResourceService resourceService;
639            @BeanReference(type = ResourcePersistence.class)
640            protected ResourcePersistence resourcePersistence;
641            @BeanReference(type = ResourceFinder.class)
642            protected ResourceFinder resourceFinder;
643            @BeanReference(type = UserLocalService.class)
644            protected UserLocalService userLocalService;
645            @BeanReference(type = UserService.class)
646            protected UserService userService;
647            @BeanReference(type = UserPersistence.class)
648            protected UserPersistence userPersistence;
649            @BeanReference(type = UserFinder.class)
650            protected UserFinder userFinder;
651    }