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