1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.polls.service.base;
24  
25  import com.liferay.counter.service.CounterLocalService;
26  import com.liferay.counter.service.CounterService;
27  
28  import com.liferay.portal.PortalException;
29  import com.liferay.portal.SystemException;
30  import com.liferay.portal.kernel.bean.InitializingBean;
31  import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
32  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
33  
34  import com.liferay.portlet.polls.model.PollsVote;
35  import com.liferay.portlet.polls.service.PollsChoiceLocalService;
36  import com.liferay.portlet.polls.service.PollsQuestionLocalService;
37  import com.liferay.portlet.polls.service.PollsQuestionService;
38  import com.liferay.portlet.polls.service.PollsVoteLocalService;
39  import com.liferay.portlet.polls.service.persistence.PollsChoiceFinder;
40  import com.liferay.portlet.polls.service.persistence.PollsChoicePersistence;
41  import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
42  import com.liferay.portlet.polls.service.persistence.PollsVotePersistence;
43  
44  import java.util.List;
45  
46  /**
47   * <a href="PollsVoteLocalServiceBaseImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * @author Brian Wing Shun Chan
50   *
51   */
52  public abstract class PollsVoteLocalServiceBaseImpl
53      implements PollsVoteLocalService, InitializingBean {
54      public PollsVote addPollsVote(PollsVote pollsVote)
55          throws SystemException {
56          pollsVote.setNew(true);
57  
58          return pollsVotePersistence.update(pollsVote, false);
59      }
60  
61      public void deletePollsVote(long voteId)
62          throws PortalException, SystemException {
63          pollsVotePersistence.remove(voteId);
64      }
65  
66      public void deletePollsVote(PollsVote pollsVote) throws SystemException {
67          pollsVotePersistence.remove(pollsVote);
68      }
69  
70      public List<Object> dynamicQuery(DynamicQuery dynamicQuery)
71          throws SystemException {
72          return pollsVotePersistence.findWithDynamicQuery(dynamicQuery);
73      }
74  
75      public List<Object> dynamicQuery(DynamicQuery dynamicQuery, int start,
76          int end) throws SystemException {
77          return pollsVotePersistence.findWithDynamicQuery(dynamicQuery, start,
78              end);
79      }
80  
81      public PollsVote getPollsVote(long voteId)
82          throws PortalException, SystemException {
83          return pollsVotePersistence.findByPrimaryKey(voteId);
84      }
85  
86      public List<PollsVote> getPollsVotes(int start, int end)
87          throws SystemException {
88          return pollsVotePersistence.findAll(start, end);
89      }
90  
91      public int getPollsVotesCount() throws SystemException {
92          return pollsVotePersistence.countAll();
93      }
94  
95      public PollsVote updatePollsVote(PollsVote pollsVote)
96          throws SystemException {
97          pollsVote.setNew(false);
98  
99          return pollsVotePersistence.update(pollsVote, true);
100     }
101 
102     public PollsChoiceLocalService getPollsChoiceLocalService() {
103         return pollsChoiceLocalService;
104     }
105 
106     public void setPollsChoiceLocalService(
107         PollsChoiceLocalService pollsChoiceLocalService) {
108         this.pollsChoiceLocalService = pollsChoiceLocalService;
109     }
110 
111     public PollsChoicePersistence getPollsChoicePersistence() {
112         return pollsChoicePersistence;
113     }
114 
115     public void setPollsChoicePersistence(
116         PollsChoicePersistence pollsChoicePersistence) {
117         this.pollsChoicePersistence = pollsChoicePersistence;
118     }
119 
120     public PollsChoiceFinder getPollsChoiceFinder() {
121         return pollsChoiceFinder;
122     }
123 
124     public void setPollsChoiceFinder(PollsChoiceFinder pollsChoiceFinder) {
125         this.pollsChoiceFinder = pollsChoiceFinder;
126     }
127 
128     public PollsQuestionLocalService getPollsQuestionLocalService() {
129         return pollsQuestionLocalService;
130     }
131 
132     public void setPollsQuestionLocalService(
133         PollsQuestionLocalService pollsQuestionLocalService) {
134         this.pollsQuestionLocalService = pollsQuestionLocalService;
135     }
136 
137     public PollsQuestionService getPollsQuestionService() {
138         return pollsQuestionService;
139     }
140 
141     public void setPollsQuestionService(
142         PollsQuestionService pollsQuestionService) {
143         this.pollsQuestionService = pollsQuestionService;
144     }
145 
146     public PollsQuestionPersistence getPollsQuestionPersistence() {
147         return pollsQuestionPersistence;
148     }
149 
150     public void setPollsQuestionPersistence(
151         PollsQuestionPersistence pollsQuestionPersistence) {
152         this.pollsQuestionPersistence = pollsQuestionPersistence;
153     }
154 
155     public PollsVotePersistence getPollsVotePersistence() {
156         return pollsVotePersistence;
157     }
158 
159     public void setPollsVotePersistence(
160         PollsVotePersistence pollsVotePersistence) {
161         this.pollsVotePersistence = pollsVotePersistence;
162     }
163 
164     public CounterLocalService getCounterLocalService() {
165         return counterLocalService;
166     }
167 
168     public void setCounterLocalService(CounterLocalService counterLocalService) {
169         this.counterLocalService = counterLocalService;
170     }
171 
172     public CounterService getCounterService() {
173         return counterService;
174     }
175 
176     public void setCounterService(CounterService counterService) {
177         this.counterService = counterService;
178     }
179 
180     public void afterPropertiesSet() {
181         if (pollsChoiceLocalService == null) {
182             pollsChoiceLocalService = (PollsChoiceLocalService)PortalBeanLocatorUtil.locate(PollsChoiceLocalService.class.getName() +
183                     ".impl");
184         }
185 
186         if (pollsChoicePersistence == null) {
187             pollsChoicePersistence = (PollsChoicePersistence)PortalBeanLocatorUtil.locate(PollsChoicePersistence.class.getName() +
188                     ".impl");
189         }
190 
191         if (pollsChoiceFinder == null) {
192             pollsChoiceFinder = (PollsChoiceFinder)PortalBeanLocatorUtil.locate(PollsChoiceFinder.class.getName() +
193                     ".impl");
194         }
195 
196         if (pollsQuestionLocalService == null) {
197             pollsQuestionLocalService = (PollsQuestionLocalService)PortalBeanLocatorUtil.locate(PollsQuestionLocalService.class.getName() +
198                     ".impl");
199         }
200 
201         if (pollsQuestionService == null) {
202             pollsQuestionService = (PollsQuestionService)PortalBeanLocatorUtil.locate(PollsQuestionService.class.getName() +
203                     ".impl");
204         }
205 
206         if (pollsQuestionPersistence == null) {
207             pollsQuestionPersistence = (PollsQuestionPersistence)PortalBeanLocatorUtil.locate(PollsQuestionPersistence.class.getName() +
208                     ".impl");
209         }
210 
211         if (pollsVotePersistence == null) {
212             pollsVotePersistence = (PollsVotePersistence)PortalBeanLocatorUtil.locate(PollsVotePersistence.class.getName() +
213                     ".impl");
214         }
215 
216         if (counterLocalService == null) {
217             counterLocalService = (CounterLocalService)PortalBeanLocatorUtil.locate(CounterLocalService.class.getName() +
218                     ".impl");
219         }
220 
221         if (counterService == null) {
222             counterService = (CounterService)PortalBeanLocatorUtil.locate(CounterService.class.getName() +
223                     ".impl");
224         }
225     }
226 
227     protected PollsChoiceLocalService pollsChoiceLocalService;
228     protected PollsChoicePersistence pollsChoicePersistence;
229     protected PollsChoiceFinder pollsChoiceFinder;
230     protected PollsQuestionLocalService pollsQuestionLocalService;
231     protected PollsQuestionService pollsQuestionService;
232     protected PollsQuestionPersistence pollsQuestionPersistence;
233     protected PollsVotePersistence pollsVotePersistence;
234     protected CounterLocalService counterLocalService;
235     protected CounterService counterService;
236 }