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.FileTO;
9 import java.io.Serializable;
10 import java.util.Date;
11 import java.util.Objects;
12 import javax.persistence.Basic;
13 import javax.persistence.Column;
14 import javax.persistence.Entity;
15 import javax.persistence.GeneratedValue;
16 import javax.persistence.GenerationType;
17 import javax.persistence.Id;
18 import javax.persistence.NamedQueries;
19 import javax.persistence.NamedQuery;
20 import javax.persistence.SequenceGenerator;
21 import javax.persistence.Table;
22 import javax.persistence.Temporal;
23 import javax.persistence.TemporalType;
24 import javax.validation.constraints.NotNull;
25 import javax.validation.constraints.Size;
26 import javax.xml.bind.annotation.XmlRootElement;
32 @Entity(name = "File")
33 @Table(name = "gde_file")
36 @NamedQuery(name = "File.findAll", query = "SELECT f FROM File f"),
37 @NamedQuery(name = "File.findById", query = "SELECT f FROM File f WHERE f.id = :id"),
38 @NamedQuery(name = "File.findByName", query = "SELECT f FROM File f WHERE f.name = :name"),
39 //@NamedQuery(name = "File.findByLength", query = "SELECT f FROM File f WHERE f.length = :length"),
40 //@NamedQuery(name = "File.findByChecksum", query = "SELECT f FROM File f WHERE f.checksum = :checksum"),
41 @NamedQuery(name = "File.findByCreationDate", query = "SELECT f FROM File f WHERE f.creationDate = :creationDate"),
42 @NamedQuery(name = "File.findByUpdateDate", query = "SELECT f FROM File f WHERE f.updateDate = :updateDate"),
43 //@NamedQuery(name = "File.findByValid", query = "SELECT f FROM File f WHERE f.valid = :valid"),
44 //@NamedQuery(name = "File.findByDeleted", query = "SELECT f FROM File f WHERE f.deleted = :deleted"),
45 @NamedQuery(name = "File.findByDeletionDate", query = "SELECT f FROM File f WHERE f.deletionDate = :deletionDate")
47 public class GDEFile implements Serializable {
48 private static final long serialVersionUID = 1L;
50 @Basic(optional = false)
53 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
54 @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
57 @Column(name = "name")
59 @Column(name = "length")
62 @Column(name = "checksum")
63 private String checksum;
64 @Column(name = "creation_date")
65 @Temporal(TemporalType.TIMESTAMP)
66 private Date creationDate;
67 @Column(name = "update_date")
68 @Temporal(TemporalType.TIMESTAMP)
69 private Date updateDate;
70 @Column(name = "valid")
71 private Boolean valid;
72 @Column(name = "deleted")
73 private Boolean deleted;
74 @Column(name = "deletion_date")
75 @Temporal(TemporalType.TIMESTAMP)
76 private Date deletionDate;
77 @Column(name = "attribute_group_id")
78 private long attributeGroupId;
79 @Column(name = "data_profile_id")
80 private long dataProfileId;
81 // No member for chunks: data are accessed with SQL requests
86 public GDEFile(long id) {
94 public void setId(long id) {
98 public String getName() {
102 public void setName(String name) {
106 public long getLength() {
110 public void setLength(long length) {
111 this.length = length;
114 public String getChecksum() {
118 public void setChecksum(String checksum) {
119 this.checksum = checksum;
122 public Date getCreationDate() {
126 public void setCreationDate(Date creationDate) {
127 this.creationDate = creationDate;
130 public Date getUpdateDate() {
134 public void setUpdateDate(Date updateDate) {
135 this.updateDate = updateDate;
138 public Boolean getValid() {
142 public void setValid(Boolean valid) {
146 public Boolean getDeleted() {
150 public void setDeleted(Boolean deleted) {
151 this.deleted = deleted;
154 public Date getDeletionDate() {
158 public void setDeletionDate(Date deletionDate) {
159 this.deletionDate = deletionDate;
162 public long getAttributeGroupId() {
163 return attributeGroupId;
166 public void setAttributeGroupId(long attributeGroupId) {
167 this.attributeGroupId = attributeGroupId;
170 public long getDataProfileId() {
171 return dataProfileId;
174 public void setDataProfileId(long dataProfileId) {
175 this.dataProfileId = dataProfileId;
178 public static GDEFile fromFileTO(FileTO fto) {
179 GDEFile f = new GDEFile();
180 f.checksum = fto.getChecksum();
181 f.creationDate = fto.getCreationDate();
182 f.deleted = fto.getDeleted();
183 f.deletionDate = fto.getDeletionDate();
184 f.attributeGroupId = fto.getAttributeGroupId();
186 f.length = fto.getLength();
187 f.name = fto.getName();
188 f.updateDate = fto.getUpdateDate();
189 f.valid = fto.getValid();
190 f.dataProfileId = fto.getDataProfileId();
194 public FileTO toFileTO() {
195 FileTO fto = new FileTO();
196 fto.setChecksum(this.checksum);
197 fto.setCreationDate(this.creationDate);
198 fto.setDeleted(this.deleted);
199 fto.setDeletionDate(this.deletionDate);
200 fto.setAttributeGroupId(this.attributeGroupId);
202 fto.setLength(this.length);
203 fto.setName(this.name);
204 fto.setUpdateDate(this.updateDate);
205 fto.setValid(this.valid);
206 fto.setDataProfileId(this.dataProfileId);
211 public String toString() {
212 return "com.edf.gde.entities.GDEFile[ id=" + id + " ]";
216 public int hashCode() {
218 hash = 23 * hash + (int) (this.id ^ (this.id >>> 32));
219 hash = 23 * hash + Objects.hashCode(this.name);
220 hash = 23 * hash + (int) (this.length ^ (this.length >>> 32));
221 hash = 23 * hash + Objects.hashCode(this.checksum);
222 hash = 23 * hash + Objects.hashCode(this.creationDate);
223 hash = 23 * hash + Objects.hashCode(this.updateDate);
224 hash = 23 * hash + Objects.hashCode(this.valid);
225 hash = 23 * hash + Objects.hashCode(this.deleted);
226 hash = 23 * hash + Objects.hashCode(this.deletionDate);
227 hash = 23 * hash + (int) (this.attributeGroupId ^ (this.attributeGroupId >>> 32));
228 hash = 23 * hash + (int) (this.dataProfileId ^ (this.dataProfileId >>> 32));
233 public boolean equals(Object obj) {
237 if (getClass() != obj.getClass()) {
240 final GDEFile other = (GDEFile) obj;
241 if (this.id != other.id) {