a1e7844e7203d8d449d5db60eb9adf2c4f0ba5e2
[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 @Entity
39 @Table(name="recorded")
40 public class Recording implements Serializable {
41     
42     private RecordingPk _id;
43
44     private String _basename;
45
46     private Date _progstart;
47
48     private String _title;
49     
50     private String _subtitle;
51     
52     private long _filesize;
53
54     protected Recording() {
55         // Empty
56     }
57     
58     /**
59      * @return the id
60      */
61     @EmbeddedId
62     public RecordingPk getId() {
63         return _id;
64     }
65     
66     /**
67      * @param aId the id to set
68      */
69     public void setId(RecordingPk aId) {
70         _id = aId;
71     }
72    
73     /**
74      * @return the basename
75      */
76     @Column(name="basename")
77     public String getBasename() {
78         return _basename;
79     }
80     
81     /**
82      * @param aBasename the basename to set
83      */
84     public void setBasename(String aBasename) {
85         _basename = aBasename;
86     }
87
88     /**
89      * @return the progstart
90      */
91     @Column(name="progstart")
92     @Temporal(TemporalType.TIMESTAMP)
93     public Date getProgstart() {
94         return _progstart;
95     }
96     
97     /**
98      * @param aProgstart the progstart to set
99      */
100     public void setProgstart(Date aProgstart) {
101         _progstart = aProgstart;
102     }
103     
104     @Transient
105     public Channel getChannel() { 
106         return _id.getChannel();
107     }
108     
109     @Transient
110     public Date getStarttime() { 
111         return _id.getStartTime();
112     }
113     
114     /**
115      * @return the title
116      */
117     @Column(name="title")
118     public String getTitle() {
119         return _title;
120     }
121     
122     /**
123      * @param aTitle the title to set
124      */
125     public void setTitle(String aTitle) {
126         _title = aTitle;
127     }
128
129     /**
130      * @return the subtitle
131      */
132     @Column(name="subtitle")
133     public String getSubtitle() {
134         return _subtitle;
135     }
136     
137     /**
138      * @param aSubtitle the subtitle to set
139      */
140     public void setSubtitle(String aSubtitle) {
141         _subtitle = aSubtitle;
142     }
143     
144     /**
145      * @return the filesize
146      */
147     @Column(name="filesize")
148     public long getFilesize() {
149         return _filesize;
150     }
151     
152     public void setFilesize(long aFilesize) { 
153         _filesize = aFilesize; 
154     }
155     
156     /* (non-Javadoc)
157      * @see java.lang.Object#toString()
158      */
159     @Override
160     public String toString() {
161         return "Recording(" + _id + "," + _basename + "," + _progstart + "," + _title + "," + _subtitle + ")";
162     }
163     
164     /* (non-Javadoc)
165      * @see java.lang.Object#equals(java.lang.Object)
166      */
167     @Override
168     public boolean equals(Object aObj) {
169         if ( !(aObj instanceof Recording)) { 
170             return false;
171         }
172         Recording recording = (Recording)aObj; 
173         return _id.equals(recording._id); 
174     }
175     
176     /* (non-Javadoc)
177      * @see java.lang.Object#hashCode()
178      */
179     @Override
180     public int hashCode() {
181         return _id.hashCode(); 
182     }
183
184 }