Class ClipService


  • @Service
    public class ClipService
    extends java.lang.Object

    ClipService provides a layer between ClipRepository and ClipController for business logic.

    This class also contains a nested enum, which enumerates types of lists of clips that can be returned by methods in this class.

    Since:
    1.0
    Version:
    1.0
    Author:
    Robert Dominugez, Roderick Frechette, Laura Steiner
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ClipService.Source
      The Source enum enumerates the different types of lists of clips available for access.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete​(Clip clip)
      Deletes a clip.
      java.util.Optional<Clip> get​(long id)
      Returns a single clip by id.
      java.util.List<Clip> getAllFiltered​(User user, int limit, int offset, ClipService.Source source)
      Returns a list of clips, limited and controlled by the parameters.
      java.util.List<Clip> getAllForDiscovery​(int limit, int offset)
      Returns all clips, limited by parameters.
      Clip post​(Clip clip)
      Posts a clip.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClipService

        @Autowired
        public ClipService​(ClipRepository clipRepository,
                           UserRepository userRepository,
                           RelationshipRepository relationshipRepository)
        Autowired constructor for ClipService.
        Parameters:
        clipRepository - ClipRepository
        userRepository - UserRepository
        relationshipRepository - RelationshipRepository
    • Method Detail

      • get

        public java.util.Optional<Clip> get​(long id)
        Returns a single clip by id.
        Parameters:
        id - long type
        Returns:
        Optional<Clip>
      • getAllFiltered

        public java.util.List<Clip> getAllFiltered​(User user,
                                                   int limit,
                                                   int offset,
                                                   ClipService.Source source)
        Returns a list of clips, limited and controlled by the parameters. The source parameter controls whether to return all clips, clips from the current user, or clips from the user's friends, follows, or relationships in general.
        Parameters:
        user - User
        limit - int
        offset - int
        source - Source
        Returns:
        List<Clips>
      • getAllForDiscovery

        public java.util.List<Clip> getAllForDiscovery​(int limit,
                                                       int offset)
        Returns all clips, limited by parameters. Does not require the current user to be authenticated, and so is used in Discovery mode for users who are not logged in.
        Parameters:
        limit - int
        offset - int
        Returns:
        List<Clips>
      • post

        public Clip post​(Clip clip)
        Posts a clip.
        Parameters:
        clip - Clip
        Returns:
        Clip
      • delete

        public void delete​(Clip clip)
        Deletes a clip.
        Parameters:
        clip - Clip