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