Class RelationshipService
- java.lang.Object
-
- edu.cnm.deepdive.tunefull.service.RelationshipService
-
@Service public class RelationshipService extends java.lang.ObjectRelationshipServiceprovides a layer betweenRelationshipRepositoryandRelationshipControllerfor business logic.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Robert Dominugez, Roderick Frechette, Laura Steiner
-
-
Constructor Summary
Constructors Constructor Description RelationshipService(RelationshipRepository relationshipRepository)Autowired constructor for RelationshipService.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<Relationship>get(long id)Gets the Relationship by its id, if it exists.java.util.List<Relationship>getFollows(User user)Gets all the Relationships in which the user is following other usersjava.util.List<Relationship>getFriendships(User user)Gets the Relationship between two users, using the two users as parameters.java.util.List<Relationship>getPending(User user)Gets all the Relationships in which the user has been sent a friend request and the user has not responded yet.RelationshiprequestFriendship(User requester, User requested)Creates a relationship between two users by sending a friend request.Relationshipsave(Relationship relationship)Saves the relationship to the repository.booleansetFriendshipAccepted(Relationship friendship, boolean accepted)Sets the boolean that determines whether a relationship is a friendship or not.RelationshipstartFollowing(User follower, User followed)Creates a relationship between two users in which one is following the other.
-
-
-
Constructor Detail
-
RelationshipService
@Autowired public RelationshipService(RelationshipRepository relationshipRepository)
Autowired constructor for RelationshipService.- Parameters:
relationshipRepository- RelationshipRepository
-
-
Method Detail
-
get
public java.util.Optional<Relationship> get(long id)
Gets the Relationship by its id, if it exists.- Parameters:
id- long- Returns:
- Optional<Relationship>
-
getFriendships
public java.util.List<Relationship> getFriendships(User user)
Gets the Relationship between two users, using the two users as parameters.- Parameters:
user- User- Returns:
- List<Relationships>
-
getFollows
public java.util.List<Relationship> getFollows(User user)
Gets all the Relationships in which the user is following other users- Parameters:
user- User- Returns:
- List<Relationships>
-
getPending
public java.util.List<Relationship> getPending(User user)
Gets all the Relationships in which the user has been sent a friend request and the user has not responded yet.- Parameters:
user- User- Returns:
- List<Relationships>
-
requestFriendship
public Relationship requestFriendship(User requester, User requested)
Creates a relationship between two users by sending a friend request.- Parameters:
requester- Userrequested- User- Returns:
- the relationship that was created
-
startFollowing
public Relationship startFollowing(User follower, User followed)
Creates a relationship between two users in which one is following the other.- Parameters:
follower- Userfollowed- User- Returns:
- the relationship that was created
-
save
public Relationship save(Relationship relationship)
Saves the relationship to the repository.- Parameters:
relationship- Relationship- Returns:
- returns the relationship that was saved
-
setFriendshipAccepted
public boolean setFriendshipAccepted(Relationship friendship, boolean accepted)
Sets the boolean that determines whether a relationship is a friendship or not.- Parameters:
friendship- Relationshipaccepted- boolean- Returns:
- the boolean that has been set
-
-