001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.counter.service.base;
016    
017    import com.liferay.counter.model.Counter;
018    import com.liferay.counter.service.CounterLocalService;
019    import com.liferay.counter.service.persistence.CounterFinder;
020    import com.liferay.counter.service.persistence.CounterPersistence;
021    
022    import com.liferay.portal.kernel.annotation.BeanReference;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
024    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
025    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
026    import com.liferay.portal.kernel.exception.PortalException;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.util.OrderByComparator;
029    import com.liferay.portal.service.ResourceLocalService;
030    import com.liferay.portal.service.ResourceService;
031    import com.liferay.portal.service.UserLocalService;
032    import com.liferay.portal.service.UserService;
033    import com.liferay.portal.service.persistence.ResourceFinder;
034    import com.liferay.portal.service.persistence.ResourcePersistence;
035    import com.liferay.portal.service.persistence.UserFinder;
036    import com.liferay.portal.service.persistence.UserPersistence;
037    
038    import java.util.List;
039    
040    import javax.sql.DataSource;
041    
042    /**
043     * @author Brian Wing Shun Chan
044     */
045    public abstract class CounterLocalServiceBaseImpl implements CounterLocalService {
046            public Counter addCounter(Counter counter) throws SystemException {
047                    counter.setNew(true);
048    
049                    return counterPersistence.update(counter, false);
050            }
051    
052            public Counter createCounter(String name) {
053                    return counterPersistence.create(name);
054            }
055    
056            public void deleteCounter(String name)
057                    throws PortalException, SystemException {
058                    counterPersistence.remove(name);
059            }
060    
061            public void deleteCounter(Counter counter) throws SystemException {
062                    counterPersistence.remove(counter);
063            }
064    
065            @SuppressWarnings("unchecked")
066            public List dynamicQuery(DynamicQuery dynamicQuery)
067                    throws SystemException {
068                    return counterPersistence.findWithDynamicQuery(dynamicQuery);
069            }
070    
071            @SuppressWarnings("unchecked")
072            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
073                    throws SystemException {
074                    return counterPersistence.findWithDynamicQuery(dynamicQuery, start, end);
075            }
076    
077            @SuppressWarnings("unchecked")
078            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
079                    OrderByComparator orderByComparator) throws SystemException {
080                    return counterPersistence.findWithDynamicQuery(dynamicQuery, start,
081                            end, orderByComparator);
082            }
083    
084            public long dynamicQueryCount(DynamicQuery dynamicQuery)
085                    throws SystemException {
086                    return counterPersistence.countWithDynamicQuery(dynamicQuery);
087            }
088    
089            public Counter getCounter(String name)
090                    throws PortalException, SystemException {
091                    return counterPersistence.findByPrimaryKey(name);
092            }
093    
094            public List<Counter> getCounters(int start, int end)
095                    throws SystemException {
096                    return counterPersistence.findAll(start, end);
097            }
098    
099            public int getCountersCount() throws SystemException {
100                    return counterPersistence.countAll();
101            }
102    
103            public Counter updateCounter(Counter counter) throws SystemException {
104                    counter.setNew(false);
105    
106                    return counterPersistence.update(counter, true);
107            }
108    
109            public Counter updateCounter(Counter counter, boolean merge)
110                    throws SystemException {
111                    counter.setNew(false);
112    
113                    return counterPersistence.update(counter, merge);
114            }
115    
116            public CounterLocalService getCounterLocalService() {
117                    return counterLocalService;
118            }
119    
120            public void setCounterLocalService(CounterLocalService counterLocalService) {
121                    this.counterLocalService = counterLocalService;
122            }
123    
124            public CounterPersistence getCounterPersistence() {
125                    return counterPersistence;
126            }
127    
128            public void setCounterPersistence(CounterPersistence counterPersistence) {
129                    this.counterPersistence = counterPersistence;
130            }
131    
132            public CounterFinder getCounterFinder() {
133                    return counterFinder;
134            }
135    
136            public void setCounterFinder(CounterFinder counterFinder) {
137                    this.counterFinder = counterFinder;
138            }
139    
140            public ResourceLocalService getResourceLocalService() {
141                    return resourceLocalService;
142            }
143    
144            public void setResourceLocalService(
145                    ResourceLocalService resourceLocalService) {
146                    this.resourceLocalService = resourceLocalService;
147            }
148    
149            public ResourceService getResourceService() {
150                    return resourceService;
151            }
152    
153            public void setResourceService(ResourceService resourceService) {
154                    this.resourceService = resourceService;
155            }
156    
157            public ResourcePersistence getResourcePersistence() {
158                    return resourcePersistence;
159            }
160    
161            public void setResourcePersistence(ResourcePersistence resourcePersistence) {
162                    this.resourcePersistence = resourcePersistence;
163            }
164    
165            public ResourceFinder getResourceFinder() {
166                    return resourceFinder;
167            }
168    
169            public void setResourceFinder(ResourceFinder resourceFinder) {
170                    this.resourceFinder = resourceFinder;
171            }
172    
173            public UserLocalService getUserLocalService() {
174                    return userLocalService;
175            }
176    
177            public void setUserLocalService(UserLocalService userLocalService) {
178                    this.userLocalService = userLocalService;
179            }
180    
181            public UserService getUserService() {
182                    return userService;
183            }
184    
185            public void setUserService(UserService userService) {
186                    this.userService = userService;
187            }
188    
189            public UserPersistence getUserPersistence() {
190                    return userPersistence;
191            }
192    
193            public void setUserPersistence(UserPersistence userPersistence) {
194                    this.userPersistence = userPersistence;
195            }
196    
197            public UserFinder getUserFinder() {
198                    return userFinder;
199            }
200    
201            public void setUserFinder(UserFinder userFinder) {
202                    this.userFinder = userFinder;
203            }
204    
205            protected void runSQL(String sql) throws SystemException {
206                    try {
207                            DataSource dataSource = counterPersistence.getDataSource();
208    
209                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
210                                            sql, new int[0]);
211    
212                            sqlUpdate.update();
213                    }
214                    catch (Exception e) {
215                            throw new SystemException(e);
216                    }
217            }
218    
219            @BeanReference(type = CounterLocalService.class)
220            protected CounterLocalService counterLocalService;
221            @BeanReference(type = CounterPersistence.class)
222            protected CounterPersistence counterPersistence;
223            @BeanReference(type = CounterFinder.class)
224            protected CounterFinder counterFinder;
225            @BeanReference(type = ResourceLocalService.class)
226            protected ResourceLocalService resourceLocalService;
227            @BeanReference(type = ResourceService.class)
228            protected ResourceService resourceService;
229            @BeanReference(type = ResourcePersistence.class)
230            protected ResourcePersistence resourcePersistence;
231            @BeanReference(type = ResourceFinder.class)
232            protected ResourceFinder resourceFinder;
233            @BeanReference(type = UserLocalService.class)
234            protected UserLocalService userLocalService;
235            @BeanReference(type = UserService.class)
236            protected UserService userService;
237            @BeanReference(type = UserPersistence.class)
238            protected UserPersistence userPersistence;
239            @BeanReference(type = UserFinder.class)
240            protected UserFinder userFinder;
241    }