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