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