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.counter.service.base;
16  
17  import com.liferay.counter.model.Counter;
18  import com.liferay.counter.service.CounterLocalService;
19  import com.liferay.counter.service.persistence.CounterFinder;
20  import com.liferay.counter.service.persistence.CounterPersistence;
21  
22  import com.liferay.portal.kernel.annotation.BeanReference;
23  import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
24  import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
25  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
26  import com.liferay.portal.kernel.exception.PortalException;
27  import com.liferay.portal.kernel.exception.SystemException;
28  import com.liferay.portal.kernel.util.OrderByComparator;
29  import com.liferay.portal.service.ResourceLocalService;
30  import com.liferay.portal.service.ResourceService;
31  import com.liferay.portal.service.UserLocalService;
32  import com.liferay.portal.service.UserService;
33  import com.liferay.portal.service.persistence.ResourceFinder;
34  import com.liferay.portal.service.persistence.ResourcePersistence;
35  import com.liferay.portal.service.persistence.UserFinder;
36  import com.liferay.portal.service.persistence.UserPersistence;
37  
38  import java.util.List;
39  
40  import javax.sql.DataSource;
41  
42  /**
43   * <a href="CounterLocalServiceBaseImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * @author Brian Wing Shun Chan
46   */
47  public abstract class CounterLocalServiceBaseImpl implements CounterLocalService {
48      public Counter addCounter(Counter counter) throws SystemException {
49          counter.setNew(true);
50  
51          return counterPersistence.update(counter, false);
52      }
53  
54      public Counter createCounter(String name) {
55          return counterPersistence.create(name);
56      }
57  
58      public void deleteCounter(String name)
59          throws PortalException, SystemException {
60          counterPersistence.remove(name);
61      }
62  
63      public void deleteCounter(Counter counter) throws SystemException {
64          counterPersistence.remove(counter);
65      }
66  
67      @SuppressWarnings("unchecked")
68      public List dynamicQuery(DynamicQuery dynamicQuery)
69          throws SystemException {
70          return counterPersistence.findWithDynamicQuery(dynamicQuery);
71      }
72  
73      @SuppressWarnings("unchecked")
74      public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
75          throws SystemException {
76          return counterPersistence.findWithDynamicQuery(dynamicQuery, start, end);
77      }
78  
79      @SuppressWarnings("unchecked")
80      public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
81          OrderByComparator orderByComparator) throws SystemException {
82          return counterPersistence.findWithDynamicQuery(dynamicQuery, start,
83              end, orderByComparator);
84      }
85  
86      public long dynamicQueryCount(DynamicQuery dynamicQuery)
87          throws SystemException {
88          return counterPersistence.countWithDynamicQuery(dynamicQuery);
89      }
90  
91      public Counter getCounter(String name)
92          throws PortalException, SystemException {
93          return counterPersistence.findByPrimaryKey(name);
94      }
95  
96      public List<Counter> getCounters(int start, int end)
97          throws SystemException {
98          return counterPersistence.findAll(start, end);
99      }
100 
101     public int getCountersCount() throws SystemException {
102         return counterPersistence.countAll();
103     }
104 
105     public Counter updateCounter(Counter counter) throws SystemException {
106         counter.setNew(false);
107 
108         return counterPersistence.update(counter, true);
109     }
110 
111     public Counter updateCounter(Counter counter, boolean merge)
112         throws SystemException {
113         counter.setNew(false);
114 
115         return counterPersistence.update(counter, merge);
116     }
117 
118     public CounterLocalService getCounterLocalService() {
119         return counterLocalService;
120     }
121 
122     public void setCounterLocalService(CounterLocalService counterLocalService) {
123         this.counterLocalService = counterLocalService;
124     }
125 
126     public CounterPersistence getCounterPersistence() {
127         return counterPersistence;
128     }
129 
130     public void setCounterPersistence(CounterPersistence counterPersistence) {
131         this.counterPersistence = counterPersistence;
132     }
133 
134     public CounterFinder getCounterFinder() {
135         return counterFinder;
136     }
137 
138     public void setCounterFinder(CounterFinder counterFinder) {
139         this.counterFinder = counterFinder;
140     }
141 
142     public ResourceLocalService getResourceLocalService() {
143         return resourceLocalService;
144     }
145 
146     public void setResourceLocalService(
147         ResourceLocalService resourceLocalService) {
148         this.resourceLocalService = resourceLocalService;
149     }
150 
151     public ResourceService getResourceService() {
152         return resourceService;
153     }
154 
155     public void setResourceService(ResourceService resourceService) {
156         this.resourceService = resourceService;
157     }
158 
159     public ResourcePersistence getResourcePersistence() {
160         return resourcePersistence;
161     }
162 
163     public void setResourcePersistence(ResourcePersistence resourcePersistence) {
164         this.resourcePersistence = resourcePersistence;
165     }
166 
167     public ResourceFinder getResourceFinder() {
168         return resourceFinder;
169     }
170 
171     public void setResourceFinder(ResourceFinder resourceFinder) {
172         this.resourceFinder = resourceFinder;
173     }
174 
175     public UserLocalService getUserLocalService() {
176         return userLocalService;
177     }
178 
179     public void setUserLocalService(UserLocalService userLocalService) {
180         this.userLocalService = userLocalService;
181     }
182 
183     public UserService getUserService() {
184         return userService;
185     }
186 
187     public void setUserService(UserService userService) {
188         this.userService = userService;
189     }
190 
191     public UserPersistence getUserPersistence() {
192         return userPersistence;
193     }
194 
195     public void setUserPersistence(UserPersistence userPersistence) {
196         this.userPersistence = userPersistence;
197     }
198 
199     public UserFinder getUserFinder() {
200         return userFinder;
201     }
202 
203     public void setUserFinder(UserFinder userFinder) {
204         this.userFinder = userFinder;
205     }
206 
207     protected void runSQL(String sql) throws SystemException {
208         try {
209             DataSource dataSource = counterPersistence.getDataSource();
210 
211             SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
212                     sql, new int[0]);
213 
214             sqlUpdate.update();
215         }
216         catch (Exception e) {
217             throw new SystemException(e);
218         }
219     }
220 
221     @BeanReference(type = CounterLocalService.class)
222     protected CounterLocalService counterLocalService;
223     @BeanReference(type = CounterPersistence.class)
224     protected CounterPersistence counterPersistence;
225     @BeanReference(type = CounterFinder.class)
226     protected CounterFinder counterFinder;
227     @BeanReference(type = ResourceLocalService.class)
228     protected ResourceLocalService resourceLocalService;
229     @BeanReference(type = ResourceService.class)
230     protected ResourceService resourceService;
231     @BeanReference(type = ResourcePersistence.class)
232     protected ResourcePersistence resourcePersistence;
233     @BeanReference(type = ResourceFinder.class)
234     protected ResourceFinder resourceFinder;
235     @BeanReference(type = UserLocalService.class)
236     protected UserLocalService userLocalService;
237     @BeanReference(type = UserService.class)
238     protected UserService userService;
239     @BeanReference(type = UserPersistence.class)
240     protected UserPersistence userPersistence;
241     @BeanReference(type = UserFinder.class)
242     protected UserFinder userFinder;
243 }