4 package com.edf.gde.entities;
6 import com.edf.gde.transferables.FileTO;
7 import java.io.Serializable;
9 import java.util.Objects;
10 import javax.persistence.Basic;
11 import javax.persistence.Column;
12 import javax.persistence.Entity;
13 import javax.persistence.GeneratedValue;
14 import javax.persistence.GenerationType;
15 import javax.persistence.Id;
16 import javax.persistence.NamedQueries;
17 import javax.persistence.NamedQuery;
18 import javax.persistence.SequenceGenerator;
19 import javax.persistence.Table;
20 import javax.persistence.Temporal;
21 import javax.persistence.TemporalType;
22 import javax.validation.constraints.NotNull;
23 import javax.validation.constraints.Size;
24 import javax.xml.bind.annotation.XmlRootElement;
30 @Entity(name = "File")
31 @Table(name = "gde_file")
34 @NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
35 @NamedQuery(name = "File.findById", query = "SELECT f FROM File f WHERE f.id = :id"),
36 @NamedQuery(name = "File.findByName", query = "SELECT f FROM File f WHERE f.name = :name"),
37 @NamedQuery(name = "File.findByCreationDate", query = "SELECT f FROM File f WHERE f.creationDate = :creationDate"),
38 @NamedQuery(name = "File.findByUpdateDate", query = "SELECT f FROM File f WHERE f.updateDate = :updateDate"),
39 @NamedQuery(name = "File.findByDeletionDate", query = "SELECT f FROM File f WHERE f.deletionDate = :deletionDate")
41 public class GDEFile implements Serializable {
42 private static final long serialVersionUID = 1L;
44 @Basic(optional = false)
47 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
48 @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
51 @Column(name = "name")
53 @Column(name = "length")
56 @Column(name = "checksum")
57 private String checksum;
58 @Column(name = "creation_date")
59 @Temporal(TemporalType.TIMESTAMP)
60 private Date creationDate;
61 @Column(name = "update_date")
62 @Temporal(TemporalType.TIMESTAMP)
63 private Date updateDate;
64 @Column(name = "valid")
65 private boolean valid;
66 @Column(name = "deleted")
67 private boolean deleted;
68 @Column(name = "deletion_date")
69 @Temporal(TemporalType.TIMESTAMP)
70 private Date deletionDate;
71 @Column(name = "attribute_group_id")
72 private long attributeGroupId;
73 @Column(name = "data_profile_id")
74 private long dataProfileId;
75 // No member for chunks: data are accessed with SQL requests
80 public GDEFile(long id) {
88 public void setId(long id) {
92 public String getName() {
96 public void setName(String name) {
100 public long getLength() {
104 public void setLength(long length) {
105 this.length = length;
108 public String getChecksum() {
112 public void setChecksum(String checksum) {
113 this.checksum = checksum;
116 public Date getCreationDate() {
120 public void setCreationDate(Date creationDate) {
121 this.creationDate = creationDate;
124 public Date getUpdateDate() {
128 public void setUpdateDate(Date updateDate) {
129 this.updateDate = updateDate;
132 public boolean isValid() {
136 public void setValid(boolean valid) {
140 public boolean isDeleted() {
144 public void setDeleted(boolean deleted) {
145 this.deleted = deleted;
148 public Date getDeletionDate() {
152 public void setDeletionDate(Date deletionDate) {
153 this.deletionDate = deletionDate;
156 public long getAttributeGroupId() {
157 return attributeGroupId;
160 public void setAttributeGroupId(long attributeGroupId) {
161 this.attributeGroupId = attributeGroupId;
164 public long getDataProfileId() {
165 return dataProfileId;
168 public void setDataProfileId(long dataProfileId) {
169 this.dataProfileId = dataProfileId;
172 public static GDEFile fromFileTO(FileTO fto) {
173 GDEFile f = new GDEFile();
174 f.checksum = fto.getChecksum();
175 f.creationDate = fto.getCreationDate();
176 f.deleted = fto.getDeleted();
177 f.deletionDate = fto.getDeletionDate();
178 f.attributeGroupId = fto.getAttributeGroupId();
180 f.length = fto.getLength();
181 f.name = fto.getName();
182 f.updateDate = fto.getUpdateDate();
183 f.valid = fto.getValid();
184 f.dataProfileId = fto.getDataProfileId();
188 public FileTO toFileTO() {
189 FileTO fto = new FileTO();
190 fto.setChecksum(this.checksum);
191 fto.setCreationDate(this.creationDate);
192 fto.setDeleted(this.deleted);
193 fto.setDeletionDate(this.deletionDate);
194 fto.setAttributeGroupId(this.attributeGroupId);
196 fto.setLength(this.length);
197 fto.setName(this.name);
198 fto.setUpdateDate(this.updateDate);
199 fto.setValid(this.valid);
200 fto.setDataProfileId(this.dataProfileId);
205 public String toString() {
206 return "com.edf.gde.entities.GDEFile[ id=" + id + " ]";
210 public int hashCode() {
212 hash = 23 * hash + (int) (this.id ^ (this.id >>> 32));
213 hash = 23 * hash + Objects.hashCode(this.name);
214 hash = 23 * hash + (int) (this.length ^ (this.length >>> 32));
215 hash = 23 * hash + Objects.hashCode(this.checksum);
216 hash = 23 * hash + Objects.hashCode(this.creationDate);
217 hash = 23 * hash + Objects.hashCode(this.updateDate);
218 hash = 23 * hash + Objects.hashCode(this.valid);
219 hash = 23 * hash + Objects.hashCode(this.deleted);
220 hash = 23 * hash + Objects.hashCode(this.deletionDate);
221 hash = 23 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
222 hash = 23 * hash + (int) (this.dataProfileId ^ (this.dataProfileId >>> 32));
227 public boolean equals(Object obj) {
231 if (getClass() != obj.getClass()) {
234 final GDEFile other = (GDEFile) obj;
235 if (this.id != other.id) {