2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
6 package com.edf.gde.entities;
8 import com.edf.gde.transferables.ChunkTO;
9 import com.edf.gde.transferables.FileTO;
10 import java.io.Serializable;
11 import java.util.ArrayList;
12 import java.util.Collection;
13 import java.util.Date;
14 import java.util.Objects;
15 import javax.persistence.Basic;
16 import javax.persistence.CascadeType;
17 import javax.persistence.Column;
18 import javax.persistence.Entity;
19 import javax.persistence.GeneratedValue;
20 import javax.persistence.GenerationType;
21 import javax.persistence.Id;
22 import javax.persistence.NamedQueries;
23 import javax.persistence.NamedQuery;
24 import javax.persistence.OneToMany;
25 import javax.persistence.SequenceGenerator;
26 import javax.persistence.Table;
27 import javax.persistence.Temporal;
28 import javax.persistence.TemporalType;
29 import javax.validation.constraints.NotNull;
30 import javax.validation.constraints.Size;
31 import javax.xml.bind.annotation.XmlRootElement;
32 import javax.xml.bind.annotation.XmlTransient;
38 @Entity(name = "File")
39 @Table(name = "gde_file")
42 @NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
43 @NamedQuery(name = "File.findById", query = "SELECT f FROM File f WHERE f.id = :id"),
44 @NamedQuery(name = "File.findByName", query = "SELECT f FROM File f WHERE f.name = :name"),
45 //@NamedQuery(name = "File.findByLength", query = "SELECT f FROM File f WHERE f.length = :length"),
46 //@NamedQuery(name = "File.findByChecksum", query = "SELECT f FROM File f WHERE f.checksum = :checksum"),
47 @NamedQuery(name = "File.findByCreationDate", query = "SELECT f FROM File f WHERE f.creationDate = :creationDate"),
48 @NamedQuery(name = "File.findByUpdateDate", query = "SELECT f FROM File f WHERE f.updateDate = :updateDate"),
49 //@NamedQuery(name = "File.findByValid", query = "SELECT f FROM File f WHERE f.valid = :valid"),
50 //@NamedQuery(name = "File.findByDeleted", query = "SELECT f FROM File f WHERE f.deleted = :deleted"),
51 @NamedQuery(name = "File.findByDeletionDate", query = "SELECT f FROM File f WHERE f.deletionDate = :deletionDate")
53 public class GDEFile implements Serializable {
54 private static final long serialVersionUID = 1L;
56 @Basic(optional = false)
59 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
60 @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
63 @Column(name = "name")
65 @Column(name = "length")
68 @Column(name = "checksum")
69 private String checksum;
70 @Column(name = "creation_date")
71 @Temporal(TemporalType.TIMESTAMP)
72 private Date creationDate;
73 @Column(name = "update_date")
74 @Temporal(TemporalType.TIMESTAMP)
75 private Date updateDate;
76 @Column(name = "valid")
77 private Boolean valid;
78 @Column(name = "deleted")
79 private Boolean deleted;
80 @Column(name = "deletion_date")
81 @Temporal(TemporalType.TIMESTAMP)
82 private Date deletionDate;
83 @Column(name = "attribute_group_id")
84 private long attributeGroupId;
89 public GDEFile(long id) {
97 public void setId(long id) {
101 public String getName() {
105 public void setName(String name) {
109 public long getLength() {
113 public void setLength(long length) {
114 this.length = length;
117 public String getChecksum() {
121 public void setChecksum(String checksum) {
122 this.checksum = checksum;
125 public Date getCreationDate() {
129 public void setCreationDate(Date creationDate) {
130 this.creationDate = creationDate;
133 public Date getUpdateDate() {
137 public void setUpdateDate(Date updateDate) {
138 this.updateDate = updateDate;
141 public Boolean getValid() {
145 public void setValid(Boolean valid) {
149 public Boolean getDeleted() {
153 public void setDeleted(Boolean deleted) {
154 this.deleted = deleted;
157 public Date getDeletionDate() {
161 public void setDeletionDate(Date deletionDate) {
162 this.deletionDate = deletionDate;
165 public long getAttributeGroupId() {
166 return attributeGroupId;
169 public void setAttributeGroupId(long attributeGroupId) {
170 this.attributeGroupId = attributeGroupId;
173 public static GDEFile fromFileTO(FileTO fto) {
174 GDEFile f = new GDEFile();
175 f.checksum = fto.getChecksum();
177 f.creationDate = fto.getCreationDate();
178 f.deleted = fto.getDeleted();
179 f.deletionDate = fto.getDeletionDate();
180 f.attributeGroupId = fto.getAttributeGroupId();
182 f.length = fto.getLength();
183 f.name = fto.getName();
184 f.updateDate = fto.getUpdateDate();
185 f.valid = fto.getValid();
189 public FileTO toFileTO() {
190 FileTO fto = new FileTO();
191 fto.setChecksum(this.checksum);
193 fto.setCreationDate(this.creationDate);
194 fto.setDeleted(this.deleted);
195 fto.setDeletionDate(this.deletionDate);
196 fto.setAttributeGroupId(this.attributeGroupId);
198 fto.setLength(this.length);
199 fto.setName(this.name);
200 fto.setUpdateDate(this.updateDate);
201 fto.setValid(this.valid);
206 public String toString() {
207 return "com.edf.gde.entities.GDEFile[ id=" + id + " ]";
211 public int hashCode() {
213 hash = 29 * hash + (int) (this.id ^ (this.id >>> 32));
214 hash = 29 * hash + Objects.hashCode(this.name);
215 hash = 29 * hash + (int) (this.length ^ (this.length >>> 32));
216 hash = 29 * hash + Objects.hashCode(this.checksum);
217 hash = 29 * hash + Objects.hashCode(this.creationDate);
218 hash = 29 * hash + Objects.hashCode(this.updateDate);
219 hash = 29 * hash + Objects.hashCode(this.valid);
220 hash = 29 * hash + Objects.hashCode(this.deleted);
221 hash = 29 * hash + Objects.hashCode(this.deletionDate);
222 hash = 29 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
227 public boolean equals(Object obj) {
231 if (getClass() != obj.getClass()) {
234 final GDEFile other = (GDEFile) obj;
235 if (this.id != other.id) {