Salome HOME
- Code refactoring and simplification
[modules/gde.git] / projects / GDE_App / GDE-ejb / src / java / com / edf / gde / entities / GDEFile.java
1 /*
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.
5  */
6 package com.edf.gde.entities;
7
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;
27
28 /**
29  *
30  * @author F62173
31  */
32 @Entity(name = "File")
33 @Table(name = "gde_file")
34 @XmlRootElement
35 @NamedQueries({
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")
46 })
47 public class GDEFile implements Serializable {
48     private static final long serialVersionUID = 1L;
49     @Id
50     @Basic(optional = false)
51     @NotNull
52     @Column(name = "id")
53     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
54     @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
55     private long id;
56     @Size(max = 255)
57     @Column(name = "name")
58     private String name;
59     @Column(name = "length")
60     private long length;
61     @Size(max = 255)
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
82     
83     public GDEFile() {
84     }
85
86     public GDEFile(long id) {
87         this.id = id;
88     }
89
90     public long getId() {
91         return id;
92     }
93
94     public void setId(long id) {
95         this.id = id;
96     }
97
98     public String getName() {
99         return name;
100     }
101
102     public void setName(String name) {
103         this.name = name;
104     }
105
106     public long getLength() {
107         return length;
108     }
109
110     public void setLength(long length) {
111         this.length = length;
112     }
113
114     public String getChecksum() {
115         return checksum;
116     }
117
118     public void setChecksum(String checksum) {
119         this.checksum = checksum;
120     }
121
122     public Date getCreationDate() {
123         return creationDate;
124     }
125
126     public void setCreationDate(Date creationDate) {
127         this.creationDate = creationDate;
128     }
129
130     public Date getUpdateDate() {
131         return updateDate;
132     }
133
134     public void setUpdateDate(Date updateDate) {
135         this.updateDate = updateDate;
136     }
137
138     public Boolean getValid() {
139         return valid;
140     }
141
142     public void setValid(Boolean valid) {
143         this.valid = valid;
144     }
145
146     public Boolean getDeleted() {
147         return deleted;
148     }
149
150     public void setDeleted(Boolean deleted) {
151         this.deleted = deleted;
152     }
153
154     public Date getDeletionDate() {
155         return deletionDate;
156     }
157
158     public void setDeletionDate(Date deletionDate) {
159         this.deletionDate = deletionDate;
160     }
161
162     public long getAttributeGroupId() {
163         return attributeGroupId;
164     }
165
166     public void setAttributeGroupId(long attributeGroupId) {
167         this.attributeGroupId = attributeGroupId;
168     }
169
170     public long getDataProfileId() {
171         return dataProfileId;
172     }
173
174     public void setDataProfileId(long dataProfileId) {
175         this.dataProfileId = dataProfileId;
176     }
177
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();
185         f.id = fto.getId();
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();
191         return f;
192     }
193
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);
201         fto.setId(this.id);
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);
207         return fto;
208     }
209
210     @Override
211     public String toString() {
212         return "com.edf.gde.entities.GDEFile[ id=" + id + " ]";
213     }
214
215     @Override
216     public int hashCode() {
217         int hash = 5;
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));
229         return hash;
230     }
231
232     @Override
233     public boolean equals(Object obj) {
234         if (obj == null) {
235             return false;
236         }
237         if (getClass() != obj.getClass()) {
238             return false;
239         }
240         final GDEFile other = (GDEFile) obj;
241         if (this.id != other.id) {
242             return false;
243         }
244         return true;
245     }
246
247 }