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