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.portlet.expando.service.base;
016    
017    import com.liferay.counter.service.CounterLocalService;
018    
019    import com.liferay.portal.kernel.annotation.BeanReference;
020    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
021    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
022    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
023    import com.liferay.portal.kernel.exception.PortalException;
024    import com.liferay.portal.kernel.exception.SystemException;
025    import com.liferay.portal.kernel.util.OrderByComparator;
026    import com.liferay.portal.service.ResourceLocalService;
027    import com.liferay.portal.service.ResourceService;
028    import com.liferay.portal.service.UserLocalService;
029    import com.liferay.portal.service.UserService;
030    import com.liferay.portal.service.persistence.ResourceFinder;
031    import com.liferay.portal.service.persistence.ResourcePersistence;
032    import com.liferay.portal.service.persistence.UserFinder;
033    import com.liferay.portal.service.persistence.UserPersistence;
034    
035    import com.liferay.portlet.expando.model.ExpandoValue;
036    import com.liferay.portlet.expando.service.ExpandoColumnLocalService;
037    import com.liferay.portlet.expando.service.ExpandoColumnService;
038    import com.liferay.portlet.expando.service.ExpandoRowLocalService;
039    import com.liferay.portlet.expando.service.ExpandoTableLocalService;
040    import com.liferay.portlet.expando.service.ExpandoValueLocalService;
041    import com.liferay.portlet.expando.service.ExpandoValueService;
042    import com.liferay.portlet.expando.service.persistence.ExpandoColumnPersistence;
043    import com.liferay.portlet.expando.service.persistence.ExpandoRowPersistence;
044    import com.liferay.portlet.expando.service.persistence.ExpandoTablePersistence;
045    import com.liferay.portlet.expando.service.persistence.ExpandoValuePersistence;
046    
047    import java.util.List;
048    
049    import javax.sql.DataSource;
050    
051    /**
052     * @author Brian Wing Shun Chan
053     */
054    public abstract class ExpandoValueLocalServiceBaseImpl
055            implements ExpandoValueLocalService {
056            public ExpandoValue addExpandoValue(ExpandoValue expandoValue)
057                    throws SystemException {
058                    expandoValue.setNew(true);
059    
060                    return expandoValuePersistence.update(expandoValue, false);
061            }
062    
063            public ExpandoValue createExpandoValue(long valueId) {
064                    return expandoValuePersistence.create(valueId);
065            }
066    
067            public void deleteExpandoValue(long valueId)
068                    throws PortalException, SystemException {
069                    expandoValuePersistence.remove(valueId);
070            }
071    
072            public void deleteExpandoValue(ExpandoValue expandoValue)
073                    throws SystemException {
074                    expandoValuePersistence.remove(expandoValue);
075            }
076    
077            @SuppressWarnings("unchecked")
078            public List dynamicQuery(DynamicQuery dynamicQuery)
079                    throws SystemException {
080                    return expandoValuePersistence.findWithDynamicQuery(dynamicQuery);
081            }
082    
083            @SuppressWarnings("unchecked")
084            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
085                    throws SystemException {
086                    return expandoValuePersistence.findWithDynamicQuery(dynamicQuery,
087                            start, end);
088            }
089    
090            @SuppressWarnings("unchecked")
091            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
092                    OrderByComparator orderByComparator) throws SystemException {
093                    return expandoValuePersistence.findWithDynamicQuery(dynamicQuery,
094                            start, end, orderByComparator);
095            }
096    
097            public long dynamicQueryCount(DynamicQuery dynamicQuery)
098                    throws SystemException {
099                    return expandoValuePersistence.countWithDynamicQuery(dynamicQuery);
100            }
101    
102            public ExpandoValue getExpandoValue(long valueId)
103                    throws PortalException, SystemException {
104                    return expandoValuePersistence.findByPrimaryKey(valueId);
105            }
106    
107            public List<ExpandoValue> getExpandoValues(int start, int end)
108                    throws SystemException {
109                    return expandoValuePersistence.findAll(start, end);
110            }
111    
112            public int getExpandoValuesCount() throws SystemException {
113                    return expandoValuePersistence.countAll();
114            }
115    
116            public ExpandoValue updateExpandoValue(ExpandoValue expandoValue)
117                    throws SystemException {
118                    expandoValue.setNew(false);
119    
120                    return expandoValuePersistence.update(expandoValue, true);
121            }
122    
123            public ExpandoValue updateExpandoValue(ExpandoValue expandoValue,
124                    boolean merge) throws SystemException {
125                    expandoValue.setNew(false);
126    
127                    return expandoValuePersistence.update(expandoValue, merge);
128            }
129    
130            public ExpandoColumnLocalService getExpandoColumnLocalService() {
131                    return expandoColumnLocalService;
132            }
133    
134            public void setExpandoColumnLocalService(
135                    ExpandoColumnLocalService expandoColumnLocalService) {
136                    this.expandoColumnLocalService = expandoColumnLocalService;
137            }
138    
139            public ExpandoColumnService getExpandoColumnService() {
140                    return expandoColumnService;
141            }
142    
143            public void setExpandoColumnService(
144                    ExpandoColumnService expandoColumnService) {
145                    this.expandoColumnService = expandoColumnService;
146            }
147    
148            public ExpandoColumnPersistence getExpandoColumnPersistence() {
149                    return expandoColumnPersistence;
150            }
151    
152            public void setExpandoColumnPersistence(
153                    ExpandoColumnPersistence expandoColumnPersistence) {
154                    this.expandoColumnPersistence = expandoColumnPersistence;
155            }
156    
157            public ExpandoRowLocalService getExpandoRowLocalService() {
158                    return expandoRowLocalService;
159            }
160    
161            public void setExpandoRowLocalService(
162                    ExpandoRowLocalService expandoRowLocalService) {
163                    this.expandoRowLocalService = expandoRowLocalService;
164            }
165    
166            public ExpandoRowPersistence getExpandoRowPersistence() {
167                    return expandoRowPersistence;
168            }
169    
170            public void setExpandoRowPersistence(
171                    ExpandoRowPersistence expandoRowPersistence) {
172                    this.expandoRowPersistence = expandoRowPersistence;
173            }
174    
175            public ExpandoTableLocalService getExpandoTableLocalService() {
176                    return expandoTableLocalService;
177            }
178    
179            public void setExpandoTableLocalService(
180                    ExpandoTableLocalService expandoTableLocalService) {
181                    this.expandoTableLocalService = expandoTableLocalService;
182            }
183    
184            public ExpandoTablePersistence getExpandoTablePersistence() {
185                    return expandoTablePersistence;
186            }
187    
188            public void setExpandoTablePersistence(
189                    ExpandoTablePersistence expandoTablePersistence) {
190                    this.expandoTablePersistence = expandoTablePersistence;
191            }
192    
193            public ExpandoValueLocalService getExpandoValueLocalService() {
194                    return expandoValueLocalService;
195            }
196    
197            public void setExpandoValueLocalService(
198                    ExpandoValueLocalService expandoValueLocalService) {
199                    this.expandoValueLocalService = expandoValueLocalService;
200            }
201    
202            public ExpandoValueService getExpandoValueService() {
203                    return expandoValueService;
204            }
205    
206            public void setExpandoValueService(ExpandoValueService expandoValueService) {
207                    this.expandoValueService = expandoValueService;
208            }
209    
210            public ExpandoValuePersistence getExpandoValuePersistence() {
211                    return expandoValuePersistence;
212            }
213    
214            public void setExpandoValuePersistence(
215                    ExpandoValuePersistence expandoValuePersistence) {
216                    this.expandoValuePersistence = expandoValuePersistence;
217            }
218    
219            public CounterLocalService getCounterLocalService() {
220                    return counterLocalService;
221            }
222    
223            public void setCounterLocalService(CounterLocalService counterLocalService) {
224                    this.counterLocalService = counterLocalService;
225            }
226    
227            public ResourceLocalService getResourceLocalService() {
228                    return resourceLocalService;
229            }
230    
231            public void setResourceLocalService(
232                    ResourceLocalService resourceLocalService) {
233                    this.resourceLocalService = resourceLocalService;
234            }
235    
236            public ResourceService getResourceService() {
237                    return resourceService;
238            }
239    
240            public void setResourceService(ResourceService resourceService) {
241                    this.resourceService = resourceService;
242            }
243    
244            public ResourcePersistence getResourcePersistence() {
245                    return resourcePersistence;
246            }
247    
248            public void setResourcePersistence(ResourcePersistence resourcePersistence) {
249                    this.resourcePersistence = resourcePersistence;
250            }
251    
252            public ResourceFinder getResourceFinder() {
253                    return resourceFinder;
254            }
255    
256            public void setResourceFinder(ResourceFinder resourceFinder) {
257                    this.resourceFinder = resourceFinder;
258            }
259    
260            public UserLocalService getUserLocalService() {
261                    return userLocalService;
262            }
263    
264            public void setUserLocalService(UserLocalService userLocalService) {
265                    this.userLocalService = userLocalService;
266            }
267    
268            public UserService getUserService() {
269                    return userService;
270            }
271    
272            public void setUserService(UserService userService) {
273                    this.userService = userService;
274            }
275    
276            public UserPersistence getUserPersistence() {
277                    return userPersistence;
278            }
279    
280            public void setUserPersistence(UserPersistence userPersistence) {
281                    this.userPersistence = userPersistence;
282            }
283    
284            public UserFinder getUserFinder() {
285                    return userFinder;
286            }
287    
288            public void setUserFinder(UserFinder userFinder) {
289                    this.userFinder = userFinder;
290            }
291    
292            protected void runSQL(String sql) throws SystemException {
293                    try {
294                            DataSource dataSource = expandoValuePersistence.getDataSource();
295    
296                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
297                                            sql, new int[0]);
298    
299                            sqlUpdate.update();
300                    }
301                    catch (Exception e) {
302                            throw new SystemException(e);
303                    }
304            }
305    
306            @BeanReference(type = ExpandoColumnLocalService.class)
307            protected ExpandoColumnLocalService expandoColumnLocalService;
308            @BeanReference(type = ExpandoColumnService.class)
309            protected ExpandoColumnService expandoColumnService;
310            @BeanReference(type = ExpandoColumnPersistence.class)
311            protected ExpandoColumnPersistence expandoColumnPersistence;
312            @BeanReference(type = ExpandoRowLocalService.class)
313            protected ExpandoRowLocalService expandoRowLocalService;
314            @BeanReference(type = ExpandoRowPersistence.class)
315            protected ExpandoRowPersistence expandoRowPersistence;
316            @BeanReference(type = ExpandoTableLocalService.class)
317            protected ExpandoTableLocalService expandoTableLocalService;
318            @BeanReference(type = ExpandoTablePersistence.class)
319            protected ExpandoTablePersistence expandoTablePersistence;
320            @BeanReference(type = ExpandoValueLocalService.class)
321            protected ExpandoValueLocalService expandoValueLocalService;
322            @BeanReference(type = ExpandoValueService.class)
323            protected ExpandoValueService expandoValueService;
324            @BeanReference(type = ExpandoValuePersistence.class)
325            protected ExpandoValuePersistence expandoValuePersistence;
326            @BeanReference(type = CounterLocalService.class)
327            protected CounterLocalService counterLocalService;
328            @BeanReference(type = ResourceLocalService.class)
329            protected ResourceLocalService resourceLocalService;
330            @BeanReference(type = ResourceService.class)
331            protected ResourceService resourceService;
332            @BeanReference(type = ResourcePersistence.class)
333            protected ResourcePersistence resourcePersistence;
334            @BeanReference(type = ResourceFinder.class)
335            protected ResourceFinder resourceFinder;
336            @BeanReference(type = UserLocalService.class)
337            protected UserLocalService userLocalService;
338            @BeanReference(type = UserService.class)
339            protected UserService userService;
340            @BeanReference(type = UserPersistence.class)
341            protected UserPersistence userPersistence;
342            @BeanReference(type = UserFinder.class)
343            protected UserFinder userFinder;
344    }