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