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     * @author Brian Wing Shun Chan
052     */
053    public abstract class PollsQuestionLocalServiceBaseImpl
054            implements PollsQuestionLocalService {
055            public PollsQuestion addPollsQuestion(PollsQuestion pollsQuestion)
056                    throws SystemException {
057                    pollsQuestion.setNew(true);
058    
059                    return pollsQuestionPersistence.update(pollsQuestion, false);
060            }
061    
062            public PollsQuestion createPollsQuestion(long questionId) {
063                    return pollsQuestionPersistence.create(questionId);
064            }
065    
066            public void deletePollsQuestion(long questionId)
067                    throws PortalException, SystemException {
068                    pollsQuestionPersistence.remove(questionId);
069            }
070    
071            public void deletePollsQuestion(PollsQuestion pollsQuestion)
072                    throws SystemException {
073                    pollsQuestionPersistence.remove(pollsQuestion);
074            }
075    
076            @SuppressWarnings("unchecked")
077            public List dynamicQuery(DynamicQuery dynamicQuery)
078                    throws SystemException {
079                    return pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery);
080            }
081    
082            @SuppressWarnings("unchecked")
083            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
084                    throws SystemException {
085                    return pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery,
086                            start, end);
087            }
088    
089            @SuppressWarnings("unchecked")
090            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
091                    OrderByComparator orderByComparator) throws SystemException {
092                    return pollsQuestionPersistence.findWithDynamicQuery(dynamicQuery,
093                            start, end, orderByComparator);
094            }
095    
096            public long dynamicQueryCount(DynamicQuery dynamicQuery)
097                    throws SystemException {
098                    return pollsQuestionPersistence.countWithDynamicQuery(dynamicQuery);
099            }
100    
101            public PollsQuestion getPollsQuestion(long questionId)
102                    throws PortalException, SystemException {
103                    return pollsQuestionPersistence.findByPrimaryKey(questionId);
104            }
105    
106            public PollsQuestion getPollsQuestionByUuidAndGroupId(String uuid,
107                    long groupId) throws PortalException, SystemException {
108                    return pollsQuestionPersistence.findByUUID_G(uuid, groupId);
109            }
110    
111            public List<PollsQuestion> getPollsQuestions(int start, int end)
112                    throws SystemException {
113                    return pollsQuestionPersistence.findAll(start, end);
114            }
115    
116            public int getPollsQuestionsCount() throws SystemException {
117                    return pollsQuestionPersistence.countAll();
118            }
119    
120            public PollsQuestion updatePollsQuestion(PollsQuestion pollsQuestion)
121                    throws SystemException {
122                    pollsQuestion.setNew(false);
123    
124                    return pollsQuestionPersistence.update(pollsQuestion, true);
125            }
126    
127            public PollsQuestion updatePollsQuestion(PollsQuestion pollsQuestion,
128                    boolean merge) throws SystemException {
129                    pollsQuestion.setNew(false);
130    
131                    return pollsQuestionPersistence.update(pollsQuestion, merge);
132            }
133    
134            public PollsChoiceLocalService getPollsChoiceLocalService() {
135                    return pollsChoiceLocalService;
136            }
137    
138            public void setPollsChoiceLocalService(
139                    PollsChoiceLocalService pollsChoiceLocalService) {
140                    this.pollsChoiceLocalService = pollsChoiceLocalService;
141            }
142    
143            public PollsChoicePersistence getPollsChoicePersistence() {
144                    return pollsChoicePersistence;
145            }
146    
147            public void setPollsChoicePersistence(
148                    PollsChoicePersistence pollsChoicePersistence) {
149                    this.pollsChoicePersistence = pollsChoicePersistence;
150            }
151    
152            public PollsChoiceFinder getPollsChoiceFinder() {
153                    return pollsChoiceFinder;
154            }
155    
156            public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
157                    this.pollsChoiceFinder = pollsChoiceFinder;
158            }
159    
160            public PollsQuestionLocalService getPollsQuestionLocalService() {
161                    return pollsQuestionLocalService;
162            }
163    
164            public void setPollsQuestionLocalService(
165                    PollsQuestionLocalService pollsQuestionLocalService) {
166                    this.pollsQuestionLocalService = pollsQuestionLocalService;
167            }
168    
169            public PollsQuestionService getPollsQuestionService() {
170                    return pollsQuestionService;
171            }
172    
173            public void setPollsQuestionService(
174                    PollsQuestionService pollsQuestionService) {
175                    this.pollsQuestionService = pollsQuestionService;
176            }
177    
178            public PollsQuestionPersistence getPollsQuestionPersistence() {
179                    return pollsQuestionPersistence;
180            }
181    
182            public void setPollsQuestionPersistence(
183                    PollsQuestionPersistence pollsQuestionPersistence) {
184                    this.pollsQuestionPersistence = pollsQuestionPersistence;
185            }
186    
187            public PollsVoteLocalService getPollsVoteLocalService() {
188                    return pollsVoteLocalService;
189            }
190    
191            public void setPollsVoteLocalService(
192                    PollsVoteLocalService pollsVoteLocalService) {
193                    this.pollsVoteLocalService = pollsVoteLocalService;
194            }
195    
196            public PollsVoteService getPollsVoteService() {
197                    return pollsVoteService;
198            }
199    
200            public void setPollsVoteService(PollsVoteService pollsVoteService) {
201                    this.pollsVoteService = pollsVoteService;
202            }
203    
204            public PollsVotePersistence getPollsVotePersistence() {
205                    return pollsVotePersistence;
206            }
207    
208            public void setPollsVotePersistence(
209                    PollsVotePersistence pollsVotePersistence) {
210                    this.pollsVotePersistence = pollsVotePersistence;
211            }
212    
213            public CounterLocalService getCounterLocalService() {
214                    return counterLocalService;
215            }
216    
217            public void setCounterLocalService(CounterLocalService counterLocalService) {
218                    this.counterLocalService = counterLocalService;
219            }
220    
221            public ResourceLocalService getResourceLocalService() {
222                    return resourceLocalService;
223            }
224    
225            public void setResourceLocalService(
226                    ResourceLocalService resourceLocalService) {
227                    this.resourceLocalService = resourceLocalService;
228            }
229    
230            public ResourceService getResourceService() {
231                    return resourceService;
232            }
233    
234            public void setResourceService(ResourceService resourceService) {
235                    this.resourceService = resourceService;
236            }
237    
238            public ResourcePersistence getResourcePersistence() {
239                    return resourcePersistence;
240            }
241    
242            public void setResourcePersistence(ResourcePersistence resourcePersistence) {
243                    this.resourcePersistence = resourcePersistence;
244            }
245    
246            public ResourceFinder getResourceFinder() {
247                    return resourceFinder;
248            }
249    
250            public void setResourceFinder(ResourceFinder resourceFinder) {
251                    this.resourceFinder = resourceFinder;
252            }
253    
254            public UserLocalService getUserLocalService() {
255                    return userLocalService;
256            }
257    
258            public void setUserLocalService(UserLocalService userLocalService) {
259                    this.userLocalService = userLocalService;
260            }
261    
262            public UserService getUserService() {
263                    return userService;
264            }
265    
266            public void setUserService(UserService userService) {
267                    this.userService = userService;
268            }
269    
270            public UserPersistence getUserPersistence() {
271                    return userPersistence;
272            }
273    
274            public void setUserPersistence(UserPersistence userPersistence) {
275                    this.userPersistence = userPersistence;
276            }
277    
278            public UserFinder getUserFinder() {
279                    return userFinder;
280            }
281    
282            public void setUserFinder(UserFinder userFinder) {
283                    this.userFinder = userFinder;
284            }
285    
286            protected void runSQL(String sql) throws SystemException {
287                    try {
288                            DataSource dataSource = pollsQuestionPersistence.getDataSource();
289    
290                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
291                                            sql, new int[0]);
292    
293                            sqlUpdate.update();
294                    }
295                    catch (Exception e) {
296                            throw new SystemException(e);
297                    }
298            }
299    
300            @BeanReference(type = PollsChoiceLocalService.class)
301            protected PollsChoiceLocalService pollsChoiceLocalService;
302            @BeanReference(type = PollsChoicePersistence.class)
303            protected PollsChoicePersistence pollsChoicePersistence;
304            @BeanReference(type = PollsChoiceFinder.class)
305            protected PollsChoiceFinder pollsChoiceFinder;
306            @BeanReference(type = PollsQuestionLocalService.class)
307            protected PollsQuestionLocalService pollsQuestionLocalService;
308            @BeanReference(type = PollsQuestionService.class)
309            protected PollsQuestionService pollsQuestionService;
310            @BeanReference(type = PollsQuestionPersistence.class)
311            protected PollsQuestionPersistence pollsQuestionPersistence;
312            @BeanReference(type = PollsVoteLocalService.class)
313            protected PollsVoteLocalService pollsVoteLocalService;
314            @BeanReference(type = PollsVoteService.class)
315            protected PollsVoteService pollsVoteService;
316            @BeanReference(type = PollsVotePersistence.class)
317            protected PollsVotePersistence pollsVotePersistence;
318            @BeanReference(type = CounterLocalService.class)
319            protected CounterLocalService counterLocalService;
320            @BeanReference(type = ResourceLocalService.class)
321            protected ResourceLocalService resourceLocalService;
322            @BeanReference(type = ResourceService.class)
323            protected ResourceService resourceService;
324            @BeanReference(type = ResourcePersistence.class)
325            protected ResourcePersistence resourcePersistence;
326            @BeanReference(type = ResourceFinder.class)
327            protected ResourceFinder resourceFinder;
328            @BeanReference(type = UserLocalService.class)
329            protected UserLocalService userLocalService;
330            @BeanReference(type = UserService.class)
331            protected UserService userService;
332            @BeanReference(type = UserPersistence.class)
333            protected UserPersistence userPersistence;
334            @BeanReference(type = UserFinder.class)
335            protected UserFinder userFinder;
336    }