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.service.persistence.ClassNamePersistence;
040    import com.liferay.portal.service.persistence.UserFinder;
041    import com.liferay.portal.service.persistence.UserPersistence;
042    import com.liferay.portal.util.PortalUtil;
043    
044    import com.liferay.portlet.social.model.SocialRequest;
045    import com.liferay.portlet.social.service.SocialRequestLocalService;
046    import com.liferay.portlet.social.service.persistence.SocialRequestPersistence;
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 request 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.SocialRequestLocalServiceImpl}.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portlet.social.service.impl.SocialRequestLocalServiceImpl
063     * @see com.liferay.portlet.social.service.SocialRequestLocalServiceUtil
064     * @generated
065     */
066    @ProviderType
067    public abstract class SocialRequestLocalServiceBaseImpl
068            extends BaseLocalServiceImpl implements SocialRequestLocalService,
069                    IdentifiableOSGiService {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.social.service.SocialRequestLocalServiceUtil} to access the social request local service.
074             */
075    
076            /**
077             * Adds the social request to the database. Also notifies the appropriate model listeners.
078             *
079             * @param socialRequest the social request
080             * @return the social request that was added
081             */
082            @Indexable(type = IndexableType.REINDEX)
083            @Override
084            public SocialRequest addSocialRequest(SocialRequest socialRequest) {
085                    socialRequest.setNew(true);
086    
087                    return socialRequestPersistence.update(socialRequest);
088            }
089    
090            /**
091             * Creates a new social request with the primary key. Does not add the social request to the database.
092             *
093             * @param requestId the primary key for the new social request
094             * @return the new social request
095             */
096            @Override
097            public SocialRequest createSocialRequest(long requestId) {
098                    return socialRequestPersistence.create(requestId);
099            }
100    
101            /**
102             * Deletes the social request with the primary key from the database. Also notifies the appropriate model listeners.
103             *
104             * @param requestId the primary key of the social request
105             * @return the social request that was removed
106             * @throws PortalException if a social request with the primary key could not be found
107             */
108            @Indexable(type = IndexableType.DELETE)
109            @Override
110            public SocialRequest deleteSocialRequest(long requestId)
111                    throws PortalException {
112                    return socialRequestPersistence.remove(requestId);
113            }
114    
115            /**
116             * Deletes the social request from the database. Also notifies the appropriate model listeners.
117             *
118             * @param socialRequest the social request
119             * @return the social request that was removed
120             */
121            @Indexable(type = IndexableType.DELETE)
122            @Override
123            public SocialRequest deleteSocialRequest(SocialRequest socialRequest) {
124                    return socialRequestPersistence.remove(socialRequest);
125            }
126    
127            @Override
128            public DynamicQuery dynamicQuery() {
129                    Class<?> clazz = getClass();
130    
131                    return DynamicQueryFactoryUtil.forClass(SocialRequest.class,
132                            clazz.getClassLoader());
133            }
134    
135            /**
136             * Performs a dynamic query on the database and returns the matching rows.
137             *
138             * @param dynamicQuery the dynamic query
139             * @return the matching rows
140             */
141            @Override
142            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery) {
143                    return socialRequestPersistence.findWithDynamicQuery(dynamicQuery);
144            }
145    
146            /**
147             * Performs a dynamic query on the database and returns a range of the matching rows.
148             *
149             * <p>
150             * 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.SocialRequestModelImpl}. 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.
151             * </p>
152             *
153             * @param dynamicQuery the dynamic query
154             * @param start the lower bound of the range of model instances
155             * @param end the upper bound of the range of model instances (not inclusive)
156             * @return the range of matching rows
157             */
158            @Override
159            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
160                    int end) {
161                    return socialRequestPersistence.findWithDynamicQuery(dynamicQuery,
162                            start, end);
163            }
164    
165            /**
166             * Performs a dynamic query on the database and returns an ordered range of the matching rows.
167             *
168             * <p>
169             * 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.SocialRequestModelImpl}. 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.
170             * </p>
171             *
172             * @param dynamicQuery the dynamic query
173             * @param start the lower bound of the range of model instances
174             * @param end the upper bound of the range of model instances (not inclusive)
175             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
176             * @return the ordered range of matching rows
177             */
178            @Override
179            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
180                    int end, OrderByComparator<T> orderByComparator) {
181                    return socialRequestPersistence.findWithDynamicQuery(dynamicQuery,
182                            start, end, orderByComparator);
183            }
184    
185            /**
186             * Returns the number of rows matching the dynamic query.
187             *
188             * @param dynamicQuery the dynamic query
189             * @return the number of rows matching the dynamic query
190             */
191            @Override
192            public long dynamicQueryCount(DynamicQuery dynamicQuery) {
193                    return socialRequestPersistence.countWithDynamicQuery(dynamicQuery);
194            }
195    
196            /**
197             * Returns the number of rows matching the dynamic query.
198             *
199             * @param dynamicQuery the dynamic query
200             * @param projection the projection to apply to the query
201             * @return the number of rows matching the dynamic query
202             */
203            @Override
204            public long dynamicQueryCount(DynamicQuery dynamicQuery,
205                    Projection projection) {
206                    return socialRequestPersistence.countWithDynamicQuery(dynamicQuery,
207                            projection);
208            }
209    
210            @Override
211            public SocialRequest fetchSocialRequest(long requestId) {
212                    return socialRequestPersistence.fetchByPrimaryKey(requestId);
213            }
214    
215            /**
216             * Returns the social request matching the UUID and group.
217             *
218             * @param uuid the social request's UUID
219             * @param groupId the primary key of the group
220             * @return the matching social request, or <code>null</code> if a matching social request could not be found
221             */
222            @Override
223            public SocialRequest fetchSocialRequestByUuidAndGroupId(String uuid,
224                    long groupId) {
225                    return socialRequestPersistence.fetchByUUID_G(uuid, groupId);
226            }
227    
228            /**
229             * Returns the social request with the primary key.
230             *
231             * @param requestId the primary key of the social request
232             * @return the social request
233             * @throws PortalException if a social request with the primary key could not be found
234             */
235            @Override
236            public SocialRequest getSocialRequest(long requestId)
237                    throws PortalException {
238                    return socialRequestPersistence.findByPrimaryKey(requestId);
239            }
240    
241            @Override
242            public ActionableDynamicQuery getActionableDynamicQuery() {
243                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
244    
245                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialRequestLocalServiceUtil.getService());
246                    actionableDynamicQuery.setClassLoader(getClassLoader());
247                    actionableDynamicQuery.setModelClass(SocialRequest.class);
248    
249                    actionableDynamicQuery.setPrimaryKeyPropertyName("requestId");
250    
251                    return actionableDynamicQuery;
252            }
253    
254            @Override
255            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
256                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
257    
258                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialRequestLocalServiceUtil.getService());
259                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
260                    indexableActionableDynamicQuery.setModelClass(SocialRequest.class);
261    
262                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName("requestId");
263    
264                    return indexableActionableDynamicQuery;
265            }
266    
267            protected void initActionableDynamicQuery(
268                    ActionableDynamicQuery actionableDynamicQuery) {
269                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialRequestLocalServiceUtil.getService());
270                    actionableDynamicQuery.setClassLoader(getClassLoader());
271                    actionableDynamicQuery.setModelClass(SocialRequest.class);
272    
273                    actionableDynamicQuery.setPrimaryKeyPropertyName("requestId");
274            }
275    
276            /**
277             * @throws PortalException
278             */
279            @Override
280            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
281                    throws PortalException {
282                    return socialRequestLocalService.deleteSocialRequest((SocialRequest)persistedModel);
283            }
284    
285            @Override
286            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
287                    throws PortalException {
288                    return socialRequestPersistence.findByPrimaryKey(primaryKeyObj);
289            }
290    
291            /**
292             * Returns all the social requests matching the UUID and company.
293             *
294             * @param uuid the UUID of the social requests
295             * @param companyId the primary key of the company
296             * @return the matching social requests, or an empty list if no matches were found
297             */
298            @Override
299            public List<SocialRequest> getSocialRequestsByUuidAndCompanyId(
300                    String uuid, long companyId) {
301                    return socialRequestPersistence.findByUuid_C(uuid, companyId);
302            }
303    
304            /**
305             * Returns a range of social requests matching the UUID and company.
306             *
307             * @param uuid the UUID of the social requests
308             * @param companyId the primary key of the company
309             * @param start the lower bound of the range of social requests
310             * @param end the upper bound of the range of social requests (not inclusive)
311             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
312             * @return the range of matching social requests, or an empty list if no matches were found
313             */
314            @Override
315            public List<SocialRequest> getSocialRequestsByUuidAndCompanyId(
316                    String uuid, long companyId, int start, int end,
317                    OrderByComparator<SocialRequest> orderByComparator) {
318                    return socialRequestPersistence.findByUuid_C(uuid, companyId, start,
319                            end, orderByComparator);
320            }
321    
322            /**
323             * Returns the social request matching the UUID and group.
324             *
325             * @param uuid the social request's UUID
326             * @param groupId the primary key of the group
327             * @return the matching social request
328             * @throws PortalException if a matching social request could not be found
329             */
330            @Override
331            public SocialRequest getSocialRequestByUuidAndGroupId(String uuid,
332                    long groupId) throws PortalException {
333                    return socialRequestPersistence.findByUUID_G(uuid, groupId);
334            }
335    
336            /**
337             * Returns a range of all the social requests.
338             *
339             * <p>
340             * 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.SocialRequestModelImpl}. 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.
341             * </p>
342             *
343             * @param start the lower bound of the range of social requests
344             * @param end the upper bound of the range of social requests (not inclusive)
345             * @return the range of social requests
346             */
347            @Override
348            public List<SocialRequest> getSocialRequests(int start, int end) {
349                    return socialRequestPersistence.findAll(start, end);
350            }
351    
352            /**
353             * Returns the number of social requests.
354             *
355             * @return the number of social requests
356             */
357            @Override
358            public int getSocialRequestsCount() {
359                    return socialRequestPersistence.countAll();
360            }
361    
362            /**
363             * Updates the social request in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
364             *
365             * @param socialRequest the social request
366             * @return the social request that was updated
367             */
368            @Indexable(type = IndexableType.REINDEX)
369            @Override
370            public SocialRequest updateSocialRequest(SocialRequest socialRequest) {
371                    return socialRequestPersistence.update(socialRequest);
372            }
373    
374            /**
375             * Returns the social request local service.
376             *
377             * @return the social request local service
378             */
379            public SocialRequestLocalService getSocialRequestLocalService() {
380                    return socialRequestLocalService;
381            }
382    
383            /**
384             * Sets the social request local service.
385             *
386             * @param socialRequestLocalService the social request local service
387             */
388            public void setSocialRequestLocalService(
389                    SocialRequestLocalService socialRequestLocalService) {
390                    this.socialRequestLocalService = socialRequestLocalService;
391            }
392    
393            /**
394             * Returns the social request persistence.
395             *
396             * @return the social request persistence
397             */
398            public SocialRequestPersistence getSocialRequestPersistence() {
399                    return socialRequestPersistence;
400            }
401    
402            /**
403             * Sets the social request persistence.
404             *
405             * @param socialRequestPersistence the social request persistence
406             */
407            public void setSocialRequestPersistence(
408                    SocialRequestPersistence socialRequestPersistence) {
409                    this.socialRequestPersistence = socialRequestPersistence;
410            }
411    
412            /**
413             * Returns the counter local service.
414             *
415             * @return the counter local service
416             */
417            public com.liferay.counter.service.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(
427                    com.liferay.counter.service.CounterLocalService counterLocalService) {
428                    this.counterLocalService = counterLocalService;
429            }
430    
431            /**
432             * Returns the class name local service.
433             *
434             * @return the class name local service
435             */
436            public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
437                    return classNameLocalService;
438            }
439    
440            /**
441             * Sets the class name local service.
442             *
443             * @param classNameLocalService the class name local service
444             */
445            public void setClassNameLocalService(
446                    com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
447                    this.classNameLocalService = classNameLocalService;
448            }
449    
450            /**
451             * Returns the class name persistence.
452             *
453             * @return the class name persistence
454             */
455            public ClassNamePersistence getClassNamePersistence() {
456                    return classNamePersistence;
457            }
458    
459            /**
460             * Sets the class name persistence.
461             *
462             * @param classNamePersistence the class name persistence
463             */
464            public void setClassNamePersistence(
465                    ClassNamePersistence classNamePersistence) {
466                    this.classNamePersistence = classNamePersistence;
467            }
468    
469            /**
470             * Returns the user local service.
471             *
472             * @return the user local service
473             */
474            public com.liferay.portal.service.UserLocalService getUserLocalService() {
475                    return userLocalService;
476            }
477    
478            /**
479             * Sets the user local service.
480             *
481             * @param userLocalService the user local service
482             */
483            public void setUserLocalService(
484                    com.liferay.portal.service.UserLocalService userLocalService) {
485                    this.userLocalService = userLocalService;
486            }
487    
488            /**
489             * Returns the user persistence.
490             *
491             * @return the user persistence
492             */
493            public UserPersistence getUserPersistence() {
494                    return userPersistence;
495            }
496    
497            /**
498             * Sets the user persistence.
499             *
500             * @param userPersistence the user persistence
501             */
502            public void setUserPersistence(UserPersistence userPersistence) {
503                    this.userPersistence = userPersistence;
504            }
505    
506            /**
507             * Returns the user finder.
508             *
509             * @return the user finder
510             */
511            public UserFinder getUserFinder() {
512                    return userFinder;
513            }
514    
515            /**
516             * Sets the user finder.
517             *
518             * @param userFinder the user finder
519             */
520            public void setUserFinder(UserFinder userFinder) {
521                    this.userFinder = userFinder;
522            }
523    
524            /**
525             * Returns the social request interpreter local service.
526             *
527             * @return the social request interpreter local service
528             */
529            public com.liferay.portlet.social.service.SocialRequestInterpreterLocalService getSocialRequestInterpreterLocalService() {
530                    return socialRequestInterpreterLocalService;
531            }
532    
533            /**
534             * Sets the social request interpreter local service.
535             *
536             * @param socialRequestInterpreterLocalService the social request interpreter local service
537             */
538            public void setSocialRequestInterpreterLocalService(
539                    com.liferay.portlet.social.service.SocialRequestInterpreterLocalService socialRequestInterpreterLocalService) {
540                    this.socialRequestInterpreterLocalService = socialRequestInterpreterLocalService;
541            }
542    
543            public void afterPropertiesSet() {
544                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.social.model.SocialRequest",
545                            socialRequestLocalService);
546            }
547    
548            public void destroy() {
549                    persistedModelLocalServiceRegistry.unregister(
550                            "com.liferay.portlet.social.model.SocialRequest");
551            }
552    
553            /**
554             * Returns the OSGi service identifier.
555             *
556             * @return the OSGi service identifier
557             */
558            @Override
559            public String getOSGiServiceIdentifier() {
560                    return SocialRequestLocalService.class.getName();
561            }
562    
563            protected Class<?> getModelClass() {
564                    return SocialRequest.class;
565            }
566    
567            protected String getModelClassName() {
568                    return SocialRequest.class.getName();
569            }
570    
571            /**
572             * Performs a SQL query.
573             *
574             * @param sql the sql query
575             */
576            protected void runSQL(String sql) {
577                    try {
578                            DataSource dataSource = socialRequestPersistence.getDataSource();
579    
580                            DB db = DBManagerUtil.getDB();
581    
582                            sql = db.buildSQL(sql);
583                            sql = PortalUtil.transformSQL(sql);
584    
585                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
586                                            sql, new int[0]);
587    
588                            sqlUpdate.update();
589                    }
590                    catch (Exception e) {
591                            throw new SystemException(e);
592                    }
593            }
594    
595            @BeanReference(type = com.liferay.portlet.social.service.SocialRequestLocalService.class)
596            protected SocialRequestLocalService socialRequestLocalService;
597            @BeanReference(type = SocialRequestPersistence.class)
598            protected SocialRequestPersistence socialRequestPersistence;
599            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
600            protected com.liferay.counter.service.CounterLocalService counterLocalService;
601            @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
602            protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
603            @BeanReference(type = ClassNamePersistence.class)
604            protected ClassNamePersistence classNamePersistence;
605            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
606            protected com.liferay.portal.service.UserLocalService userLocalService;
607            @BeanReference(type = UserPersistence.class)
608            protected UserPersistence userPersistence;
609            @BeanReference(type = UserFinder.class)
610            protected UserFinder userFinder;
611            @BeanReference(type = com.liferay.portlet.social.service.SocialRequestInterpreterLocalService.class)
612            protected com.liferay.portlet.social.service.SocialRequestInterpreterLocalService socialRequestInterpreterLocalService;
613            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
614            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
615    }