now using JPA annotations.
[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.Entity;
24 import javax.persistence.Id;
25 import javax.persistence.IdClass;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.JoinColumns;
28 import javax.persistence.ManyToOne;
29 import javax.persistence.Table;
30
31 /**
32  * 
33  */
34 @Entity
35 @Table(name="recorded")
36 //@IdClass(RecordingPk.class)
37 public class Recording implements Serializable {
38
39     //@Id
40     @ManyToOne(targetEntity=Channel.class)
41     @JoinColumn(name="chanid")
42     private Channel _channel;
43     @Id
44     @Column(name="starttime")
45     private Date _starttime;
46
47     @Column(name="basename")
48     private String _basename;
49
50     @Column(name="progstart")
51     private Date _progstart;
52
53     @Column(name="title")
54     private String _title;
55
56     @Column(name="subtitle")
57     private String _subtitle;
58     
59     @Column(name="filesize")
60     private long _filesize;
61
62     protected Recording() {
63         // Empty
64     }
65
66     /**
67      * @return the channel
68      */
69     public Channel getChannel() {
70         return _channel;
71     }
72
73     /**
74      * @return the basename
75      */
76     public String getBasename() {
77         return _basename;
78     }
79
80     /**
81      * @return the progstart
82      */
83     public Date getStartTime() {
84         return _starttime;
85     }
86
87     /**
88      * @return the progstart
89      */
90     public Date getProgstart() {
91         return _progstart;
92     }
93     
94     /**
95      * @return the title
96      */
97     public String getTitle() {
98         return _title;
99     }
100
101     /**
102      * @return the subtitle
103      */
104     public String getSubtitle() {
105         return _subtitle;
106     }
107     
108     /**
109      * @return the filesize
110      */
111     public long getFilesize() {
112         return _filesize;
113     }
114     
115     public void setFilesize(long aFilesize) { 
116         _filesize = aFilesize; 
117     }
118     
119     /* (non-Javadoc)
120      * @see java.lang.Object#toString()
121      */
122     @Override
123     public String toString() {
124         return "Recording(" + _channel + "," + _basename + "," + _progstart + "," + _title + "," + _subtitle + ")";
125     }
126     
127     /* (non-Javadoc)
128      * @see java.lang.Object#equals(java.lang.Object)
129      */
130     @Override
131     public boolean equals(Object aObj) {
132         if ( !(aObj instanceof Recording)) { 
133             return false;
134         }
135         Recording recording = (Recording)aObj; 
136         return _channel.equals(recording._channel) && _starttime.equals(recording._starttime); 
137     }
138     
139     /* (non-Javadoc)
140      * @see java.lang.Object#hashCode()
141      */
142     @Override
143     public int hashCode() {
144         return _channel.hashCode()*10 + ((int)_starttime.getTime() %10); 
145     }
146
147 }