Class ClipService
- java.lang.Object
-
- edu.cnm.deepdive.tunefull.service.ClipService
-
@Service public class ClipService extends java.lang.Object
ClipService
provides a layer betweenClipRepository
andClipController
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.
-
Constructor Summary
Constructors Constructor Description ClipService(ClipRepository clipRepository, UserRepository userRepository, RelationshipRepository relationshipRepository)
Autowired constructor forClipService
.
-
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.
-
-
-
Constructor Detail
-
ClipService
@Autowired public ClipService(ClipRepository clipRepository, UserRepository userRepository, RelationshipRepository relationshipRepository)
Autowired constructor forClipService
.- Parameters:
clipRepository
- ClipRepositoryuserRepository
- UserRepositoryrelationshipRepository
- 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
- Userlimit
- intoffset
- intsource
- 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
- intoffset
- int- Returns:
- List<Clips>
-
delete
public void delete(Clip clip)
Deletes a clip.- Parameters:
clip
- Clip
-
-