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.PortalException;
31  import com.liferay.portal.SystemException;
32  import com.liferay.portal.kernel.dao.DynamicQueryInitializer;
33  
34  import com.liferay.portlet.ratings.model.RatingsStats;
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 ratingsStats)
58          throws SystemException {
59          ratingsStats.setNew(true);
60  
61          return ratingsStatsPersistence.update(ratingsStats, false);
62      }
63  
64      public void deleteRatingsStats(long statsId)
65          throws PortalException, SystemException {
66          ratingsStatsPersistence.remove(statsId);
67      }
68  
69      public void deleteRatingsStats(RatingsStats ratingsStats)
70          throws PortalException, SystemException {
71          ratingsStatsPersistence.remove(ratingsStats);
72      }
73  
74      public List<RatingsStats> dynamicQuery(
75          DynamicQueryInitializer queryInitializer) throws SystemException {
76          return ratingsStatsPersistence.findWithDynamicQuery(queryInitializer);
77      }
78  
79      public List<RatingsStats> dynamicQuery(
80          DynamicQueryInitializer queryInitializer, int begin, int end)
81          throws SystemException {
82          return ratingsStatsPersistence.findWithDynamicQuery(queryInitializer,
83              begin, end);
84      }
85  
86      public RatingsStats updateRatingsStats(RatingsStats ratingsStats)
87          throws SystemException {
88          ratingsStats.setNew(false);
89  
90          return ratingsStatsPersistence.update(ratingsStats, true);
91      }
92  
93      public RatingsEntryLocalService getRatingsEntryLocalService() {
94          return ratingsEntryLocalService;
95      }
96  
97      public void setRatingsEntryLocalService(
98          RatingsEntryLocalService ratingsEntryLocalService) {
99          this.ratingsEntryLocalService = ratingsEntryLocalService;
100     }
101 
102     public RatingsEntryService getRatingsEntryService() {
103         return ratingsEntryService;
104     }
105 
106     public void setRatingsEntryService(RatingsEntryService ratingsEntryService) {
107         this.ratingsEntryService = ratingsEntryService;
108     }
109 
110     public RatingsEntryPersistence getRatingsEntryPersistence() {
111         return ratingsEntryPersistence;
112     }
113 
114     public void setRatingsEntryPersistence(
115         RatingsEntryPersistence ratingsEntryPersistence) {
116         this.ratingsEntryPersistence = ratingsEntryPersistence;
117     }
118 
119     public RatingsStatsPersistence getRatingsStatsPersistence() {
120         return ratingsStatsPersistence;
121     }
122 
123     public void setRatingsStatsPersistence(
124         RatingsStatsPersistence ratingsStatsPersistence) {
125         this.ratingsStatsPersistence = ratingsStatsPersistence;
126     }
127 
128     public CounterLocalService getCounterLocalService() {
129         return counterLocalService;
130     }
131 
132     public void setCounterLocalService(CounterLocalService counterLocalService) {
133         this.counterLocalService = counterLocalService;
134     }
135 
136     public CounterService getCounterService() {
137         return counterService;
138     }
139 
140     public void setCounterService(CounterService counterService) {
141         this.counterService = counterService;
142     }
143 
144     public void afterPropertiesSet() {
145         if (ratingsEntryLocalService == null) {
146             ratingsEntryLocalService = RatingsEntryLocalServiceFactory.getImpl();
147         }
148 
149         if (ratingsEntryService == null) {
150             ratingsEntryService = RatingsEntryServiceFactory.getImpl();
151         }
152 
153         if (ratingsEntryPersistence == null) {
154             ratingsEntryPersistence = RatingsEntryUtil.getPersistence();
155         }
156 
157         if (ratingsStatsPersistence == null) {
158             ratingsStatsPersistence = RatingsStatsUtil.getPersistence();
159         }
160 
161         if (counterLocalService == null) {
162             counterLocalService = CounterLocalServiceFactory.getImpl();
163         }
164 
165         if (counterService == null) {
166             counterService = CounterServiceFactory.getImpl();
167         }
168     }
169 
170     protected RatingsEntryLocalService ratingsEntryLocalService;
171     protected RatingsEntryService ratingsEntryService;
172     protected RatingsEntryPersistence ratingsEntryPersistence;
173     protected RatingsStatsPersistence ratingsStatsPersistence;
174     protected CounterLocalService counterLocalService;
175     protected CounterService counterService;
176 }