moved socketproxy to https://wamblee.org/svn/public/socketproxy
[utils] / mythtv / monitor / src / main / java / org / wamblee / mythtv / Recording.java
index cab43a6b76affb79b3c5b9fe1a5a3bd854154672..c3ad6286bba908ebce369910479ecd212099ec72 100644 (file)
@@ -19,21 +19,36 @@ package org.wamblee.mythtv;
 import java.io.Serializable;
 import java.util.Date;
 
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.IdClass;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
 /**
  * 
+ *
+ * @author Erik Brakkee
  */
+@Entity
+@Table(name="recorded")
 public class Recording implements Serializable {
+    
+    private RecordingPk _id;
 
-    private Channel _channel;
-    private Date _starttime;
-
-  
     private String _basename;
 
     private Date _progstart;
-    private String _title;
 
+    private String _title;
+    
     private String _subtitle;
     
     private long _filesize;
@@ -41,52 +56,97 @@ public class Recording implements Serializable {
     protected Recording() {
         // Empty
     }
-
+    
     /**
-     * @return the channel
+     * @return the id
      */
-    public Channel getChannel() {
-        return _channel;
+    @EmbeddedId
+    public RecordingPk getId() {
+        return _id;
     }
-
+    
+    /**
+     * @param aId the id to set
+     */
+    public void setId(RecordingPk aId) {
+        _id = aId;
+    }
+   
     /**
      * @return the basename
      */
+    @Column(name="basename")
     public String getBasename() {
         return _basename;
     }
-
+    
     /**
-     * @return the progstart
+     * @param aBasename the basename to set
      */
-    public Date getStartTime() {
-        return _starttime;
+    public void setBasename(String aBasename) {
+        _basename = aBasename;
     }
 
     /**
      * @return the progstart
      */
+    @Column(name="progstart")
+    @Temporal(TemporalType.TIMESTAMP)
     public Date getProgstart() {
         return _progstart;
     }
     
+    /**
+     * @param aProgstart the progstart to set
+     */
+    public void setProgstart(Date aProgstart) {
+        _progstart = aProgstart;
+    }
+    
+    @Transient
+    public Channel getChannel() { 
+        return _id.getChannel();
+    }
+    
+    @Transient
+    public Date getStarttime() { 
+        return _id.getStartTime();
+    }
+    
     /**
      * @return the title
      */
+    @Column(name="title")
     public String getTitle() {
         return _title;
     }
+    
+    /**
+     * @param aTitle the title to set
+     */
+    public void setTitle(String aTitle) {
+        _title = aTitle;
+    }
 
     /**
      * @return the subtitle
      */
+    @Column(name="subtitle")
     public String getSubtitle() {
         return _subtitle;
     }
     
+    /**
+     * @param aSubtitle the subtitle to set
+     */
+    public void setSubtitle(String aSubtitle) {
+        _subtitle = aSubtitle;
+    }
+    
     /**
      * @return the filesize
      */
+    @Column(name="filesize")
     public long getFilesize() {
         return _filesize;
     }
@@ -100,7 +160,7 @@ public class Recording implements Serializable {
      */
     @Override
     public String toString() {
-        return "Recording(" + _channel + "," + _basename + "," + _progstart + "," + _title + "," + _subtitle + ")";
+        return "Recording(" + _id + "," + _basename + "," + _progstart + "," + _title + "," + _subtitle + ")";
     }
     
     /* (non-Javadoc)
@@ -112,7 +172,7 @@ public class Recording implements Serializable {
             return false;
         }
         Recording recording = (Recording)aObj; 
-        return _channel.equals(recording._channel) && _starttime.equals(recording._starttime); 
+        return _id.equals(recording._id); 
     }
     
     /* (non-Javadoc)
@@ -120,7 +180,7 @@ public class Recording implements Serializable {
      */
     @Override
     public int hashCode() {
-        return _channel.hashCode()*10 + ((int)_starttime.getTime() %10); 
+        return _id.hashCode(); 
     }
 
 }