c3ad6286bba908ebce369910479ecd212099ec72
[utils] / mythtv / monitor / src / main / java / org / wamblee / mythtv / Recording.java
1 /*
2  * Copyright 2006 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.wamblee.mythtv;
18
19 import java.io.Serializable;
20 import java.util.Date;
21
22 import javax.persistence.Column;
23 import javax.persistence.EmbeddedId;
24 import javax.persistence.Entity;
25 import javax.persistence.Id;
26 import javax.persistence.IdClass;
27 import javax.persistence.JoinColumn;
28 import javax.persistence.JoinColumns;
29 import javax.persistence.ManyToOne;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import javax.persistence.Transient;
34
35 /**
36  * 
37  *
38  * @author Erik Brakkee
39  */
40 @Entity
41 @Table(name="recorded")
42 public class Recording implements Serializable {
43     
44     private RecordingPk _id;
45
46     private String _basename;
47
48     private Date _progstart;
49
50     private String _title;
51     
52     private String _subtitle;
53     
54     private long _filesize;
55
56     protected Recording() {
57         // Empty
58     }
59     
60     /**
61      * @return the id
62      */
63     @EmbeddedId
64     public RecordingPk getId() {
65         return _id;
66     }
67     
68     /**
69      * @param aId the id to set
70      */
71     public void setId(RecordingPk aId) {
72         _id = aId;
73     }
74    
75     /**
76      * @return the basename
77      */
78     @Column(name="basename")
79     public String getBasename() {
80         return _basename;
81     }
82     
83     /**
84      * @param aBasename the basename to set
85      */
86     public void setBasename(String aBasename) {
87         _basename = aBasename;
88     }
89
90     /**
91      * @return the progstart
92      */
93     @Column(name="progstart")
94     @Temporal(TemporalType.TIMESTAMP)
95     public Date getProgstart() {
96         return _progstart;
97     }
98     
99     /**
100      * @param aProgstart the progstart to set
101      */
102     public void setProgstart(Date aProgstart) {
103         _progstart = aProgstart;
104     }
105     
106     @Transient
107     public Channel getChannel() { 
108         return _id.getChannel();
109     }
110     
111     @Transient
112     public Date getStarttime() { 
113         return _id.getStartTime();
114     }
115     
116     /**
117      * @return the title
118      */
119     @Column(name="title")
120     public String getTitle() {
121         return _title;
122     }
123     
124     /**
125      * @param aTitle the title to set
126      */
127     public void setTitle(String aTitle) {
128         _title = aTitle;
129     }
130
131     /**
132      * @return the subtitle
133      */
134     @Column(name="subtitle")
135     public String getSubtitle() {
136         return _subtitle;
137     }
138     
139     /**
140      * @param aSubtitle the subtitle to set
141      */
142     public void setSubtitle(String aSubtitle) {
143         _subtitle = aSubtitle;
144     }
145     
146     /**
147      * @return the filesize
148      */
149     @Column(name="filesize")
150     public long getFilesize() {
151         return _filesize;
152     }
153     
154     public void setFilesize(long aFilesize) { 
155         _filesize = aFilesize; 
156     }
157     
158     /* (non-Javadoc)
159      * @see java.lang.Object#toString()
160      */
161     @Override
162     public String toString() {
163         return "Recording(" + _id + "," + _basename + "," + _progstart + "," + _title + "," + _subtitle + ")";
164     }
165     
166     /* (non-Javadoc)
167      * @see java.lang.Object#equals(java.lang.Object)
168      */
169     @Override
170     public boolean equals(Object aObj) {
171         if ( !(aObj instanceof Recording)) { 
172             return false;
173         }
174         Recording recording = (Recording)aObj; 
175         return _id.equals(recording._id); 
176     }
177     
178     /* (non-Javadoc)
179      * @see java.lang.Object#hashCode()
180      */
181     @Override
182     public int hashCode() {
183         return _id.hashCode(); 
184     }
185
186 }