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.ratings.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.ratings.model.RatingsStats;
036    import com.liferay.portlet.ratings.service.RatingsEntryLocalService;
037    import com.liferay.portlet.ratings.service.RatingsEntryService;
038    import com.liferay.portlet.ratings.service.RatingsStatsLocalService;
039    import com.liferay.portlet.ratings.service.persistence.RatingsEntryFinder;
040    import com.liferay.portlet.ratings.service.persistence.RatingsEntryPersistence;
041    import com.liferay.portlet.ratings.service.persistence.RatingsStatsFinder;
042    import com.liferay.portlet.ratings.service.persistence.RatingsStatsPersistence;
043    
044    import java.util.List;
045    
046    import javax.sql.DataSource;
047    
048    /**
049     * The base implementation of the ratings stats local service.
050     *
051     * <p>
052     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portlet.ratings.service.impl.RatingsStatsLocalServiceImpl}.
053     * </p>
054     *
055     * <p>
056     * Never modify or reference this class directly. Always use {@link com.liferay.portlet.ratings.service.RatingsStatsLocalServiceUtil} to access the ratings stats local service.
057     * </p>
058     *
059     * @author Brian Wing Shun Chan
060     * @see com.liferay.portlet.ratings.service.impl.RatingsStatsLocalServiceImpl
061     * @see com.liferay.portlet.ratings.service.RatingsStatsLocalServiceUtil
062     * @generated
063     */
064    public abstract class RatingsStatsLocalServiceBaseImpl
065            implements RatingsStatsLocalService {
066            /**
067             * Adds the ratings stats to the database. Also notifies the appropriate model listeners.
068             *
069             * @param ratingsStats the ratings stats to add
070             * @return the ratings stats that was added
071             * @throws SystemException if a system exception occurred
072             */
073            public RatingsStats addRatingsStats(RatingsStats ratingsStats)
074                    throws SystemException {
075                    ratingsStats.setNew(true);
076    
077                    return ratingsStatsPersistence.update(ratingsStats, false);
078            }
079    
080            /**
081             * Creates a new ratings stats with the primary key. Does not add the ratings stats to the database.
082             *
083             * @param statsId the primary key for the new ratings stats
084             * @return the new ratings stats
085             */
086            public RatingsStats createRatingsStats(long statsId) {
087                    return ratingsStatsPersistence.create(statsId);
088            }
089    
090            /**
091             * Deletes the ratings stats with the primary key from the database. Also notifies the appropriate model listeners.
092             *
093             * @param statsId the primary key of the ratings stats to delete
094             * @throws PortalException if a ratings stats with the primary key could not be found
095             * @throws SystemException if a system exception occurred
096             */
097            public void deleteRatingsStats(long statsId)
098                    throws PortalException, SystemException {
099                    ratingsStatsPersistence.remove(statsId);
100            }
101    
102            /**
103             * Deletes the ratings stats from the database. Also notifies the appropriate model listeners.
104             *
105             * @param ratingsStats the ratings stats to delete
106             * @throws SystemException if a system exception occurred
107             */
108            public void deleteRatingsStats(RatingsStats ratingsStats)
109                    throws SystemException {
110                    ratingsStatsPersistence.remove(ratingsStats);
111            }
112    
113            /**
114             * Performs a dynamic query on the database and returns the matching rows.
115             *
116             * @param dynamicQuery the dynamic query to search with
117             * @return the matching rows
118             * @throws SystemException if a system exception occurred
119             */
120            @SuppressWarnings("rawtypes")
121            public List dynamicQuery(DynamicQuery dynamicQuery)
122                    throws SystemException {
123                    return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery);
124            }
125    
126            /**
127             * Performs a dynamic query on the database and returns a range of the matching rows.
128             *
129             * <p>
130             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
131             * </p>
132             *
133             * @param dynamicQuery the dynamic query to search with
134             * @param start the lower bound of the range of model instances to return
135             * @param end the upper bound of the range of model instances to return (not inclusive)
136             * @return the range of matching rows
137             * @throws SystemException if a system exception occurred
138             */
139            @SuppressWarnings("rawtypes")
140            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end)
141                    throws SystemException {
142                    return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery,
143                            start, end);
144            }
145    
146            /**
147             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
148             *
149             * <p>
150             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
151             * </p>
152             *
153             * @param dynamicQuery the dynamic query to search with
154             * @param start the lower bound of the range of model instances to return
155             * @param end the upper bound of the range of model instances to return (not inclusive)
156             * @param orderByComparator the comparator to order the results by
157             * @return the ordered range of matching rows
158             * @throws SystemException if a system exception occurred
159             */
160            @SuppressWarnings("rawtypes")
161            public List dynamicQuery(DynamicQuery dynamicQuery, int start, int end,
162                    OrderByComparator orderByComparator) throws SystemException {
163                    return ratingsStatsPersistence.findWithDynamicQuery(dynamicQuery,
164                            start, end, orderByComparator);
165            }
166    
167            /**
168             * Counts the number of rows that match the dynamic query.
169             *
170             * @param dynamicQuery the dynamic query to search with
171             * @return the number of rows that match the dynamic query
172             * @throws SystemException if a system exception occurred
173             */
174            public long dynamicQueryCount(DynamicQuery dynamicQuery)
175                    throws SystemException {
176                    return ratingsStatsPersistence.countWithDynamicQuery(dynamicQuery);
177            }
178    
179            /**
180             * Gets the ratings stats with the primary key.
181             *
182             * @param statsId the primary key of the ratings stats to get
183             * @return the ratings stats
184             * @throws PortalException if a ratings stats with the primary key could not be found
185             * @throws SystemException if a system exception occurred
186             */
187            public RatingsStats getRatingsStats(long statsId)
188                    throws PortalException, SystemException {
189                    return ratingsStatsPersistence.findByPrimaryKey(statsId);
190            }
191    
192            /**
193             * Gets a range of all the ratings statses.
194             *
195             * <p>
196             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
197             * </p>
198             *
199             * @param start the lower bound of the range of ratings statses to return
200             * @param end the upper bound of the range of ratings statses to return (not inclusive)
201             * @return the range of ratings statses
202             * @throws SystemException if a system exception occurred
203             */
204            public List<RatingsStats> getRatingsStatses(int start, int end)
205                    throws SystemException {
206                    return ratingsStatsPersistence.findAll(start, end);
207            }
208    
209            /**
210             * Gets the number of ratings statses.
211             *
212             * @return the number of ratings statses
213             * @throws SystemException if a system exception occurred
214             */
215            public int getRatingsStatsesCount() throws SystemException {
216                    return ratingsStatsPersistence.countAll();
217            }
218    
219            /**
220             * Updates the ratings stats in the database. Also notifies the appropriate model listeners.
221             *
222             * @param ratingsStats the ratings stats to update
223             * @return the ratings stats that was updated
224             * @throws SystemException if a system exception occurred
225             */
226            public RatingsStats updateRatingsStats(RatingsStats ratingsStats)
227                    throws SystemException {
228                    ratingsStats.setNew(false);
229    
230                    return ratingsStatsPersistence.update(ratingsStats, true);
231            }
232    
233            /**
234             * Updates the ratings stats in the database. Also notifies the appropriate model listeners.
235             *
236             * @param ratingsStats the ratings stats to update
237             * @param merge whether to merge the ratings stats with the current session. See {@link com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session, com.liferay.portal.model.BaseModel, boolean)} for an explanation.
238             * @return the ratings stats that was updated
239             * @throws SystemException if a system exception occurred
240             */
241            public RatingsStats updateRatingsStats(RatingsStats ratingsStats,
242                    boolean merge) throws SystemException {
243                    ratingsStats.setNew(false);
244    
245                    return ratingsStatsPersistence.update(ratingsStats, merge);
246            }
247    
248            /**
249             * Gets the ratings entry local service.
250             *
251             * @return the ratings entry local service
252             */
253            public RatingsEntryLocalService getRatingsEntryLocalService() {
254                    return ratingsEntryLocalService;
255            }
256    
257            /**
258             * Sets the ratings entry local service.
259             *
260             * @param ratingsEntryLocalService the ratings entry local service
261             */
262            public void setRatingsEntryLocalService(
263                    RatingsEntryLocalService ratingsEntryLocalService) {
264                    this.ratingsEntryLocalService = ratingsEntryLocalService;
265            }
266    
267            /**
268             * Gets the ratings entry remote service.
269             *
270             * @return the ratings entry remote service
271             */
272            public RatingsEntryService getRatingsEntryService() {
273                    return ratingsEntryService;
274            }
275    
276            /**
277             * Sets the ratings entry remote service.
278             *
279             * @param ratingsEntryService the ratings entry remote service
280             */
281            public void setRatingsEntryService(RatingsEntryService ratingsEntryService) {
282                    this.ratingsEntryService = ratingsEntryService;
283            }
284    
285            /**
286             * Gets the ratings entry persistence.
287             *
288             * @return the ratings entry persistence
289             */
290            public RatingsEntryPersistence getRatingsEntryPersistence() {
291                    return ratingsEntryPersistence;
292            }
293    
294            /**
295             * Sets the ratings entry persistence.
296             *
297             * @param ratingsEntryPersistence the ratings entry persistence
298             */
299            public void setRatingsEntryPersistence(
300                    RatingsEntryPersistence ratingsEntryPersistence) {
301                    this.ratingsEntryPersistence = ratingsEntryPersistence;
302            }
303    
304            /**
305             * Gets the ratings entry finder.
306             *
307             * @return the ratings entry finder
308             */
309            public RatingsEntryFinder getRatingsEntryFinder() {
310                    return ratingsEntryFinder;
311            }
312    
313            /**
314             * Sets the ratings entry finder.
315             *
316             * @param ratingsEntryFinder the ratings entry finder
317             */
318            public void setRatingsEntryFinder(RatingsEntryFinder ratingsEntryFinder) {
319                    this.ratingsEntryFinder = ratingsEntryFinder;
320            }
321    
322            /**
323             * Gets the ratings stats local service.
324             *
325             * @return the ratings stats local service
326             */
327            public RatingsStatsLocalService getRatingsStatsLocalService() {
328                    return ratingsStatsLocalService;
329            }
330    
331            /**
332             * Sets the ratings stats local service.
333             *
334             * @param ratingsStatsLocalService the ratings stats local service
335             */
336            public void setRatingsStatsLocalService(
337                    RatingsStatsLocalService ratingsStatsLocalService) {
338                    this.ratingsStatsLocalService = ratingsStatsLocalService;
339            }
340    
341            /**
342             * Gets the ratings stats persistence.
343             *
344             * @return the ratings stats persistence
345             */
346            public RatingsStatsPersistence getRatingsStatsPersistence() {
347                    return ratingsStatsPersistence;
348            }
349    
350            /**
351             * Sets the ratings stats persistence.
352             *
353             * @param ratingsStatsPersistence the ratings stats persistence
354             */
355            public void setRatingsStatsPersistence(
356                    RatingsStatsPersistence ratingsStatsPersistence) {
357                    this.ratingsStatsPersistence = ratingsStatsPersistence;
358            }
359    
360            /**
361             * Gets the ratings stats finder.
362             *
363             * @return the ratings stats finder
364             */
365            public RatingsStatsFinder getRatingsStatsFinder() {
366                    return ratingsStatsFinder;
367            }
368    
369            /**
370             * Sets the ratings stats finder.
371             *
372             * @param ratingsStatsFinder the ratings stats finder
373             */
374            public void setRatingsStatsFinder(RatingsStatsFinder ratingsStatsFinder) {
375                    this.ratingsStatsFinder = ratingsStatsFinder;
376            }
377    
378            /**
379             * Gets the counter local service.
380             *
381             * @return the counter local service
382             */
383            public CounterLocalService getCounterLocalService() {
384                    return counterLocalService;
385            }
386    
387            /**
388             * Sets the counter local service.
389             *
390             * @param counterLocalService the counter local service
391             */
392            public void setCounterLocalService(CounterLocalService counterLocalService) {
393                    this.counterLocalService = counterLocalService;
394            }
395    
396            /**
397             * Gets the resource local service.
398             *
399             * @return the resource local service
400             */
401            public ResourceLocalService getResourceLocalService() {
402                    return resourceLocalService;
403            }
404    
405            /**
406             * Sets the resource local service.
407             *
408             * @param resourceLocalService the resource local service
409             */
410            public void setResourceLocalService(
411                    ResourceLocalService resourceLocalService) {
412                    this.resourceLocalService = resourceLocalService;
413            }
414    
415            /**
416             * Gets the resource remote service.
417             *
418             * @return the resource remote service
419             */
420            public ResourceService getResourceService() {
421                    return resourceService;
422            }
423    
424            /**
425             * Sets the resource remote service.
426             *
427             * @param resourceService the resource remote service
428             */
429            public void setResourceService(ResourceService resourceService) {
430                    this.resourceService = resourceService;
431            }
432    
433            /**
434             * Gets the resource persistence.
435             *
436             * @return the resource persistence
437             */
438            public ResourcePersistence getResourcePersistence() {
439                    return resourcePersistence;
440            }
441    
442            /**
443             * Sets the resource persistence.
444             *
445             * @param resourcePersistence the resource persistence
446             */
447            public void setResourcePersistence(ResourcePersistence resourcePersistence) {
448                    this.resourcePersistence = resourcePersistence;
449            }
450    
451            /**
452             * Gets the resource finder.
453             *
454             * @return the resource finder
455             */
456            public ResourceFinder getResourceFinder() {
457                    return resourceFinder;
458            }
459    
460            /**
461             * Sets the resource finder.
462             *
463             * @param resourceFinder the resource finder
464             */
465            public void setResourceFinder(ResourceFinder resourceFinder) {
466                    this.resourceFinder = resourceFinder;
467            }
468    
469            /**
470             * Gets the user local service.
471             *
472             * @return the user local service
473             */
474            public UserLocalService getUserLocalService() {
475                    return userLocalService;
476            }
477    
478            /**
479             * Sets the user local service.
480             *
481             * @param userLocalService the user local service
482             */
483            public void setUserLocalService(UserLocalService userLocalService) {
484                    this.userLocalService = userLocalService;
485            }
486    
487            /**
488             * Gets the user remote service.
489             *
490             * @return the user remote service
491             */
492            public UserService getUserService() {
493                    return userService;
494            }
495    
496            /**
497             * Sets the user remote service.
498             *
499             * @param userService the user remote service
500             */
501            public void setUserService(UserService userService) {
502                    this.userService = userService;
503            }
504    
505            /**
506             * Gets the user persistence.
507             *
508             * @return the user persistence
509             */
510            public UserPersistence getUserPersistence() {
511                    return userPersistence;
512            }
513    
514            /**
515             * Sets the user persistence.
516             *
517             * @param userPersistence the user persistence
518             */
519            public void setUserPersistence(UserPersistence userPersistence) {
520                    this.userPersistence = userPersistence;
521            }
522    
523            /**
524             * Gets the user finder.
525             *
526             * @return the user finder
527             */
528            public UserFinder getUserFinder() {
529                    return userFinder;
530            }
531    
532            /**
533             * Sets the user finder.
534             *
535             * @param userFinder the user finder
536             */
537            public void setUserFinder(UserFinder userFinder) {
538                    this.userFinder = userFinder;
539            }
540    
541            /**
542             * Performs an SQL query.
543             *
544             * @param sql the sql query to perform
545             */
546            protected void runSQL(String sql) throws SystemException {
547                    try {
548                            DataSource dataSource = ratingsStatsPersistence.getDataSource();
549    
550                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
551                                            sql, new int[0]);
552    
553                            sqlUpdate.update();
554                    }
555                    catch (Exception e) {
556                            throw new SystemException(e);
557                    }
558            }
559    
560            @BeanReference(type = RatingsEntryLocalService.class)
561            protected RatingsEntryLocalService ratingsEntryLocalService;
562            @BeanReference(type = RatingsEntryService.class)
563            protected RatingsEntryService ratingsEntryService;
564            @BeanReference(type = RatingsEntryPersistence.class)
565            protected RatingsEntryPersistence ratingsEntryPersistence;
566            @BeanReference(type = RatingsEntryFinder.class)
567            protected RatingsEntryFinder ratingsEntryFinder;
568            @BeanReference(type = RatingsStatsLocalService.class)
569            protected RatingsStatsLocalService ratingsStatsLocalService;
570            @BeanReference(type = RatingsStatsPersistence.class)
571            protected RatingsStatsPersistence ratingsStatsPersistence;
572            @BeanReference(type = RatingsStatsFinder.class)
573            protected RatingsStatsFinder ratingsStatsFinder;
574            @BeanReference(type = CounterLocalService.class)
575            protected CounterLocalService counterLocalService;
576            @BeanReference(type = ResourceLocalService.class)
577            protected ResourceLocalService resourceLocalService;
578            @BeanReference(type = ResourceService.class)
579            protected ResourceService resourceService;
580            @BeanReference(type = ResourcePersistence.class)
581            protected ResourcePersistence resourcePersistence;
582            @BeanReference(type = ResourceFinder.class)
583            protected ResourceFinder resourceFinder;
584            @BeanReference(type = UserLocalService.class)
585            protected UserLocalService userLocalService;
586            @BeanReference(type = UserService.class)
587            protected UserService userService;
588            @BeanReference(type = UserPersistence.class)
589            protected UserPersistence userPersistence;
590            @BeanReference(type = UserFinder.class)
591            protected UserFinder userFinder;
592    }