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.ratings.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.ratings.model.RatingsStats;
34  import com.liferay.portlet.ratings.model.impl.RatingsStatsImpl;
35  import com.liferay.portlet.ratings.service.RatingsEntryLocalService;
36  import com.liferay.portlet.ratings.service.RatingsEntryLocalServiceFactory;
37  import com.liferay.portlet.ratings.service.RatingsEntryService;
38  import com.liferay.portlet.ratings.service.RatingsEntryServiceFactory;
39  import com.liferay.portlet.ratings.service.RatingsStatsLocalService;
40  import com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence;
41  import com.liferay.portlet.ratings.service.persistence.RatingsEntryUtil;
42  import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
43  import com.liferay.portlet.ratings.service.persistence.RatingsStatsUtil;
44  
45  import org.springframework.beans.factory.InitializingBean;
46  
47  import java.util.List;
48  
49  /**
50   * <a href="RatingsStatsLocalServiceBaseImpl.java.html"><b><i>View Source</i></b></a>
51   *
52   * @author Brian Wing Shun Chan
53   *
54   */
55  public abstract class RatingsStatsLocalServiceBaseImpl
56      implements RatingsStatsLocalService, InitializingBean {
57      public RatingsStats addRatingsStats(RatingsStats model)
58          throws SystemException {
59          RatingsStats ratingsStats = new RatingsStatsImpl();
60  
61          ratingsStats.setNew(true);
62  
63          ratingsStats.setStatsId(model.getStatsId());
64          ratingsStats.setClassNameId(model.getClassNameId());
65          ratingsStats.setClassPK(model.getClassPK());
66          ratingsStats.setTotalEntries(model.getTotalEntries());
67          ratingsStats.setTotalScore(model.getTotalScore());
68          ratingsStats.setAverageScore(model.getAverageScore());
69  
70          return ratingsStatsPersistence.update(ratingsStats);
71      }
72  
73      public List dynamicQuery(DynamicQueryInitializer queryInitializer)
74          throws SystemException {
75          return ratingsStatsPersistence.findWithDynamicQuery(queryInitializer);
76      }
77  
78      public List dynamicQuery(DynamicQueryInitializer queryInitializer,
79          int begin, int end) throws SystemException {
80          return ratingsStatsPersistence.findWithDynamicQuery(queryInitializer,
81              begin, end);
82      }
83  
84      public RatingsStats updateRatingsStats(RatingsStats model)
85          throws SystemException {
86          RatingsStats ratingsStats = new RatingsStatsImpl();
87  
88          ratingsStats.setNew(false);
89  
90          ratingsStats.setStatsId(model.getStatsId());
91          ratingsStats.setClassNameId(model.getClassNameId());
92          ratingsStats.setClassPK(model.getClassPK());
93          ratingsStats.setTotalEntries(model.getTotalEntries());
94          ratingsStats.setTotalScore(model.getTotalScore());
95          ratingsStats.setAverageScore(model.getAverageScore());
96  
97          return ratingsStatsPersistence.update(ratingsStats);
98      }
99  
100     public RatingsEntryLocalService getRatingsEntryLocalService() {
101         return ratingsEntryLocalService;
102     }
103 
104     public void setRatingsEntryLocalService(
105         RatingsEntryLocalService ratingsEntryLocalService) {
106         this.ratingsEntryLocalService = ratingsEntryLocalService;
107     }
108 
109     public RatingsEntryService getRatingsEntryService() {
110         return ratingsEntryService;
111     }
112 
113     public void setRatingsEntryService(RatingsEntryService ratingsEntryService) {
114         this.ratingsEntryService = ratingsEntryService;
115     }
116 
117     public RatingsEntryPersistence getRatingsEntryPersistence() {
118         return ratingsEntryPersistence;
119     }
120 
121     public void setRatingsEntryPersistence(
122         RatingsEntryPersistence ratingsEntryPersistence) {
123         this.ratingsEntryPersistence = ratingsEntryPersistence;
124     }
125 
126     public RatingsStatsPersistence getRatingsStatsPersistence() {
127         return ratingsStatsPersistence;
128     }
129 
130     public void setRatingsStatsPersistence(
131         RatingsStatsPersistence ratingsStatsPersistence) {
132         this.ratingsStatsPersistence = ratingsStatsPersistence;
133     }
134 
135     public CounterLocalService getCounterLocalService() {
136         return counterLocalService;
137     }
138 
139     public void setCounterLocalService(CounterLocalService counterLocalService) {
140         this.counterLocalService = counterLocalService;
141     }
142 
143     public CounterService getCounterService() {
144         return counterService;
145     }
146 
147     public void setCounterService(CounterService counterService) {
148         this.counterService = counterService;
149     }
150 
151     public void afterPropertiesSet() {
152         if (ratingsEntryLocalService == null) {
153             ratingsEntryLocalService = RatingsEntryLocalServiceFactory.getImpl();
154         }
155 
156         if (ratingsEntryService == null) {
157             ratingsEntryService = RatingsEntryServiceFactory.getImpl();
158         }
159 
160         if (ratingsEntryPersistence == null) {
161             ratingsEntryPersistence = RatingsEntryUtil.getPersistence();
162         }
163 
164         if (ratingsStatsPersistence == null) {
165             ratingsStatsPersistence = RatingsStatsUtil.getPersistence();
166         }
167 
168         if (counterLocalService == null) {
169             counterLocalService = CounterLocalServiceFactory.getImpl();
170         }
171 
172         if (counterService == null) {
173             counterService = CounterServiceFactory.getImpl();
174         }
175     }
176 
177     protected RatingsEntryLocalService ratingsEntryLocalService;
178     protected RatingsEntryService ratingsEntryService;
179     protected RatingsEntryPersistence ratingsEntryPersistence;
180     protected RatingsStatsPersistence ratingsStatsPersistence;
181     protected CounterLocalService counterLocalService;
182     protected CounterService counterService;
183 }