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.CounterLocalServiceFactory;
27  import com.liferay.counter.service.CounterService;
28  import com.liferay.counter.service.CounterServiceFactory;
29  
30  import com.liferay.portal.SystemException;
31  import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
32  
33  import com.liferay.portlet.polls.model.PollsVote;
34  import com.liferay.portlet.polls.model.impl.PollsVoteImpl;
35  import com.liferay.portlet.polls.service.PollsChoiceLocalService;
36  import com.liferay.portlet.polls.service.PollsChoiceLocalServiceFactory;
37  import com.liferay.portlet.polls.service.PollsQuestionLocalService;
38  import com.liferay.portlet.polls.service.PollsQuestionLocalServiceFactory;
39  import com.liferay.portlet.polls.service.PollsQuestionService;
40  import com.liferay.portlet.polls.service.PollsQuestionServiceFactory;
41  import com.liferay.portlet.polls.service.PollsVoteLocalService;
42  import com.liferay.portlet.polls.service.persistence.PollsChoiceFinder;
43  import com.liferay.portlet.polls.service.persistence.PollsChoiceFinderUtil;
44  import com.liferay.portlet.polls.service.persistence.PollsChoicePersistence;
45  import com.liferay.portlet.polls.service.persistence.PollsChoiceUtil;
46  import com.liferay.portlet.polls.service.persistence.PollsQuestionPersistence;
47  import com.liferay.portlet.polls.service.persistence.PollsQuestionUtil;
48  import com.liferay.portlet.polls.service.persistence.PollsVotePersistence;
49  import com.liferay.portlet.polls.service.persistence.PollsVoteUtil;
50  
51  import org.springframework.beans.factory.InitializingBean;
52  
53  import java.util.List;
54  
55  /**
56   * <a href="PollsVoteLocalServiceBaseImpl.java.html"><b><i>View Source</i></b></a>
57   *
58   * @author Brian Wing Shun Chan
59   *
60   */
61  public abstract class PollsVoteLocalServiceBaseImpl
62      implements PollsVoteLocalService, InitializingBean {
63      public PollsVote addPollsVote(PollsVote model) throws SystemException {
64          PollsVote pollsVote = new PollsVoteImpl();
65  
66          pollsVote.setNew(true);
67  
68          pollsVote.setVoteId(model.getVoteId());
69          pollsVote.setUserId(model.getUserId());
70          pollsVote.setQuestionId(model.getQuestionId());
71          pollsVote.setChoiceId(model.getChoiceId());
72          pollsVote.setVoteDate(model.getVoteDate());
73  
74          return pollsVotePersistence.update(pollsVote);
75      }
76  
77      public List dynamicQuery(DynamicQueryInitializer queryInitializer)
78          throws SystemException {
79          return pollsVotePersistence.findWithDynamicQuery(queryInitializer);
80      }
81  
82      public List dynamicQuery(DynamicQueryInitializer queryInitializer,
83          int begin, int end) throws SystemException {
84          return pollsVotePersistence.findWithDynamicQuery(queryInitializer,
85              begin, end);
86      }
87  
88      public PollsVote updatePollsVote(PollsVote model) throws SystemException {
89          PollsVote pollsVote = new PollsVoteImpl();
90  
91          pollsVote.setNew(false);
92  
93          pollsVote.setVoteId(model.getVoteId());
94          pollsVote.setUserId(model.getUserId());
95          pollsVote.setQuestionId(model.getQuestionId());
96          pollsVote.setChoiceId(model.getChoiceId());
97          pollsVote.setVoteDate(model.getVoteDate());
98  
99          return pollsVotePersistence.update(pollsVote);
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 = PollsChoiceLocalServiceFactory.getImpl();
183         }
184 
185         if (pollsChoicePersistence == null) {
186             pollsChoicePersistence = PollsChoiceUtil.getPersistence();
187         }
188 
189         if (pollsChoiceFinder == null) {
190             pollsChoiceFinder = PollsChoiceFinderUtil.getFinder();
191         }
192 
193         if (pollsQuestionLocalService == null) {
194             pollsQuestionLocalService = PollsQuestionLocalServiceFactory.getImpl();
195         }
196 
197         if (pollsQuestionService == null) {
198             pollsQuestionService = PollsQuestionServiceFactory.getImpl();
199         }
200 
201         if (pollsQuestionPersistence == null) {
202             pollsQuestionPersistence = PollsQuestionUtil.getPersistence();
203         }
204 
205         if (pollsVotePersistence == null) {
206             pollsVotePersistence = PollsVoteUtil.getPersistence();
207         }
208 
209         if (counterLocalService == null) {
210             counterLocalService = CounterLocalServiceFactory.getImpl();
211         }
212 
213         if (counterService == null) {
214             counterService = CounterServiceFactory.getImpl();
215         }
216     }
217 
218     protected PollsChoiceLocalService pollsChoiceLocalService;
219     protected PollsChoicePersistence pollsChoicePersistence;
220     protected PollsChoiceFinder pollsChoiceFinder;
221     protected PollsQuestionLocalService pollsQuestionLocalService;
222     protected PollsQuestionService pollsQuestionService;
223     protected PollsQuestionPersistence pollsQuestionPersistence;
224     protected PollsVotePersistence pollsVotePersistence;
225     protected CounterLocalService counterLocalService;
226     protected CounterService counterService;
227 }