Class RelationshipService


  • @Service
    public class RelationshipService
    extends java.lang.Object
    RelationshipService provides a layer between RelationshipRepository and RelationshipController for business logic.
    Since:
    1.0
    Version:
    1.0
    Author:
    Robert Dominugez, Roderick Frechette, Laura Steiner
    • 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 - User
        requested - 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 - User
        followed - 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 - Relationship
        accepted - boolean
        Returns:
        the boolean that has been set