Liferay 6.1.2-ce-ga3

com.liferay.portlet.social.service.impl
Class SocialRelationLocalServiceImpl

java.lang.Object
  extended by com.liferay.portal.service.BaseLocalServiceImpl
      extended by com.liferay.portlet.social.service.base.SocialRelationLocalServiceBaseImpl
          extended by com.liferay.portlet.social.service.impl.SocialRelationLocalServiceImpl
All Implemented Interfaces:
IdentifiableBean, BaseLocalService, PersistedModelLocalService, SocialRelationLocalService

public class SocialRelationLocalServiceImpl
extends SocialRelationLocalServiceBaseImpl

The social relation local service. This service provides methods to handle unidirectional or bidirectional relations between users.

Relations between users can be unidirectional or bidirectional. The type of relation is determined by an integer constant. Some example relations are co-worker, friend, romantic partner, sibling, spouse, child, enemy, follower, parent, subordinate, supervisor.

The two users participating in the relation are designated as User1 and User2. In case of unidirectional relations User1 should always be the subject of the relation. You can use the following English sentence to find out which user to use as User1 and which to use as User2:

User1 is <relation> of User2 (e.g. User1 is parent of User2; User1 is supervisor of User2)

For bidirectional relations, the service automatically generates the inverse relation.


Field Summary
 
Fields inherited from class com.liferay.portlet.social.service.base.SocialRelationLocalServiceBaseImpl
counterLocalService, persistedModelLocalServiceRegistry, resourceFinder, resourceLocalService, resourcePersistence, resourceService, socialActivityAchievementLocalService, socialActivityAchievementPersistence, socialActivityCounterFinder, socialActivityCounterLocalService, socialActivityCounterPersistence, socialActivityFinder, socialActivityInterpreterLocalService, socialActivityLimitLocalService, socialActivityLimitPersistence, socialActivityLocalService, socialActivityPersistence, socialActivitySettingLocalService, socialActivitySettingPersistence, socialActivitySettingService, socialRelationLocalService, socialRelationPersistence, socialRequestInterpreterLocalService, socialRequestLocalService, socialRequestPersistence, userFinder, userLocalService, userPersistence, userService
 
Constructor Summary
SocialRelationLocalServiceImpl()
           
 
Method Summary
 SocialRelation addRelation(long userId1, long userId2, int type)
          Adds a social relation between the two users to the database.
 void deleteRelation(long relationId)
          Removes the relation (and its inverse in case of a bidirectional relation) from the database.
 void deleteRelation(long userId1, long userId2, int type)
          Removes the matching relation (and its inverse in case of a bidirectional relation) from the database.
 void deleteRelation(SocialRelation relation)
          Removes the relation (and its inverse in case of a bidirectional relation) from the database.
 void deleteRelations(long userId)
          Removes all relations involving the user from the database.
 void deleteRelations(long userId1, long userId2)
          Removes all relations between User1 and User2.
 List<SocialRelation> getInverseRelations(long userId, int type, int start, int end)
          Returns a range of all the inverse relations of the given type for which the user is User2 of the relation.
 int getInverseRelationsCount(long userId, int type)
          Returns the number of inverse relations of the given type for which the user is User2 of the relation.
 SocialRelation getRelation(long relationId)
          Returns the relation identified by its primary key.
 SocialRelation getRelation(long userId1, long userId2, int type)
          Returns the relation of the given type between User1 and User2.
 List<SocialRelation> getRelations(long userId, int type, int start, int end)
          Returns a range of all the relations of the given type where the user is the subject of the relation.
 List<SocialRelation> getRelations(long userId1, long userId2, int start, int end)
          Returns a range of all the relations between User1 and User2.
 int getRelationsCount(long userId, int type)
          Returns the number of relations of the given type where the user is the subject of the relation.
 int getRelationsCount(long userId1, long userId2)
          Returns the number of relations between User1 and User2.
 boolean hasRelation(long userId1, long userId2, int type)
          Returns true if a relation of the given type exists where the user with primary key userId1 is User1 of the relation and the user with the primary key userId2 is User2 of the relation.
 boolean isRelatable(long userId1, long userId2, int type)
          Returns true if the users can be in a relation of the given type where the user with primary key userId1 is User1 of the relation and the user with the primary key userId2 is User2 of the relation.
 
Methods inherited from class com.liferay.portlet.social.service.base.SocialRelationLocalServiceBaseImpl
addSocialRelation, afterPropertiesSet, createSocialRelation, deleteSocialRelation, deleteSocialRelation, destroy, dynamicQuery, dynamicQuery, dynamicQuery, dynamicQuery, dynamicQueryCount, fetchSocialRelation, getBeanIdentifier, getCounterLocalService, getModelClass, getModelClassName, getPersistedModel, getResourceFinder, getResourceLocalService, getResourcePersistence, getResourceService, getSocialActivityAchievementLocalService, getSocialActivityAchievementPersistence, getSocialActivityCounterFinder, getSocialActivityCounterLocalService, getSocialActivityCounterPersistence, getSocialActivityFinder, getSocialActivityInterpreterLocalService, getSocialActivityLimitLocalService, getSocialActivityLimitPersistence, getSocialActivityLocalService, getSocialActivityPersistence, getSocialActivitySettingLocalService, getSocialActivitySettingPersistence, getSocialActivitySettingService, getSocialRelation, getSocialRelationLocalService, getSocialRelationPersistence, getSocialRelations, getSocialRelationsCount, getSocialRequestInterpreterLocalService, getSocialRequestLocalService, getSocialRequestPersistence, getUserFinder, getUserLocalService, getUserPersistence, getUserService, runSQL, setBeanIdentifier, setCounterLocalService, setResourceFinder, setResourceLocalService, setResourcePersistence, setResourceService, setSocialActivityAchievementLocalService, setSocialActivityAchievementPersistence, setSocialActivityCounterFinder, setSocialActivityCounterLocalService, setSocialActivityCounterPersistence, setSocialActivityFinder, setSocialActivityInterpreterLocalService, setSocialActivityLimitLocalService, setSocialActivityLimitPersistence, setSocialActivityLocalService, setSocialActivityPersistence, setSocialActivitySettingLocalService, setSocialActivitySettingPersistence, setSocialActivitySettingService, setSocialRelationLocalService, setSocialRelationPersistence, setSocialRequestInterpreterLocalService, setSocialRequestLocalService, setSocialRequestPersistence, setUserFinder, setUserLocalService, setUserPersistence, setUserService, updateSocialRelation, updateSocialRelation
 
Methods inherited from class com.liferay.portal.service.BaseLocalServiceImpl
getClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocialRelationLocalServiceImpl

public SocialRelationLocalServiceImpl()
Method Detail

addRelation

public SocialRelation addRelation(long userId1,
                                  long userId2,
                                  int type)
                           throws PortalException,
                                  SystemException
Adds a social relation between the two users to the database.

Parameters:
userId1 - the user that is the subject of the relation
userId2 - the user at the other end of the relation
type - the type of the relation
Returns:
the social relation
Throws:
PortalException - if the users could not be found, if the users were not from the same company, or if either of the users was the default user
SystemException - if a system exception occurred

deleteRelation

public void deleteRelation(long relationId)
                    throws PortalException,
                           SystemException
Removes the relation (and its inverse in case of a bidirectional relation) from the database.

Parameters:
relationId - the primary key of the relation
Throws:
PortalException - if the relation could not be found
SystemException - if a system exception occurred

deleteRelation

public void deleteRelation(long userId1,
                           long userId2,
                           int type)
                    throws PortalException,
                           SystemException
Removes the matching relation (and its inverse in case of a bidirectional relation) from the database.

Parameters:
userId1 - the user that is the subject of the relation
userId2 - the user at the other end of the relation
type - the relation's type
Throws:
PortalException - if the relation or its inverse relation (if applicable) could not be found
SystemException - if a system exception occurred

deleteRelation

public void deleteRelation(SocialRelation relation)
                    throws PortalException,
                           SystemException
Removes the relation (and its inverse in case of a bidirectional relation) from the database.

Parameters:
relation - the relation to be removed
Throws:
PortalException - if the relation is bidirectional and its inverse relation could not be found
SystemException - if a system exception occurred

deleteRelations

public void deleteRelations(long userId)
                     throws SystemException
Removes all relations involving the user from the database.

Parameters:
userId - the primary key of the user
Throws:
SystemException - if a system exception occurred

deleteRelations

public void deleteRelations(long userId1,
                            long userId2)
                     throws PortalException,
                            SystemException
Removes all relations between User1 and User2.

Parameters:
userId1 - the user that is the subject of the relation
userId2 - the user at the other end of the relation
Throws:
PortalException - if the inverse relation could not be found
SystemException - if a system exception occurred

getInverseRelations

public List<SocialRelation> getInverseRelations(long userId,
                                                int type,
                                                int start,
                                                int end)
                                         throws SystemException
Returns a range of all the inverse relations of the given type for which the user is User2 of the relation.

Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
userId - the primary key of the user
type - the relation's type
start - the lower bound of the range of results
end - the upper bound of the range of results (not inclusive)
Returns:
the range of matching relations
Throws:
SystemException - if a system exception occurred

getInverseRelationsCount

public int getInverseRelationsCount(long userId,
                                    int type)
                             throws SystemException
Returns the number of inverse relations of the given type for which the user is User2 of the relation.

Parameters:
userId - the primary key of the user
type - the relation's type
Returns:
the number of matching relations
Throws:
SystemException - if a system exception occurred

getRelation

public SocialRelation getRelation(long relationId)
                           throws PortalException,
                                  SystemException
Returns the relation identified by its primary key.

Parameters:
relationId - the primary key of the relation
Returns:
Returns the relation
Throws:
PortalException - if the relation could not be found
SystemException - if a system exception occurred

getRelation

public SocialRelation getRelation(long userId1,
                                  long userId2,
                                  int type)
                           throws PortalException,
                                  SystemException
Returns the relation of the given type between User1 and User2.

Parameters:
userId1 - the user that is the subject of the relation
userId2 - the user at the other end of the relation
type - the relation's type
Returns:
Returns the relation
Throws:
PortalException - if the relation could not be found
SystemException - if a system exception occurred

getRelations

public List<SocialRelation> getRelations(long userId,
                                         int type,
                                         int start,
                                         int end)
                                  throws SystemException
Returns a range of all the relations of the given type where the user is the subject of the relation.

Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
userId - the primary key of the user
type - the relation's type
start - the lower bound of the range of results
end - the upper bound of the range of results (not inclusive)
Returns:
the range of relations
Throws:
SystemException - if a system exception occurred

getRelations

public List<SocialRelation> getRelations(long userId1,
                                         long userId2,
                                         int start,
                                         int end)
                                  throws SystemException
Returns a range of all the relations between User1 and User2.

Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
userId1 - the user that is the subject of the relation
userId2 - the user at the other end of the relation
start - the lower bound of the range of results
end - the upper bound of the range of results (not inclusive)
Returns:
the range of relations
Throws:
SystemException - if a system exception occurred

getRelationsCount

public int getRelationsCount(long userId,
                             int type)
                      throws SystemException
Returns the number of relations of the given type where the user is the subject of the relation.

Parameters:
userId - the primary key of the user
type - the relation's type
Returns:
the number of relations
Throws:
SystemException - if a system exception occurred

getRelationsCount

public int getRelationsCount(long userId1,
                             long userId2)
                      throws SystemException
Returns the number of relations between User1 and User2.

Parameters:
userId1 - the user that is the subject of the relation
userId2 - the user at the other end of the relation
Returns:
the number of relations
Throws:
SystemException - if a system exception occurred

hasRelation

public boolean hasRelation(long userId1,
                           long userId2,
                           int type)
                    throws SystemException
Returns true if a relation of the given type exists where the user with primary key userId1 is User1 of the relation and the user with the primary key userId2 is User2 of the relation.

Parameters:
userId1 - the user that is the subject of the relation
userId2 - the user at the other end of the relation
type - the relation's type
Returns:
true if the relation exists; false otherwise
Throws:
SystemException - if a system exception occurred

isRelatable

public boolean isRelatable(long userId1,
                           long userId2,
                           int type)
                    throws SystemException
Returns true if the users can be in a relation of the given type where the user with primary key userId1 is User1 of the relation and the user with the primary key userId2 is User2 of the relation.

This method returns false if User1 and User2 are the same, if either user is the default user, or if a matching relation already exists.

Parameters:
userId1 - the user that is the subject of the relation
userId2 - the user at the other end of the relation
type - the relation's type
Returns:
true if the two users can be in a new relation of the given type; false otherwise
Throws:
SystemException - if a system exception occurred

Liferay 6.1.2-ce-ga3