1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.ratings.service.base;
16  
17  import com.liferay.counter.service.CounterLocalService;
18  
19  import com.liferay.portal.kernel.annotation.BeanReference;
20  import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
21  import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
22  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
23  import com.liferay.portal.kernel.exception.PortalException;
24  import com.liferay.portal.kernel.exception.SystemException;
25  import com.liferay.portal.kernel.util.OrderByComparator;
26  import com.liferay.portal.service.ResourceLocalService;
27  import com.liferay.portal.service.ResourceService;
28  import com.liferay.portal.service.UserLocalService;
29  import com.liferay.portal.service.UserService;
30  import com.liferay.portal.service.persistence.ResourceFinder;
31  import com.liferay.portal.service.persistence.ResourcePersistence;
32  import com.liferay.portal.service.persistence.UserFinder;
33  import com.liferay.portal.service.persistence.UserPersistence;
34  
35  import com.liferay.portlet.ratings.model.RatingsStats;
36  import com.liferay.portlet.ratings.service.RatingsEntryLocalService;
37  import com.liferay.portlet.ratings.service.RatingsEntryService;
38  import com.liferay.portlet.ratings.service.RatingsStatsLocalService;
39  import com.liferay.portlet.ratings.service.persistence.RatingsEntryFinder;
40  import com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence;
41  import com.liferay.portlet.ratings.service.persistence.RatingsStatsFinder;
42  import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
43  
44  import java.util.List;
45  
46  import javax.sql.DataSource;
47  
48  /**
49   * <a href="RatingsStatsLocalServiceBaseImpl.java.html"><b><i>View Source</i>
50   * </b></a>
51   *
52   * @author Brian Wing Shun Chan
53   */
54  public abstract class RatingsStatsLocalServiceBaseImpl
55      implements RatingsStatsLocalService {
56      public RatingsStats addRatingsStats(RatingsStats ratingsStats)
57          throws SystemException {
58          ratingsStats.setNew(true);
59  
60          return ratingsStatsPersistence.update(ratingsStats, false);
61      }
62  
63      public RatingsStats createRatingsStats(long statsId) {
64          return ratingsStatsPersistence.create(statsId);
65      }
66  
67      public void deleteRatingsStats(long statsId)
68          throws PortalException, SystemException {
69          ratingsStatsPersistence.remove(statsId);
70      }
71  
72      public void deleteRatingsStats(RatingsStats ratingsStats)
73          throws SystemException {
74          ratingsStatsPersistence.remove(ratingsStats);
75      }
76  
77      @SuppressWarnings("unchecked")
78      public List dynamicQuery(DynamicQuery dynamicQuery)
79          throws SystemException {
80          return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery);
81      }
82  
83      @SuppressWarnings("unchecked")
84      public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
85          throws SystemException {
86          return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery,
87              start, end);
88      }
89  
90      @SuppressWarnings("unchecked")
91      public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
92          OrderByComparator orderByComparator) throws SystemException {
93          return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery,
94              start, end, orderByComparator);
95      }
96  
97      public long dynamicQueryCount(DynamicQuery dynamicQuery)
98          throws SystemException {
99          return ratingsStatsPersistence.countWithDynamicQuery(dynamicQuery);
100     }
101 
102     public RatingsStats getRatingsStats(long statsId)
103         throws PortalException, SystemException {
104         return ratingsStatsPersistence.findByPrimaryKey(statsId);
105     }
106 
107     public List<RatingsStats> getRatingsStatses(int start, int end)
108         throws SystemException {
109         return ratingsStatsPersistence.findAll(start, end);
110     }
111 
112     public int getRatingsStatsesCount() throws SystemException {
113         return ratingsStatsPersistence.countAll();
114     }
115 
116     public RatingsStats updateRatingsStats(RatingsStats ratingsStats)
117         throws SystemException {
118         ratingsStats.setNew(false);
119 
120         return ratingsStatsPersistence.update(ratingsStats, true);
121     }
122 
123     public RatingsStats updateRatingsStats(RatingsStats ratingsStats,
124         boolean merge) throws SystemException {
125         ratingsStats.setNew(false);
126 
127         return ratingsStatsPersistence.update(ratingsStats, merge);
128     }
129 
130     public RatingsEntryLocalService getRatingsEntryLocalService() {
131         return ratingsEntryLocalService;
132     }
133 
134     public void setRatingsEntryLocalService(
135         RatingsEntryLocalService ratingsEntryLocalService) {
136         this.ratingsEntryLocalService = ratingsEntryLocalService;
137     }
138 
139     public RatingsEntryService getRatingsEntryService() {
140         return ratingsEntryService;
141     }
142 
143     public void setRatingsEntryService(RatingsEntryService ratingsEntryService) {
144         this.ratingsEntryService = ratingsEntryService;
145     }
146 
147     public RatingsEntryPersistence getRatingsEntryPersistence() {
148         return ratingsEntryPersistence;
149     }
150 
151     public void setRatingsEntryPersistence(
152         RatingsEntryPersistence ratingsEntryPersistence) {
153         this.ratingsEntryPersistence = ratingsEntryPersistence;
154     }
155 
156     public RatingsEntryFinder getRatingsEntryFinder() {
157         return ratingsEntryFinder;
158     }
159 
160     public void setRatingsEntryFinder(RatingsEntryFinder ratingsEntryFinder) {
161         this.ratingsEntryFinder = ratingsEntryFinder;
162     }
163 
164     public RatingsStatsLocalService getRatingsStatsLocalService() {
165         return ratingsStatsLocalService;
166     }
167 
168     public void setRatingsStatsLocalService(
169         RatingsStatsLocalService ratingsStatsLocalService) {
170         this.ratingsStatsLocalService = ratingsStatsLocalService;
171     }
172 
173     public RatingsStatsPersistence getRatingsStatsPersistence() {
174         return ratingsStatsPersistence;
175     }
176 
177     public void setRatingsStatsPersistence(
178         RatingsStatsPersistence ratingsStatsPersistence) {
179         this.ratingsStatsPersistence = ratingsStatsPersistence;
180     }
181 
182     public RatingsStatsFinder getRatingsStatsFinder() {
183         return ratingsStatsFinder;
184     }
185 
186     public void setRatingsStatsFinder(RatingsStatsFinder ratingsStatsFinder) {
187         this.ratingsStatsFinder = ratingsStatsFinder;
188     }
189 
190     public CounterLocalService getCounterLocalService() {
191         return counterLocalService;
192     }
193 
194     public void setCounterLocalService(CounterLocalService counterLocalService) {
195         this.counterLocalService = counterLocalService;
196     }
197 
198     public ResourceLocalService getResourceLocalService() {
199         return resourceLocalService;
200     }
201 
202     public void setResourceLocalService(
203         ResourceLocalService resourceLocalService) {
204         this.resourceLocalService = resourceLocalService;
205     }
206 
207     public ResourceService getResourceService() {
208         return resourceService;
209     }
210 
211     public void setResourceService(ResourceService resourceService) {
212         this.resourceService = resourceService;
213     }
214 
215     public ResourcePersistence getResourcePersistence() {
216         return resourcePersistence;
217     }
218 
219     public void setResourcePersistence(ResourcePersistence resourcePersistence) {
220         this.resourcePersistence = resourcePersistence;
221     }
222 
223     public ResourceFinder getResourceFinder() {
224         return resourceFinder;
225     }
226 
227     public void setResourceFinder(ResourceFinder resourceFinder) {
228         this.resourceFinder = resourceFinder;
229     }
230 
231     public UserLocalService getUserLocalService() {
232         return userLocalService;
233     }
234 
235     public void setUserLocalService(UserLocalService userLocalService) {
236         this.userLocalService = userLocalService;
237     }
238 
239     public UserService getUserService() {
240         return userService;
241     }
242 
243     public void setUserService(UserService userService) {
244         this.userService = userService;
245     }
246 
247     public UserPersistence getUserPersistence() {
248         return userPersistence;
249     }
250 
251     public void setUserPersistence(UserPersistence userPersistence) {
252         this.userPersistence = userPersistence;
253     }
254 
255     public UserFinder getUserFinder() {
256         return userFinder;
257     }
258 
259     public void setUserFinder(UserFinder userFinder) {
260         this.userFinder = userFinder;
261     }
262 
263     protected void runSQL(String sql) throws SystemException {
264         try {
265             DataSource dataSource = ratingsStatsPersistence.getDataSource();
266 
267             SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
268                     sql, new int[0]);
269 
270             sqlUpdate.update();
271         }
272         catch (Exception e) {
273             throw new SystemException(e);
274         }
275     }
276 
277     @BeanReference(type = RatingsEntryLocalService.class)
278     protected RatingsEntryLocalService ratingsEntryLocalService;
279     @BeanReference(type = RatingsEntryService.class)
280     protected RatingsEntryService ratingsEntryService;
281     @BeanReference(type = RatingsEntryPersistence.class)
282     protected RatingsEntryPersistence ratingsEntryPersistence;
283     @BeanReference(type = RatingsEntryFinder.class)
284     protected RatingsEntryFinder ratingsEntryFinder;
285     @BeanReference(type = RatingsStatsLocalService.class)
286     protected RatingsStatsLocalService ratingsStatsLocalService;
287     @BeanReference(type = RatingsStatsPersistence.class)
288     protected RatingsStatsPersistence ratingsStatsPersistence;
289     @BeanReference(type = RatingsStatsFinder.class)
290     protected RatingsStatsFinder ratingsStatsFinder;
291     @BeanReference(type = CounterLocalService.class)
292     protected CounterLocalService counterLocalService;
293     @BeanReference(type = ResourceLocalService.class)
294     protected ResourceLocalService resourceLocalService;
295     @BeanReference(type = ResourceService.class)
296     protected ResourceService resourceService;
297     @BeanReference(type = ResourcePersistence.class)
298     protected ResourcePersistence resourcePersistence;
299     @BeanReference(type = ResourceFinder.class)
300     protected ResourceFinder resourceFinder;
301     @BeanReference(type = UserLocalService.class)
302     protected UserLocalService userLocalService;
303     @BeanReference(type = UserService.class)
304     protected UserService userService;
305     @BeanReference(type = UserPersistence.class)
306     protected UserPersistence userPersistence;
307     @BeanReference(type = UserFinder.class)
308     protected UserFinder userFinder;
309 }