Salome HOME
Improves file management
[modules/gde.git] / projects / GDE_App / GDE-ejb / src / java / com / edf / gde / entities / GDEFile.java
1 /*
2  * (C) 2015 EDF
3  */
4 package com.edf.gde.entities;
5
6 import com.edf.gde.transferables.FileTO;
7 import java.io.Serializable;
8 import java.util.Date;
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;
25
26 /**
27  *
28  * @author F62173
29  */
30 @Entity(name = "File")
31 @Table(name = "gde_file")
32 @XmlRootElement
33 @NamedQueries({
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")
40 })
41 public class GDEFile implements Serializable {
42     private static final long serialVersionUID = 1L;
43     @Id
44     @Basic(optional = false)
45     @NotNull
46     @Column(name = "id")
47     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
48     @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
49     private long id;
50     @Size(max = 255)
51     @Column(name = "name")
52     private String name;
53     @Column(name = "length")
54     private long length;
55     @Size(max = 255)
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
76     
77     public GDEFile() {
78     }
79
80     public GDEFile(long id) {
81         this.id = id;
82     }
83
84     public long getId() {
85         return id;
86     }
87
88     public void setId(long id) {
89         this.id = id;
90     }
91
92     public String getName() {
93         return name;
94     }
95
96     public void setName(String name) {
97         this.name = name;
98     }
99
100     public long getLength() {
101         return length;
102     }
103
104     public void setLength(long length) {
105         this.length = length;
106     }
107
108     public String getChecksum() {
109         return checksum;
110     }
111
112     public void setChecksum(String checksum) {
113         this.checksum = checksum;
114     }
115
116     public Date getCreationDate() {
117         return creationDate;
118     }
119
120     public void setCreationDate(Date creationDate) {
121         this.creationDate = creationDate;
122     }
123
124     public Date getUpdateDate() {
125         return updateDate;
126     }
127
128     public void setUpdateDate(Date updateDate) {
129         this.updateDate = updateDate;
130     }
131
132     public boolean isValid() {
133         return valid;
134     }
135
136     public void setValid(boolean valid) {
137         this.valid = valid;
138     }
139
140     public boolean isDeleted() {
141         return deleted;
142     }
143
144     public void setDeleted(boolean deleted) {
145         this.deleted = deleted;
146     }
147
148     public Date getDeletionDate() {
149         return deletionDate;
150     }
151
152     public void setDeletionDate(Date deletionDate) {
153         this.deletionDate = deletionDate;
154     }
155
156     public long getAttributeGroupId() {
157         return attributeGroupId;
158     }
159
160     public void setAttributeGroupId(long attributeGroupId) {
161         this.attributeGroupId = attributeGroupId;
162     }
163
164     public long getDataProfileId() {
165         return dataProfileId;
166     }
167
168     public void setDataProfileId(long dataProfileId) {
169         this.dataProfileId = dataProfileId;
170     }
171
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();
179         f.id = fto.getId();
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();
185         return f;
186     }
187
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);
195         fto.setId(this.id);
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);
201         return fto;
202     }
203
204     @Override
205     public String toString() {
206         return "com.edf.gde.entities.GDEFile[ id=" + id + " ]";
207     }
208
209     @Override
210     public int hashCode() {
211         int hash = 5;
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));
223         return hash;
224     }
225
226     @Override
227     public boolean equals(Object obj) {
228         if (obj == null) {
229             return false;
230         }
231         if (getClass() != obj.getClass()) {
232             return false;
233         }
234         final GDEFile other = (GDEFile) obj;
235         if (this.id != other.id) {
236             return false;
237         }
238         return true;
239     }
240
241 }