Class InvitationService


  • @Service
    public class InvitationService
    extends Object
    Author:
    Bensalem Nabil
    • Field Detail

      • INVITATION_ALREADY_EXISTING

        public static final int INVITATION_ALREADY_EXISTING
        Predefined status code for an invitation already existing at relationship invitation.
        See Also:
        Constant Field Values
      • RELATIONSHIP_ALREADY_EXISTING

        public static final int RELATIONSHIP_ALREADY_EXISTING
        Predefined status code for a relationship already existing between two users at invitation acceptance.
        See Also:
        Constant Field Values
      • INVITATION_NOT_EXISTING

        public static final int INVITATION_NOT_EXISTING
        Predefined status code for a non existing invitation at invitation acceptance.
        See Also:
        Constant Field Values
    • Method Detail

      • invite

        public int invite​(Invitation invitation)
        send invitation
        Parameters:
        invitation - an Invitation object
        Returns:
        the following integer value
        • -1 if the invitation already exists
        • -2 if the relationship already exists
        • the id of invitation if the adding has been done successfully
      • ignoreInvitation

        public void ignoreInvitation​(int id)
        ignore this invitation
        Parameters:
        id - the invitation identifier to ignore (delete)
      • acceptInvitation

        public int acceptInvitation​(int idInvitation)
        accept invitation between sender and receiver and create the relationship
        Parameters:
        idInvitation - invitation identifier
        Returns:
        -1 if this Invitation not exists, -2 if the RelationShip already exists, else the id of RelationShip if the action has been done successfully
      • getAllMyInvitationsSent

        public List<Invitation> getAllMyInvitationsSent​(int userId)
        return all my invitations sent
        Parameters:
        userId - the user identifier
        Returns:
        a list of invitations
      • getAllMyInvitationsReceive

        public List<Invitation> getAllMyInvitationsReceive​(int myId)
      • getInvitation

        public Invitation getInvitation​(int id)
      • getInvitation

        public Invitation getInvitation​(int senderId,
                                        int receiverId)
      • deleteAllMyInvitations

        public void deleteAllMyInvitations​(String userId)
        Deletes all the invitations both sent and received of the specified user.
        Parameters:
        userId - the unique identifier of the user.