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