View Javadoc
1   /******************************************************************************
2    * Database.java - Interface into the BuckoVidLib database 
3    * 
4    * BuckoVidLib - The BuckoSoft Video Library
5    * Copyright(c) 2014 - Dick Balaska
6    * 
7    */
8   package com.buckosoft.BuckoVidLib.db;
9   
10  import java.util.List;
11  
12  import com.buckosoft.BuckoVidLib.domain.Actor;
13  import com.buckosoft.BuckoVidLib.domain.Director;
14  import com.buckosoft.BuckoVidLib.domain.FailedToRip;
15  import com.buckosoft.BuckoVidLib.domain.Genre;
16  import com.buckosoft.BuckoVidLib.domain.LibrarySection;
17  import com.buckosoft.BuckoVidLib.domain.TVSeason;
18  import com.buckosoft.BuckoVidLib.domain.UserAttribute;
19  import com.buckosoft.BuckoVidLib.domain.Video;
20  import com.buckosoft.BuckoVidLib.domain.VideoBase;
21  import com.buckosoft.BuckoVidLib.domain.VideoTexts;
22  import com.buckosoft.BuckoVidLib.domain.WishList;
23  import com.buckosoft.BuckoVidLib.domain.Writer;
24  
25  public interface Database {
26  	List<FailedToRip>	getFailedToRip();
27  	List<WishList>		getWishList();
28  	void				addWishList(WishList wishList);
29  	
30  	void					addLibrarySection(LibrarySection librarySection);
31  	LibrarySection			getLibrarySection(int key);
32  	List<LibrarySection>	getLibrarySections();
33  	
34  	/** Return the number of unique videos in the library
35  	 * @return The count
36  	 */
37  	int					getVideoCount();
38  	List<Integer>		getVideoIdsByActor(int key);
39  	List<Integer>		getVideoIdsByDirector(int key);
40  	List<Integer>		getVideoIdsByWriter(int key);
41  	List<Integer>		getVideoIdsByGenre(int key);
42  
43  	/** Return the tagline and summary texts for the video. <br>
44  	 * Texts are urlencoded on disk and decoded in memory.
45  	 * @param id the videoId to fetch
46  	 * @return A VideoTexts that has at least one of tagline or summary.  May be null if neither present.
47  	 */
48  	VideoTexts			getVideoTexts(int id);
49  	int					getMaxVideoTextsSummaryLength();
50  	int					getMaxVideoTextsTaglineLength();
51  
52  	/** Reset to empty all of the tables */
53  	void			truncateLibrary();
54  	
55  	void			addActor(Actor actor);
56  	Actor			getActor(int actorId);
57  	Actor			getActor(String actorName);
58  	List<Actor>		getActors();
59  	List<Actor>		findActors(String key, int limit);
60  
61  	void			addWriter(Writer writer);
62  	Writer			getWriter(int writerId);
63  	Writer			getWriter(String writerName);
64  	List<Writer>	getWriters();
65  	List<Writer>	findWriters(String key, int limit);
66  	
67  	void			addDirector(Director director);
68  	Director		getDirector(int directorId);
69  	Director		getDirector(String directorName);
70  	List<Director>	getDirectors();
71  	List<Director>	findDirectors(String key, int limit);
72  	
73  	void			addGenre(Genre genre);
74  	Genre			getGenre(int genreId);
75  	Genre			getGenre(String genreTag);
76  	List<Genre>		getGenres();
77  	List<Genre>		findGenres(String key, int limit);
78  
79  	void			saveVideo(Video video);
80  	Video			getVideo(int videoId);
81  	List<Video>		getVideos();
82  
83  	/** Delete this Video and all of its related records
84  	 * @param vb The VideoBase to delete
85  	 */
86  	void			deleteVideo(VideoBase vb);
87  
88  	/** Return a list of Videos with this id.
89  	 * 
90  	 *  This is a dumb function just for debugging.
91  	 *  There can be only one video per id, but hibernate is freaking out.
92  	 * @param videoId The id to look up.
93  	 * @return Better be a list of 1
94  	 */
95  	//List<Video>		getVideos(int videoId);
96  
97  	/** Get the VideoBase with this videoId.
98  	 * @param videoId The id to fetch.
99  	 * @return The VideoBase or null if not found.
100 	 */
101 	VideoBase		getVideoBase(int videoId);
102 	List<VideoBase>	getVideoBases();
103 
104 	void			saveTVSeason(TVSeason season);
105 	TVSeason		getTVSeason(int seasonId);
106 	List<TVSeason>	getTVSeasons();
107 
108 	/** Return a list of TVSeasons for a show
109 	 * @param videoId The show to lookup
110 	 * @return A list, maybe empty.
111 	 */
112 	List<TVSeason>	getTVSeasons(int videoId);
113 	
114 	/** Get a TV Season based on its plex key
115 	 * @param key The plex key to lookup
116 	 * @return A TVSeason, null if not found.
117 	 */
118 	TVSeason		getTVSeasonFromHashKey(int key);
119 
120 	/** Get the UserAttributes for this userId.
121 	 * {@link com.buckosoft.BuckoVidLib.domain.User} parses these into his working attributes.
122 	 * @param userId The id of this user
123 	 * @return A list
124 	 */
125 	List<UserAttribute>		getUserAttributes(int userId);
126 	void					saveUserAttributes(List<UserAttribute> list);
127 }