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          return ratingsStatsPersistence.update(model, true);
87      }
88  
89      public RatingsEntryLocalService getRatingsEntryLocalService() {
90          return ratingsEntryLocalService;
91      }
92  
93      public void setRatingsEntryLocalService(
94          RatingsEntryLocalService ratingsEntryLocalService) {
95          this.ratingsEntryLocalService = ratingsEntryLocalService;
96      }
97  
98      public RatingsEntryService getRatingsEntryService() {
99          return ratingsEntryService;
100     }
101 
102     public void setRatingsEntryService(RatingsEntryService ratingsEntryService) {
103         this.ratingsEntryService = ratingsEntryService;
104     }
105 
106     public RatingsEntryPersistence getRatingsEntryPersistence() {
107         return ratingsEntryPersistence;
108     }
109 
110     public void setRatingsEntryPersistence(
111         RatingsEntryPersistence ratingsEntryPersistence) {
112         this.ratingsEntryPersistence = ratingsEntryPersistence;
113     }
114 
115     public RatingsStatsPersistence getRatingsStatsPersistence() {
116         return ratingsStatsPersistence;
117     }
118 
119     public void setRatingsStatsPersistence(
120         RatingsStatsPersistence ratingsStatsPersistence) {
121         this.ratingsStatsPersistence = ratingsStatsPersistence;
122     }
123 
124     public CounterLocalService getCounterLocalService() {
125         return counterLocalService;
126     }
127 
128     public void setCounterLocalService(CounterLocalService counterLocalService) {
129         this.counterLocalService = counterLocalService;
130     }
131 
132     public CounterService getCounterService() {
133         return counterService;
134     }
135 
136     public void setCounterService(CounterService counterService) {
137         this.counterService = counterService;
138     }
139 
140     public void afterPropertiesSet() {
141         if (ratingsEntryLocalService == null) {
142             ratingsEntryLocalService = RatingsEntryLocalServiceFactory.getImpl();
143         }
144 
145         if (ratingsEntryService == null) {
146             ratingsEntryService = RatingsEntryServiceFactory.getImpl();
147         }
148 
149         if (ratingsEntryPersistence == null) {
150             ratingsEntryPersistence = RatingsEntryUtil.getPersistence();
151         }
152 
153         if (ratingsStatsPersistence == null) {
154             ratingsStatsPersistence = RatingsStatsUtil.getPersistence();
155         }
156 
157         if (counterLocalService == null) {
158             counterLocalService = CounterLocalServiceFactory.getImpl();
159         }
160 
161         if (counterService == null) {
162             counterService = CounterServiceFactory.getImpl();
163         }
164     }
165 
166     protected RatingsEntryLocalService ratingsEntryLocalService;
167     protected RatingsEntryService ratingsEntryService;
168     protected RatingsEntryPersistence ratingsEntryPersistence;
169     protected RatingsStatsPersistence ratingsStatsPersistence;
170     protected CounterLocalService counterLocalService;
171     protected CounterService counterService;
172 }