1 /******************************************************************************
2 * Video.java - domain object
3 * $Id: Video.java,v 1.16 2015/05/14 04:58:21 dick Exp $
4 *
5 * BuckoVidLib - The BuckoSoft Video Library
6 * Copyright(c) 2014 - Dick Balaska
7 *
8 * $Log: Video.java,v $
9 * Revision 1.16 2015/05/14 04:58:21 dick
10 * We don't need updatedAt in VideoBase anymore. Move it to Video.
11 *
12 * Revision 1.15 2015/05/11 17:52:58 dick
13 * Better alpha sorting. VideoBase gets a sortIndex which is derived from Video's sortTitle.
14 *
15 * Revision 1.14 2015/04/30 03:18:04 dick
16 * Deal mostly with VideoBase. Only fetch full Video when we really need it.
17 * Protect all (most) calls to the restricted section of the library by session.
18 *
19 * Revision 1.13 2015/04/29 14:34:08 dick
20 * Break up Video into base class VideoBase and Video.
21 * All of the parts to define a Video are in VideoBase.
22 * The idea is that I'm going to be throwing a lot of these things around, and I really don't
23 * want the memory baggage of Summaries and Actor Lists, when really, I just want the
24 * name of the video.
25 *
26 * Revision 1.12 2015/04/28 09:55:36 dick
27 * We don't need to store the urls. They can be derived.
28 *
29 * Revision 1.11 2015/04/26 23:38:58 dick
30 * Javadoc.
31 *
32 * Revision 1.10 2015/04/12 09:13:05 dick
33 * Separate the lengthy texts from the base Video object.
34 *
35 * Revision 1.9 2015/04/02 23:37:07 dick
36 * We use Actors, not Roles.
37 *
38 * Revision 1.8 2015/04/01 02:42:38 dick
39 * Store the hashKey as an attribute instead of always deriving it.
40 * This is in case it somehow changes, I don't want to lose the mappings.
41 * The key will stay the key.
42 *
43 * Revision 1.7 2015/03/25 06:22:21 dick
44 * Add more of the plex fields to a Video.
45 *
46 * Revision 1.6 2014/10/31 06:52:55 dick
47 * Add the classType attribute so hibernate can distinguish between Video and TVShow.
48 *
49 * Revision 1.5 2014/10/20 01:25:01 dick
50 * Add addedAt, updatedAt, and ratingKey.
51 *
52 * Revision 1.4 2014/10/12 07:25:10 dick
53 * commentality.
54 *
55 * Revision 1.3 2014/10/09 08:34:35 dick
56 * Use the Video as a key for the client, not just the image url.
57 *
58 * Revision 1.2 2014/10/08 04:28:29 dick
59 * Add poster and background keys.
60 *
61 * Revision 1.1 2014/10/06 08:10:05 dick
62 * Client facing domain object
63 */
64 package com.buckosoft.BuckoVidLib.domain;
65
66 import java.util.Collection;
67 import java.util.HashSet;
68 import java.util.Set;
69
70
71 /** Represents a single movie/tv show entry in Plex.
72 * (2 part movies are one entry).
73 * @author dick
74 * @since 2014-10-05
75 */
76 public class Video extends VideoBase {
77 private String ctype = "V"; // class type
78 private int duration;
79 private long updatedAt;
80
81 private String studio;
82 private VideoTexts videoTexts;
83 private String sortTitle;
84
85 Set<Genre> genres = new HashSet<Genre>();
86 Set<Writer> writers = new HashSet<Writer>();
87 Set<Director> directors = new HashSet<Director>();
88 Set<Actor> actors = new HashSet<Actor>();
89
90 public Video(){}
91
92 public Video(VideoBase videoBase) {
93 this.setId(videoBase.getId());
94 this.setPlexKey(videoBase.getPlexKey());
95 this.setTitle(videoBase.getTitle());
96 this.setYear(videoBase.getYear());
97 this.setSection(videoBase.getSection());
98 this.setHashKey(videoBase.getHashKey());
99 this.setAddedAt(videoBase.getAddedAt());
100 }
101
102 @Override
103 public void setId(int id) {
104 super.setId(id);
105 if (videoTexts != null) {
106 videoTexts.setVideoId(id);
107 }
108 }
109
110 /** Declare our class type.
111 * Possible values are V=Video and T=TVShow.
112 * Hibernate uses this for subclassing abilities.
113 * @return the ctype
114 */
115 public String getCtype() {
116 return ctype;
117 }
118
119 /**
120 * @param ctype the ctype to set
121 */
122 public void setCtype(String ctype) {
123 this.ctype = ctype;
124 }
125
126 /**
127 * @return the updatedAt
128 */
129 public long getUpdatedAt() {
130 return updatedAt;
131 }
132
133 /**
134 * @param updatedAt the updatedAt to set
135 */
136 public void setUpdatedAt(long updatedAt) {
137 this.updatedAt = updatedAt;
138 }
139
140 /**
141 * @return the duration
142 */
143 public int getDuration() {
144 return duration;
145 }
146
147 /**
148 * @param duration the duration to set
149 */
150 public void setDuration(int duration) {
151 this.duration = duration;
152 }
153
154 /**
155 * @return the studio
156 */
157 public String getStudio() {
158 return studio;
159 }
160
161 /**
162 * @param studio the studio to set
163 */
164 public void setStudio(String studio) {
165 this.studio = studio;
166 }
167
168 /** Get the sort title. <br>
169 * When the library is reloaded, update the {@link LibraryBase#sortIndex}es order
170 * @return the sortTitle
171 */
172 public String getSortTitle() {
173 return sortTitle;
174 }
175
176 /**
177 * @param sortTitle the sortTitle to set
178 */
179 public void setSortTitle(String sortTitle) {
180 this.sortTitle = sortTitle;
181 }
182
183 /**
184 * @return the genres
185 */
186 public Collection<Genre> getGenres() {
187 return genres;
188 }
189
190 /**
191 * @param genres the genres to set
192 */
193 public void setGenres(Set<Genre> genres) {
194 this.genres = genres;
195 }
196
197 public void addGenre(Genre genre) {
198 this.genres.add(genre);
199 }
200
201 /**
202 * @return the writers
203 */
204 public Set<Writer> getWriters() {
205 return writers;
206 }
207
208 /**
209 * @param writers the writers to set
210 */
211 public void setWriters(Set<Writer> writers) {
212 this.writers = writers;
213 }
214
215 public void addWriter(Writer writer) {
216 this.writers.add(writer);
217 }
218 /**
219 * @return the directors
220 */
221 public Set<Director> getDirectors() {
222 return directors;
223 }
224
225 /**
226 * @param directors the directors to set
227 */
228 public void setDirectors(Set<Director> directors) {
229 this.directors = directors;
230 }
231
232 public void addDirector(Director director) {
233 this.directors.add(director);
234 }
235 /**
236 * @return the roles
237 */
238 public Collection<Actor> getActors() {
239 return actors;
240 }
241
242 /**
243 * @param roles the roles to set
244 */
245 public void setActors(Set<Actor> actors) {
246 this.actors = actors;
247 }
248
249 public void addActor(Actor actor) {
250 this.actors.add(actor);
251 }
252
253 /**
254 * @return the videoTexts
255 */
256 public VideoTexts getVideoTexts() {
257 return videoTexts;
258 }
259
260 /**
261 * @param videoTexts the videoTexts to set
262 */
263 public void setVideoTexts(VideoTexts videoTexts) {
264 this.videoTexts = videoTexts;
265 }
266
267 }