View Javadoc
1   /******************************************************************************
2    * VideoBase.java - domain object
3    * 
4    * BuckoVidLib - The BuckoSoft Video Library
5    * Copyright(c) 2014 - Dick Balaska
6    * 
7    */
8   package com.buckosoft.BuckoVidLib.domain;
9   
10  import com.buckosoft.BuckoVidLib.util.HashCodeUtil;
11  
12  /** Represents a single movie/tv show entry in Plex and the database.<br>
13   * (2 part movies are one entry. 211 hours of NCIS is one entry).<br>
14   * This slim object contains just the neccessary fields to define one video.  All of the other fluff;
15   * actors, summaries, episodes, are in the full Video object
16   * @author dick
17   * @since 2014-10-05
18   */
19  public class VideoBase {
20  	private	int		id;
21  	private	int		hashKey;
22  	private String	title;
23  	private	int		year;
24  	private	int		section;
25  	private	int		sortIndex;
26  	private	int		plexKey;		// plex key used for image urls
27  	private	long	addedAt;		// number of seconds since the epoch
28  
29  	/** Rather than expose the internal url to a client, hash the url
30  	 * into a key and then use the key to get to the Image.  <br>
31  	 * Hopefully, this will be constant enough for the google image searcher.
32  	 * Really, I could just use the plex key, it's unique. 
33  	 * But I don't want to neccessarily expose that. So make my own.  
34  	 */
35  	@Override
36  	public int	hashCode() {
37  		int result = HashCodeUtil.SEED;
38  		result = HashCodeUtil.hash(result, title);
39  		result = HashCodeUtil.hash(result, year);
40  		result = HashCodeUtil.hash(result, section);
41  		return(result);
42  	}
43  
44  	@Override
45  	public boolean equals(Object other) {
46  		if (this.year != ((VideoBase)other).year)
47  			return(false);
48  		if (this.section != ((VideoBase)other).section)
49  			return(false);
50  		if (!this.title.equals(((VideoBase)other).title))
51  			return(false);
52  		return(true);
53  	}
54  	
55  	/** Get the database index number
56  	 * @return the id
57  	 */
58  	public int getId() {
59  		return id;
60  	}
61  	/**
62  	 * @param id the id to set
63  	 */
64  	public void setId(int id) {
65  		this.id = id;
66  	}
67  
68  	/**
69  	 * @return the hashKey
70  	 */
71  	public int getHashKey() {
72  		return hashKey;
73  	}
74  
75  	/**
76  	 * @param hashKey the hashKey to set
77  	 */
78  	public void setHashKey(int hashKey) {
79  		this.hashKey = hashKey;
80  	}
81  
82  	/**
83  	 * @return the title
84  	 */
85  	public String getTitle() {
86  		return title;
87  	}
88  	/**
89  	 * @param title the title to set
90  	 */
91  	public void setTitle(String title) {
92  		this.title = title;
93  	}
94  	/**
95  	 * @return the year
96  	 */
97  	public int getYear() {
98  		return year;
99  	}
100 	/**
101 	 * @param year the year to set
102 	 */
103 	public void setYear(int year) {
104 		this.year = year;
105 	}
106 	/**
107 	 * @return the section
108 	 */
109 	public int getSection() {
110 		return section;
111 	}
112 	/**
113 	 * @param section the section to set
114 	 */
115 	public void setSection(int section) {
116 		this.section = section;
117 	}
118 	/**
119 	 * @return the posterUrl
120 	 */
121 //	public String getPosterUrl() {
122 //		return(String.format("library/metadata/%d/thumb", this.plexKey));
123 //	}
124 
125 	/**
126 	 * @return the backgroundUrl
127 	 */
128 	public String getBackgroundUrl() {
129 		return(String.format("library/metadata/%d/art", this.plexKey));
130 	}
131 
132 	/**
133 	 * @return the plexKey
134 	 */
135 	public int getPlexKey() {
136 		return plexKey;
137 	}
138 
139 	/**
140 	 * @param plexKey the plexKey to set
141 	 */
142 	public void setPlexKey(int plexKey) {
143 		this.plexKey = plexKey;
144 	}
145 
146 	/**
147 	 * @return the addedAt
148 	 */
149 	public long getAddedAt() {
150 		return addedAt;
151 	}
152 
153 	/**
154 	 * @param addedAt the addedAt to set
155 	 */
156 	public void setAddedAt(long addedAt) {
157 		this.addedAt = addedAt;
158 	}
159 
160 	/** Get the sort order index.
161 	 * What order should this entry be displayed in.
162 	 * @return Our position in the list.
163 	 */
164 	public int getSortIndex() {
165 		return sortIndex;
166 	}
167 
168 	/**
169 	 * @param sortIndex the sortIndex to set
170 	 */
171 	public void setSortIndex(int sortIndex) {
172 		this.sortIndex = sortIndex;
173 	}
174 
175 }