001    /**
002     * Copyright (c) 2000-2011 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;
016    
017    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
018    import com.liferay.portal.kernel.util.MethodCache;
019    import com.liferay.portal.kernel.util.ReferenceRegistry;
020    
021    /**
022     * The utility for the social relation local service. This utility wraps {@link com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl} and is the primary access point for service operations in application layer code running on the local server.
023     *
024     * <p>
025     * This is a local service. Methods of this service will not have security checks based on the propagated JAAS credentials because this service can only be accessed from within the same VM.
026     * </p>
027     *
028     * @author Brian Wing Shun Chan
029     * @see SocialRelationLocalService
030     * @see com.liferay.portlet.social.service.base.SocialRelationLocalServiceBaseImpl
031     * @see com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl
032     * @generated
033     */
034    public class SocialRelationLocalServiceUtil {
035            /*
036             * NOTE FOR DEVELOPERS:
037             *
038             * Never modify this class directly. Add custom service methods to {@link com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl} and rerun ServiceBuilder to regenerate this class.
039             */
040    
041            /**
042            * Adds the social relation to the database. Also notifies the appropriate model listeners.
043            *
044            * @param socialRelation the social relation
045            * @return the social relation that was added
046            * @throws SystemException if a system exception occurred
047            */
048            public static com.liferay.portlet.social.model.SocialRelation addSocialRelation(
049                    com.liferay.portlet.social.model.SocialRelation socialRelation)
050                    throws com.liferay.portal.kernel.exception.SystemException {
051                    return getService().addSocialRelation(socialRelation);
052            }
053    
054            /**
055            * Creates a new social relation with the primary key. Does not add the social relation to the database.
056            *
057            * @param relationId the primary key for the new social relation
058            * @return the new social relation
059            */
060            public static com.liferay.portlet.social.model.SocialRelation createSocialRelation(
061                    long relationId) {
062                    return getService().createSocialRelation(relationId);
063            }
064    
065            /**
066            * Deletes the social relation with the primary key from the database. Also notifies the appropriate model listeners.
067            *
068            * @param relationId the primary key of the social relation
069            * @throws PortalException if a social relation with the primary key could not be found
070            * @throws SystemException if a system exception occurred
071            */
072            public static void deleteSocialRelation(long relationId)
073                    throws com.liferay.portal.kernel.exception.PortalException,
074                            com.liferay.portal.kernel.exception.SystemException {
075                    getService().deleteSocialRelation(relationId);
076            }
077    
078            /**
079            * Deletes the social relation from the database. Also notifies the appropriate model listeners.
080            *
081            * @param socialRelation the social relation
082            * @throws SystemException if a system exception occurred
083            */
084            public static void deleteSocialRelation(
085                    com.liferay.portlet.social.model.SocialRelation socialRelation)
086                    throws com.liferay.portal.kernel.exception.SystemException {
087                    getService().deleteSocialRelation(socialRelation);
088            }
089    
090            /**
091            * Performs a dynamic query on the database and returns the matching rows.
092            *
093            * @param dynamicQuery the dynamic query
094            * @return the matching rows
095            * @throws SystemException if a system exception occurred
096            */
097            @SuppressWarnings("rawtypes")
098            public static java.util.List dynamicQuery(
099                    com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery)
100                    throws com.liferay.portal.kernel.exception.SystemException {
101                    return getService().dynamicQuery(dynamicQuery);
102            }
103    
104            /**
105            * Performs a dynamic query on the database and returns a range of the matching rows.
106            *
107            * <p>
108            * 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.
109            * </p>
110            *
111            * @param dynamicQuery the dynamic query
112            * @param start the lower bound of the range of model instances
113            * @param end the upper bound of the range of model instances (not inclusive)
114            * @return the range of matching rows
115            * @throws SystemException if a system exception occurred
116            */
117            @SuppressWarnings("rawtypes")
118            public static java.util.List dynamicQuery(
119                    com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
120                    int end) throws com.liferay.portal.kernel.exception.SystemException {
121                    return getService().dynamicQuery(dynamicQuery, start, end);
122            }
123    
124            /**
125            * Performs a dynamic query on the database and returns an ordered range of the matching rows.
126            *
127            * <p>
128            * 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.
129            * </p>
130            *
131            * @param dynamicQuery the dynamic query
132            * @param start the lower bound of the range of model instances
133            * @param end the upper bound of the range of model instances (not inclusive)
134            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
135            * @return the ordered range of matching rows
136            * @throws SystemException if a system exception occurred
137            */
138            @SuppressWarnings("rawtypes")
139            public static java.util.List dynamicQuery(
140                    com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start,
141                    int end,
142                    com.liferay.portal.kernel.util.OrderByComparator orderByComparator)
143                    throws com.liferay.portal.kernel.exception.SystemException {
144                    return getService()
145                                       .dynamicQuery(dynamicQuery, start, end, orderByComparator);
146            }
147    
148            /**
149            * Returns the number of rows that match the dynamic query.
150            *
151            * @param dynamicQuery the dynamic query
152            * @return the number of rows that match the dynamic query
153            * @throws SystemException if a system exception occurred
154            */
155            public static long dynamicQueryCount(
156                    com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery)
157                    throws com.liferay.portal.kernel.exception.SystemException {
158                    return getService().dynamicQueryCount(dynamicQuery);
159            }
160    
161            /**
162            * Returns the social relation with the primary key.
163            *
164            * @param relationId the primary key of the social relation
165            * @return the social relation
166            * @throws PortalException if a social relation with the primary key could not be found
167            * @throws SystemException if a system exception occurred
168            */
169            public static com.liferay.portlet.social.model.SocialRelation getSocialRelation(
170                    long relationId)
171                    throws com.liferay.portal.kernel.exception.PortalException,
172                            com.liferay.portal.kernel.exception.SystemException {
173                    return getService().getSocialRelation(relationId);
174            }
175    
176            public static com.liferay.portal.model.PersistedModel getPersistedModel(
177                    java.io.Serializable primaryKeyObj)
178                    throws com.liferay.portal.kernel.exception.PortalException,
179                            com.liferay.portal.kernel.exception.SystemException {
180                    return getService().getPersistedModel(primaryKeyObj);
181            }
182    
183            /**
184            * Returns a range of all the social relations.
185            *
186            * <p>
187            * 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.
188            * </p>
189            *
190            * @param start the lower bound of the range of social relations
191            * @param end the upper bound of the range of social relations (not inclusive)
192            * @return the range of social relations
193            * @throws SystemException if a system exception occurred
194            */
195            public static java.util.List<com.liferay.portlet.social.model.SocialRelation> getSocialRelations(
196                    int start, int end)
197                    throws com.liferay.portal.kernel.exception.SystemException {
198                    return getService().getSocialRelations(start, end);
199            }
200    
201            /**
202            * Returns the number of social relations.
203            *
204            * @return the number of social relations
205            * @throws SystemException if a system exception occurred
206            */
207            public static int getSocialRelationsCount()
208                    throws com.liferay.portal.kernel.exception.SystemException {
209                    return getService().getSocialRelationsCount();
210            }
211    
212            /**
213            * Updates the social relation in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
214            *
215            * @param socialRelation the social relation
216            * @return the social relation that was updated
217            * @throws SystemException if a system exception occurred
218            */
219            public static com.liferay.portlet.social.model.SocialRelation updateSocialRelation(
220                    com.liferay.portlet.social.model.SocialRelation socialRelation)
221                    throws com.liferay.portal.kernel.exception.SystemException {
222                    return getService().updateSocialRelation(socialRelation);
223            }
224    
225            /**
226            * Updates the social relation in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
227            *
228            * @param socialRelation the social relation
229            * @param merge whether to merge the social relation with the current session. See {@link com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session, com.liferay.portal.model.BaseModel, boolean)} for an explanation.
230            * @return the social relation that was updated
231            * @throws SystemException if a system exception occurred
232            */
233            public static com.liferay.portlet.social.model.SocialRelation updateSocialRelation(
234                    com.liferay.portlet.social.model.SocialRelation socialRelation,
235                    boolean merge)
236                    throws com.liferay.portal.kernel.exception.SystemException {
237                    return getService().updateSocialRelation(socialRelation, merge);
238            }
239    
240            /**
241            * Returns the Spring bean ID for this bean.
242            *
243            * @return the Spring bean ID for this bean
244            */
245            public static java.lang.String getBeanIdentifier() {
246                    return getService().getBeanIdentifier();
247            }
248    
249            /**
250            * Sets the Spring bean ID for this bean.
251            *
252            * @param beanIdentifier the Spring bean ID for this bean
253            */
254            public static void setBeanIdentifier(java.lang.String beanIdentifier) {
255                    getService().setBeanIdentifier(beanIdentifier);
256            }
257    
258            /**
259            * Adds a social relation between the two users to the database.
260            *
261            * @param userId1 the user that is the subject of the relation
262            * @param userId2 the user at the other end of the relation
263            * @param type the type of the relation
264            * @return the social relation
265            * @throws PortalException if the users could not be found, if the users
266            were not from the same company, or if either of the users was
267            the default user
268            * @throws SystemException if a system exception occurred
269            */
270            public static com.liferay.portlet.social.model.SocialRelation addRelation(
271                    long userId1, long userId2, int type)
272                    throws com.liferay.portal.kernel.exception.PortalException,
273                            com.liferay.portal.kernel.exception.SystemException {
274                    return getService().addRelation(userId1, userId2, type);
275            }
276    
277            /**
278            * Removes the relation (and its inverse in case of a bidirectional
279            * relation) from the database.
280            *
281            * @param relationId the primary key of the relation
282            * @throws PortalException if the relation could not be found
283            * @throws SystemException if a system exception occurred
284            */
285            public static void deleteRelation(long relationId)
286                    throws com.liferay.portal.kernel.exception.PortalException,
287                            com.liferay.portal.kernel.exception.SystemException {
288                    getService().deleteRelation(relationId);
289            }
290    
291            /**
292            * Removes the matching relation (and its inverse in case of a
293            * bidirectional relation) from the database.
294            *
295            * @param userId1 the user that is the subject of the relation
296            * @param userId2 the user at the other end of the relation
297            * @param type the relation's type
298            * @throws PortalException if the relation or its inverse relation (if
299            applicable) could not be found
300            * @throws SystemException if a system exception occurred
301            */
302            public static void deleteRelation(long userId1, long userId2, int type)
303                    throws com.liferay.portal.kernel.exception.PortalException,
304                            com.liferay.portal.kernel.exception.SystemException {
305                    getService().deleteRelation(userId1, userId2, type);
306            }
307    
308            /**
309            * Removes the relation (and its inverse in case of a bidirectional
310            * relation) from the database.
311            *
312            * @param relation the relation to be removed
313            * @throws PortalException if the relation is bidirectional and its inverse
314            relation could not be found
315            * @throws SystemException if a system exception occurred
316            */
317            public static void deleteRelation(
318                    com.liferay.portlet.social.model.SocialRelation relation)
319                    throws com.liferay.portal.kernel.exception.PortalException,
320                            com.liferay.portal.kernel.exception.SystemException {
321                    getService().deleteRelation(relation);
322            }
323    
324            /**
325            * Removes all relations involving the user from the database.
326            *
327            * @param userId the primary key of the user
328            * @throws SystemException if a system exception occurred
329            */
330            public static void deleteRelations(long userId)
331                    throws com.liferay.portal.kernel.exception.SystemException {
332                    getService().deleteRelations(userId);
333            }
334    
335            /**
336            * Removes all relations between User1 and User2.
337            *
338            * @param userId1 the user that is the subject of the relation
339            * @param userId2 the user at the other end of the relation
340            * @throws PortalException if the inverse relation could not be found
341            * @throws SystemException if a system exception occurred
342            */
343            public static void deleteRelations(long userId1, long userId2)
344                    throws com.liferay.portal.kernel.exception.PortalException,
345                            com.liferay.portal.kernel.exception.SystemException {
346                    getService().deleteRelations(userId1, userId2);
347            }
348    
349            /**
350            * Returns a range of all the inverse relations of the given type for which
351            * the user is User2 of the relation.
352            *
353            * <p>
354            * Useful when paginating results. Returns a maximum of <code>end -
355            * start</code> instances. <code>start</code> and <code>end</code> are not
356            * primary keys, they are indexes in the result set. Thus, <code>0</code>
357            * refers to the first result in the set. Setting both <code>start</code>
358            * and <code>end</code> to {@link
359            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the
360            * full result set.
361            * </p>
362            *
363            * @param userId the primary key of the user
364            * @param type the relation's type
365            * @param start the lower bound of the range of results
366            * @param end the upper bound of the range of results (not inclusive)
367            * @return the range of matching relations
368            * @throws SystemException if a system exception occurred
369            */
370            public static java.util.List<com.liferay.portlet.social.model.SocialRelation> getInverseRelations(
371                    long userId, int type, int start, int end)
372                    throws com.liferay.portal.kernel.exception.SystemException {
373                    return getService().getInverseRelations(userId, type, start, end);
374            }
375    
376            /**
377            * Returns the number of inverse relations of the given type for which the
378            * user is User2 of the relation.
379            *
380            * @param userId the primary key of the user
381            * @param type the relation's type
382            * @return the number of matching relations
383            * @throws SystemException if a system exception occurred
384            */
385            public static int getInverseRelationsCount(long userId, int type)
386                    throws com.liferay.portal.kernel.exception.SystemException {
387                    return getService().getInverseRelationsCount(userId, type);
388            }
389    
390            /**
391            * Returns the relation identified by its primary key.
392            *
393            * @param relationId the primary key of the relation
394            * @return Returns the relation
395            * @throws PortalException if the relation could not be found
396            * @throws SystemException if a system exception occurred
397            */
398            public static com.liferay.portlet.social.model.SocialRelation getRelation(
399                    long relationId)
400                    throws com.liferay.portal.kernel.exception.PortalException,
401                            com.liferay.portal.kernel.exception.SystemException {
402                    return getService().getRelation(relationId);
403            }
404    
405            /**
406            * Returns the relation of the given type between User1 and User2.
407            *
408            * @param userId1 the user that is the subject of the relation
409            * @param userId2 the user at the other end of the relation
410            * @param type the relation's type
411            * @return Returns the relation
412            * @throws PortalException if the relation could not be found
413            * @throws SystemException if a system exception occurred
414            */
415            public static com.liferay.portlet.social.model.SocialRelation getRelation(
416                    long userId1, long userId2, int type)
417                    throws com.liferay.portal.kernel.exception.PortalException,
418                            com.liferay.portal.kernel.exception.SystemException {
419                    return getService().getRelation(userId1, userId2, type);
420            }
421    
422            /**
423            * Returns a range of all the relations of the given type where the user is
424            * the subject of the relation.
425            *
426            * <p>
427            * Useful when paginating results. Returns a maximum of <code>end -
428            * start</code> instances. <code>start</code> and <code>end</code> are not
429            * primary keys, they are indexes in the result set. Thus, <code>0</code>
430            * refers to the first result in the set. Setting both <code>start</code>
431            * and <code>end</code> to {@link
432            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the
433            * full result set.
434            * </p>
435            *
436            * @param userId the primary key of the user
437            * @param type the relation's type
438            * @param start the lower bound of the range of results
439            * @param end the upper bound of the range of results (not inclusive)
440            * @return the range of relations
441            * @throws SystemException if a system exception occurred
442            */
443            public static java.util.List<com.liferay.portlet.social.model.SocialRelation> getRelations(
444                    long userId, int type, int start, int end)
445                    throws com.liferay.portal.kernel.exception.SystemException {
446                    return getService().getRelations(userId, type, start, end);
447            }
448    
449            /**
450            * Returns a range of all the relations between User1 and User2.
451            *
452            * <p>
453            * Useful when paginating results. Returns a maximum of <code>end -
454            * start</code> instances. <code>start</code> and <code>end</code> are not
455            * primary keys, they are indexes in the result set. Thus, <code>0</code>
456            * refers to the first result in the set. Setting both <code>start</code>
457            * and <code>end</code> to {@link
458            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the
459            * full result set.
460            * </p>
461            *
462            * @param userId1 the user that is the subject of the relation
463            * @param userId2 the user at the other end of the relation
464            * @param start the lower bound of the range of results
465            * @param end the upper bound of the range of results (not inclusive)
466            * @return the range of relations
467            * @throws SystemException if a system exception occurred
468            */
469            public static java.util.List<com.liferay.portlet.social.model.SocialRelation> getRelations(
470                    long userId1, long userId2, int start, int end)
471                    throws com.liferay.portal.kernel.exception.SystemException {
472                    return getService().getRelations(userId1, userId2, start, end);
473            }
474    
475            /**
476            * Returns the number of relations of the given type where the user is the
477            * subject of the relation.
478            *
479            * @param userId the primary key of the user
480            * @param type the relation's type
481            * @return the number of relations
482            * @throws SystemException if a system exception occurred
483            */
484            public static int getRelationsCount(long userId, int type)
485                    throws com.liferay.portal.kernel.exception.SystemException {
486                    return getService().getRelationsCount(userId, type);
487            }
488    
489            /**
490            * Returns the number of relations between User1 and User2.
491            *
492            * @param userId1 the user that is the subject of the relation
493            * @param userId2 the user at the other end of the relation
494            * @return the number of relations
495            * @throws SystemException if a system exception occurred
496            */
497            public static int getRelationsCount(long userId1, long userId2)
498                    throws com.liferay.portal.kernel.exception.SystemException {
499                    return getService().getRelationsCount(userId1, userId2);
500            }
501    
502            /**
503            * Returns <code>true</code> if a relation of the given type exists where
504            * the user with primary key <code>userId1</code> is User1 of the relation
505            * and the user with the primary key <code>userId2</code> is User2 of the
506            * relation.
507            *
508            * @param userId1 the user that is the subject of the relation
509            * @param userId2 the user at the other end of the relation
510            * @param type the relation's type
511            * @return <code>true</code> if the relation exists; <code>false</code>
512            otherwise
513            * @throws SystemException if a system exception occurred
514            */
515            public static boolean hasRelation(long userId1, long userId2, int type)
516                    throws com.liferay.portal.kernel.exception.SystemException {
517                    return getService().hasRelation(userId1, userId2, type);
518            }
519    
520            /**
521            * Returns <code>true</code> if the users can be in a relation of the given
522            * type where the user with primary key <code>userId1</code> is User1 of
523            * the relation and the user with the primary key <code>userId2</code> is
524            * User2 of the relation.
525            *
526            * <p>
527            * This method returns <code>false</code> if User1 and User2 are the same,
528            * if either user is the default user, or if a matching relation already
529            * exists.
530            * </p>
531            *
532            * @param userId1 the user that is the subject of the relation
533            * @param userId2 the user at the other end of the relation
534            * @param type the relation's type
535            * @return <code>true</code> if the two users can be in a new relation of
536            the given type; <code>false</code> otherwise
537            * @throws SystemException if a system exception occurred
538            */
539            public static boolean isRelatable(long userId1, long userId2, int type)
540                    throws com.liferay.portal.kernel.exception.SystemException {
541                    return getService().isRelatable(userId1, userId2, type);
542            }
543    
544            public static SocialRelationLocalService getService() {
545                    if (_service == null) {
546                            _service = (SocialRelationLocalService)PortalBeanLocatorUtil.locate(SocialRelationLocalService.class.getName());
547    
548                            ReferenceRegistry.registerReference(SocialRelationLocalServiceUtil.class,
549                                    "_service");
550                            MethodCache.remove(SocialRelationLocalService.class);
551                    }
552    
553                    return _service;
554            }
555    
556            public void setService(SocialRelationLocalService service) {
557                    MethodCache.remove(SocialRelationLocalService.class);
558    
559                    _service = service;
560    
561                    ReferenceRegistry.registerReference(SocialRelationLocalServiceUtil.class,
562                            "_service");
563                    MethodCache.remove(SocialRelationLocalService.class);
564            }
565    
566            private static SocialRelationLocalService _service;
567    }