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