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.social.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.util.PortalUtil;
040    
041    import com.liferay.portlet.social.model.SocialActivitySet;
042    import com.liferay.portlet.social.service.SocialActivitySetLocalService;
043    import com.liferay.portlet.social.service.persistence.SocialActivityFinder;
044    import com.liferay.portlet.social.service.persistence.SocialActivityPersistence;
045    import com.liferay.portlet.social.service.persistence.SocialActivitySetFinder;
046    import com.liferay.portlet.social.service.persistence.SocialActivitySetPersistence;
047    
048    import java.io.Serializable;
049    
050    import java.util.List;
051    
052    import javax.sql.DataSource;
053    
054    /**
055     * Provides the base implementation for the social activity set local service.
056     *
057     * <p>
058     * This implementation exists only as a container for the default service methods generated by ServiceBuilder. All custom service methods should be put in {@link com.liferay.portlet.social.service.impl.SocialActivitySetLocalServiceImpl}.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portlet.social.service.impl.SocialActivitySetLocalServiceImpl
063     * @see com.liferay.portlet.social.service.SocialActivitySetLocalServiceUtil
064     * @generated
065     */
066    @ProviderType
067    public abstract class SocialActivitySetLocalServiceBaseImpl
068            extends BaseLocalServiceImpl implements SocialActivitySetLocalService,
069                    IdentifiableOSGiService {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.social.service.SocialActivitySetLocalServiceUtil} to access the social activity set local service.
074             */
075    
076            /**
077             * Adds the social activity set to the database. Also notifies the appropriate model listeners.
078             *
079             * @param socialActivitySet the social activity set
080             * @return the social activity set that was added
081             */
082            @Indexable(type = IndexableType.REINDEX)
083            @Override
084            public SocialActivitySet addSocialActivitySet(
085                    SocialActivitySet socialActivitySet) {
086                    socialActivitySet.setNew(true);
087    
088                    return socialActivitySetPersistence.update(socialActivitySet);
089            }
090    
091            /**
092             * Creates a new social activity set with the primary key. Does not add the social activity set to the database.
093             *
094             * @param activitySetId the primary key for the new social activity set
095             * @return the new social activity set
096             */
097            @Override
098            public SocialActivitySet createSocialActivitySet(long activitySetId) {
099                    return socialActivitySetPersistence.create(activitySetId);
100            }
101    
102            /**
103             * Deletes the social activity set with the primary key from the database. Also notifies the appropriate model listeners.
104             *
105             * @param activitySetId the primary key of the social activity set
106             * @return the social activity set that was removed
107             * @throws PortalException if a social activity set with the primary key could not be found
108             */
109            @Indexable(type = IndexableType.DELETE)
110            @Override
111            public SocialActivitySet deleteSocialActivitySet(long activitySetId)
112                    throws PortalException {
113                    return socialActivitySetPersistence.remove(activitySetId);
114            }
115    
116            /**
117             * Deletes the social activity set from the database. Also notifies the appropriate model listeners.
118             *
119             * @param socialActivitySet the social activity set
120             * @return the social activity set that was removed
121             */
122            @Indexable(type = IndexableType.DELETE)
123            @Override
124            public SocialActivitySet deleteSocialActivitySet(
125                    SocialActivitySet socialActivitySet) {
126                    return socialActivitySetPersistence.remove(socialActivitySet);
127            }
128    
129            @Override
130            public DynamicQuery dynamicQuery() {
131                    Class<?> clazz = getClass();
132    
133                    return DynamicQueryFactoryUtil.forClass(SocialActivitySet.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 socialActivitySetPersistence.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.social.model.impl.SocialActivitySetModelImpl}. 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 socialActivitySetPersistence.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.social.model.impl.SocialActivitySetModelImpl}. 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 socialActivitySetPersistence.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 socialActivitySetPersistence.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 socialActivitySetPersistence.countWithDynamicQuery(dynamicQuery,
209                            projection);
210            }
211    
212            @Override
213            public SocialActivitySet fetchSocialActivitySet(long activitySetId) {
214                    return socialActivitySetPersistence.fetchByPrimaryKey(activitySetId);
215            }
216    
217            /**
218             * Returns the social activity set with the primary key.
219             *
220             * @param activitySetId the primary key of the social activity set
221             * @return the social activity set
222             * @throws PortalException if a social activity set with the primary key could not be found
223             */
224            @Override
225            public SocialActivitySet getSocialActivitySet(long activitySetId)
226                    throws PortalException {
227                    return socialActivitySetPersistence.findByPrimaryKey(activitySetId);
228            }
229    
230            @Override
231            public ActionableDynamicQuery getActionableDynamicQuery() {
232                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
233    
234                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialActivitySetLocalServiceUtil.getService());
235                    actionableDynamicQuery.setClassLoader(getClassLoader());
236                    actionableDynamicQuery.setModelClass(SocialActivitySet.class);
237    
238                    actionableDynamicQuery.setPrimaryKeyPropertyName("activitySetId");
239    
240                    return actionableDynamicQuery;
241            }
242    
243            @Override
244            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
245                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
246    
247                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialActivitySetLocalServiceUtil.getService());
248                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
249                    indexableActionableDynamicQuery.setModelClass(SocialActivitySet.class);
250    
251                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName(
252                            "activitySetId");
253    
254                    return indexableActionableDynamicQuery;
255            }
256    
257            protected void initActionableDynamicQuery(
258                    ActionableDynamicQuery actionableDynamicQuery) {
259                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialActivitySetLocalServiceUtil.getService());
260                    actionableDynamicQuery.setClassLoader(getClassLoader());
261                    actionableDynamicQuery.setModelClass(SocialActivitySet.class);
262    
263                    actionableDynamicQuery.setPrimaryKeyPropertyName("activitySetId");
264            }
265    
266            /**
267             * @throws PortalException
268             */
269            @Override
270            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
271                    throws PortalException {
272                    return socialActivitySetLocalService.deleteSocialActivitySet((SocialActivitySet)persistedModel);
273            }
274    
275            @Override
276            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
277                    throws PortalException {
278                    return socialActivitySetPersistence.findByPrimaryKey(primaryKeyObj);
279            }
280    
281            /**
282             * Returns a range of all the social activity sets.
283             *
284             * <p>
285             * 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.social.model.impl.SocialActivitySetModelImpl}. 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.
286             * </p>
287             *
288             * @param start the lower bound of the range of social activity sets
289             * @param end the upper bound of the range of social activity sets (not inclusive)
290             * @return the range of social activity sets
291             */
292            @Override
293            public List<SocialActivitySet> getSocialActivitySets(int start, int end) {
294                    return socialActivitySetPersistence.findAll(start, end);
295            }
296    
297            /**
298             * Returns the number of social activity sets.
299             *
300             * @return the number of social activity sets
301             */
302            @Override
303            public int getSocialActivitySetsCount() {
304                    return socialActivitySetPersistence.countAll();
305            }
306    
307            /**
308             * Updates the social activity set in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
309             *
310             * @param socialActivitySet the social activity set
311             * @return the social activity set that was updated
312             */
313            @Indexable(type = IndexableType.REINDEX)
314            @Override
315            public SocialActivitySet updateSocialActivitySet(
316                    SocialActivitySet socialActivitySet) {
317                    return socialActivitySetPersistence.update(socialActivitySet);
318            }
319    
320            /**
321             * Returns the social activity set local service.
322             *
323             * @return the social activity set local service
324             */
325            public SocialActivitySetLocalService getSocialActivitySetLocalService() {
326                    return socialActivitySetLocalService;
327            }
328    
329            /**
330             * Sets the social activity set local service.
331             *
332             * @param socialActivitySetLocalService the social activity set local service
333             */
334            public void setSocialActivitySetLocalService(
335                    SocialActivitySetLocalService socialActivitySetLocalService) {
336                    this.socialActivitySetLocalService = socialActivitySetLocalService;
337            }
338    
339            /**
340             * Returns the social activity set persistence.
341             *
342             * @return the social activity set persistence
343             */
344            public SocialActivitySetPersistence getSocialActivitySetPersistence() {
345                    return socialActivitySetPersistence;
346            }
347    
348            /**
349             * Sets the social activity set persistence.
350             *
351             * @param socialActivitySetPersistence the social activity set persistence
352             */
353            public void setSocialActivitySetPersistence(
354                    SocialActivitySetPersistence socialActivitySetPersistence) {
355                    this.socialActivitySetPersistence = socialActivitySetPersistence;
356            }
357    
358            /**
359             * Returns the social activity set finder.
360             *
361             * @return the social activity set finder
362             */
363            public SocialActivitySetFinder getSocialActivitySetFinder() {
364                    return socialActivitySetFinder;
365            }
366    
367            /**
368             * Sets the social activity set finder.
369             *
370             * @param socialActivitySetFinder the social activity set finder
371             */
372            public void setSocialActivitySetFinder(
373                    SocialActivitySetFinder socialActivitySetFinder) {
374                    this.socialActivitySetFinder = socialActivitySetFinder;
375            }
376    
377            /**
378             * Returns the counter local service.
379             *
380             * @return the counter local service
381             */
382            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
383                    return counterLocalService;
384            }
385    
386            /**
387             * Sets the counter local service.
388             *
389             * @param counterLocalService the counter local service
390             */
391            public void setCounterLocalService(
392                    com.liferay.counter.service.CounterLocalService counterLocalService) {
393                    this.counterLocalService = counterLocalService;
394            }
395    
396            /**
397             * Returns the social activity local service.
398             *
399             * @return the social activity local service
400             */
401            public com.liferay.portlet.social.service.SocialActivityLocalService getSocialActivityLocalService() {
402                    return socialActivityLocalService;
403            }
404    
405            /**
406             * Sets the social activity local service.
407             *
408             * @param socialActivityLocalService the social activity local service
409             */
410            public void setSocialActivityLocalService(
411                    com.liferay.portlet.social.service.SocialActivityLocalService socialActivityLocalService) {
412                    this.socialActivityLocalService = socialActivityLocalService;
413            }
414    
415            /**
416             * Returns the social activity persistence.
417             *
418             * @return the social activity persistence
419             */
420            public SocialActivityPersistence getSocialActivityPersistence() {
421                    return socialActivityPersistence;
422            }
423    
424            /**
425             * Sets the social activity persistence.
426             *
427             * @param socialActivityPersistence the social activity persistence
428             */
429            public void setSocialActivityPersistence(
430                    SocialActivityPersistence socialActivityPersistence) {
431                    this.socialActivityPersistence = socialActivityPersistence;
432            }
433    
434            /**
435             * Returns the social activity finder.
436             *
437             * @return the social activity finder
438             */
439            public SocialActivityFinder getSocialActivityFinder() {
440                    return socialActivityFinder;
441            }
442    
443            /**
444             * Sets the social activity finder.
445             *
446             * @param socialActivityFinder the social activity finder
447             */
448            public void setSocialActivityFinder(
449                    SocialActivityFinder socialActivityFinder) {
450                    this.socialActivityFinder = socialActivityFinder;
451            }
452    
453            public void afterPropertiesSet() {
454                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.social.model.SocialActivitySet",
455                            socialActivitySetLocalService);
456            }
457    
458            public void destroy() {
459                    persistedModelLocalServiceRegistry.unregister(
460                            "com.liferay.portlet.social.model.SocialActivitySet");
461            }
462    
463            /**
464             * Returns the OSGi service identifier.
465             *
466             * @return the OSGi service identifier
467             */
468            @Override
469            public String getOSGiServiceIdentifier() {
470                    return SocialActivitySetLocalService.class.getName();
471            }
472    
473            protected Class<?> getModelClass() {
474                    return SocialActivitySet.class;
475            }
476    
477            protected String getModelClassName() {
478                    return SocialActivitySet.class.getName();
479            }
480    
481            /**
482             * Performs a SQL query.
483             *
484             * @param sql the sql query
485             */
486            protected void runSQL(String sql) {
487                    try {
488                            DataSource dataSource = socialActivitySetPersistence.getDataSource();
489    
490                            DB db = DBManagerUtil.getDB();
491    
492                            sql = db.buildSQL(sql);
493                            sql = PortalUtil.transformSQL(sql);
494    
495                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
496                                            sql, new int[0]);
497    
498                            sqlUpdate.update();
499                    }
500                    catch (Exception e) {
501                            throw new SystemException(e);
502                    }
503            }
504    
505            @BeanReference(type = com.liferay.portlet.social.service.SocialActivitySetLocalService.class)
506            protected SocialActivitySetLocalService socialActivitySetLocalService;
507            @BeanReference(type = SocialActivitySetPersistence.class)
508            protected SocialActivitySetPersistence socialActivitySetPersistence;
509            @BeanReference(type = SocialActivitySetFinder.class)
510            protected SocialActivitySetFinder socialActivitySetFinder;
511            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
512            protected com.liferay.counter.service.CounterLocalService counterLocalService;
513            @BeanReference(type = com.liferay.portlet.social.service.SocialActivityLocalService.class)
514            protected com.liferay.portlet.social.service.SocialActivityLocalService socialActivityLocalService;
515            @BeanReference(type = SocialActivityPersistence.class)
516            protected SocialActivityPersistence socialActivityPersistence;
517            @BeanReference(type = SocialActivityFinder.class)
518            protected SocialActivityFinder socialActivityFinder;
519            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
520            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
521    }