001    /**
002     * Copyright (c) 2000-present 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.blogs.service.base;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.dao.db.DB;
021    import com.liferay.portal.kernel.dao.db.DBManagerUtil;
022    import com.liferay.portal.kernel.dao.jdbc.SqlUpdate;
023    import com.liferay.portal.kernel.dao.jdbc.SqlUpdateFactoryUtil;
024    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
025    import com.liferay.portal.kernel.dao.orm.DefaultActionableDynamicQuery;
026    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
027    import com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil;
028    import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
029    import com.liferay.portal.kernel.dao.orm.Projection;
030    import com.liferay.portal.kernel.exception.PortalException;
031    import com.liferay.portal.kernel.exception.SystemException;
032    import com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService;
033    import com.liferay.portal.kernel.search.Indexable;
034    import com.liferay.portal.kernel.search.IndexableType;
035    import com.liferay.portal.kernel.util.OrderByComparator;
036    import com.liferay.portal.model.PersistedModel;
037    import com.liferay.portal.service.BaseLocalServiceImpl;
038    import com.liferay.portal.service.PersistedModelLocalServiceRegistry;
039    import com.liferay.portal.service.persistence.GroupFinder;
040    import com.liferay.portal.service.persistence.GroupPersistence;
041    import com.liferay.portal.util.PortalUtil;
042    
043    import com.liferay.portlet.blogs.model.BlogsStatsUser;
044    import com.liferay.portlet.blogs.service.BlogsStatsUserLocalService;
045    import com.liferay.portlet.blogs.service.persistence.BlogsEntryFinder;
046    import com.liferay.portlet.blogs.service.persistence.BlogsEntryPersistence;
047    import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserFinder;
048    import com.liferay.portlet.blogs.service.persistence.BlogsStatsUserPersistence;
049    
050    import java.io.Serializable;
051    
052    import java.util.List;
053    
054    import javax.sql.DataSource;
055    
056    /**
057     * Provides the base implementation for the blogs stats user local service.
058     *
059     * <p>
060     * 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.blogs.service.impl.BlogsStatsUserLocalServiceImpl}.
061     * </p>
062     *
063     * @author Brian Wing Shun Chan
064     * @see com.liferay.portlet.blogs.service.impl.BlogsStatsUserLocalServiceImpl
065     * @see com.liferay.portlet.blogs.service.BlogsStatsUserLocalServiceUtil
066     * @generated
067     */
068    @ProviderType
069    public abstract class BlogsStatsUserLocalServiceBaseImpl
070            extends BaseLocalServiceImpl implements BlogsStatsUserLocalService,
071                    IdentifiableOSGiService {
072            /*
073             * NOTE FOR DEVELOPERS:
074             *
075             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.blogs.service.BlogsStatsUserLocalServiceUtil} to access the blogs stats user local service.
076             */
077    
078            /**
079             * Adds the blogs stats user to the database. Also notifies the appropriate model listeners.
080             *
081             * @param blogsStatsUser the blogs stats user
082             * @return the blogs stats user that was added
083             */
084            @Indexable(type = IndexableType.REINDEX)
085            @Override
086            public BlogsStatsUser addBlogsStatsUser(BlogsStatsUser blogsStatsUser) {
087                    blogsStatsUser.setNew(true);
088    
089                    return blogsStatsUserPersistence.update(blogsStatsUser);
090            }
091    
092            /**
093             * Creates a new blogs stats user with the primary key. Does not add the blogs stats user to the database.
094             *
095             * @param statsUserId the primary key for the new blogs stats user
096             * @return the new blogs stats user
097             */
098            @Override
099            public BlogsStatsUser createBlogsStatsUser(long statsUserId) {
100                    return blogsStatsUserPersistence.create(statsUserId);
101            }
102    
103            /**
104             * Deletes the blogs stats user with the primary key from the database. Also notifies the appropriate model listeners.
105             *
106             * @param statsUserId the primary key of the blogs stats user
107             * @return the blogs stats user that was removed
108             * @throws PortalException if a blogs stats user with the primary key could not be found
109             */
110            @Indexable(type = IndexableType.DELETE)
111            @Override
112            public BlogsStatsUser deleteBlogsStatsUser(long statsUserId)
113                    throws PortalException {
114                    return blogsStatsUserPersistence.remove(statsUserId);
115            }
116    
117            /**
118             * Deletes the blogs stats user from the database. Also notifies the appropriate model listeners.
119             *
120             * @param blogsStatsUser the blogs stats user
121             * @return the blogs stats user that was removed
122             */
123            @Indexable(type = IndexableType.DELETE)
124            @Override
125            public BlogsStatsUser deleteBlogsStatsUser(BlogsStatsUser blogsStatsUser) {
126                    return blogsStatsUserPersistence.remove(blogsStatsUser);
127            }
128    
129            @Override
130            public DynamicQuery dynamicQuery() {
131                    Class<?> clazz = getClass();
132    
133                    return DynamicQueryFactoryUtil.forClass(BlogsStatsUser.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             */
143            @Override
144            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
145                    return blogsStatsUserPersistence.findWithDynamicQuery(dynamicQuery);
146            }
147    
148            /**
149             * Performs a dynamic query on the database and returns a range of the matching rows.
150             *
151             * <p>
152             * 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.blogs.model.impl.BlogsStatsUserModelImpl}. 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.
153             * </p>
154             *
155             * @param dynamicQuery the dynamic query
156             * @param start the lower bound of the range of model instances
157             * @param end the upper bound of the range of model instances (not inclusive)
158             * @return the range of matching rows
159             */
160            @Override
161            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
162                    int end) {
163                    return blogsStatsUserPersistence.findWithDynamicQuery(dynamicQuery,
164                            start, end);
165            }
166    
167            /**
168             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
169             *
170             * <p>
171             * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. 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.blogs.model.impl.BlogsStatsUserModelImpl}. 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.
172             * </p>
173             *
174             * @param dynamicQuery the dynamic query
175             * @param start the lower bound of the range of model instances
176             * @param end the upper bound of the range of model instances (not inclusive)
177             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
178             * @return the ordered range of matching rows
179             */
180            @Override
181            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
182                    int end, OrderByComparator<T> orderByComparator) {
183                    return blogsStatsUserPersistence.findWithDynamicQuery(dynamicQuery,
184                            start, end, orderByComparator);
185            }
186    
187            /**
188             * Returns the number of rows matching the dynamic query.
189             *
190             * @param dynamicQuery the dynamic query
191             * @return the number of rows matching the dynamic query
192             */
193            @Override
194            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
195                    return blogsStatsUserPersistence.countWithDynamicQuery(dynamicQuery);
196            }
197    
198            /**
199             * Returns the number of rows matching the dynamic query.
200             *
201             * @param dynamicQuery the dynamic query
202             * @param projection the projection to apply to the query
203             * @return the number of rows matching the dynamic query
204             */
205            @Override
206            public long dynamicQueryCount(DynamicQuery dynamicQuery,
207                    Projection projection) {
208                    return blogsStatsUserPersistence.countWithDynamicQuery(dynamicQuery,
209                            projection);
210            }
211    
212            @Override
213            public BlogsStatsUser fetchBlogsStatsUser(long statsUserId) {
214                    return blogsStatsUserPersistence.fetchByPrimaryKey(statsUserId);
215            }
216    
217            /**
218             * Returns the blogs stats user with the primary key.
219             *
220             * @param statsUserId the primary key of the blogs stats user
221             * @return the blogs stats user
222             * @throws PortalException if a blogs stats user with the primary key could not be found
223             */
224            @Override
225            public BlogsStatsUser getBlogsStatsUser(long statsUserId)
226                    throws PortalException {
227                    return blogsStatsUserPersistence.findByPrimaryKey(statsUserId);
228            }
229    
230            @Override
231            public ActionableDynamicQuery getActionableDynamicQuery() {
232                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
233    
234                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.blogs.service.BlogsStatsUserLocalServiceUtil.getService());
235                    actionableDynamicQuery.setClassLoader(getClassLoader());
236                    actionableDynamicQuery.setModelClass(BlogsStatsUser.class);
237    
238                    actionableDynamicQuery.setPrimaryKeyPropertyName("statsUserId");
239    
240                    return actionableDynamicQuery;
241            }
242    
243            @Override
244            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
245                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
246    
247                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portlet.blogs.service.BlogsStatsUserLocalServiceUtil.getService());
248                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
249                    indexableActionableDynamicQuery.setModelClass(BlogsStatsUser.class);
250    
251                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName("statsUserId");
252    
253                    return indexableActionableDynamicQuery;
254            }
255    
256            protected void initActionableDynamicQuery(
257                    ActionableDynamicQuery actionableDynamicQuery) {
258                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.blogs.service.BlogsStatsUserLocalServiceUtil.getService());
259                    actionableDynamicQuery.setClassLoader(getClassLoader());
260                    actionableDynamicQuery.setModelClass(BlogsStatsUser.class);
261    
262                    actionableDynamicQuery.setPrimaryKeyPropertyName("statsUserId");
263            }
264    
265            /**
266             * @throws PortalException
267             */
268            @Override
269            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
270                    throws PortalException {
271                    return blogsStatsUserLocalService.deleteBlogsStatsUser((BlogsStatsUser)persistedModel);
272            }
273    
274            @Override
275            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
276                    throws PortalException {
277                    return blogsStatsUserPersistence.findByPrimaryKey(primaryKeyObj);
278            }
279    
280            /**
281             * Returns a range of all the blogs stats users.
282             *
283             * <p>
284             * 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.blogs.model.impl.BlogsStatsUserModelImpl}. 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.
285             * </p>
286             *
287             * @param start the lower bound of the range of blogs stats users
288             * @param end the upper bound of the range of blogs stats users (not inclusive)
289             * @return the range of blogs stats users
290             */
291            @Override
292            public List<BlogsStatsUser> getBlogsStatsUsers(int start, int end) {
293                    return blogsStatsUserPersistence.findAll(start, end);
294            }
295    
296            /**
297             * Returns the number of blogs stats users.
298             *
299             * @return the number of blogs stats users
300             */
301            @Override
302            public int getBlogsStatsUsersCount() {
303                    return blogsStatsUserPersistence.countAll();
304            }
305    
306            /**
307             * Updates the blogs stats user in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
308             *
309             * @param blogsStatsUser the blogs stats user
310             * @return the blogs stats user that was updated
311             */
312            @Indexable(type = IndexableType.REINDEX)
313            @Override
314            public BlogsStatsUser updateBlogsStatsUser(BlogsStatsUser blogsStatsUser) {
315                    return blogsStatsUserPersistence.update(blogsStatsUser);
316            }
317    
318            /**
319             * Returns the blogs stats user local service.
320             *
321             * @return the blogs stats user local service
322             */
323            public BlogsStatsUserLocalService getBlogsStatsUserLocalService() {
324                    return blogsStatsUserLocalService;
325            }
326    
327            /**
328             * Sets the blogs stats user local service.
329             *
330             * @param blogsStatsUserLocalService the blogs stats user local service
331             */
332            public void setBlogsStatsUserLocalService(
333                    BlogsStatsUserLocalService blogsStatsUserLocalService) {
334                    this.blogsStatsUserLocalService = blogsStatsUserLocalService;
335            }
336    
337            /**
338             * Returns the blogs stats user persistence.
339             *
340             * @return the blogs stats user persistence
341             */
342            public BlogsStatsUserPersistence getBlogsStatsUserPersistence() {
343                    return blogsStatsUserPersistence;
344            }
345    
346            /**
347             * Sets the blogs stats user persistence.
348             *
349             * @param blogsStatsUserPersistence the blogs stats user persistence
350             */
351            public void setBlogsStatsUserPersistence(
352                    BlogsStatsUserPersistence blogsStatsUserPersistence) {
353                    this.blogsStatsUserPersistence = blogsStatsUserPersistence;
354            }
355    
356            /**
357             * Returns the blogs stats user finder.
358             *
359             * @return the blogs stats user finder
360             */
361            public BlogsStatsUserFinder getBlogsStatsUserFinder() {
362                    return blogsStatsUserFinder;
363            }
364    
365            /**
366             * Sets the blogs stats user finder.
367             *
368             * @param blogsStatsUserFinder the blogs stats user finder
369             */
370            public void setBlogsStatsUserFinder(
371                    BlogsStatsUserFinder blogsStatsUserFinder) {
372                    this.blogsStatsUserFinder = blogsStatsUserFinder;
373            }
374    
375            /**
376             * Returns the counter local service.
377             *
378             * @return the counter local service
379             */
380            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
381                    return counterLocalService;
382            }
383    
384            /**
385             * Sets the counter local service.
386             *
387             * @param counterLocalService the counter local service
388             */
389            public void setCounterLocalService(
390                    com.liferay.counter.service.CounterLocalService counterLocalService) {
391                    this.counterLocalService = counterLocalService;
392            }
393    
394            /**
395             * Returns the group local service.
396             *
397             * @return the group local service
398             */
399            public com.liferay.portal.service.GroupLocalService getGroupLocalService() {
400                    return groupLocalService;
401            }
402    
403            /**
404             * Sets the group local service.
405             *
406             * @param groupLocalService the group local service
407             */
408            public void setGroupLocalService(
409                    com.liferay.portal.service.GroupLocalService groupLocalService) {
410                    this.groupLocalService = groupLocalService;
411            }
412    
413            /**
414             * Returns the group persistence.
415             *
416             * @return the group persistence
417             */
418            public GroupPersistence getGroupPersistence() {
419                    return groupPersistence;
420            }
421    
422            /**
423             * Sets the group persistence.
424             *
425             * @param groupPersistence the group persistence
426             */
427            public void setGroupPersistence(GroupPersistence groupPersistence) {
428                    this.groupPersistence = groupPersistence;
429            }
430    
431            /**
432             * Returns the group finder.
433             *
434             * @return the group finder
435             */
436            public GroupFinder getGroupFinder() {
437                    return groupFinder;
438            }
439    
440            /**
441             * Sets the group finder.
442             *
443             * @param groupFinder the group finder
444             */
445            public void setGroupFinder(GroupFinder groupFinder) {
446                    this.groupFinder = groupFinder;
447            }
448    
449            /**
450             * Returns the blogs entry local service.
451             *
452             * @return the blogs entry local service
453             */
454            public com.liferay.portlet.blogs.service.BlogsEntryLocalService getBlogsEntryLocalService() {
455                    return blogsEntryLocalService;
456            }
457    
458            /**
459             * Sets the blogs entry local service.
460             *
461             * @param blogsEntryLocalService the blogs entry local service
462             */
463            public void setBlogsEntryLocalService(
464                    com.liferay.portlet.blogs.service.BlogsEntryLocalService blogsEntryLocalService) {
465                    this.blogsEntryLocalService = blogsEntryLocalService;
466            }
467    
468            /**
469             * Returns the blogs entry persistence.
470             *
471             * @return the blogs entry persistence
472             */
473            public BlogsEntryPersistence getBlogsEntryPersistence() {
474                    return blogsEntryPersistence;
475            }
476    
477            /**
478             * Sets the blogs entry persistence.
479             *
480             * @param blogsEntryPersistence the blogs entry persistence
481             */
482            public void setBlogsEntryPersistence(
483                    BlogsEntryPersistence blogsEntryPersistence) {
484                    this.blogsEntryPersistence = blogsEntryPersistence;
485            }
486    
487            /**
488             * Returns the blogs entry finder.
489             *
490             * @return the blogs entry finder
491             */
492            public BlogsEntryFinder getBlogsEntryFinder() {
493                    return blogsEntryFinder;
494            }
495    
496            /**
497             * Sets the blogs entry finder.
498             *
499             * @param blogsEntryFinder the blogs entry finder
500             */
501            public void setBlogsEntryFinder(BlogsEntryFinder blogsEntryFinder) {
502                    this.blogsEntryFinder = blogsEntryFinder;
503            }
504    
505            public void afterPropertiesSet() {
506                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.blogs.model.BlogsStatsUser",
507                            blogsStatsUserLocalService);
508            }
509    
510            public void destroy() {
511                    persistedModelLocalServiceRegistry.unregister(
512                            "com.liferay.portlet.blogs.model.BlogsStatsUser");
513            }
514    
515            /**
516             * Returns the OSGi service identifier.
517             *
518             * @return the OSGi service identifier
519             */
520            @Override
521            public String getOSGiServiceIdentifier() {
522                    return BlogsStatsUserLocalService.class.getName();
523            }
524    
525            protected Class<?> getModelClass() {
526                    return BlogsStatsUser.class;
527            }
528    
529            protected String getModelClassName() {
530                    return BlogsStatsUser.class.getName();
531            }
532    
533            /**
534             * Performs a SQL query.
535             *
536             * @param sql the sql query
537             */
538            protected void runSQL(String sql) {
539                    try {
540                            DataSource dataSource = blogsStatsUserPersistence.getDataSource();
541    
542                            DB db = DBManagerUtil.getDB();
543    
544                            sql = db.buildSQL(sql);
545                            sql = PortalUtil.transformSQL(sql);
546    
547                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
548                                            sql, new int[0]);
549    
550                            sqlUpdate.update();
551                    }
552                    catch (Exception e) {
553                            throw new SystemException(e);
554                    }
555            }
556    
557            @BeanReference(type = com.liferay.portlet.blogs.service.BlogsStatsUserLocalService.class)
558            protected BlogsStatsUserLocalService blogsStatsUserLocalService;
559            @BeanReference(type = BlogsStatsUserPersistence.class)
560            protected BlogsStatsUserPersistence blogsStatsUserPersistence;
561            @BeanReference(type = BlogsStatsUserFinder.class)
562            protected BlogsStatsUserFinder blogsStatsUserFinder;
563            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
564            protected com.liferay.counter.service.CounterLocalService counterLocalService;
565            @BeanReference(type = com.liferay.portal.service.GroupLocalService.class)
566            protected com.liferay.portal.service.GroupLocalService groupLocalService;
567            @BeanReference(type = GroupPersistence.class)
568            protected GroupPersistence groupPersistence;
569            @BeanReference(type = GroupFinder.class)
570            protected GroupFinder groupFinder;
571            @BeanReference(type = com.liferay.portlet.blogs.service.BlogsEntryLocalService.class)
572            protected com.liferay.portlet.blogs.service.BlogsEntryLocalService blogsEntryLocalService;
573            @BeanReference(type = BlogsEntryPersistence.class)
574            protected BlogsEntryPersistence blogsEntryPersistence;
575            @BeanReference(type = BlogsEntryFinder.class)
576            protected BlogsEntryFinder blogsEntryFinder;
577            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
578            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
579    }