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.SocialRelation;
045    import com.liferay.portlet.social.service.SocialRelationLocalService;
046    import com.liferay.portlet.social.service.persistence.SocialRelationPersistence;
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 relation 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.SocialRelationLocalServiceImpl}.
059     * </p>
060     *
061     * @author Brian Wing Shun Chan
062     * @see com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl
063     * @see com.liferay.portlet.social.service.SocialRelationLocalServiceUtil
064     * @generated
065     */
066    @ProviderType
067    public abstract class SocialRelationLocalServiceBaseImpl
068            extends BaseLocalServiceImpl implements SocialRelationLocalService,
069                    IdentifiableOSGiService {
070            /*
071             * NOTE FOR DEVELOPERS:
072             *
073             * Never modify or reference this class directly. Always use {@link com.liferay.portlet.social.service.SocialRelationLocalServiceUtil} to access the social relation local service.
074             */
075    
076            /**
077             * Adds the social relation to the database. Also notifies the appropriate model listeners.
078             *
079             * @param socialRelation the social relation
080             * @return the social relation that was added
081             */
082            @Indexable(type = IndexableType.REINDEX)
083            @Override
084            public SocialRelation addSocialRelation(SocialRelation socialRelation) {
085                    socialRelation.setNew(true);
086    
087                    return socialRelationPersistence.update(socialRelation);
088            }
089    
090            /**
091             * Creates a new social relation with the primary key. Does not add the social relation to the database.
092             *
093             * @param relationId the primary key for the new social relation
094             * @return the new social relation
095             */
096            @Override
097            public SocialRelation createSocialRelation(long relationId) {
098                    return socialRelationPersistence.create(relationId);
099            }
100    
101            /**
102             * Deletes the social relation with the primary key from the database. Also notifies the appropriate model listeners.
103             *
104             * @param relationId the primary key of the social relation
105             * @return the social relation that was removed
106             * @throws PortalException if a social relation with the primary key could not be found
107             */
108            @Indexable(type = IndexableType.DELETE)
109            @Override
110            public SocialRelation deleteSocialRelation(long relationId)
111                    throws PortalException {
112                    return socialRelationPersistence.remove(relationId);
113            }
114    
115            /**
116             * Deletes the social relation from the database. Also notifies the appropriate model listeners.
117             *
118             * @param socialRelation the social relation
119             * @return the social relation that was removed
120             */
121            @Indexable(type = IndexableType.DELETE)
122            @Override
123            public SocialRelation deleteSocialRelation(SocialRelation socialRelation) {
124                    return socialRelationPersistence.remove(socialRelation);
125            }
126    
127            @Override
128            public DynamicQuery dynamicQuery() {
129                    Class<?> clazz = getClass();
130    
131                    return DynamicQueryFactoryUtil.forClass(SocialRelation.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 socialRelationPersistence.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.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.
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 socialRelationPersistence.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.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.
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 socialRelationPersistence.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 socialRelationPersistence.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 socialRelationPersistence.countWithDynamicQuery(dynamicQuery,
207                            projection);
208            }
209    
210            @Override
211            public SocialRelation fetchSocialRelation(long relationId) {
212                    return socialRelationPersistence.fetchByPrimaryKey(relationId);
213            }
214    
215            /**
216             * Returns the social relation with the matching UUID and company.
217             *
218             * @param uuid the social relation's UUID
219             * @param companyId the primary key of the company
220             * @return the matching social relation, or <code>null</code> if a matching social relation could not be found
221             */
222            @Override
223            public SocialRelation fetchSocialRelationByUuidAndCompanyId(String uuid,
224                    long companyId) {
225                    return socialRelationPersistence.fetchByUuid_C_First(uuid, companyId,
226                            null);
227            }
228    
229            /**
230             * Returns the social relation with the primary key.
231             *
232             * @param relationId the primary key of the social relation
233             * @return the social relation
234             * @throws PortalException if a social relation with the primary key could not be found
235             */
236            @Override
237            public SocialRelation getSocialRelation(long relationId)
238                    throws PortalException {
239                    return socialRelationPersistence.findByPrimaryKey(relationId);
240            }
241    
242            @Override
243            public ActionableDynamicQuery getActionableDynamicQuery() {
244                    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();
245    
246                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialRelationLocalServiceUtil.getService());
247                    actionableDynamicQuery.setClassLoader(getClassLoader());
248                    actionableDynamicQuery.setModelClass(SocialRelation.class);
249    
250                    actionableDynamicQuery.setPrimaryKeyPropertyName("relationId");
251    
252                    return actionableDynamicQuery;
253            }
254    
255            @Override
256            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery() {
257                    IndexableActionableDynamicQuery indexableActionableDynamicQuery = new IndexableActionableDynamicQuery();
258    
259                    indexableActionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialRelationLocalServiceUtil.getService());
260                    indexableActionableDynamicQuery.setClassLoader(getClassLoader());
261                    indexableActionableDynamicQuery.setModelClass(SocialRelation.class);
262    
263                    indexableActionableDynamicQuery.setPrimaryKeyPropertyName("relationId");
264    
265                    return indexableActionableDynamicQuery;
266            }
267    
268            protected void initActionableDynamicQuery(
269                    ActionableDynamicQuery actionableDynamicQuery) {
270                    actionableDynamicQuery.setBaseLocalService(com.liferay.portlet.social.service.SocialRelationLocalServiceUtil.getService());
271                    actionableDynamicQuery.setClassLoader(getClassLoader());
272                    actionableDynamicQuery.setModelClass(SocialRelation.class);
273    
274                    actionableDynamicQuery.setPrimaryKeyPropertyName("relationId");
275            }
276    
277            /**
278             * @throws PortalException
279             */
280            @Override
281            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
282                    throws PortalException {
283                    return socialRelationLocalService.deleteSocialRelation((SocialRelation)persistedModel);
284            }
285    
286            @Override
287            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
288                    throws PortalException {
289                    return socialRelationPersistence.findByPrimaryKey(primaryKeyObj);
290            }
291    
292            /**
293             * Returns the social relation with the matching UUID and company.
294             *
295             * @param uuid the social relation's UUID
296             * @param companyId the primary key of the company
297             * @return the matching social relation
298             * @throws PortalException if a matching social relation could not be found
299             */
300            @Override
301            public SocialRelation getSocialRelationByUuidAndCompanyId(String uuid,
302                    long companyId) throws PortalException {
303                    return socialRelationPersistence.findByUuid_C_First(uuid, companyId,
304                            null);
305            }
306    
307            /**
308             * Returns a range of all the social relations.
309             *
310             * <p>
311             * 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.
312             * </p>
313             *
314             * @param start the lower bound of the range of social relations
315             * @param end the upper bound of the range of social relations (not inclusive)
316             * @return the range of social relations
317             */
318            @Override
319            public List<SocialRelation> getSocialRelations(int start, int end) {
320                    return socialRelationPersistence.findAll(start, end);
321            }
322    
323            /**
324             * Returns the number of social relations.
325             *
326             * @return the number of social relations
327             */
328            @Override
329            public int getSocialRelationsCount() {
330                    return socialRelationPersistence.countAll();
331            }
332    
333            /**
334             * Updates the social relation in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
335             *
336             * @param socialRelation the social relation
337             * @return the social relation that was updated
338             */
339            @Indexable(type = IndexableType.REINDEX)
340            @Override
341            public SocialRelation updateSocialRelation(SocialRelation socialRelation) {
342                    return socialRelationPersistence.update(socialRelation);
343            }
344    
345            /**
346             * Returns the social relation local service.
347             *
348             * @return the social relation local service
349             */
350            public SocialRelationLocalService getSocialRelationLocalService() {
351                    return socialRelationLocalService;
352            }
353    
354            /**
355             * Sets the social relation local service.
356             *
357             * @param socialRelationLocalService the social relation local service
358             */
359            public void setSocialRelationLocalService(
360                    SocialRelationLocalService socialRelationLocalService) {
361                    this.socialRelationLocalService = socialRelationLocalService;
362            }
363    
364            /**
365             * Returns the social relation persistence.
366             *
367             * @return the social relation persistence
368             */
369            public SocialRelationPersistence getSocialRelationPersistence() {
370                    return socialRelationPersistence;
371            }
372    
373            /**
374             * Sets the social relation persistence.
375             *
376             * @param socialRelationPersistence the social relation persistence
377             */
378            public void setSocialRelationPersistence(
379                    SocialRelationPersistence socialRelationPersistence) {
380                    this.socialRelationPersistence = socialRelationPersistence;
381            }
382    
383            /**
384             * Returns the counter local service.
385             *
386             * @return the counter local service
387             */
388            public com.liferay.counter.service.CounterLocalService getCounterLocalService() {
389                    return counterLocalService;
390            }
391    
392            /**
393             * Sets the counter local service.
394             *
395             * @param counterLocalService the counter local service
396             */
397            public void setCounterLocalService(
398                    com.liferay.counter.service.CounterLocalService counterLocalService) {
399                    this.counterLocalService = counterLocalService;
400            }
401    
402            /**
403             * Returns the class name local service.
404             *
405             * @return the class name local service
406             */
407            public com.liferay.portal.service.ClassNameLocalService getClassNameLocalService() {
408                    return classNameLocalService;
409            }
410    
411            /**
412             * Sets the class name local service.
413             *
414             * @param classNameLocalService the class name local service
415             */
416            public void setClassNameLocalService(
417                    com.liferay.portal.service.ClassNameLocalService classNameLocalService) {
418                    this.classNameLocalService = classNameLocalService;
419            }
420    
421            /**
422             * Returns the class name persistence.
423             *
424             * @return the class name persistence
425             */
426            public ClassNamePersistence getClassNamePersistence() {
427                    return classNamePersistence;
428            }
429    
430            /**
431             * Sets the class name persistence.
432             *
433             * @param classNamePersistence the class name persistence
434             */
435            public void setClassNamePersistence(
436                    ClassNamePersistence classNamePersistence) {
437                    this.classNamePersistence = classNamePersistence;
438            }
439    
440            /**
441             * Returns the user local service.
442             *
443             * @return the user local service
444             */
445            public com.liferay.portal.service.UserLocalService getUserLocalService() {
446                    return userLocalService;
447            }
448    
449            /**
450             * Sets the user local service.
451             *
452             * @param userLocalService the user local service
453             */
454            public void setUserLocalService(
455                    com.liferay.portal.service.UserLocalService userLocalService) {
456                    this.userLocalService = userLocalService;
457            }
458    
459            /**
460             * Returns the user persistence.
461             *
462             * @return the user persistence
463             */
464            public UserPersistence getUserPersistence() {
465                    return userPersistence;
466            }
467    
468            /**
469             * Sets the user persistence.
470             *
471             * @param userPersistence the user persistence
472             */
473            public void setUserPersistence(UserPersistence userPersistence) {
474                    this.userPersistence = userPersistence;
475            }
476    
477            /**
478             * Returns the user finder.
479             *
480             * @return the user finder
481             */
482            public UserFinder getUserFinder() {
483                    return userFinder;
484            }
485    
486            /**
487             * Sets the user finder.
488             *
489             * @param userFinder the user finder
490             */
491            public void setUserFinder(UserFinder userFinder) {
492                    this.userFinder = userFinder;
493            }
494    
495            public void afterPropertiesSet() {
496                    persistedModelLocalServiceRegistry.register("com.liferay.portlet.social.model.SocialRelation",
497                            socialRelationLocalService);
498            }
499    
500            public void destroy() {
501                    persistedModelLocalServiceRegistry.unregister(
502                            "com.liferay.portlet.social.model.SocialRelation");
503            }
504    
505            /**
506             * Returns the OSGi service identifier.
507             *
508             * @return the OSGi service identifier
509             */
510            @Override
511            public String getOSGiServiceIdentifier() {
512                    return SocialRelationLocalService.class.getName();
513            }
514    
515            protected Class<?> getModelClass() {
516                    return SocialRelation.class;
517            }
518    
519            protected String getModelClassName() {
520                    return SocialRelation.class.getName();
521            }
522    
523            /**
524             * Performs a SQL query.
525             *
526             * @param sql the sql query
527             */
528            protected void runSQL(String sql) {
529                    try {
530                            DataSource dataSource = socialRelationPersistence.getDataSource();
531    
532                            DB db = DBManagerUtil.getDB();
533    
534                            sql = db.buildSQL(sql);
535                            sql = PortalUtil.transformSQL(sql);
536    
537                            SqlUpdate sqlUpdate = SqlUpdateFactoryUtil.getSqlUpdate(dataSource,
538                                            sql, new int[0]);
539    
540                            sqlUpdate.update();
541                    }
542                    catch (Exception e) {
543                            throw new SystemException(e);
544                    }
545            }
546    
547            @BeanReference(type = com.liferay.portlet.social.service.SocialRelationLocalService.class)
548            protected SocialRelationLocalService socialRelationLocalService;
549            @BeanReference(type = SocialRelationPersistence.class)
550            protected SocialRelationPersistence socialRelationPersistence;
551            @BeanReference(type = com.liferay.counter.service.CounterLocalService.class)
552            protected com.liferay.counter.service.CounterLocalService counterLocalService;
553            @BeanReference(type = com.liferay.portal.service.ClassNameLocalService.class)
554            protected com.liferay.portal.service.ClassNameLocalService classNameLocalService;
555            @BeanReference(type = ClassNamePersistence.class)
556            protected ClassNamePersistence classNamePersistence;
557            @BeanReference(type = com.liferay.portal.service.UserLocalService.class)
558            protected com.liferay.portal.service.UserLocalService userLocalService;
559            @BeanReference(type = UserPersistence.class)
560            protected UserPersistence userPersistence;
561            @BeanReference(type = UserFinder.class)
562            protected UserFinder userFinder;
563            @BeanReference(type = PersistedModelLocalServiceRegistry.class)
564            protected PersistedModelLocalServiceRegistry persistedModelLocalServiceRegistry;
565    }