Salome HOME
Fixe entities
[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.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;
33
34 /**
35  *
36  * @author F62173
37  */
38 @Entity(name = "File")
39 @Table(name = "gde_file")
40 @XmlRootElement
41 @NamedQueries({
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")
52 })
53 public class GDEFile implements Serializable {
54     private static final long serialVersionUID = 1L;
55     @Id
56     @Basic(optional = false)
57     @NotNull
58     @Column(name = "id")
59     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_GEN_SEQUENCE")
60     @SequenceGenerator(name = "SEQ_GEN_SEQUENCE", allocationSize = 50)
61     private long id;
62     @Size(max = 255)
63     @Column(name = "name")
64     private String name;
65     @Column(name = "length")
66     private long length;
67     @Size(max = 255)
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;
85
86     public GDEFile() {
87     }
88
89     public GDEFile(long id) {
90         this.id = id;
91     }
92
93     public long getId() {
94         return id;
95     }
96
97     public void setId(long id) {
98         this.id = id;
99     }
100
101     public String getName() {
102         return name;
103     }
104
105     public void setName(String name) {
106         this.name = name;
107     }
108
109     public long getLength() {
110         return length;
111     }
112
113     public void setLength(long length) {
114         this.length = length;
115     }
116
117     public String getChecksum() {
118         return checksum;
119     }
120
121     public void setChecksum(String checksum) {
122         this.checksum = checksum;
123     }
124
125     public Date getCreationDate() {
126         return creationDate;
127     }
128
129     public void setCreationDate(Date creationDate) {
130         this.creationDate = creationDate;
131     }
132
133     public Date getUpdateDate() {
134         return updateDate;
135     }
136
137     public void setUpdateDate(Date updateDate) {
138         this.updateDate = updateDate;
139     }
140
141     public Boolean getValid() {
142         return valid;
143     }
144
145     public void setValid(Boolean valid) {
146         this.valid = valid;
147     }
148
149     public Boolean getDeleted() {
150         return deleted;
151     }
152
153     public void setDeleted(Boolean deleted) {
154         this.deleted = deleted;
155     }
156
157     public Date getDeletionDate() {
158         return deletionDate;
159     }
160
161     public void setDeletionDate(Date deletionDate) {
162         this.deletionDate = deletionDate;
163     }
164
165     public long getAttributeGroupId() {
166         return attributeGroupId;
167     }
168
169     public void setAttributeGroupId(long attributeGroupId) {
170         this.attributeGroupId = attributeGroupId;
171     }
172
173     public static GDEFile fromFileTO(FileTO fto) {
174         GDEFile f = new GDEFile();
175         f.checksum = fto.getChecksum();
176         
177         f.creationDate = fto.getCreationDate();
178         f.deleted = fto.getDeleted();
179         f.deletionDate = fto.getDeletionDate();
180         f.attributeGroupId = fto.getAttributeGroupId();
181         f.id = fto.getId();
182         f.length = fto.getLength();
183         f.name = fto.getName();
184         f.updateDate = fto.getUpdateDate();
185         f.valid = fto.getValid();
186         return f;
187     }
188
189     public FileTO toFileTO() {
190         FileTO fto = new FileTO();
191         fto.setChecksum(this.checksum);
192                 
193         fto.setCreationDate(this.creationDate);
194         fto.setDeleted(this.deleted);
195         fto.setDeletionDate(this.deletionDate);
196         fto.setAttributeGroupId(this.attributeGroupId);
197         fto.setId(this.id);
198         fto.setLength(this.length);
199         fto.setName(this.name);
200         fto.setUpdateDate(this.updateDate);
201         fto.setValid(this.valid);
202         return fto;
203     }
204
205     @Override
206     public String toString() {
207         return "com.edf.gde.entities.GDEFile[ id=" + id + " ]";
208     }
209
210     @Override
211     public int hashCode() {
212         int hash = 3;
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));
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 }