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.social.kernel.service;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery;
020    import com.liferay.portal.kernel.dao.orm.DynamicQuery;
021    import com.liferay.portal.kernel.dao.orm.IndexableActionableDynamicQuery;
022    import com.liferay.portal.kernel.dao.orm.Projection;
023    import com.liferay.portal.kernel.exception.PortalException;
024    import com.liferay.portal.kernel.exception.SystemException;
025    import com.liferay.portal.kernel.model.PersistedModel;
026    import com.liferay.portal.kernel.search.Indexable;
027    import com.liferay.portal.kernel.search.IndexableType;
028    import com.liferay.portal.kernel.service.BaseLocalService;
029    import com.liferay.portal.kernel.service.PersistedModelLocalService;
030    import com.liferay.portal.kernel.transaction.Isolation;
031    import com.liferay.portal.kernel.transaction.Propagation;
032    import com.liferay.portal.kernel.transaction.Transactional;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    
035    import com.liferay.social.kernel.model.SocialRelation;
036    
037    import java.io.Serializable;
038    
039    import java.util.List;
040    
041    /**
042     * Provides the local service interface for SocialRelation. Methods of this
043     * service will not have security checks based on the propagated JAAS
044     * credentials because this service can only be accessed from within the same
045     * VM.
046     *
047     * @author Brian Wing Shun Chan
048     * @see SocialRelationLocalServiceUtil
049     * @see com.liferay.portlet.social.service.base.SocialRelationLocalServiceBaseImpl
050     * @see com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl
051     * @generated
052     */
053    @ProviderType
054    @Transactional(isolation = Isolation.PORTAL, rollbackFor =  {
055            PortalException.class, SystemException.class})
056    public interface SocialRelationLocalService extends BaseLocalService,
057            PersistedModelLocalService {
058            /*
059             * NOTE FOR DEVELOPERS:
060             *
061             * Never modify or reference this interface directly. Always use {@link SocialRelationLocalServiceUtil} to access the social relation local service. Add custom service methods to {@link com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl} and rerun ServiceBuilder to automatically copy the method declarations to this interface.
062             */
063    
064            /**
065            * Adds a social relation between the two users to the database.
066            *
067            * @param userId1 the user that is the subject of the relation
068            * @param userId2 the user at the other end of the relation
069            * @param type the type of the relation
070            * @return the social relation
071            */
072            public SocialRelation addRelation(long userId1, long userId2, int type)
073                    throws PortalException;
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            public SocialRelation addSocialRelation(SocialRelation socialRelation);
083    
084            /**
085            * Creates a new social relation with the primary key. Does not add the social relation to the database.
086            *
087            * @param relationId the primary key for the new social relation
088            * @return the new social relation
089            */
090            public SocialRelation createSocialRelation(long relationId);
091    
092            /**
093            * @throws PortalException
094            */
095            @Override
096            public PersistedModel deletePersistedModel(PersistedModel persistedModel)
097                    throws PortalException;
098    
099            /**
100            * Removes the relation (and its inverse in case of a bidirectional
101            * relation) from the database.
102            *
103            * @param relation the relation to be removed
104            */
105            public void deleteRelation(SocialRelation relation)
106                    throws PortalException;
107    
108            /**
109            * Removes the relation (and its inverse in case of a bidirectional
110            * relation) from the database.
111            *
112            * @param relationId the primary key of the relation
113            */
114            public void deleteRelation(long relationId) throws PortalException;
115    
116            /**
117            * Removes the matching relation (and its inverse in case of a bidirectional
118            * relation) from the database.
119            *
120            * @param userId1 the user that is the subject of the relation
121            * @param userId2 the user at the other end of the relation
122            * @param type the relation's type
123            */
124            public void deleteRelation(long userId1, long userId2, int type)
125                    throws PortalException;
126    
127            /**
128            * Removes all relations involving the user from the database.
129            *
130            * @param userId the primary key of the user
131            */
132            public void deleteRelations(long userId);
133    
134            /**
135            * Removes all relations between User1 and User2.
136            *
137            * @param userId1 the user that is the subject of the relation
138            * @param userId2 the user at the other end of the relation
139            */
140            public void deleteRelations(long userId1, long userId2)
141                    throws PortalException;
142    
143            /**
144            * Deletes the social relation with the primary key from the database. Also notifies the appropriate model listeners.
145            *
146            * @param relationId the primary key of the social relation
147            * @return the social relation that was removed
148            * @throws PortalException if a social relation with the primary key could not be found
149            */
150            @Indexable(type = IndexableType.DELETE)
151            public SocialRelation deleteSocialRelation(long relationId)
152                    throws PortalException;
153    
154            /**
155            * Deletes the social relation from the database. Also notifies the appropriate model listeners.
156            *
157            * @param socialRelation the social relation
158            * @return the social relation that was removed
159            */
160            @Indexable(type = IndexableType.DELETE)
161            public SocialRelation deleteSocialRelation(SocialRelation socialRelation);
162    
163            public DynamicQuery dynamicQuery();
164    
165            /**
166            * Performs a dynamic query on the database and returns the matching rows.
167            *
168            * @param dynamicQuery the dynamic query
169            * @return the matching rows
170            */
171            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery);
172    
173            /**
174            * Performs a dynamic query on the database and returns a range of the matching rows.
175            *
176            * <p>
177            * 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.
178            * </p>
179            *
180            * @param dynamicQuery the dynamic query
181            * @param start the lower bound of the range of model instances
182            * @param end the upper bound of the range of model instances (not inclusive)
183            * @return the range of matching rows
184            */
185            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
186                    int end);
187    
188            /**
189            * Performs a dynamic query on the database and returns an ordered range of the matching rows.
190            *
191            * <p>
192            * 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.
193            * </p>
194            *
195            * @param dynamicQuery the dynamic query
196            * @param start the lower bound of the range of model instances
197            * @param end the upper bound of the range of model instances (not inclusive)
198            * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
199            * @return the ordered range of matching rows
200            */
201            public <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start,
202                    int end, OrderByComparator<T> orderByComparator);
203    
204            /**
205            * Returns the number of rows matching the dynamic query.
206            *
207            * @param dynamicQuery the dynamic query
208            * @return the number of rows matching the dynamic query
209            */
210            public long dynamicQueryCount(DynamicQuery dynamicQuery);
211    
212            /**
213            * Returns the number of rows matching the dynamic query.
214            *
215            * @param dynamicQuery the dynamic query
216            * @param projection the projection to apply to the query
217            * @return the number of rows matching the dynamic query
218            */
219            public long dynamicQueryCount(DynamicQuery dynamicQuery,
220                    Projection projection);
221    
222            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
223            public SocialRelation fetchSocialRelation(long relationId);
224    
225            /**
226            * Returns the social relation with the matching UUID and company.
227            *
228            * @param uuid the social relation's UUID
229            * @param companyId the primary key of the company
230            * @return the matching social relation, or <code>null</code> if a matching social relation could not be found
231            */
232            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
233            public SocialRelation fetchSocialRelationByUuidAndCompanyId(
234                    java.lang.String uuid, long companyId);
235    
236            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
237            public ActionableDynamicQuery getActionableDynamicQuery();
238    
239            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
240            public IndexableActionableDynamicQuery getIndexableActionableDynamicQuery();
241    
242            /**
243            * Returns a range of all the inverse relations of the given type for which
244            * the user is User2 of the relation.
245            *
246            * <p>
247            * Useful when paginating results. Returns a maximum of <code>end -
248            * start</code> instances. <code>start</code> and <code>end</code> are not
249            * primary keys, they are indexes in the result set. Thus, <code>0</code>
250            * refers to the first result in the set. Setting both <code>start</code>
251            * and <code>end</code> to {@link
252            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
253            * result set.
254            * </p>
255            *
256            * @param userId the primary key of the user
257            * @param type the relation's type
258            * @param start the lower bound of the range of results
259            * @param end the upper bound of the range of results (not inclusive)
260            * @return the range of matching relations
261            */
262            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
263            public List<SocialRelation> getInverseRelations(long userId, int type,
264                    int start, int end);
265    
266            /**
267            * Returns the number of inverse relations of the given type for which the
268            * user is User2 of the relation.
269            *
270            * @param userId the primary key of the user
271            * @param type the relation's type
272            * @return the number of matching relations
273            */
274            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
275            public int getInverseRelationsCount(long userId, int type);
276    
277            /**
278            * Returns the OSGi service identifier.
279            *
280            * @return the OSGi service identifier
281            */
282            public java.lang.String getOSGiServiceIdentifier();
283    
284            @Override
285            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
286            public PersistedModel getPersistedModel(Serializable primaryKeyObj)
287                    throws PortalException;
288    
289            /**
290            * Returns the relation identified by its primary key.
291            *
292            * @param relationId the primary key of the relation
293            * @return Returns the relation
294            */
295            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
296            public SocialRelation getRelation(long relationId)
297                    throws PortalException;
298    
299            /**
300            * Returns the relation of the given type between User1 and User2.
301            *
302            * @param userId1 the user that is the subject of the relation
303            * @param userId2 the user at the other end of the relation
304            * @param type the relation's type
305            * @return Returns the relation
306            */
307            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
308            public SocialRelation getRelation(long userId1, long userId2, int type)
309                    throws PortalException;
310    
311            /**
312            * Returns a range of all the relations of the given type where the user is
313            * the subject of the relation.
314            *
315            * <p>
316            * Useful when paginating results. Returns a maximum of <code>end -
317            * start</code> instances. <code>start</code> and <code>end</code> are not
318            * primary keys, they are indexes in the result set. Thus, <code>0</code>
319            * refers to the first result in the set. Setting both <code>start</code>
320            * and <code>end</code> to {@link
321            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
322            * result set.
323            * </p>
324            *
325            * @param userId the primary key of the user
326            * @param type the relation's type
327            * @param start the lower bound of the range of results
328            * @param end the upper bound of the range of results (not inclusive)
329            * @return the range of relations
330            */
331            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
332            public List<SocialRelation> getRelations(long userId, int type, int start,
333                    int end);
334    
335            /**
336            * Returns a range of all the relations between User1 and User2.
337            *
338            * <p>
339            * Useful when paginating results. Returns a maximum of <code>end -
340            * start</code> instances. <code>start</code> and <code>end</code> are not
341            * primary keys, they are indexes in the result set. Thus, <code>0</code>
342            * refers to the first result in the set. Setting both <code>start</code>
343            * and <code>end</code> to {@link
344            * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full
345            * result set.
346            * </p>
347            *
348            * @param userId1 the user that is the subject of the relation
349            * @param userId2 the user at the other end of the relation
350            * @param start the lower bound of the range of results
351            * @param end the upper bound of the range of results (not inclusive)
352            * @return the range of relations
353            */
354            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
355            public List<SocialRelation> getRelations(long userId1, long userId2,
356                    int start, int end);
357    
358            /**
359            * Returns the number of relations of the given type where the user is the
360            * subject of the relation.
361            *
362            * @param userId the primary key of the user
363            * @param type the relation's type
364            * @return the number of relations
365            */
366            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
367            public int getRelationsCount(long userId, int type);
368    
369            /**
370            * Returns the number of relations between User1 and User2.
371            *
372            * @param userId1 the user that is the subject of the relation
373            * @param userId2 the user at the other end of the relation
374            * @return the number of relations
375            */
376            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
377            public int getRelationsCount(long userId1, long userId2);
378    
379            /**
380            * Returns the social relation with the primary key.
381            *
382            * @param relationId the primary key of the social relation
383            * @return the social relation
384            * @throws PortalException if a social relation with the primary key could not be found
385            */
386            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
387            public SocialRelation getSocialRelation(long relationId)
388                    throws PortalException;
389    
390            /**
391            * Returns the social relation with the matching UUID and company.
392            *
393            * @param uuid the social relation's UUID
394            * @param companyId the primary key of the company
395            * @return the matching social relation
396            * @throws PortalException if a matching social relation could not be found
397            */
398            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
399            public SocialRelation getSocialRelationByUuidAndCompanyId(
400                    java.lang.String uuid, long companyId) throws PortalException;
401    
402            /**
403            * Returns a range of all the social relations.
404            *
405            * <p>
406            * 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.
407            * </p>
408            *
409            * @param start the lower bound of the range of social relations
410            * @param end the upper bound of the range of social relations (not inclusive)
411            * @return the range of social relations
412            */
413            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
414            public List<SocialRelation> getSocialRelations(int start, int end);
415    
416            /**
417            * Returns the number of social relations.
418            *
419            * @return the number of social relations
420            */
421            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
422            public int getSocialRelationsCount();
423    
424            /**
425            * Returns <code>true</code> if a relation of the given type exists where
426            * the user with primary key <code>userId1</code> is User1 of the relation
427            * and the user with the primary key <code>userId2</code> is User2 of the
428            * relation.
429            *
430            * @param userId1 the user that is the subject of the relation
431            * @param userId2 the user at the other end of the relation
432            * @param type the relation's type
433            * @return <code>true</code> if the relation exists; <code>false</code>
434            otherwise
435            */
436            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
437            public boolean hasRelation(long userId1, long userId2, int type);
438    
439            /**
440            * Returns <code>true</code> if the users can be in a relation of the given
441            * type where the user with primary key <code>userId1</code> is User1 of the
442            * relation and the user with the primary key <code>userId2</code> is User2
443            * of the relation.
444            *
445            * <p>
446            * This method returns <code>false</code> if User1 and User2 are the same,
447            * if either user is the default user, or if a matching relation already
448            * exists.
449            * </p>
450            *
451            * @param userId1 the user that is the subject of the relation
452            * @param userId2 the user at the other end of the relation
453            * @param type the relation's type
454            * @return <code>true</code> if the two users can be in a new relation of
455            the given type; <code>false</code> otherwise
456            */
457            @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
458            public boolean isRelatable(long userId1, long userId2, int type);
459    
460            /**
461            * Updates the social relation in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.
462            *
463            * @param socialRelation the social relation
464            * @return the social relation that was updated
465            */
466            @Indexable(type = IndexableType.REINDEX)
467            public SocialRelation updateSocialRelation(SocialRelation socialRelation);
468    }