Salome HOME
Add study
[modules/gde.git] / projects / GDE_App / GDE-ejb / src / java / com / edf / gde / entities / GDEFile.java
index 4596b6ecdb61c8bb472fdda47ec42bfc05aa2e91..ce7e0a126a003851a2a329ff51cbdd66fd531900 100644 (file)
@@ -13,6 +13,7 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Objects;
 import javax.persistence.Basic;
+import javax.persistence.CascadeType;
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.Id;
@@ -25,13 +26,14 @@ import javax.persistence.TemporalType;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 
 /**
  *
  * @author F62173
  */
 @Entity(name = "File")
-@Table(name = "file")
+@Table(name = "gde_file")
 @XmlRootElement
 @NamedQueries({
     @NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
@@ -47,7 +49,6 @@ import javax.xml.bind.annotation.XmlRootElement;
 })
 public class GDEFile implements Serializable {
     private static final long serialVersionUID = 1L;
-
     @Id
     @Basic(optional = false)
     @NotNull
@@ -74,13 +75,11 @@ public class GDEFile implements Serializable {
     @Column(name = "deletion_date")
     @Temporal(TemporalType.TIMESTAMP)
     private Date deletionDate;
-    //@JoinColumn(name = "group_id", referencedColumnName = "id", nullable = false)
-    @Column(name = "group_id", nullable = false)
-    //@ManyToOne
-    private long groupId;
-    @OneToMany
-    private Collection<Chunk> chunks;
-    
+    @OneToMany(cascade = CascadeType.ALL)
+    private Collection<Chunk> chunkCollection;
+    @Column(name = "attribute_group_id")
+    private long attributeGroupId;
+
     public GDEFile() {
     }
 
@@ -160,36 +159,37 @@ public class GDEFile implements Serializable {
         this.deletionDate = deletionDate;
     }
 
-    public long getGroupId() {
-        return groupId;
+    @XmlTransient
+    public Collection<Chunk> getChunkCollection() {
+        return chunkCollection;
     }
 
-    public void setGroupId(long groupId) {
-        this.groupId = groupId;
+    public void setChunkCollection(Collection<Chunk> chunkCollection) {
+        this.chunkCollection = chunkCollection;
     }
 
-    public Collection<Chunk> getChunks() {
-        return chunks;
+    public long getAttributeGroupId() {
+        return attributeGroupId;
     }
 
-    public void setChunks(Collection<Chunk> chunks) {
-        this.chunks = chunks;
+    public void setAttributeGroupId(long attributeGroupId) {
+        this.attributeGroupId = attributeGroupId;
     }
 
     public static GDEFile fromFileTO(FileTO fto) {
         GDEFile f = new GDEFile();
         f.checksum = fto.getChecksum();
 
-        f.chunks = new ArrayList<>();
-        Collection<ChunkTO> chunks = fto.getChunks();
+        f.chunkCollection = new ArrayList<>();
+        Collection<ChunkTO> chunks = fto.getChunkCollection();
         for (ChunkTO cto : chunks) {
-            f.chunks.add(Chunk.fromChunkTO(cto));
+            f.chunkCollection.add(Chunk.fromChunkTO(cto));
         }
         
         f.creationDate = fto.getCreationDate();
         f.deleted = fto.getDeleted();
         f.deletionDate = fto.getDeletionDate();
-        f.groupId = fto.getAttributeGroupId();
+        f.attributeGroupId = fto.getAttributeGroupId();
         f.id = fto.getId();
         f.length = fto.getLength();
         f.name = fto.getName();
@@ -203,15 +203,15 @@ public class GDEFile implements Serializable {
         fto.setChecksum(this.checksum);
         
         Collection<ChunkTO> ctos = new ArrayList<>();
-        for (Chunk c : this.chunks) {
+        for (Chunk c : this.chunkCollection) {
             ctos.add(c.toChunkTO());
         }
-        fto.setChunks(ctos);
+        fto.setChunkCollection(ctos);
         
         fto.setCreationDate(this.creationDate);
         fto.setDeleted(this.deleted);
         fto.setDeletionDate(this.deletionDate);
-        fto.setAttributeGroupId(this.groupId);
+        fto.setAttributeGroupId(this.attributeGroupId);
         fto.setId(this.id);
         fto.setLength(this.length);
         fto.setName(this.name);
@@ -222,23 +222,23 @@ public class GDEFile implements Serializable {
 
     @Override
     public String toString() {
-        return "com.edf.gde.entities.File[ id=" + id + " ]";
+        return "com.edf.gde.entities.GDEFile[ id=" + id + " ]";
     }
 
     @Override
     public int hashCode() {
-        int hash = 5;
-        hash = 41 * hash + (int) (this.id ^ (this.id >>> 32));
-        hash = 41 * hash + Objects.hashCode(this.name);
-        hash = 41 * hash + (int) (this.length ^ (this.length >>> 32));
-        hash = 41 * hash + Objects.hashCode(this.checksum);
-        hash = 41 * hash + Objects.hashCode(this.creationDate);
-        hash = 41 * hash + Objects.hashCode(this.updateDate);
-        hash = 41 * hash + Objects.hashCode(this.valid);
-        hash = 41 * hash + Objects.hashCode(this.deleted);
-        hash = 41 * hash + Objects.hashCode(this.deletionDate);
-        hash = 41 * hash + (int) (this.groupId ^ (this.groupId >>> 32));
-        hash = 41 * hash + Objects.hashCode(this.chunks);
+        int hash = 3;
+        hash = 29 * hash + (int) (this.id ^ (this.id >>> 32));
+        hash = 29 * hash + Objects.hashCode(this.name);
+        hash = 29 * hash + (int) (this.length ^ (this.length >>> 32));
+        hash = 29 * hash + Objects.hashCode(this.checksum);
+        hash = 29 * hash + Objects.hashCode(this.creationDate);
+        hash = 29 * hash + Objects.hashCode(this.updateDate);
+        hash = 29 * hash + Objects.hashCode(this.valid);
+        hash = 29 * hash + Objects.hashCode(this.deleted);
+        hash = 29 * hash + Objects.hashCode(this.deletionDate);
+        hash = 29 * hash + Objects.hashCode(this.chunkCollection);
+        hash = 29 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
         return hash;
     }